From 133415a3f236df052ab661a943c58d73e3aa6a31 Mon Sep 17 00:00:00 2001 From: EnzinoBB Date: Tue, 10 Nov 2026 00:22:53 +0100 Subject: [PATCH] tests: PollUntil deadline test tolerates a slow runner The macOS release build of community.18.1 failed PollUntil.LastAttemptAtTheDeadline: a slow runner overslept the 100 ms interval, so fewer than 3 attempts fit in 250 ms. The test now requires the first attempt and the one at or after the deadline (2), the upper bound and the deadline itself, which the code guarantees. Co-Authored-By: Claude Opus 5.5 --- tests/csnode/polluntil_tests.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/csnode/polluntil_tests.cpp b/tests/csnode/polluntil_tests.cpp index 76f8af247..16a848b57 100644 --- a/tests/csnode/polluntil_tests.cpp +++ b/tests/csnode/polluntil_tests.cpp @@ -20,13 +20,15 @@ TEST(PollUntil, StopsAtTheFirstSuccess) { EXPECT_LT(std::chrono::steady_clock::now() - start, 1000ms); } -// never answers: tried until the deadline, the last attempt at or after it +// never answers: tried until the deadline, the last attempt at or after it. A slow CI runner may +// oversleep an interval, so only the first attempt, the one at the deadline and an upper bound +// are certain TEST(PollUntil, LastAttemptAtTheDeadline) { int calls = 0; std::chrono::steady_clock::time_point last; const auto start = std::chrono::steady_clock::now(); EXPECT_FALSE(pollUntil(250ms, 100ms, [&] { ++calls; last = std::chrono::steady_clock::now(); return false; }, never)); - EXPECT_GE(calls, 3); + EXPECT_GE(calls, 2); EXPECT_LE(calls, 6); EXPECT_GE(last - start, 250ms); }