bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] tests: tail-2/infloop-1: avoid rare test failure on a busy syste


From: Jim Meyering
Subject: [PATCH] tests: tail-2/infloop-1: avoid rare test failure on a busy system
Date: Mon, 07 Sep 2009 19:15:17 +0200

I've seen this test fail a few times, recently,
but it's not easy to trigger.  With this change,
I saw no failure in 60 iterations.

>From 494fed027114d63719439b399a7602f8d0384bcf Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Mon, 7 Sep 2009 11:39:19 +0200
Subject: [PATCH] tests: tail-2/infloop-1: avoid rare test failure on a busy 
system

* tests/tail-2/infloop-1: Sleep 3 seconds, not 1, but in increments
of 0.1 second.  Before, this test would fail ~1 time in 20 via
"make -j9 check" on a quad-core system.
Correct comment.
---
 tests/tail-2/infloop-1 |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/tests/tail-2/infloop-1 b/tests/tail-2/infloop-1
index 6a456de..72d51d9 100755
--- a/tests/tail-2/infloop-1
+++ b/tests/tail-2/infloop-1
@@ -27,16 +27,22 @@ yes > t &
 yes_pid=$!
 while :; do
   test -s t && break
+  sleep .1
 done
 tail -n 1 t &
 tail_pid=$!
 kill $yes_pid

 # This test is racy, and can fail under unusual circumstances.
-# On a busy system, "yes" will fail to write
-# (and hence fail to be killed by SIGPIPE) in that 1-second interval.
+# On a very busy system, tail will fail to notice that $yes_pid is gone.
 # Then the following kill will succeed and cause this test to fail.
-sleep 1
+
+# Wait for up to 3 seconds for tail to detect the death of $yes_pid.
+for i in $(seq 30); do
+    kill -0 $tail_pid || break
+    echo sleep 0.1s
+    sleep .1
+done

 fail=0
 kill $tail_pid && fail=1 || :
--
1.6.4.2.419.gab238




reply via email to

[Prev in Thread] Current Thread [Next in Thread]