From 3f670463f48578b1ef5dfd535fc6f51eee17d1f5 Mon Sep 17 00:00:00 2001 From: Johannes Schmidt Date: Tue, 31 Mar 2026 09:32:28 +0200 Subject: [PATCH 1/2] Revert "Give timer tests more leeway for inaccurate implementations" This reverts commit 1430e63e727dd2dddadaa84aec31ea183e9cb82d. --- test/base-timer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/base-timer.cpp b/test/base-timer.cpp index 0d07405dd..77232e0c9 100644 --- a/test/base-timer.cpp +++ b/test/base-timer.cpp @@ -32,7 +32,7 @@ BOOST_AUTO_TEST_CASE(invoke) timer->SetInterval(.1); timer->Start(); - Utility::Sleep(.575); + Utility::Sleep(.55); timer->Stop(); // At this point, the timer should have fired exactly 5 times (0.5 / 0.1) and the sixth time @@ -49,7 +49,7 @@ BOOST_AUTO_TEST_CASE(scope) timer->SetInterval(.1); timer->Start(); - Utility::Sleep(.575); + Utility::Sleep(.55); timer.reset(); Utility::Sleep(.1); From 72ebd43ef184322f67939aa910ac3290659aa541 Mon Sep 17 00:00:00 2001 From: Johannes Schmidt Date: Mon, 30 Mar 2026 10:18:06 +0200 Subject: [PATCH 2/2] Give base_timer/(invoke|scope) timers a 10x multiplier on Windows --- test/base-timer.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/test/base-timer.cpp b/test/base-timer.cpp index 77232e0c9..ff9496436 100644 --- a/test/base-timer.cpp +++ b/test/base-timer.cpp @@ -6,6 +6,15 @@ #include "base/application.hpp" #include +/** + * Windows needs a special handicap to keep up with the other OSs. + */ +#ifdef _WIN32 +static constexpr double timeMultiplier = 10; +#else //_WIN32 +static constexpr double timeMultiplier = 1; +#endif //_WIN32 + using namespace icinga; BOOST_AUTO_TEST_SUITE(base_timer) @@ -29,10 +38,10 @@ BOOST_AUTO_TEST_CASE(invoke) Timer::Ptr timer = Timer::Create(); timer->OnTimerExpired.connect([&counter](const Timer* const&) { counter++; }); - timer->SetInterval(.1); + timer->SetInterval(.1 * timeMultiplier); timer->Start(); - Utility::Sleep(.55); + Utility::Sleep(.55 * timeMultiplier); timer->Stop(); // At this point, the timer should have fired exactly 5 times (0.5 / 0.1) and the sixth time @@ -46,12 +55,12 @@ BOOST_AUTO_TEST_CASE(scope) Timer::Ptr timer = Timer::Create(); timer->OnTimerExpired.connect([&counter](const Timer* const&) { counter++; }); - timer->SetInterval(.1); + timer->SetInterval(.1 * timeMultiplier); timer->Start(); - Utility::Sleep(.55); + Utility::Sleep(.55 * timeMultiplier); timer.reset(); - Utility::Sleep(.1); + Utility::Sleep(.1 * timeMultiplier); // At this point, the timer should have fired exactly 5 times (0.5 / 0.1) and the sixth time // should not have fired yet as we destroyed the timer after 0.55 seconds (0.6 would be needed),