From: Jesse Gross Date: Thu, 10 Jun 2010 23:35:34 +0000 (-0700) Subject: tests: Allow some difference in rounding in timeval test. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=02029a699a1642043ca50d90cf4a39949708426e;p=openvswitch tests: Allow some difference in rounding in timeval test. 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. --- diff --git a/tests/test-timeval.c b/tests/test-timeval.c index f0552f88..b336f395 100644 --- a/tests/test-timeval.c +++ b/tests/test-timeval.c @@ -70,8 +70,12 @@ do_test(void) } 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; } }