]> 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>
Tue, 14 Mar 2017 14:22:27 +0000 (15:22 +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.

(cherry picked from commit 35d883a830af0284efafe94d1a6bd1c1ad04bae7)

19 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-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/testrunner.cc [new file with mode: 0644]

index 112b82a3267d443c56fcc117e4cfbdcc60b50504..2538b8b6afc6fd8e059dc3283fa24a719933816e 100755 (executable)
@@ -383,6 +383,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"
@@ -531,6 +532,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 66cd5676aa76ca28b64191a1fed2a57818c83c19..6231b932f87a388531cf059c8b36a33050ed821f 100644 (file)
@@ -1127,8 +1127,6 @@ testrunner_SOURCES = \
        packetcache.cc \
        qtype.cc \
        rcpgenerator.cc \
-       recpacketcache.cc recpacketcache.hh \
-       rec-protobuf.hh \
        responsestats.cc \
        responsestats-auth.cc \
        sillyrecords.cc \
@@ -1150,7 +1148,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-zoneparser_tng_cc.cc \
@@ -1170,18 +1167,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 3b8b402d27ebc19b641408f74ea6a731df4cba1d..77b43c5e2b87869294ac763488ee5b13a987446f 100644 (file)
@@ -62,6 +62,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 \
@@ -157,6 +167,62 @@ 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-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 \
+       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
@@ -197,6 +263,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 fe5e6256121c6f0edd856ab27cbaee2d721299cb..d623f2efe61301473ebe97ee5032afd6dc30f000 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-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/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>
+
+