about summary refs log tree commit diff
path: root/rt
diff options
context:
space:
mode:
authorDJ Delorie <dj@redhat.com>2021-10-05 14:52:05 -0400
committerDJ Delorie <dj@redhat.com>2021-10-07 22:38:49 -0400
commitf3c6c190388bb445568cfbf190a0942fc3c28553 (patch)
tree4d93091910ab6db86b8254a3829f4ab90c0b3996 /rt
parent490e6c62aa31a8aa5c4a059f6e646ede121edf0a (diff)
downloadglibc-f3c6c190388bb445568cfbf190a0942fc3c28553.tar.gz
glibc-f3c6c190388bb445568cfbf190a0942fc3c28553.tar.xz
glibc-f3c6c190388bb445568cfbf190a0942fc3c28553.zip
Remove unreliable parts of rt/tst-cpuclock2
This is a follow-up to the tst-cpuclock1.c change here:
9a29f1a2ae3d4bb253ee368e0d71db0ca9494120

This test, like tst-cpuclock1, may fail on heavily loaded VM
servers (and has occasionally failed on the 32bit trybot),
so tests that rely on "wall time" have been removed.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
Diffstat (limited to 'rt')
-rw-r--r--rt/tst-cpuclock2.c91
1 files changed, 13 insertions, 78 deletions
diff --git a/rt/tst-cpuclock2.c b/rt/tst-cpuclock2.c
index eebc3609d0..32a1b75c2f 100644
--- a/rt/tst-cpuclock2.c
+++ b/rt/tst-cpuclock2.c
@@ -62,22 +62,9 @@ chew_cpu (void *arg)
   return NULL;
 }
 
-static unsigned long long int
-tsdiff (const struct timespec *before, const struct timespec *after)
-{
-  struct timespec diff = { .tv_sec = after->tv_sec - before->tv_sec,
-			   .tv_nsec = after->tv_nsec - before->tv_nsec };
-  while (diff.tv_nsec < 0)
-    {
-      --diff.tv_sec;
-      diff.tv_nsec += 1000000000;
-    }
-  return diff.tv_sec * 1000000000ULL + diff.tv_nsec;
-}
-
-static unsigned long long int
+static void
 test_nanosleep (clockid_t clock, const char *which,
-		const struct timespec *before, int *bad)
+		int *bad)
 {
   const struct timespec sleeptime = { .tv_nsec = 100000000 };
   int e = clock_nanosleep (clock, 0, &sleeptime, NULL);
@@ -85,13 +72,13 @@ test_nanosleep (clockid_t clock, const char *which,
     {
       printf ("clock_nanosleep not supported for %s CPU clock: %s\n",
 	      which, strerror (e));
-      return 0;
+      return;
     }
   if (e != 0)
     {
       printf ("clock_nanosleep on %s CPU clock: %s\n", which, strerror (e));
       *bad = 1;
-      return 0;
+      return;
     }
 
   struct timespec after;
@@ -100,16 +87,7 @@ test_nanosleep (clockid_t clock, const char *which,
       printf ("clock_gettime on %s CPU clock %lx => %s\n",
 	      which, (unsigned long int) clock, strerror (errno));
       *bad = 1;
-      return 0;
-    }
-
-  unsigned long long int diff = tsdiff (before, &after);
-  if (diff < sleeptime.tv_nsec || diff > sleeptime.tv_nsec * 2)
-    {
-      printf ("clock_nanosleep on %s slept %llu (outside reasonable range)\n",
-	      which, diff);
-      *bad = 1;
-      return diff;
+      return;
     }
 
   struct timespec sleeptimeabs = sleeptime;
@@ -126,7 +104,7 @@ test_nanosleep (clockid_t clock, const char *which,
       printf ("absolute clock_nanosleep on %s CPU clock: %s\n",
 	      which, strerror (e));
       *bad = 1;
-      return diff;
+      return;
     }
 
   struct timespec afterabs;
@@ -135,28 +113,10 @@ test_nanosleep (clockid_t clock, const char *which,
       printf ("clock_gettime on %s CPU clock %lx => %s\n",
 	      which, (unsigned long int) clock, strerror (errno));
       *bad = 1;
-      return diff;
-    }
-
-  unsigned long long int sleepdiff = tsdiff (&sleeptimeabs, &afterabs);
-  if (sleepdiff > sleeptime.tv_nsec)
-    {
-      printf ("\
-absolute clock_nanosleep on %s %llu past target (outside reasonable range)\n",
-	      which, sleepdiff);
-      *bad = 1;
+      return;
     }
 
-  unsigned long long int diffabs = tsdiff (&after, &afterabs);
-  if (diffabs < sleeptime.tv_nsec || diffabs > sleeptime.tv_nsec * 2)
-    {
-      printf ("\
-absolute clock_nanosleep on %s slept %llu (outside reasonable range)\n",
-	      which, diffabs);
-      *bad = 1;
-    }
-
-  return diff + diffabs;
+  return;
 }
 
 
@@ -290,37 +250,12 @@ do_test (void)
   printf ("self thread after sleep => %ju.%.9ju\n",
 	  (uintmax_t) me_after.tv_sec, (uintmax_t) me_after.tv_nsec);
 
-  unsigned long long int th_diff = tsdiff (&before, &after);
-  unsigned long long int pdiff = tsdiff (&process_before, &process_after);
-  unsigned long long int my_diff = tsdiff (&me_before, &me_after);
-
-  if (th_diff < 100000000 || th_diff > 600000000)
-    {
-      printf ("live thread before - after %llu outside reasonable range\n",
-	      th_diff);
-      result = 1;
-    }
-
-  if (my_diff > 100000000)
-    {
-      printf ("self thread before - after %llu outside reasonable range\n",
-	      my_diff);
-      result = 1;
-    }
-
-  if (pdiff < th_diff)
-    {
-      printf ("process before - after %llu outside reasonable range (%llu)\n",
-	      pdiff, th_diff);
-      result = 1;
-    }
-
-  process_after.tv_nsec += test_nanosleep (th_clock, "live thread",
-					   &after, &result);
-  process_after.tv_nsec += test_nanosleep (process_clock, "process",
-					   &process_after, &result);
+  test_nanosleep (th_clock, "live thread",
+		  &result);
+  test_nanosleep (process_clock, "process",
+		  &result);
   test_nanosleep (CLOCK_PROCESS_CPUTIME_ID,
-		  "PROCESS_CPUTIME_ID", &process_after, &result);
+		  "PROCESS_CPUTIME_ID", &result);
 
   pthread_cancel (th);