From 914b393871af535dde5e3f6fd1314368ca1b363f Mon Sep 17 00:00:00 2001 From: Pepe Date: Mon, 13 Jul 2026 10:46:20 +0100 Subject: [PATCH] Fix WakeUp test flakiness by using steady_clock The `WakeUp.BasicTest` previously used `system_clock`, which is not monotonic and can be affected by system time adjustments (NTP, DST). This made the test susceptible to flaky failures. This change switches to `steady_clock` for robust, monotonic time measurement. Additionally, the assertion threshold is increased from `25ms` to `100ms` to provide adequate headroom for scheduler jitter, especially on loaded CI environments. --- tests/gtest_wakeup.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/gtest_wakeup.cpp b/tests/gtest_wakeup.cpp index 0da9eb8bc..cca75f2fa 100644 --- a/tests/gtest_wakeup.cpp +++ b/tests/gtest_wakeup.cpp @@ -41,13 +41,16 @@ TEST(WakeUp, BasicTest) using namespace std::chrono; - auto t1 = system_clock::now(); + auto t1 = steady_clock::now(); tree.tickOnce(); tree.sleep(milliseconds(200)); - auto t2 = system_clock::now(); + auto t2 = steady_clock::now(); auto dT = duration_cast(t2 - t1).count(); std::cout << "Woke up after msec: " << dT << std::endl; - ASSERT_LT(dT, 25); + // steady_clock is monotonic and immune to NTP/DST jumps. + // 100 ms gives headroom for scheduler jitter on loaded CI runners; + // the wake-up should fire well under that threshold. + ASSERT_LT(dT, 100); }