[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] tests: fix race in tail test without inotify
From: |
Pádraig Brady |
Subject: |
[PATCH] tests: fix race in tail test without inotify |
Date: |
Mon, 1 Jun 2015 17:03:50 +0100 |
* 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
---
tests/tail-2/wait.sh | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/tests/tail-2/wait.sh b/tests/tail-2/wait.sh
index 071d889..2e58e82 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
--
2.4.1
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] tests: fix race in tail test without inotify,
Pádraig Brady <=