[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/2] tests: fix tail test race causing false failure
From: |
Pádraig Brady |
Subject: |
[PATCH 2/2] tests: fix tail test race causing false failure |
Date: |
Tue, 31 Jan 2017 21:41:36 -0800 |
* tests/tail-2/retry.sh: The replacement of the "missing" directory
is not atomic, and therefore tail(1) can take a different path,
especially if there is a delay between the rmdir(2) and creat(2).
This is noticeable for example with `make coverage` because in
that case the coverage files written by rmdir(1) on exit,
induce a significant delay thus triggering the issue.
---
tests/tail-2/retry.sh | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/tests/tail-2/retry.sh b/tests/tail-2/retry.sh
index 40d66d6..6901ca4 100755
--- a/tests/tail-2/retry.sh
+++ b/tests/tail-2/retry.sh
@@ -165,17 +165,18 @@ mkdir untailable || framework_failure_
timeout 10 \
tail $mode $fastpoll -F untailable >out 2>&1 & pid=$!
# Wait for "cannot follow" error.
-retry_delay_ wait4lines_ .1 6 2 || { cat out; fail=1; }
+retry_delay_ wait4lines_ .1 6 2 || { cat out; fail=1; }
{ rmdir untailable; echo foo > untailable; } || framework_failure_
# Wait for the expected output.
-retry_delay_ wait4lines_ .1 6 4 || { cat out; fail=1; }
+retry_delay_ wait4lines_ .1 6 4 || { cat out; fail=1; }
cleanup_
-[ "$(countlines_)" = 4 ] || { fail=1; cat out; }
-grep -F 'cannot follow' out || { fail=1; cat out; }
-grep -F 'has become accessible' out || { fail=1; cat out; }
-grep -F 'giving up' out && { fail=1; cat out; }
-grep -F 'foo' out || { fail=1; cat out; }
-rm -fd untailable out || framework_failure_
+[ "$(countlines_)" = 4 ] || { fail=1; cat out; }
+grep -F 'cannot follow' out || { fail=1; cat out; }
+grep -F 'become accessible' out || # usual case
+grep -F 'has appeared' out || { fail=1; cat out; } # with slow rmdir
+grep -F 'giving up' out && { fail=1; cat out; }
+grep -F 'foo' out || { fail=1; cat out; }
+rm -fd untailable out || framework_failure_
fi
done
--
2.5.5