summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2015-02-16 13:19:20 +0000
committerPádraig Brady <P@draigBrady.com>2015-02-18 23:41:27 +0000
commit3f2f05f06763d79a7cab525a3ea2d726df3e3736 (patch)
tree77b3fb71882b8b790a8975c825cf0b14056d756c /tests
parentced120406f47584eb672f9731d5fee0e62761c0c (diff)
downloadcoreutils-3f2f05f06763d79a7cab525a3ea2d726df3e3736.tar.xz
tee: exit early if no more writable outputs
* src/tee.c (main): Don't continue reading if we can't output anywhere. * tests/misc/tee.sh: Ensure we exit when no more outputs. * NEWS: Mention the change in behavior.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/misc/tee.sh25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/misc/tee.sh b/tests/misc/tee.sh
index 3c3fd11d7..5f2eeda7b 100755
--- a/tests/misc/tee.sh
+++ b/tests/misc/tee.sh
@@ -31,4 +31,29 @@ for n in 0 $nums; do
done
done
+
+# Ensure tee exits early if no more writable outputs
+if test -w /dev/full && test -c /dev/full; then
+ yes | returns_ 1 timeout 10 tee /dev/full 2>err >/dev/full || fail=1
+ # Ensure an error for each of the 2 outputs
+ # (and no redundant errors for stdout).
+ test $(wc -l < err) = 2 || { cat err; fail=1; }
+
+
+ # Ensure we continue with outputs that are OK
+ seq 10000 > multi_read || framework_failure_
+
+ returns_ 1 tee /dev/full out2 2>err >out1 <multi_read || fail=1
+ cmp multi_read out1 || fail=1
+ cmp multi_read out2 || fail=1
+ # Ensure an error for failing output
+ test $(wc -l < err) = 1 || { cat err; fail=1; }
+
+ returns_ 1 tee out1 out2 2>err >/dev/full <multi_read || fail=1
+ cmp multi_read out1 || fail=1
+ cmp multi_read out2 || fail=1
+ # Ensure an error for failing output
+ test $(wc -l < err) = 1 || { cat err; fail=1; }
+fi
+
Exit $fail