]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
MFC r360033, r360108: better precision in kqueue timer tests
authorKyle Evans <kevans@FreeBSD.org>
Fri, 24 Apr 2020 13:29:08 +0000 (13:29 +0000)
committerKyle Evans <kevans@FreeBSD.org>
Fri, 24 Apr 2020 13:29:08 +0000 (13:29 +0000)
commit89dbf48451d5b1fcfe8fe77c360a43f517ad404a
treed9b825f86528e03146c1bebeb37b09b715f000f0
parent59bc5d08531fc9c21f7fa663c64aa631e814db9b
MFC r360033, r360108: better precision in kqueue timer tests

r360033:
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.

r360108:
tests: kqueue: fix some issues with now() on ILP32 platforms

There were ultimately two separate problems here:
- a 32-bit long cannot represent microseconds since 1970 (noted by ian)
- time_t is 32-bit on i386, so now() was wrong anyways even with the correct
  return type.

For the first, just explicitly use a uint64_t for now() and all of the
callers. For the second, we need to explicitly cast tv_sec to uint64_t
before it gets multiplied in the SEC_TO_US macro. Casting this instance
rather than generally in the macro was arbitrarily chosen simply because all
other uses are converting small relative time values.

The tests now pass on i386, at least; presumably other ILP32 will be fine
now as well.
tests/sys/kqueue/libkqueue/timer.c