From: Eugene Syromyatnikov Date: Fri, 11 Oct 2019 11:36:15 +0000 (+0200) Subject: tests: try to avoid false positives in times sanity check X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c5ed146fa97cf50b11c6fcf9181e2fc501e245f8;p=strace tests: try to avoid false positives in times sanity check Checking clock_gettime(CLOCK_PROCESS_CPUTIME_ID) starting from the second iteration may produce false positives sometimes, try to spend more iterations before starting checking it. * tests/times.c (NUM_USER_ITERS_SQRT): New enum entity. (NUM_USER_ITERS): Define via NUM_USER_ITERS_SQRT. (main): Check i against NUM_USER_ITERS_SQRT first before checking the returned CPU time for sanity. --- diff --git a/tests/times.c b/tests/times.c index 4f7e361e..06a0f257 100644 --- a/tests/times.c +++ b/tests/times.c @@ -24,7 +24,8 @@ #include enum { - NUM_USER_ITERS = 1000000, + NUM_USER_ITERS_SQRT = 1000, + NUM_USER_ITERS = NUM_USER_ITERS_SQRT * NUM_USER_ITERS_SQRT, PARENT_CPUTIME_LIMIT_NSEC = 200000000, CHILD_CPUTIME_LIMIT_NSEC = 300000000 }; @@ -48,7 +49,7 @@ main(void) if (ts.tv_sec || ts.tv_nsec >= cputime_limit) break; - if (i && !(ts.tv_sec || ts.tv_nsec)) + if ((i > NUM_USER_ITERS_SQRT) && !(ts.tv_sec || ts.tv_nsec)) error_msg_and_skip("clock_gettime(CLOCK_PROCESS_CPUTIME_ID, {0, 0})"); for (i = 0; i < NUM_USER_ITERS; ++i)