X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=tests%2Ftest-timeval.c;h=442b27af6cd0fc90a6afc73839c86049af935d2c;hb=58a89177ab00d6a1c1b13479f8fd8e3a7b0aca6c;hp=f0552f88135fb0d4eac17235c84d0d4e113afb26;hpb=c73814a3e6cbdf8c4083ef1d510377e41cb82f6a;p=sliver-openvswitch.git diff --git a/tests/test-timeval.c b/tests/test-timeval.c index f0552f881..442b27af6 100644 --- a/tests/test-timeval.c +++ b/tests/test-timeval.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2010 Nicira Networks. + * Copyright (c) 2009, 2010, 2011 Nicira Networks. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,7 +37,7 @@ gettimeofday_in_msec(void) { struct timeval tv; - assert(!gettimeofday(&tv, NULL)); + xgettimeofday(&tv); return timeval_to_msec(&tv); } @@ -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; } } @@ -89,7 +93,6 @@ main(int argc, char *argv[]) { proctitle_init(argc, argv); set_program_name(argv[0]); - time_init(); if (argc != 2) { usage();