On 14/10/15 19:40, Jim Meyering wrote:
> FYI, I hit another failure,
> but now in another race-susceptible test:
> 
> + diff -u exp out
> --- exp 2015-10-14 11:26:05.424685178 -0700
> +++ out 2015-10-14 11:26:05.424685178 -0700
> @@ -1 +0,0 @@
> -line
> + fail=1
> + Exit 1
> + set +e
> + exit 1
> + exit 1
> + remove_tmp_
> + __st=1
> + cleanup_
> + :
> + cd /data/users/meyering/w/co/cu
> + chmod -R u+rwx /data/users/meyering/w/co/cu/gt-follow-stdin.sh.y0sA
> + rm -rf /data/users/meyering/w/co/cu/gt-follow-stdin.sh.y0sA
> + exit 1
> FAIL tests/tail-2/follow-stdin.sh (exit status: 1)
> 
> So I'll just remember to use reduced parallelism for this task.

That was an easier fix. Attached.

thanks,
Pádraig.
>From e94b04f65f5da6ba1230c3ab2888952f0adfdfb8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <[email protected]>
Date: Thu, 15 Oct 2015 03:16:50 +0100
Subject: [PATCH] tests: fix a false failure due to a race in a tail test

* tests/tail-2/follow-stdin.sh: Use the standard tail
testing framework to avoid the race seen under very high load,
and also test the non inotify case.
Reported by Jim Meyering
---
 tests/tail-2/follow-stdin.sh | 32 ++++++++++++++++++++++++--------
 1 file changed, 24 insertions(+), 8 deletions(-)

diff --git a/tests/tail-2/follow-stdin.sh b/tests/tail-2/follow-stdin.sh
index f50dd72..ba740ee 100755
--- a/tests/tail-2/follow-stdin.sh
+++ b/tests/tail-2/follow-stdin.sh
@@ -19,18 +19,34 @@
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
 print_ver_ tail
 
-echo line > exp || framework_failure_
+check_tail_output()
+{
+  local delay="$1"
+  grep "$tail_re" out ||
+    { sleep $delay; return 1; }
+}
+
+# Terminate any background tail process
+cleanup_() { kill $pid 2>/dev/null && wait $pid; }
+
+# Speedup the non inotify case
+fastpoll='-s.1 --max-unchanged-stats=1'
+
 echo line > in || framework_failure_
 
-timeout 1 tail -f < in > out 2> err
+for mode in '' '---disable-inotify'; do
+  echo line > exp || framework_failure_
+
+  tail $mode -f $fastpoll < in > out 2> err & pid=$!
 
-# tail from coreutils-7.5 would fail
-test $? = 124 || fail=1
+  # Wait up to 12.7s for output to appear:
+  tail_re='line' retry_delay_ check_tail_output .1 7 ||
+    { echo "$0: a: unexpected delay?"; cat out; fail=1; }
 
-# Ensure there was no error output.
-compare /dev/null err || fail=1
+  # Ensure there was no error output.
+  compare /dev/null err || fail=1
 
-# Ensure there was
-compare exp out || fail=1
+  cleanup_
+done
 
 Exit $fail
-- 
2.5.0

Reply via email to