From 09fcf494a10c4b1ad2b037d093f571e7462e08c4 Mon Sep 17 00:00:00 2001 From: Pádraig Brady
Date: Mon, 5 Jul 2010 08:53:10 +0100 Subject: 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. --- tests/dd/misc | 2 ++ tests/dd/reblock | 40 +++++++++++++++++++++++++++------------- 2 files changed, 29 insertions(+), 13 deletions(-) (limited to 'tests/dd') 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 -- cgit v1.2.3-70-g09d2