summaryrefslogtreecommitdiff
path: root/tests/tail-2/flush-initial
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/flush-initial
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/flush-initial')
-rwxr-xr-xtests/tail-2/flush-initial17
1 files changed, 9 insertions, 8 deletions
diff --git a/tests/tail-2/flush-initial b/tests/tail-2/flush-initial
index cf5438011..98de2e1f5 100755
--- a/tests/tail-2/flush-initial
+++ b/tests/tail-2/flush-initial
@@ -29,14 +29,15 @@ echo line > in || fail=1
tail -f in > out &
tail_pid=$!
-# Wait for 1 second for the file to be flushed.
-for i in $(seq 10); do
- test -s out && break
- echo sleep .1s
- sleep .1
-done
-
-test -s out || fail=1
+# Wait for 1.5s for the file to be flushed.
+tail_flush()
+{
+ local delay="$1"
+
+ test -s out ||
+ { sleep "$delay"; return 1; }
+}
+retry_delay_ tail_flush .1 5 || fail=1
kill $tail_pid