summaryrefslogtreecommitdiff
path: root/tests/tail-2
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2015-06-01 16:46:33 +0100
committerPádraig Brady <P@draigBrady.com>2015-06-01 17:02:02 +0100
commitd796a29f2fb92f74d73d0aa27c86caf58d753f46 (patch)
treed86c08a815172b687522128e8046cbc13cf06c72 /tests/tail-2
parentb09f34b80f7bfe7e596d8cae6bdc44eb2d3e6526 (diff)
downloadcoreutils-d796a29f2fb92f74d73d0aa27c86caf58d753f46.tar.xz
tests: fix race in tail test without inotify
* tests/tail-2/wait.sh: Without inotify, skip a portion of the test that checks that -F never outputs from a tailed descriptor after the followed name is recreated, because tail_forever() doesn't guarantee that. Noticed at http://hydra.nixos.org/build/22766288
Diffstat (limited to 'tests/tail-2')
-rwxr-xr-xtests/tail-2/wait.sh17
1 files changed, 13 insertions, 4 deletions
diff --git a/tests/tail-2/wait.sh b/tests/tail-2/wait.sh
index 071d889d6..2e58e8211 100755
--- a/tests/tail-2/wait.sh
+++ b/tests/tail-2/wait.sh
@@ -20,6 +20,11 @@
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ tail
+grep '^#define HAVE_INOTIFY 1' "$CONFIG_HEADER" >/dev/null \
+ && HAVE_INOTIFY=1
+
+inotify_failed_re='inotify (resources exhausted|cannot be used)'
+
touch here || framework_failure_
{ touch unreadable && chmod a-r unreadable; } || framework_failure_
@@ -54,11 +59,13 @@ for mode in '' '---disable-inotify'; do
timeout .1 tail $fastpoll -F $mode not_here
test $? = 124 || fail=1
- grep -Ev 'inotify (resources exhausted|cannot be used)' tail.err > x
+ grep -Ev "$inotify_failed_re" tail.err > x
mv x tail.err
compare /dev/null tail.err || fail=1
>tail.err
+done
+if test "$HAVE_INOTIFY"; then
# Ensure -F never follows a descriptor after rename
# either with tiny or significant delays between operations
tail_F()
@@ -66,7 +73,7 @@ for mode in '' '---disable-inotify'; do
local delay="$1"
touch k || framework_failure_
- tail $fastpoll -F $mode k > tail.out & pid=$!
+ tail $fastpoll -F $mode k >tail.out 2>tail.err & pid=$!
sleep $delay
mv k l
sleep $delay
@@ -78,10 +85,12 @@ for mode in '' '---disable-inotify'; do
cleanup_
rm -f k l
- test -s tail.out
+ test -s tail.out \
+ && ! grep -E "$inotify_failed_re" tail.err >/dev/null
}
+
retry_delay_ tail_F 0 1 && { cat tail.out; fail=1; }
retry_delay_ tail_F .2 1 && { cat tail.out; fail=1; }
-done
+fi
Exit $fail