summaryrefslogtreecommitdiff
path: root/tests/misc/stdbuf
diff options
context:
space:
mode:
Diffstat (limited to 'tests/misc/stdbuf')
-rwxr-xr-xtests/misc/stdbuf55
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