summaryrefslogtreecommitdiff
path: root/tests/tail-2/assert.sh
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2015-07-04 17:13:50 +0300
committerIgor Pashev <pashev.igor@gmail.com>2015-07-04 17:13:50 +0300
commit71cd8e3a743046573744123777061b64881bf372 (patch)
tree82522befe647f4fff186a5630cad0cad33f8ef53 /tests/tail-2/assert.sh
parentc18578632fd3c9e513e613a86ba2b7c4ebee6c45 (diff)
downloadcoreutils-upstream.tar.gz
Imported Upstream version 8.24upstream/8.24upstream
Diffstat (limited to 'tests/tail-2/assert.sh')
-rwxr-xr-xtests/tail-2/assert.sh55
1 files changed, 31 insertions, 24 deletions
diff --git a/tests/tail-2/assert.sh b/tests/tail-2/assert.sh
index 35a10da2..43bd1e14 100755
--- a/tests/tail-2/assert.sh
+++ b/tests/tail-2/assert.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Test for assertion failure in "test".
-# Copyright (C) 1999-2014 Free Software Foundation, Inc.
+# Copyright (C) 1999-2015 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -26,36 +26,43 @@
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ tail
-# Not "expensive" per se, but sleeping for so long is annoying.
-very_expensive_
+check_tail_output()
+{
+ local delay="$1"
+ grep "$tail_re" out ||
+ { sleep $delay; return 1; }
+}
-ok='ok ok ok'
+# Terminate any background tail process
+cleanup_() { kill $pid 2>/dev/null && wait $pid; }
-touch a foo
-tail --follow=name a foo > err 2>&1 &
-tail_pid=$!
-# Arrange for the tail process to die after 12 seconds.
-(sleep 12; kill $tail_pid) &
+# Speedup the non inotify case
+fastpoll='-s.1 --max-unchanged-stats=1'
-echo sleeping for 7 seconds...
+for mode in '' '---disable-inotify'; do
+ rm -f a foo out
+ touch a foo || framework_failure_
-# Give the backgrounded 'tail' a chance to start before removing foo.
-# Otherwise, without --retry, tail wouldn't try to open 'foo' again.
-sleep 1
+ tail $mode --follow=name $fastpoll a foo > out 2>&1 & pid=$!
-rm -f foo
-sleep 6
-echo $ok > f
-mv f foo
+ # Wait up to 12.7s for tail to start.
+ echo x > a || framework_failure_
+ tail_re='^x$' retry_delay_ check_tail_output .1 7 ||
+ { cat out; fail=1; break; }
-# echo waiting....
-wait
+ # Wait 12.7s for this diagnostic:
+ # tail: foo: No such file or directory
+ rm foo || framework_failure_
+ tail_re='No such file' retry_delay_ check_tail_output .1 7 ||
+ { cat out; fail=1; break; }
-case "$(cat err)" in
- *$ok) ;;
- *) fail=1;;
-esac
+ # Wait up to 12.7s for tail to notice new foo file
+ ok='ok ok ok'
+ echo "$ok" > foo || framework_failure_
+ tail_re="^$ok$" retry_delay_ check_tail_output .1 7 ||
+ { echo "$0: foo: unexpected delay?"; cat out; fail=1; break; }
-test $fail = 1 && cat err
+ cleanup_
+done
Exit $fail