summaryrefslogtreecommitdiff
path: root/tests/tail-2/tail-n0f
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2010-07-05 08:53:10 +0100
committerPádraig Brady <P@draigBrady.com>2010-07-05 15:06:07 +0100
commit09fcf494a10c4b1ad2b037d093f571e7462e08c4 (patch)
treeb37ab28311bb36e20c3f18f09531196dd70381b1 /tests/tail-2/tail-n0f
parent1d95457b3ecc57df4cd67175abd093b84e29372b (diff)
downloadcoreutils-09fcf494a10c4b1ad2b037d093f571e7462e08c4.tar.xz
tests: make tests requiring a delay to pass, more robust
* tests/init.cfg: Introduce a retry_delay_() function to repeatedly call a test function that requires a delay. This delay can now be shorter for the common case on fast systems, but will double until a configurable limit it reached before failing on slower systems. * tests/dd/reblock: Use retry_delay_. * tests/misc/cat-buf: Likewise. * tests/misc/stdbuf: Likewise. * tests/tail-2/F-vs-rename: Likewise. * tests/tail-2/flush-initial: Likewise. * tests/tail-2/tail-n0f: Likewise. * tests/tail-2/wait: Likewise. * test/dd/misc: Comment that delay is needed to trigger failure.
Diffstat (limited to 'tests/tail-2/tail-n0f')
-rwxr-xr-xtests/tail-2/tail-n0f18
1 files changed, 12 insertions, 6 deletions
diff --git a/tests/tail-2/tail-n0f b/tests/tail-2/tail-n0f
index 0ff3a3d01..6a9b59c37 100755
--- a/tests/tail-2/tail-n0f
+++ b/tests/tail-2/tail-n0f
@@ -39,12 +39,18 @@ for inotify in ---disable-inotify ''; do
for c_or_n in c n; do
tail --sleep=4 -${c_or_n} 0 -f $inotify $file &
pid=$!
- sleep .5
- state=$(get_process_status_ $pid)
- case $state in
- S*) ;;
- *) echo $0: process in unexpected state: $state 1>&2; fail=1 ;;
- esac
+ tail_sleeping()
+ {
+ local delay="$1"; sleep $delay
+ state=$(get_process_status_ $pid)
+ case $state in
+ S*) ;;
+ *) return 1;;
+ esac
+ }
+ # Wait up to 1.5s for tail to sleep
+ retry_delay_ tail_sleeping .1 4 ||
+ { echo $0: process in unexpected state: $state >&2; fail=1; }
kill $pid
done
done