Commit 99348f65 authored by Philippe Gerum's avatar Philippe Gerum Committed by Jan Kiszka
Browse files

testsuite/smokey: posix_clock: prevent false positive in time-dependent test

clock_decrease_after_periodic_timer_first_tick checks that periodic
interval timers based on CLOCK_REALTIME are not (pathologically)
affected by the epoch going backwards.

To this end, we measure the actual time observed between two ticks of
a periodic timer based on CLOCK_REALTIME with a call to
clock_settime() injecting a negative offset in between, equivalent to
five ticks.

Due to processing delays induced by clock_settime() and other latency,
we could observe a duration which exceeds a tick by a few tenths of
microseconds. Since we can't anticipate the amount of latency
involved, let's accept a longer delay of at most two ticks.

This is still correct from the standpoint of the test, which verifies
that no correlation exists between the clock offset injected by
clock_settime() and the delay until the next tick generated by the
affected clock.
Signed-off-by: Philippe Gerum's avatarPhilippe Gerum <>
Signed-off-by: Jan Kiszka's avatarJan Kiszka <>
parent 2e6fb812
...@@ -417,7 +417,7 @@ static int clock_decrease_after_periodic_timer_first_tick(void) ...@@ -417,7 +417,7 @@ static int clock_decrease_after_periodic_timer_first_tick(void)
diff = now.tv_sec * 1000000000ULL + now.tv_nsec - diff = now.tv_sec * 1000000000ULL + now.tv_nsec -
(timer.it_value.tv_sec * 1000000000ULL + timer.it_value.tv_nsec); (timer.it_value.tv_sec * 1000000000ULL + timer.it_value.tv_nsec);
if (!smokey_assert(diff < 1000000000)) if (!smokey_assert(diff < 2000000000))
return -EINVAL; return -EINVAL;
ret = smokey_check_errno(read(t, &ticks, sizeof(ticks))); ret = smokey_check_errno(read(t, &ticks, sizeof(ticks)));
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment