]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
unittest now links in 75% of PowerDNS, plus actuall tests for AddressIsUs now.
authorbert hubert <bert.hubert@netherlabs.nl>
Mon, 6 May 2013 19:06:58 +0000 (21:06 +0200)
committerbert hubert <bert.hubert@netherlabs.nl>
Mon, 6 May 2013 19:06:58 +0000 (21:06 +0200)
pdns/Makefile.am
pdns/nameserver.hh
pdns/test-nameserver_cc.cc [new file with mode: 0644]

index a7655eda6c56f171ed178e55bc7d68763cf3d6b7..82a6b23ebaacaa42e1d287046372799c9de16c2b 100644 (file)
@@ -241,7 +241,11 @@ dnsdemog_SOURCES=dnsdemog.cc misc.cc unix_utility.cc qtype.cc \
 rec_control_SOURCES=rec_channel.cc rec_channel.hh rec_control.cc arguments.cc arguments.hh misc.cc qtype.cc \
        unix_utility.cc logger.cc statbag.cc
 
-testrunner_SOURCES=testrunner.cc test-misc_hh.cc
+testrunner_SOURCES=testrunner.cc test-misc_hh.cc test-nameserver_cc.cc nameserver.cc misc.cc \
+       unix_utility.cc logger.cc statbag.cc arguments.cc qtype.cc dnspacket.cc \
+       dnswriter.cc base64.cc base32.cc dnsrecords.cc dnslabeltext.cc dnsparser.cc \
+       rcpgenerator.cc ednssubnet.cc nsecrecords.cc sillyrecords.cc dnssecinfra.cc \
+       md5.cc
 testrunner_LDFLAGS= @DYNLINKFLAGS@ @THREADFLAGS@ $(BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS)
 testrunner_LDADD= $(BOOST_UNIT_TEST_FRAMEWORK_LIBS)
 
index f7b56cb037465d0268acee1c249e70dadc0423ff..ff0cb87a17fcd413d3dcd654db18b95aa352de36 100644 (file)
@@ -34,6 +34,7 @@
 #include <boost/foreach.hpp>
 #include "statbag.hh"
 #include "namespaces.hh"
+#include "dnspacket.hh"
 
 /** This is the main class. It opens a socket on udp port 53 and waits for packets. Those packets can 
     be retrieved with the receive() member function, which returns a DNSPacket.
diff --git a/pdns/test-nameserver_cc.cc b/pdns/test-nameserver_cc.cc
new file mode 100644 (file)
index 0000000..7a91b22
--- /dev/null
@@ -0,0 +1,55 @@
+#define BOOST_TEST_DYN_LINK
+#define BOOST_TEST_NO_MAIN
+
+#include <boost/test/unit_test.hpp>
+#include "iputils.hh"
+#include "nameserver.hh"
+#include "statbag.hh"
+#include "arguments.hh"
+#include <utility>
+
+extern vector<ComboAddress> g_localaddresses;
+StatBag S;
+
+ArgvMap &arg()
+{
+  static ArgvMap theArg;
+  return theArg;
+}
+
+BOOST_AUTO_TEST_SUITE(nameserver_cc)
+
+BOOST_AUTO_TEST_CASE(test_AddressIsUs4) {
+  ComboAddress local1("127.0.0.1", 53);
+  ComboAddress local2("127.0.0.2", 53);
+  ComboAddress Remote("192.168.255.255", 53);
+
+  g_localaddresses.push_back(ComboAddress("0.0.0.0", 53));
+    
+  BOOST_CHECK_EQUAL(AddressIsUs(local1), true);
+  BOOST_CHECK_EQUAL(AddressIsUs(local2), false);
+  BOOST_CHECK_EQUAL(AddressIsUs(Remote), false);
+  
+  g_localaddresses.clear();
+  g_localaddresses.push_back(ComboAddress("192.168.255.255", 53));
+  BOOST_CHECK_EQUAL(AddressIsUs(Remote), true);
+  Remote.sin4.sin_port = 1;
+  BOOST_CHECK_EQUAL(AddressIsUs(Remote), false);
+}
+
+BOOST_AUTO_TEST_CASE(test_AddressIsUs6) {
+  ComboAddress local1("127.0.0.1", 53);
+  ComboAddress local2("127.0.0.2", 53);
+  ComboAddress local3("::1", 53);
+  ComboAddress NotUs("192.168.255.255", 53);
+  
+  g_localaddresses.clear();
+  g_localaddresses.push_back(ComboAddress("::", 53));
+  
+  BOOST_CHECK_EQUAL(AddressIsUs(local1), true);
+  BOOST_CHECK_EQUAL(AddressIsUs(local2), false);
+  BOOST_CHECK_EQUAL(AddressIsUs(local3), true);
+  BOOST_CHECK_EQUAL(AddressIsUs(NotUs), false);
+}
+
+BOOST_AUTO_TEST_SUITE_END()