diff options
author | Jim Meyering <meyering@redhat.com> | 2011-10-28 18:06:44 +0200 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2011-10-29 08:32:11 +0200 |
commit | f013fe07ab430e3fb0a501fe27c57a37c7734206 (patch) | |
tree | 27a4e442c073a1bfe00d68716b48e859925f5923 | |
parent | 2f1384b7e4674f2bdf4c471eee050bece59e01e6 (diff) | |
download | coreutils-f013fe07ab430e3fb0a501fe27c57a37c7734206.tar.xz |
tests: don't make tail's pipe-f2 test take the full 10 seconds
* tests/tail-2/pipe-f2: Don't always wait 10 seconds.
Before, this test would always wait 10 seconds.
Now, it stops early when it detects that tail -f has written output.
BTW, the race condition that prompted changing the timeout from 1 second
to 10 was that tail -f could be killed by the timeout before producing
any output.
-rwxr-xr-x | tests/tail-2/pipe-f2 | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/tests/tail-2/pipe-f2 b/tests/tail-2/pipe-f2 index f1ae47015..3421798b4 100755 --- a/tests/tail-2/pipe-f2 +++ b/tests/tail-2/pipe-f2 @@ -24,9 +24,20 @@ mkfifo_or_skip_ fifo echo 1 > fifo & echo 1 > exp || framework_failure_ -timeout 10 tail -f fifo > out -test $? = 124 || fail=1 +timeout 10 tail -f fifo > out & pid=$! + +check_tail_output() +{ + local n_sec="$1" + test -s out || { sleep $n_sec; return 1; } +} + +# Wait 6.3s for tail to write something. +retry_delay_ check_tail_output .1 7 || fail=1 compare out exp || fail=1 +# Kill the still-running tail, or fail if it's gone. +kill $pid || fail=1 + Exit $fail |