tests: Add some rounding tolerance in timeout test
Occasionally this test fails in CI with the message:
assertion failed: (current_time / 1000000 - last_time / 1000000 == 1)
The way this calculation is done at the moment, a difference of 1001ms
between current_time
and last_time
can result in failure, if the
times are close to a multiple to 1000ms.
Change it to only truncate the result after doing the subtraction, and
add a 500ms tolerance to account for scheduling delays in the test. (For
example, the test_func()
could be called, then descheduled before it
gets to call g_get_monotonic_time()
.
Additionally, change the test to use g_assert_cmpint()
so that future
failures provide more useful debug information.
Signed-off-by: Philip Withnall pwithnall@endlessos.org