3
0
forked from pool/coreutils
coreutils/coreutils-tests-make-inotify-rotate-more-robust-and-efficient.patch
2015-01-19 23:25:06 +00:00

101 lines
3.3 KiB
Diff

Upstream patch on top of v8.23 (to be removed with v8.24).
http://git.sv.gnu.org/cgit/coreutils.git/commit/?id=111a2b91da
From 111a2b91da142bf6fb9edb7836c1979ba698cf6e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <P@draigBrady.com>
Date: Wed, 29 Oct 2014 14:08:05 +0000
Subject: [PATCH] tests: make inotify-rotate more robust and efficient
* tests/tail-2/inotify-rotate.sh: Use retry_delay_
to employ an exponential backoff with a total delay of
up to 25.5s. The 15s delay was seen to trigger a false
failure in http://hydra.nixos.org/build/16546517
Also remove the .1s sleep in each of the 50 iterations
to reduce the running time of the test and thus the
expensive_ tag on this test was removed.
Also ensure that we use the standard exit procedure
upon failure to avoid any erroneous diagnostics due
to persistent files on NFS.
---
tests/tail-2/inotify-rotate.sh | 45 ++++++++++++++++++++++-------------------
1 file changed, 25 insertions(+), 20 deletions(-)
Index: tests/tail-2/inotify-rotate.sh
===================================================================
--- tests/tail-2/inotify-rotate.sh.orig
+++ tests/tail-2/inotify-rotate.sh
@@ -22,48 +22,53 @@ if test "$VERBOSE" = yes; then
fi
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
-expensive_
-# Wait several seconds for grep REGEXP FILE to succeed.
-# Usage: grep_timeout REGEXP FILE
-grep_timeout()
+check_tail_output()
{
- local j
- for j in $(seq 150); do
- grep $1 $2 > /dev/null && return 0
- sleep 0.1
- done
- return 1
+ local delay="$1"
+ grep "$tail_re" out > /dev/null ||
+ { sleep $delay; return 1; }
}
+# Wait up to 25.5 seconds for grep REGEXP 'out' to succeed.
+grep_timeout() { tail_re="$1" retry_delay_ check_tail_output .1 8; }
+
# For details, see
# http://lists.gnu.org/archive/html/bug-coreutils/2009-11/msg00213.html
+cleanup_fail()
+{
+ cat out
+ warn_ $1
+ kill $pid
+}
+
# Perform at least this many iterations, because on multi-core systems
# the offending sequence of events can be surprisingly uncommon.
for i in $(seq 50); do
echo $i
- rm -rf k x out
+ rm -f k x out
+
# Normally less than a second is required here, but with heavy load
# and a lot of disk activity, even 20 seconds is insufficient, which
# leads to this timeout killing tail before the "ok" is written below.
>k && >x || framework_failure_ failed to initialize files
- timeout 40 tail -F k > out 2>&1 &
+ timeout 60 tail -F k > out 2>&1 &
pid=$!
- sleep .1
+
echo b > k;
# wait for b to appear in out
- grep_timeout b out || fail_ failed to find b in out
- while :; do grep b out > /dev/null && break; done
+ grep_timeout 'b' || { cleanup_fail 'failed to find b in out'; break; }
+
mv x k
# wait for tail to detect the rename
- grep_timeout tail: out || { cat out; fail_ failed to detect rename; }
+ grep_timeout 'tail:' || { cleanup_fail 'failed to detect rename'; break; }
+
echo ok >> k
- found=0
- # wait up to 10 seconds for "ok" to appear in out
- grep_timeout ok out && found=1
+ # wait for "ok" to appear in 'out'
+ grep_timeout 'ok' || { cleanup_fail 'failed to detect echoed ok'; break; }
+
kill $pid
- test $found = 0 && { cat out; fail_ failed to detect echoed '"ok"'; }
done
wait