From b270f30e8b3b5e71ae3af9659da4a2490d47db57 Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Wed, 16 Sep 2026 17:17:00 -0700 Subject: [PATCH] [test] Fix test_poll_blocking_asyncify flake: start the clock before arming the timer --- test/core/test_poll_blocking_asyncify.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/core/test_poll_blocking_asyncify.c b/test/core/test_poll_blocking_asyncify.c index a5a32bf71e7b4..579b41dc1367e 100644 --- a/test/core/test_poll_blocking_asyncify.c +++ b/test/core/test_poll_blocking_asyncify.c @@ -72,8 +72,11 @@ void test_unblock_poll() { {pipe_a[0], POLLIN, 0}, {pipe_shared[0], POLLIN, 0}, }; - emscripten_set_timeout(write_to_pipe, 1000, NULL); + // Start the clock before arming the timer: any delay between the two (e.g. + // preemption on a loaded machine) would otherwise shorten the measured + // duration below the timer's. clock_gettime(CLOCK_MONOTONIC, &begin); + emscripten_set_timeout(write_to_pipe, 1000, NULL); assert(poll(fds, 2, -1) == 1); clock_gettime(CLOCK_MONOTONIC, &end); assert(fds[1].revents & POLLIN);