git: 994bec47ee7f - main - tests/kqueue: repair flaky test

From: Gleb Smirnoff <glebius_at_FreeBSD.org>
Date: Tue, 24 Jun 2025 22:30:30 UTC
The branch main has been updated by glebius:

URL: https://cgit.FreeBSD.org/src/commit/?id=994bec47ee7f38bd20366b812313b2ea0714ef19

commit 994bec47ee7f38bd20366b812313b2ea0714ef19
Author:     Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2025-06-24 22:28:07 +0000
Commit:     Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2025-06-24 22:29:03 +0000

    tests/kqueue: repair flaky test
    
    The test arms timer for 500 msec and then sleeps 1 second and expects that
    the timer would always fire exactly 2 times.  However, it has a chance to
    legitimately fire only once.  This makes the test flaky.  Fix the test
    reducing sleep time down to 495 msec.
    
    The problem started to show up recently, and I attribute that to
    626ea75ed2e9.  Before this revision sleep(3) was almost always sleeping
    over 1000 msec, now it can sleep exactly 1000 msec.
    
    Reviewed by:            markj
    Differential Revision:  https://reviews.freebsd.org/D50996
---
 tests/sys/kqueue/libkqueue/timer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/sys/kqueue/libkqueue/timer.c b/tests/sys/kqueue/libkqueue/timer.c
index 523dedc7c800..5116aea98b83 100644
--- a/tests/sys/kqueue/libkqueue/timer.c
+++ b/tests/sys/kqueue/libkqueue/timer.c
@@ -199,7 +199,7 @@ test_periodic_modify(void)
     kevent_cmp(&kev, kevent_get(kqfd));
 
     /* Check if the event occurs again */
-    EV_SET(&kev, vnode_fd, EVFILT_TIMER, EV_ADD, 0, 500, NULL);
+    EV_SET(&kev, vnode_fd, EVFILT_TIMER, EV_ADD, 0, 495, NULL);
     if (kevent(kqfd, &kev, 1, NULL, 0, NULL) < 0)
         err(1, "%s", test_id);