From: Otto Moerbeek Date: Wed, 28 Aug 2024 07:28:48 +0000 (+0200) Subject: dnsdist: adapt unit test to avoid race on OpenBSD X-Git-Tag: rec-5.2.0-alpha1~105^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F14602%2Fhead;p=thirdparty%2Fpdns.git dnsdist: adapt unit test to avoid race on OpenBSD It looks like OpenBSD has different thread scheduler behaviour, and it can take a while for the error condition to be set. --- diff --git a/pdns/dnsdistdist/test-dnsdistasync.cc b/pdns/dnsdistdist/test-dnsdistasync.cc index e535ba3cb4..3b7d09efba 100644 --- a/pdns/dnsdistdist/test-dnsdistasync.cc +++ b/pdns/dnsdistdist/test-dnsdistasync.cc @@ -135,7 +135,10 @@ BOOST_AUTO_TEST_CASE(test_TimeoutFailClose) // the event should be triggered after 10 ms, but we have seen // many spurious failures on our CI, likely because the box is // overloaded, so sleep for up to 100 ms to be sure - for (size_t counter = 0; !holder->empty() && counter < 10; counter++) { + for (size_t counter = 0; counter < 10; counter++) { + if (holder->empty() && sender->errorRaised.load()) { + break; + } usleep(10000); } @@ -168,7 +171,10 @@ BOOST_AUTO_TEST_CASE(test_AddingExpiredEvent) // but we have seen many spurious failures on our CI, // likely because the box is overloaded, so sleep for up to // 100 ms to be sure - for (size_t counter = 0; !holder->empty() && counter < 10; counter++) { + for (size_t counter = 0; counter < 10; counter++) { + if (holder->empty() && sender->errorRaised.load()) { + break; + } usleep(10000); }