This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix time/tst-cpuclock1 intermitent failures


This test fails intermittently in systems with heavy load as
CLOCK_PROCESS_CPUTIME_ID is subject to scheduler pressure.  Thus the
test boundaries where relaxed to keep it from fail on this systems.

--

Hi,

I tried to implement the solution suggested by Adhemerval and it worked
fine on my tests.

The curious thing I had much more problems with nanosleep returning a
lot earlier then expected.  On the 1s sleep it many times returned in
0.2s for a heavy loaded system.

 time/tst-cpuclock1.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/time/tst-cpuclock1.c b/time/tst-cpuclock1.c
index 0120906f23..4968038207 100644
--- a/time/tst-cpuclock1.c
+++ b/time/tst-cpuclock1.c
@@ -157,14 +157,17 @@ do_test (void)
 
   struct timespec diff = { .tv_sec = after.tv_sec - before.tv_sec,
 			   .tv_nsec = after.tv_nsec - before.tv_nsec };
+  /* In ideal scheduler pressure this diff should be closer to 0.5s.  But in
+     a heavy loaded system the scheduler pressure can make this times to be
+     uncertain.  That's why the upper bound is 0.7s and there is no lower bound
+   */
   if (diff.tv_nsec < 0)
     {
       --diff.tv_sec;
       diff.tv_nsec += 1000000000;
     }
   if (diff.tv_sec != 0
-      || diff.tv_nsec > 600000000
-      || diff.tv_nsec < 100000000)
+      || diff.tv_nsec > 700000000)
     {
       printf ("before - after %ju.%.9ju outside reasonable range\n",
 	      (uintmax_t) diff.tv_sec, (uintmax_t) diff.tv_nsec);
@@ -196,13 +199,15 @@ do_test (void)
 	{
 	  struct timespec d = { .tv_sec = afterns.tv_sec - after.tv_sec,
 				.tv_nsec = afterns.tv_nsec - after.tv_nsec };
+	  /* scheduler pressure may affect sleep time so this test have relaxed
+	     time restrictions.  */
 	  if (d.tv_nsec < 0)
 	    {
 	      --d.tv_sec;
 	      d.tv_nsec += 1000000000;
 	    }
 	  if (d.tv_sec > 0
-	      || d.tv_nsec < sleeptime.tv_nsec
+	      || d.tv_nsec < 100000000
 	      || d.tv_nsec > sleeptime.tv_nsec * 2)
 	    {
 	      printf ("nanosleep time %ju.%.9ju outside reasonable range\n",
-- 
2.20.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]