tests: kqueue: use a more precise timer for the NOTE_ABSTIME test
Originally noticed while attempting to run the kqueue tests under qemu-user-static, this apparently just happens sometimes when running in a jail in general -- the timer will fire off "too early," but it's really just the result of imprecise measurements (noted by cem). Kicking this over to NOTE_USECONDS still tests the correct thing while allowing it to work more consistently; a basic sanity test reveals that we often end up coming in just less than 200 microseconds after the timer fired off. MFC after: 3 days
This commit is contained in:
parent
82164bdd76
commit
c17dd0e88b
@ -216,17 +216,17 @@ test_abstime(void)
|
|||||||
{
|
{
|
||||||
const char *test_id = "kevent(EVFILT_TIMER, EV_ONESHOT, NOTE_ABSTIME)";
|
const char *test_id = "kevent(EVFILT_TIMER, EV_ONESHOT, NOTE_ABSTIME)";
|
||||||
struct kevent kev;
|
struct kevent kev;
|
||||||
time_t start;
|
long end, start, stop;
|
||||||
time_t stop;
|
const int timeout_sec = 3;
|
||||||
const int timeout = 3;
|
|
||||||
|
|
||||||
test_begin(test_id);
|
test_begin(test_id);
|
||||||
|
|
||||||
test_no_kevents();
|
test_no_kevents();
|
||||||
|
|
||||||
start = time(NULL);
|
start = now();
|
||||||
|
end = start + SEC_TO_US(timeout_sec);
|
||||||
EV_SET(&kev, vnode_fd, EVFILT_TIMER, EV_ADD | EV_ONESHOT,
|
EV_SET(&kev, vnode_fd, EVFILT_TIMER, EV_ADD | EV_ONESHOT,
|
||||||
NOTE_ABSTIME | NOTE_SECONDS, start + timeout, NULL);
|
NOTE_ABSTIME | NOTE_USECONDS, end, NULL);
|
||||||
if (kevent(kqfd, &kev, 1, NULL, 0, NULL) < 0)
|
if (kevent(kqfd, &kev, 1, NULL, 0, NULL) < 0)
|
||||||
err(1, "%s", test_id);
|
err(1, "%s", test_id);
|
||||||
|
|
||||||
@ -235,10 +235,10 @@ test_abstime(void)
|
|||||||
kev.data = 1;
|
kev.data = 1;
|
||||||
kev.fflags = 0;
|
kev.fflags = 0;
|
||||||
kevent_cmp(&kev, kevent_get(kqfd));
|
kevent_cmp(&kev, kevent_get(kqfd));
|
||||||
stop = time(NULL);
|
|
||||||
if (stop < start + timeout)
|
|
||||||
err(1, "too early %jd %jd", (intmax_t)stop, (intmax_t)(start + timeout));
|
|
||||||
|
|
||||||
|
stop = now();
|
||||||
|
if (stop < end)
|
||||||
|
err(1, "too early %jd %jd", (intmax_t)stop, (intmax_t)end);
|
||||||
/* Check if the event occurs again */
|
/* Check if the event occurs again */
|
||||||
sleep(3);
|
sleep(3);
|
||||||
test_no_kevents();
|
test_no_kevents();
|
||||||
|
Loading…
Reference in New Issue
Block a user