]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Really fix time computation in the async unit tests
authorRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 23 Jan 2023 09:58:29 +0000 (10:58 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 23 Jan 2023 09:58:29 +0000 (10:58 +0100)
pdns/dnsdistdist/test-dnsdistasync.cc

index 6dac39e11d19d47bba1c0dbfc94764abf3c06fc1..2e35d3679f5ba3a84ae471384e23e41285b56dbb 100644 (file)
@@ -84,8 +84,8 @@ BOOST_AUTO_TEST_CASE(test_Basic)
     struct timeval ttd;
     gettimeofday(&ttd, nullptr);
     // timeout in 100 ms
-    const timeval sub{0, 100000};
-    timersub(&ttd, &sub, &ttd);
+    const timeval add{0, 100000};
+    timeradd(&ttd, &add, &ttd);
 
     holder->push(asyncID, queryID, ttd, std::make_unique<DummyCrossProtocolQuery>());
     BOOST_CHECK(!holder->empty());
@@ -115,7 +115,8 @@ BOOST_AUTO_TEST_CASE(test_TimeoutFailClose)
   struct timeval ttd;
   gettimeofday(&ttd, nullptr);
   // timeout in 10 ms
-  ttd.tv_usec += 10000;
+  const timeval add{0, 10000};
+  timeradd(&ttd, &add, &ttd);
 
   std::shared_ptr<DummyQuerySender> sender{nullptr};
   {
@@ -143,7 +144,8 @@ BOOST_AUTO_TEST_CASE(test_AddingExpiredEvent)
   struct timeval ttd;
   gettimeofday(&ttd, nullptr);
   // timeout was 10 ms ago, for some reason (long processing time, CPU starvation...)
-  ttd.tv_usec -= 10000;
+  const timeval sub{0, 10000};
+  timersub(&ttd, &sub, &ttd);
 
   std::shared_ptr<DummyQuerySender> sender{nullptr};
   {