From: Remi Gacogne Date: Mon, 23 Jan 2023 09:58:29 +0000 (+0100) Subject: dnsdist: Really fix time computation in the async unit tests X-Git-Tag: dnsdist-1.8.0-rc1~86^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fecdfa6eb46212485b68c6966305ecb8db5386dc;p=thirdparty%2Fpdns.git dnsdist: Really fix time computation in the async unit tests --- diff --git a/pdns/dnsdistdist/test-dnsdistasync.cc b/pdns/dnsdistdist/test-dnsdistasync.cc index 6dac39e11d..2e35d3679f 100644 --- a/pdns/dnsdistdist/test-dnsdistasync.cc +++ b/pdns/dnsdistdist/test-dnsdistasync.cc @@ -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()); 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 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 sender{nullptr}; {