Quoting https://lkml.org/lkml/2015/2/19/384 "The idea that time() would be ok as being HZ granular, and its been this way since 2.6.23. Thus you have a < HZ sized window where gettimeofday() will return the next second before time() gets updated by the tick."
Avoid running this test on second boundary as there is small window, where this test can fail on Linux, reporting that 2 seconds has passed. Signed-off-by: Jan Stancek <jstan...@redhat.com> --- .../conformance/interfaces/difftime/1-1.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/testcases/open_posix_testsuite/conformance/interfaces/difftime/1-1.c b/testcases/open_posix_testsuite/conformance/interfaces/difftime/1-1.c index 97bf443..2872e08 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/difftime/1-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/difftime/1-1.c @@ -15,14 +15,31 @@ #include <stdio.h> #include <stdlib.h> #include <unistd.h> +#include <sys/time.h> #include "posixtest.h" int main(void) { time_t time1, time0; - double time_diff; - time_diff = 0; + struct timeval t1; + + /* + * Quoting https://lkml.org/lkml/2015/2/19/384 + * "The idea that time() would be ok as being HZ granular, and its + * been this way since 2.6.23. Thus you have a < HZ sized window + * where gettimeofday() will return the next second before time() + * gets updated by the tick." + * + * Avoid running this test on second boundary as there is small + * window, where this test can fail on Linux, reporting that 2 + * seconds has passed. + */ + do { + usleep(10000); + gettimeofday(&t1, NULL); + } while (t1.tv_usec > 700*1000 || t1.tv_usec < 300*1000); + time0 = time(NULL); sleep(WAIT_DURATION); time1 = time(NULL); -- 1.8.3.1 ------------------------------------------------------------------------------ Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server from Actuate! Instantly Supercharge Your Business Reports and Dashboards with Interactivity, Sharing, Native Excel Exports, App Integration & more Get technology previously reserved for billion-dollar corporations, FREE http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk _______________________________________________ Ltp-list mailing list Ltp-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ltp-list