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/misc/stdbuf | 55 ++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 17 deletions(-) (limited to 'tests/misc/stdbuf') diff --git a/tests/misc/stdbuf b/tests/misc/stdbuf index 0e94ae21e..5822698ea 100755 --- a/tests/misc/stdbuf +++ b/tests/misc/stdbuf @@ -59,18 +59,32 @@ stdbuf -o1 no_such # no such command test $? = 127 || fail=1 # Ensure line buffering stdout takes effect -printf '1\n' > exp -dd count=1 if=fifo > out 2> err & -(printf '1\n'; sleep .2; printf '2\n') | stdbuf -oL uniq > fifo -wait # for dd to complete -compare out exp || fail=1 - -# Ensure un buffering stdout takes effect -printf '1\n' > exp -dd count=1 if=fifo > out 2> err & -(printf '1\n'; sleep .2; printf '2\n') | stdbuf -o0 uniq > fifo -wait # for dd to complete -compare out exp || fail=1 +stdbuf_linebuffer() +{ + local delay="$1" + + printf '1\n' > exp + dd count=1 if=fifo > out 2> err & + (printf '1\n'; sleep $delay; printf '2\n') | stdbuf -oL uniq > fifo + wait # for dd to complete + compare out exp +} + +retry_delay_ stdbuf_linebuffer .1 6 || fail=1 + +stdbuf_unbuffer() +{ + local delay="$1" + + # Ensure un buffering stdout takes effect + printf '1\n' > exp + dd count=1 if=fifo > out 2> err & + (printf '1\n'; sleep $delay; printf '2\n') | stdbuf -o0 uniq > fifo + wait # for dd to complete + compare out exp +} + +retry_delay_ stdbuf_unbuffer .1 6 || fail=1 # Ensure un buffering stdin takes effect # The following works for me, but is racy. I.E. we're depending @@ -93,10 +107,17 @@ compare out exp || fail=1 # Ensure block buffering stdout takes effect # We don't currently test block buffering failures as # this doesn't work on on GLIBC-2.7 or GLIBC-2.9 at least. - # printf '1\n2\n' > exp - # dd count=1 if=fifo > out 2> err & - # (printf '1\n'; sleep .2; printf '2\n') | stdbuf -o4 uniq > fifo - # wait # for dd to complete - # compare out exp || fail=1 + # stdbuf_blockbuffer() + # { + # local delay="$1" + # + # printf '1\n2\n' > exp + # dd count=1 if=fifo > out 2> err & + # (printf '1\n'; sleep $delay; printf '2\n') | stdbuf -o4 uniq > fifo + # wait # for dd to complete + # compare out exp + # } + # + # retry_delay_ stdbuf_blockbuffer .1 6 || fail=1 Exit $fail -- cgit v1.2.3-54-g00ecf