We now use a time source that provides nanosecond granularity.
However, our test uses gettimeofday() for comparision, which has
microsecond granularity. In some cases this can lead to different
values depending on the rounding. This allows us to be off by one
to prevent intermittent test failures.
}
if (gettimeofday_in_msec() - start_gtod >= TIME_UPDATE_INTERVAL) {
- assert(time_msec() - start_time_msec >= TIME_UPDATE_INTERVAL);
- assert(time_wall_msec() - start_time_wall >= TIME_UPDATE_INTERVAL);
+ /* gettimeofday() and time_msec() have different granularities in
+ * their time sources. Depending on the rounding used this could
+ * result in a slight difference, so we allow for 1 ms of slop. */
+ assert(time_msec() - start_time_msec >= TIME_UPDATE_INTERVAL - 1);
+ assert(time_wall_msec() - start_time_wall >=
+ TIME_UPDATE_INTERVAL - 1);
break;
}
}