fix syscall-sign-extend test
authorSzabolcs Nagy <nsz@port70.net>
Tue, 20 May 2014 23:08:24 +0000 (01:08 +0200)
committerSzabolcs Nagy <nsz@port70.net>
Tue, 20 May 2014 23:08:24 +0000 (01:08 +0200)
adjust the time a bit so non-monotonic vdso vs syscall gettime does
not trigger a failure

src/regression/syscall-sign-extend.c

index 89ef9b6..7d3e0d8 100644 (file)
@@ -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;