]> granicus.if.org Git - pdns/commitdiff
rec: Run unit tests, split recursor-specific unit tests from the auth
authorRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 13 Mar 2017 12:52:51 +0000 (13:52 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 13 Mar 2017 12:52:51 +0000 (13:52 +0100)
Some unit tests are common and will be run twice, once in the auth
build and once in the rec one. This ensures that they will be run on
rec-4.0.x and auth-4.0.x branches as well.

21 files changed:
build-scripts/travis.sh
pdns/Makefile.am
pdns/recursordist/Makefile.am
pdns/recursordist/configure.ac
pdns/recursordist/m4/pdns_enable_unit_tests.m4 [new symlink]
pdns/recursordist/sha.hh [deleted symlink]
pdns/recursordist/test-arguments_cc.cc [new symlink]
pdns/recursordist/test-base32_cc.cc [new symlink]
pdns/recursordist/test-base64_cc.cc [new symlink]
pdns/recursordist/test-dns_random_hh.cc [new symlink]
pdns/recursordist/test-dnsname_cc.cc [new symlink]
pdns/recursordist/test-dnsparser_hh.cc [new symlink]
pdns/recursordist/test-dnsrecordcontent.cc [new symlink]
pdns/recursordist/test-dnsrecords_cc.cc [new symlink]
pdns/recursordist/test-iputils_hh.cc [new symlink]
pdns/recursordist/test-misc_hh.cc [new symlink]
pdns/recursordist/test-nmtree.cc [new symlink]
pdns/recursordist/test-rcpgenerator_cc.cc [new symlink]
pdns/recursordist/test-recpacketcache_cc.cc [new symlink]
pdns/recursordist/test-tsig.cc [new symlink]
pdns/recursordist/testrunner.cc [new file with mode: 0644]

index 6b314cb8b6f5bc73ade4e3b3e5644810dc1bacef..bbeb86fd371b6fe7b1b905cac43182e37d686268 100755 (executable)
@@ -357,7 +357,7 @@ install_recursor() {
 }
 
 install_dnsdist() {
-  # recursor test requirements / setup
+  # test requirements / setup
   run "sudo apt-get -qq --no-install-recommends install \
     snmpd \
     libsnmp-dev"
@@ -399,6 +399,7 @@ build_recursor() {
   run "cd pdns-recursor-*"
   run "CFLAGS='-O1' CXXFLAGS='-O1' ./configure \
     --prefix=$PDNS_RECURSOR_DIR \
+    --enable-unit-tests \
     --disable-silent-rules"
   run "make -k -j3"
   run "make install"
@@ -553,6 +554,9 @@ test_recursor() {
   export PDNSRECURSOR="${PDNS_RECURSOR_DIR}/sbin/pdns_recursor"
   export DNSBULKTEST="/usr/bin/dnsbulktest"
   export RECCONTROL="${PDNS_RECURSOR_DIR}/bin/rec_control"
+  run "cd pdns/recursordist/pdns-recursor-*"
+  run "make -j 3 check"
+  run "cd ${TRAVIS_BUILD_DIR}"
   run "./build-scripts/test-recursor"
   export RECURSOR="${PDNSRECURSOR}"
   run "cd regression-tests"
index 33b829ca5e25e6761320dadfeba949450f17d251..65482f5305795559e4aa0d6df4194e42df97720a 100644 (file)
@@ -1131,8 +1131,6 @@ testrunner_SOURCES = \
        packetcache.cc \
        qtype.cc \
        rcpgenerator.cc \
-       recpacketcache.cc recpacketcache.hh \
-       rec-protobuf.hh \
        responsestats.cc \
        responsestats-auth.cc \
        sillyrecords.cc \
@@ -1155,7 +1153,6 @@ testrunner_SOURCES = \
        test-nmtree.cc \
        test-packetcache_cc.cc \
        test-rcpgenerator_cc.cc \
-       test-recpacketcache_cc.cc \
        test-sha_hh.cc \
        test-statbag_cc.cc \
        test-tsig.cc \
@@ -1176,18 +1173,6 @@ testrunner_LDADD = \
        $(RT_LIBS) \
        $(LIBDL)
 
-if HAVE_PROTOBUF
-if HAVE_PROTOC
-nodist_testrunner_SOURCES = \
-       dnsmessage.pb.cc dnsmessage.pb.h
-
-testrunner_LDADD += \
-       $(PROTOBUF_LIBS)
-
-recpacketcache.$(OBJEXT): dnsmessage.pb.cc
-endif
-endif
-
 if PKCS11
 testrunner_SOURCES += pkcs11signers.cc pkcs11signers.hh
 testrunner_LDADD += $(P11KIT1_LIBS)
index ddfb76bf9b661d29440a160a5bd8051718a031da..c1738df56fc1ddad3a135173e3472e72d2343f63 100644 (file)
@@ -64,6 +64,16 @@ EXTRA_DIST = \
 sbin_PROGRAMS = pdns_recursor
 bin_PROGRAMS = rec_control
 
+if UNIT_TESTS
+noinst_PROGRAMS = testrunner
+TESTS_ENVIRONMENT = env BOOST_TEST_LOG_LEVEL=message SRCDIR='$(srcdir)'
+TESTS=testrunner
+else
+check-local:
+       @echo "Unit tests are not enabled"
+       @echo "Run ./configure --enable-unit-tests"
+endif
+
 pdns_recursor_SOURCES = \
        arguments.cc \
        base32.cc base32.hh \
@@ -163,6 +173,64 @@ pdns_recursor_LDADD = \
 pdns_recursor_LDFLAGS = $(AM_LDFLAGS) \
        $(LIBCRYPTO_LDFLAGS) $(BOOST_CONTEXT_LDFLAGS)
 
+testrunner_SOURCES = \
+       arguments.cc \
+       base32.cc \
+       base64.cc base64.hh \
+       dns.cc dns.hh \
+       dnslabeltext.cc \
+       dnsname.cc dnsname.hh \
+       dnsparser.hh dnsparser.cc \
+       dnsrecords.cc \
+       dnssecinfra.cc \
+       dnswriter.cc dnswriter.hh \
+       ednsoptions.cc ednsoptions.hh \
+       ednssubnet.cc ednssubnet.hh \
+       gettime.cc gettime.hh \
+       gss_context.cc gss_context.hh \
+       iputils.cc iputils.hh \
+       logger.cc logger.hh \
+       misc.cc misc.hh \
+       namespaces.hh \
+       nsecrecords.cc \
+       pdnsexception.hh \
+       protobuf.cc protobuf.hh \
+       qtype.cc qtype.hh \
+       rcpgenerator.cc \
+       recpacketcache.cc recpacketcache.hh \
+       rec-protobuf.cc rec-protobuf.hh \
+       responsestats.cc \
+       sillyrecords.cc \
+       sholder.hh \
+       sstuff.hh \
+       test-arguments_cc.cc \
+       test-base32_cc.cc \
+       test-base64_cc.cc \
+       test-dnsrecordcontent.cc \
+       test-dns_random_hh.cc \
+       test-dnsname_cc.cc \
+       test-dnsparser_hh.cc \
+       test-dnsrecords_cc.cc \
+       test-iputils_hh.cc \
+       test-misc_hh.cc \
+       test-nmtree.cc \
+       test-rcpgenerator_cc.cc \
+       test-recpacketcache_cc.cc \
+       test-tsig.cc \
+       testrunner.cc \
+       unix_utility.cc \
+       zoneparser-tng.cc zoneparser-tng.hh
+
+testrunner_LDFLAGS = \
+       $(AM_LDFLAGS) \
+       $(BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS) \
+       $(LIBCRYPTO_LDFLAGS)
+
+testrunner_LDADD = \
+       $(BOOST_UNIT_TEST_FRAMEWORK_LIBS) \
+       $(LIBCRYPTO_LIBS) \
+       $(RT_LIBS)
+
 if BOTAN110
 pdns_recursor_SOURCES += \
        botan110signers.cc
@@ -209,6 +277,11 @@ BUILT_SOURCES += dnsmessage.pb.cc
 pdns_recursor_LDADD += $(PROTOBUF_LIBS)
 nodist_pdns_recursor_SOURCES = dnsmessage.pb.cc dnsmessage.pb.h
 pdns_recursor.$(OBJEXT): dnsmessage.pb.cc
+
+nodist_testrunner_SOURCES = dnsmessage.pb.cc dnsmessage.pb.h
+testrunner_LDADD += $(PROTOBUF_LIBS)
+testrunner$(OBJEXT): dnsmessage.pb.cc
+
 endif
 endif
 
index e79af91b8cb716fd66aef3ab3e2b240d2b820dac..7bca7a68613c272c6b388a62303bb9be4e1ba5ac 100644 (file)
@@ -94,6 +94,7 @@ AS_IF([test "x$PROTOBUF_LIBS" != "x" -a x"$PROTOC" != "x"],
 BOOST_REQUIRE([$boost_required_version])
 PDNS_SELECT_CONTEXT_IMPL
 
+PDNS_ENABLE_UNIT_TESTS
 PDNS_ENABLE_REPRODUCIBLE
 
 PDNS_WITH_LUAJIT
diff --git a/pdns/recursordist/m4/pdns_enable_unit_tests.m4 b/pdns/recursordist/m4/pdns_enable_unit_tests.m4
new file mode 120000 (symlink)
index 0000000..469b730
--- /dev/null
@@ -0,0 +1 @@
+../../../m4/pdns_enable_unit_tests.m4
\ No newline at end of file
diff --git a/pdns/recursordist/sha.hh b/pdns/recursordist/sha.hh
deleted file mode 120000 (symlink)
index 53ffc66..0000000
+++ /dev/null
@@ -1 +0,0 @@
-../sha.hh
\ No newline at end of file
diff --git a/pdns/recursordist/test-arguments_cc.cc b/pdns/recursordist/test-arguments_cc.cc
new file mode 120000 (symlink)
index 0000000..8c0885c
--- /dev/null
@@ -0,0 +1 @@
+../test-arguments_cc.cc
\ No newline at end of file
diff --git a/pdns/recursordist/test-base32_cc.cc b/pdns/recursordist/test-base32_cc.cc
new file mode 120000 (symlink)
index 0000000..092c637
--- /dev/null
@@ -0,0 +1 @@
+../test-base32_cc.cc
\ No newline at end of file
diff --git a/pdns/recursordist/test-base64_cc.cc b/pdns/recursordist/test-base64_cc.cc
new file mode 120000 (symlink)
index 0000000..1f48930
--- /dev/null
@@ -0,0 +1 @@
+../test-base64_cc.cc
\ No newline at end of file
diff --git a/pdns/recursordist/test-dns_random_hh.cc b/pdns/recursordist/test-dns_random_hh.cc
new file mode 120000 (symlink)
index 0000000..5707086
--- /dev/null
@@ -0,0 +1 @@
+../test-dns_random_hh.cc
\ No newline at end of file
diff --git a/pdns/recursordist/test-dnsname_cc.cc b/pdns/recursordist/test-dnsname_cc.cc
new file mode 120000 (symlink)
index 0000000..1bd7c63
--- /dev/null
@@ -0,0 +1 @@
+../test-dnsname_cc.cc
\ No newline at end of file
diff --git a/pdns/recursordist/test-dnsparser_hh.cc b/pdns/recursordist/test-dnsparser_hh.cc
new file mode 120000 (symlink)
index 0000000..b80a824
--- /dev/null
@@ -0,0 +1 @@
+../test-dnsparser_hh.cc
\ No newline at end of file
diff --git a/pdns/recursordist/test-dnsrecordcontent.cc b/pdns/recursordist/test-dnsrecordcontent.cc
new file mode 120000 (symlink)
index 0000000..c6e85a5
--- /dev/null
@@ -0,0 +1 @@
+../test-dnsrecordcontent.cc
\ No newline at end of file
diff --git a/pdns/recursordist/test-dnsrecords_cc.cc b/pdns/recursordist/test-dnsrecords_cc.cc
new file mode 120000 (symlink)
index 0000000..d72a22e
--- /dev/null
@@ -0,0 +1 @@
+../test-dnsrecords_cc.cc
\ No newline at end of file
diff --git a/pdns/recursordist/test-iputils_hh.cc b/pdns/recursordist/test-iputils_hh.cc
new file mode 120000 (symlink)
index 0000000..5536c3e
--- /dev/null
@@ -0,0 +1 @@
+../test-iputils_hh.cc
\ No newline at end of file
diff --git a/pdns/recursordist/test-misc_hh.cc b/pdns/recursordist/test-misc_hh.cc
new file mode 120000 (symlink)
index 0000000..f1e02f0
--- /dev/null
@@ -0,0 +1 @@
+../test-misc_hh.cc
\ No newline at end of file
diff --git a/pdns/recursordist/test-nmtree.cc b/pdns/recursordist/test-nmtree.cc
new file mode 120000 (symlink)
index 0000000..923334b
--- /dev/null
@@ -0,0 +1 @@
+../test-nmtree.cc
\ No newline at end of file
diff --git a/pdns/recursordist/test-rcpgenerator_cc.cc b/pdns/recursordist/test-rcpgenerator_cc.cc
new file mode 120000 (symlink)
index 0000000..94a123e
--- /dev/null
@@ -0,0 +1 @@
+../test-rcpgenerator_cc.cc
\ No newline at end of file
diff --git a/pdns/recursordist/test-recpacketcache_cc.cc b/pdns/recursordist/test-recpacketcache_cc.cc
new file mode 120000 (symlink)
index 0000000..cd15923
--- /dev/null
@@ -0,0 +1 @@
+../test-recpacketcache_cc.cc
\ No newline at end of file
diff --git a/pdns/recursordist/test-tsig.cc b/pdns/recursordist/test-tsig.cc
new file mode 120000 (symlink)
index 0000000..5302c4b
--- /dev/null
@@ -0,0 +1 @@
+../test-tsig.cc
\ No newline at end of file
diff --git a/pdns/recursordist/testrunner.cc b/pdns/recursordist/testrunner.cc
new file mode 100644 (file)
index 0000000..b6a6852
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * This file is part of PowerDNS or dnsdist.
+ * Copyright -- PowerDNS.COM B.V. and its contributors
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * In addition, for the avoidance of any doubt, permission is granted to
+ * link this program with OpenSSL and to (re)distribute the binaries
+ * produced as the result of such linking.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#define BOOST_TEST_DYN_LINK
+#define BOOST_TEST_MAIN
+#define BOOST_TEST_MODULE unit
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#include <boost/test/unit_test.hpp>
+
+