[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] tests: don't make tail's pipe-f2 test take the full 10 secon
From: |
Pádraig Brady |
Subject: |
Re: [PATCH] tests: don't make tail's pipe-f2 test take the full 10 seconds |
Date: |
Fri, 28 Oct 2011 23:36:18 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20110816 Thunderbird/6.0 |
On 10/28/2011 05:08 PM, Jim Meyering wrote:
> I noticed that on a very fast system, the tail-2/pipe-f2 test
> was nearly the last one to complete. Turns out it was taking
> 10 seconds, when in fact it needs more than 1 only very rarely.
> Now, it usually completes in less than 1/3 of a second:
>
>>From 7b901da8c364e8880bc8798f949630c04723ec7b Mon Sep 17 00:00:00 2001
> From: Jim Meyering <address@hidden>
> Date: Fri, 28 Oct 2011 18:06:44 +0200
> Subject: [PATCH] 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.
> ---
> 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 f1ae470..d0d08c9 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.
> +tail_re='inaccessible' retry_delay_ check_tail_output .1 7 || fail=1
You don't need the tail_re here.
Otherwise it looks good.
cheers,
Pádraig.