From 56149fde0433fb05751f1e8f29d03029c852f1c8 Mon Sep 17 00:00:00 2001 From: Chris Tate Date: Thu, 22 Oct 2026 19:56:53 -0500 Subject: [PATCH] Count each epoll test deadline from its own arm call The poller test recorded every initial deadline as the same start time plus the delay, while the poller reads the clock at each arm call; when arming the 2,000 timers took over 1 ms, the recorded order could differ from the delivered one by more than the assertion's slack. Each deadline now counts from the time read just before its scrp_timer_arm call, as the re-arm loop's do, and a 3 ms pause halfway through arming keeps the test exercising that case. --- packages/runtime/src/scr_loop_epoll.test.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/runtime/src/scr_loop_epoll.test.c b/packages/runtime/src/scr_loop_epoll.test.c index 4c0798e29..6ab1621c5 100644 --- a/packages/runtime/src/scr_loop_epoll.test.c +++ b/packages/runtime/src/scr_loop_epoll.test.c @@ -38,10 +38,17 @@ int main(void) { assert(p != NULL); srand(7); double start = now_ms(); + /* Each deadline counts from its own arm call: arming takes time, here + * stretched by a pause halfway, and the poller reads the clock at each + * call. */ for (int i = 0; i < KEYS; i++) { + if (i == KEYS / 2) + for (double until = now_ms() + 3; now_ms() < until;) { + } double ms = 5 + rand() % 120; + double t = now_ms(); assert(scrp_timer_arm(p, &keys[i], ms, &keys[i])); - deadline[i] = start + ms; + deadline[i] = t + ms; state[i] = 1; } /* re-arm a third later and earlier, cancel a third (the heap and the key