summaryrefslogtreecommitdiff
path: root/tests/tail-2
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2015-10-15 03:16:50 +0100
committerPádraig Brady <P@draigBrady.com>2015-10-15 08:44:09 +0100
commit0458701041d89be7a55a7575b172621ac977aec5 (patch)
treef8669477e22e448cef00a8e4154e19e31b438435 /tests/tail-2
parentf9fb9acb0da91b40a2ba1a0bb93b4c3c72ed7aa6 (diff)
downloadcoreutils-0458701041d89be7a55a7575b172621ac977aec5.tar.xz
tests: avoid false failure in a tail test under load
* 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
Diffstat (limited to 'tests/tail-2')
-rwxr-xr-xtests/tail-2/follow-stdin.sh32
1 files changed, 24 insertions, 8 deletions
diff --git a/tests/tail-2/follow-stdin.sh b/tests/tail-2/follow-stdin.sh
index f50dd726e..ba740eeea 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