diff --git a/testcases/open_posix_testsuite/conformance/interfaces/clock_settime/8-1.c b/testcases/open_posix_testsuite/conformance/interfaces/clock_settime/8-1.c index 4340cc8de2c..069450ae615 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/clock_settime/8-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/clock_settime/8-1.c @@ -23,6 +23,7 @@ #include #include "posixtest.h" #include "helpers.h" +#include "timespec.h" #define SLEEPSEC 5 #define SMALLTIME 2 @@ -35,6 +36,10 @@ int main(void) { struct timespec tsT0, tssleep; int pid; + long diffnano, diffnano_low, diffnano_high; + + diffnano_low = (long)(SLEEPSEC - SMALLTIME) * NSEC_IN_SEC; + diffnano_high = (long)(SLEEPSEC - SMALLTIME + ACCEPTABLEDELTA) * NSEC_IN_SEC; /* Check that we're root...can't call clock_settime with CLOCK_REALTIME otherwise */ if (getuid() != 0) { @@ -67,6 +72,11 @@ int main(void) expectedsec = tsT0.tv_sec + (SLEEPSEC - SMALLTIME); + diffnano = timespec_nsec_diff(&tsT0, &tsend); + + printf("diffnano: %ld, > low: %d, < high: %d\n", diffnano, diffnano >= diffnano_low, diffnano <= diffnano_high); + + if (tsend.tv_sec >= expectedsec) { if ((tsend.tv_sec - expectedsec) <= ACCEPTABLEDELTA) { return CHILDPASS; diff --git a/testcases/open_posix_testsuite/include/timespec.h b/testcases/open_posix_testsuite/include/timespec.h index 027592db38a..210f46c3c57 100644 --- a/testcases/open_posix_testsuite/include/timespec.h +++ b/testcases/open_posix_testsuite/include/timespec.h @@ -36,8 +36,5 @@ static inline long timespec_nsec_diff(struct timespec *t1, struct timespec *t2) sec_diff = t1->tv_sec - t2->tv_sec; nsec_diff = t1->tv_nsec - t2->tv_nsec; - if (sec_diff > 1 || (sec_diff == 1 && nsec_diff >= 0)) - return NSEC_IN_SEC; - return labs(nsec_diff + NSEC_IN_SEC * sec_diff); }