HomeFreeBSD

MFC r360033, r360108: better precision in kqueue timer tests

Description

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.

Details

Provenance
kevansAuthored on
Parents
rS360256: MFC r360140, r360155: kqueue timer/data fixes
Branches
Unknown
Tags
Unknown