From: Szabolcs Nagy Date: Tue, 20 May 2014 23:08:24 +0000 (+0200) Subject: fix syscall-sign-extend test X-Git-Url: http://nsz.repo.hu/git/?p=libc-test;a=commitdiff_plain;h=efd761658d756f8cf0a552ebc0e7833ed0c47d87 fix syscall-sign-extend test adjust the time a bit so non-monotonic vdso vs syscall gettime does not trigger a failure --- diff --git a/src/regression/syscall-sign-extend.c b/src/regression/syscall-sign-extend.c index 89ef9b6..7d3e0d8 100644 --- a/src/regression/syscall-sign-extend.c +++ b/src/regression/syscall-sign-extend.c @@ -16,8 +16,11 @@ static unsigned long long tsdiff(struct timespec ts2, struct timespec ts) ts2.tv_nsec += 1000000000; ts2.tv_sec--; } - if (ts2.tv_sec < ts.tv_sec) - return -1; + if (ts2.tv_sec < ts.tv_sec) { + t_error("non-monotonic SYS_clock_gettime vs clock_gettime: %llu ns\n", + (ts.tv_sec - ts2.tv_sec)*1000000000ULL + ts.tv_nsec - ts2.tv_nsec); + return 0; + } return (ts2.tv_sec - ts.tv_sec)*1000000000ULL + (ts2.tv_nsec - ts.tv_nsec); } @@ -31,8 +34,10 @@ int main(void) // check if timespec is filled correctly T(clock_gettime(CLOCK_REALTIME, &ts2)); + // adjust because linux vdso is non-monotonic wrt the syscall.. + ts.tv_nsec += 2; diff = tsdiff(ts2, ts); - if (diff > 10 * 1000000000ULL) + if (diff > 5 * 1000000000ULL) t_error("large diff between clock_gettime calls: %llu ns\n", diff); return t_status;