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/misc/stdbuf | |
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/misc/stdbuf')
-rwxr-xr-x | tests/misc/stdbuf | 55 |
1 files changed, 38 insertions, 17 deletions
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 |