diff options
author | Pádraig Brady <P@draigBrady.com> | 2023-01-03 18:06:45 +0100 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2023-02-28 14:02:42 +0000 |
commit | b1376bb829be9147b5699fff637529378b02f758 (patch) | |
tree | 4a792c0af14b3d17036c29cc2cc1a5f181bedc64 /tests | |
parent | 6b12e62d9585726424b3105b84827d39380d7ab2 (diff) | |
download | coreutils-b1376bb829be9147b5699fff637529378b02f758.tar.gz |
tests: tee -p: add test for early exit with closed pipes
* tests/misc/tee.sh: Add a test for the new iopoll logic
to detect closed outputs and exit early without needing
further input.
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/misc/tee.sh | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/misc/tee.sh b/tests/misc/tee.sh index b96523186..30d64a9d2 100755 --- a/tests/misc/tee.sh +++ b/tests/misc/tee.sh @@ -63,6 +63,16 @@ if test -w /dev/full && test -c /dev/full; then test $(wc -l < err) = 1 || { cat err; fail=1; } fi +# Test iopoll-powered early exit for closed pipes +tee_exited() { sleep $1; test -f tee.exited; } +# Currently this functionality is most useful with +# intermittent input from a terminal, but here we +# use an input pipe that doesn't write anything +# but will exit as soon as tee does, or it times out +retry_delay_ tee_exited .1 7 | # 12.7s (Must be > following timeout) +{ timeout 10 tee -p 2>err && touch tee.exited; } | : +test $(wc -l < err) = 0 || { cat err; fail=1; } +test -f tee.exited || fail=1 # Ensure tee honors --output-error modes mkfifo_or_skip_ fifo |