From fa2811b1b41f79a7f058c3802463befbc5339eb4 Mon Sep 17 00:00:00 2001 From: Derek Schuff Date: Tue, 17 Feb 2026 23:41:20 +0000 Subject: [PATCH] Allow 1ms slop in blocking tests to fix flakiness (#26282) On the Chromium CI's node.js, setTimeout seems to be sometimes firing 1ms early relative to Date.now(), which caused these tests to fail their strict duration assertions. Allowing 1ms of slop resolves this without compromising the intent of the test. --- test/core/test_poll_blocking.c | 8 ++++---- test/core/test_poll_blocking_asyncify.c | 4 ++-- test/core/test_select_blocking.c | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/test/core/test_poll_blocking.c b/test/core/test_poll_blocking.c index bdbd6b1ee1571..36725c49e48ec 100644 --- a/test/core/test_poll_blocking.c +++ b/test/core/test_poll_blocking.c @@ -40,7 +40,7 @@ void test_timeout_without_fds() { int64_t duration = timeval_delta_ms(&begin, &end); printf(" -> duration: %lld ms\n", duration); - assert(duration >= TIMEOUT_MS); + assert(duration >= TIMEOUT_MS - 1); } // Check if timeout works with fds without events @@ -58,7 +58,7 @@ void test_timeout_with_fds_without_events() { int64_t duration = timeval_delta_ms(&begin, &end); printf(" -> duration: %lld ms\n", duration); - assert(duration >= TIMEOUT_MS); + assert(duration >= TIMEOUT_MS - 1); close(pipe_a[0]); close(pipe_a[1]); } @@ -96,7 +96,7 @@ void test_unblock_poll() { int64_t duration = timeval_delta_ms(&begin, &end); printf(" -> duration: %lld ms\n", duration); - assert(duration >= TIMEOUT_MS); + assert(duration >= TIMEOUT_MS - 1); pthread_join(tid, NULL); @@ -115,7 +115,7 @@ void *do_poll_in_thread(void * arg) { int64_t duration = timeval_delta_ms(&begin, &end); printf(" -> duration: %lld ms\n", duration); - assert((duration >= TIMEOUT_MS) && (duration < 4000)); + assert((duration >= TIMEOUT_MS - 1) && (duration < 4000)); return NULL; } diff --git a/test/core/test_poll_blocking_asyncify.c b/test/core/test_poll_blocking_asyncify.c index b4d9bf6c735a5..bb3b5a6ec24d5 100644 --- a/test/core/test_poll_blocking_asyncify.c +++ b/test/core/test_poll_blocking_asyncify.c @@ -37,7 +37,7 @@ void test_timeout_without_fds() { int64_t duration = timeval_delta_ms(&begin, &end); printf(" -> duration: %lld ms\n", duration); - assert(duration >= 1000); + assert(duration >= 1000 - 1); } int pipe_shared[2]; @@ -69,7 +69,7 @@ void test_unblock_poll() { int64_t duration = timeval_delta_ms(&begin, &end); printf(" -> duration: %lld ms\n", duration); - assert(duration >= 1000); + assert(duration >= 1000 - 1); close(pipe_a[0]); close(pipe_a[1]); close(pipe_shared[0]); close(pipe_shared[1]); diff --git a/test/core/test_select_blocking.c b/test/core/test_select_blocking.c index ddedab1aee851..2c23a26e7c1b1 100644 --- a/test/core/test_select_blocking.c +++ b/test/core/test_select_blocking.c @@ -39,7 +39,7 @@ void test_timeout_without_fds() { int64_t duration = timeval_delta_ms(&begin, &end); printf(" -> duration: %lld ms\n", duration); - assert(duration >= TIMEOUT_MS); + assert(duration >= TIMEOUT_MS - 1); } // Check if timeout works with fds without events @@ -61,7 +61,7 @@ void test_timeout_with_fds_without_events() { int64_t duration = timeval_delta_ms(&begin, &end); printf(" -> duration: %lld ms\n", duration); - assert(duration >= TIMEOUT_MS); + assert(duration >= TIMEOUT_MS - 1); close(pipe_a[0]); close(pipe_a[1]); } @@ -100,7 +100,7 @@ void test_unblock_select() { int64_t duration = timeval_delta_ms(&begin, &end); printf(" -> duration: %lld ms\n", duration); - assert(duration >= TIMEOUT_MS); + assert(duration >= TIMEOUT_MS - 1); pthread_join(tid, NULL); @@ -126,7 +126,7 @@ void *do_select_in_thread(void * arg) { int64_t duration = timeval_delta_ms(&begin, &end); printf(" -> duration: %lld ms\n", duration); - assert((duration >= TIMEOUT_MS) && (duration < 4000)); + assert((duration >= TIMEOUT_MS - 1) && (duration < 4000)); return NULL; }