From: Otto Moerbeek Date: Mon, 15 Apr 2019 10:11:58 +0000 (+0200) Subject: Explicitly call reportAllTypes() at test suite init, to avoid almost X-Git-Tag: dnsdist-1.4.0-alpha2~16^2~2^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=48215c198494fd6c621f33e291ad20eb45c71bac;p=thirdparty%2Fpdns.git Explicitly call reportAllTypes() at test suite init, to avoid almost all order dependencies and init a few globals to fix the remaining cases. --- diff --git a/pdns/test-distributor_hh.cc b/pdns/test-distributor_hh.cc index 9c476b98af..f21a9b767c 100644 --- a/pdns/test-distributor_hh.cc +++ b/pdns/test-distributor_hh.cc @@ -66,6 +66,12 @@ struct BackendSlow } }; +static std::atomic g_receivedAnswers1; +static void report1(DNSPacket* A) +{ + delete A; + g_receivedAnswers1++; +} BOOST_AUTO_TEST_CASE(test_distributor_queue) { ::arg().set("overload-queue-length","Maximum queuelength moving to packetcache only")="0"; @@ -82,7 +88,7 @@ BOOST_AUTO_TEST_CASE(test_distributor_queue) { for(n=0; n < 2000; ++n) { auto q = new Question(); q->d_dt.set(); - d->question(q, report); + d->question(q, report1); } }, DistributorFatal, [](DistributorFatal) { return true; }); }; @@ -129,8 +135,6 @@ BOOST_AUTO_TEST_CASE(test_distributor_dies) { S.declare("timedout-packets", "timedout-packets"); auto d=Distributor::Create(10); - sleep(1); - g_receivedAnswers=0; try { for(int n=0; n < 100; ++n) { diff --git a/pdns/test-dnsrecords_cc.cc b/pdns/test-dnsrecords_cc.cc index 764d8fdf36..5e50111a3f 100644 --- a/pdns/test-dnsrecords_cc.cc +++ b/pdns/test-dnsrecords_cc.cc @@ -44,7 +44,6 @@ BOOST_AUTO_TEST_CASE(test_record_types) { // tuple contains typedef boost::tuple case_t; typedef std::list cases_t; - reportAllTypes(); MRRecordContent::report(); IPSECKEYRecordContent::report(); KXRecordContent::report(); diff --git a/pdns/test-packetcache_cc.cc b/pdns/test-packetcache_cc.cc index bd16702662..ededb4c5a3 100644 --- a/pdns/test-packetcache_cc.cc +++ b/pdns/test-packetcache_cc.cc @@ -104,6 +104,7 @@ catch(PDNSException& e) { BOOST_AUTO_TEST_CASE(test_QueryCacheThreaded) { try { + g_QCmissing = 0; AuthQueryCache QC; QC.setMaxEntries(1000000); g_QC=&QC; @@ -206,6 +207,7 @@ BOOST_AUTO_TEST_CASE(test_PacketCacheThreaded) { PC.setTTL(3600); g_PC=&PC; + g_QCmissing = 0; pthread_t tid[4]; for(int i=0; i < 4; ++i) pthread_create(&tid[i], 0, threadPCMangler, (void*)(i*1000000UL)); diff --git a/pdns/testrunner.cc b/pdns/testrunner.cc index 1c6c7cb1af..08545bf425 100644 --- a/pdns/testrunner.cc +++ b/pdns/testrunner.cc @@ -1,6 +1,4 @@ #define BOOST_TEST_DYN_LINK -#define BOOST_TEST_MAIN -#define BOOST_TEST_MODULE unit #ifdef HAVE_CONFIG_H #include "config.h" @@ -19,3 +17,16 @@ ArgvMap &arg() static ArgvMap theArg; return theArg; } + + +bool init_unit_test() { + cerr << "Initing..." << endl; + reportAllTypes(); + return true; +} + +// entry point: +int main(int argc, char* argv[]) +{ + return boost::unit_test::unit_test_main( &init_unit_test, argc, argv ); +}