]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Explicitly call reportAllTypes() at test suite init, to avoid almost
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 15 Apr 2019 10:11:58 +0000 (12:11 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 15 Apr 2019 10:11:58 +0000 (12:11 +0200)
all order dependencies and init a few globals to fix the remaining
cases.

pdns/test-distributor_hh.cc
pdns/test-dnsrecords_cc.cc
pdns/test-packetcache_cc.cc
pdns/testrunner.cc

index 9c476b98aff66e088a8f3962e86b3c4541b2196d..f21a9b767cbfbcee3f332a18788f6449882ee349 100644 (file)
@@ -66,6 +66,12 @@ struct BackendSlow
   }
 };
 
+static std::atomic<int> 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<DNSPacket, Question, BackendDies>::Create(10);
-  sleep(1);
-  g_receivedAnswers=0;
 
   try {
     for(int n=0; n < 100; ++n)  {
index 764d8fdf367343b08c2ac14e6f64ba7e760ba851..5e50111a3f1d6a3bef404f3c762124090d37aeae 100644 (file)
@@ -44,7 +44,6 @@ BOOST_AUTO_TEST_CASE(test_record_types) {
   // tuple contains <type, user value, zone representation, line value, broken>
   typedef boost::tuple<QType::typeenum, std::string, std::string, std::string, broken_marker> case_t;
   typedef std::list<case_t> cases_t;
-  reportAllTypes();
   MRRecordContent::report();
   IPSECKEYRecordContent::report();
   KXRecordContent::report();
index bd16702662aed97e411faa048d24cbc721f8963b..ededb4c5a31442cc842a9e26c9ca01c31d9027be 100644 (file)
@@ -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));
index 1c6c7cb1af8306b07b1275c0ae8103e591701ceb..08545bf425bbeecfede96823836600272da3e131 100644 (file)
@@ -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 );
+}