diff options
author | Pádraig Brady <P@draigBrady.com> | 2010-07-05 08:53:10 +0100 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2010-07-05 15:06:07 +0100 |
commit | 09fcf494a10c4b1ad2b037d093f571e7462e08c4 (patch) | |
tree | b37ab28311bb36e20c3f18f09531196dd70381b1 /tests/dd | |
parent | 1d95457b3ecc57df4cd67175abd093b84e29372b (diff) | |
download | coreutils-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/dd')
-rwxr-xr-x | tests/dd/misc | 2 | ||||
-rwxr-xr-x | tests/dd/reblock | 40 |
2 files changed, 29 insertions, 13 deletions
diff --git a/tests/dd/misc b/tests/dd/misc index 7caacbc7b..ddd7bbd9e 100755 --- a/tests/dd/misc +++ b/tests/dd/misc @@ -87,6 +87,8 @@ fi outbytes=`echo x | dd bs=3 ibs=10 obs=10 conv=sync 2>/dev/null | wc -c` test "$outbytes" -eq 3 || fail=1 +# A delay is required to trigger a failure. +# There might be some missed failures but it's unlikely. (echo a; sleep .1; echo b) \ | env LC_ALL=C dd bs=4 status=noxfer iflag=fullblock >out 2>err || fail=1 printf 'a\nb\n' > out_ok || framework_failure diff --git a/tests/dd/reblock b/tests/dd/reblock index 4a487663b..9c9b0f85f 100755 --- a/tests/dd/reblock +++ b/tests/dd/reblock @@ -45,18 +45,32 @@ EOF # from each printf separately. mkfifo dd.fifo || framework_failure -# ensure that dd reblocks when bs= is not specified -dd ibs=3 obs=3 if=dd.fifo > out 2> err& -(printf 'ab'; sleep .2; printf 'cd') > dd.fifo -wait #for dd to complete -sed 's/,.*//' err > k && mv k err -compare err exp-reblock || fail=1 - -# Demonstrate that bs=N supersedes even following ibs= and obs= settings. -dd bs=3 ibs=1 obs=1 if=dd.fifo > out 2> err& -(printf 'ab'; sleep .2; printf 'cd') > dd.fifo -wait #for dd to complete -sed 's/,.*//' err > k && mv k err -compare err exp-no-reblock || fail=1 +dd_reblock_1() +{ + local delay="$1" + + # ensure that dd reblocks when bs= is not specified + dd ibs=3 obs=3 if=dd.fifo > out 2> err& + (printf 'ab'; sleep $delay; printf 'cd') > dd.fifo + wait #for dd to complete + sed 's/,.*//' err > k && mv k err + compare err exp-reblock +} + +retry_delay_ dd_reblock_1 .1 6 || fail=1 + +dd_reblock_2() +{ + local delay="$1" + + # Demonstrate that bs=N supersedes even following ibs= and obs= settings. + dd bs=3 ibs=1 obs=1 if=dd.fifo > out 2> err& + (printf 'ab'; sleep $delay; printf 'cd') > dd.fifo + wait #for dd to complete + sed 's/,.*//' err > k && mv k err + compare err exp-no-reblock +} + +retry_delay_ dd_reblock_2 .1 6 || fail=1 Exit $fail |