X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=tests%2Ftest-timeval.c;h=b336f3957e63467a75f33e82a1e505ee5ade8d73;hb=fceb2a5bb2063023777fc75c68a2670b5169fa13;hp=533f81aed3ff87e7e236628cb237d9ff800df591;hpb=c69ee87c10818267f991236201150b1fa51ae519;p=openvswitch diff --git a/tests/test-timeval.c b/tests/test-timeval.c index 533f81ae..b336f395 100644 --- a/tests/test-timeval.c +++ b/tests/test-timeval.c @@ -48,10 +48,11 @@ do_test(void) * setitimer()). Then ensure that, if time has really advanced by * TIME_UPDATE_INTERVAL, then time_msec() reports that it advanced. */ - long long int start_time_msec; + long long int start_time_msec, start_time_wall; long long int start_gtod; start_time_msec = time_msec(); + start_time_wall = time_wall_msec(); start_gtod = gettimeofday_in_msec(); for (;;) { /* Wait up to 1 second. Using select() to do the timeout avoids @@ -69,7 +70,12 @@ do_test(void) } if (gettimeofday_in_msec() - start_gtod >= TIME_UPDATE_INTERVAL) { - assert(time_msec() - start_time_msec >= 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; } }