From: Remi Gacogne Date: Mon, 13 Mar 2017 12:52:51 +0000 (+0100) Subject: rec: Run unit tests, split recursor-specific unit tests from the auth X-Git-Tag: rec-4.0.5-rc1~4^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c15857dd06dbefcc9f9ef5d9625472063d5a23a7;p=pdns rec: Run unit tests, split recursor-specific unit tests from the auth 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) --- diff --git a/build-scripts/travis.sh b/build-scripts/travis.sh index 112b82a32..2538b8b6a 100755 --- a/build-scripts/travis.sh +++ b/build-scripts/travis.sh @@ -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" diff --git a/pdns/Makefile.am b/pdns/Makefile.am index 66cd5676a..6231b932f 100644 --- a/pdns/Makefile.am +++ b/pdns/Makefile.am @@ -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) diff --git a/pdns/recursordist/Makefile.am b/pdns/recursordist/Makefile.am index 3b8b402d2..77b43c5e2 100644 --- a/pdns/recursordist/Makefile.am +++ b/pdns/recursordist/Makefile.am @@ -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 diff --git a/pdns/recursordist/configure.ac b/pdns/recursordist/configure.ac index fe5e62561..d623f2efe 100644 --- a/pdns/recursordist/configure.ac +++ b/pdns/recursordist/configure.ac @@ -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 index 000000000..469b73007 --- /dev/null +++ b/pdns/recursordist/m4/pdns_enable_unit_tests.m4 @@ -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 index 53ffc6673..000000000 --- a/pdns/recursordist/sha.hh +++ /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 index 000000000..8c0885c66 --- /dev/null +++ b/pdns/recursordist/test-arguments_cc.cc @@ -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 index 000000000..092c6375b --- /dev/null +++ b/pdns/recursordist/test-base32_cc.cc @@ -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 index 000000000..1f4893086 --- /dev/null +++ b/pdns/recursordist/test-base64_cc.cc @@ -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 index 000000000..570708646 --- /dev/null +++ b/pdns/recursordist/test-dns_random_hh.cc @@ -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 index 000000000..1bd7c6351 --- /dev/null +++ b/pdns/recursordist/test-dnsname_cc.cc @@ -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 index 000000000..b80a824d0 --- /dev/null +++ b/pdns/recursordist/test-dnsparser_hh.cc @@ -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 index 000000000..d72a22ed6 --- /dev/null +++ b/pdns/recursordist/test-dnsrecords_cc.cc @@ -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 index 000000000..5536c3e9d --- /dev/null +++ b/pdns/recursordist/test-iputils_hh.cc @@ -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 index 000000000..f1e02f0ad --- /dev/null +++ b/pdns/recursordist/test-misc_hh.cc @@ -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 index 000000000..923334b33 --- /dev/null +++ b/pdns/recursordist/test-nmtree.cc @@ -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 index 000000000..94a123efd --- /dev/null +++ b/pdns/recursordist/test-rcpgenerator_cc.cc @@ -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 index 000000000..cd15923d0 --- /dev/null +++ b/pdns/recursordist/test-recpacketcache_cc.cc @@ -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 index 000000000..b6a685288 --- /dev/null +++ b/pdns/recursordist/testrunner.cc @@ -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 + +