Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [PATCH] Enable sub-second timeout in zsystem flock



Sorry for the delay.

On 8 Mar 2020, at 13:39, Cedric Ware <cedric.ware__bml@xxxxxxxxxxxxxx> wrote:
> One thing about the tests: I've used the (...)& syntax to launch a
> sub-shell in the background for concurrency checks.  But does the test
> script wait for sub-processes to finish between tests?

It does not, no.

Some more comments:

> +  (
> +    : > $tst_dir/file
> +    zsystem flock -t 0.1 -i 0.000001 $tst_dir/file
> +  )

If this file is meant to be used by the other tests, it seems like it might
make more sense to create it in %prep. Like it'll be fine this way, but unless
there's a specific reason to do it like that...

> +  (
> +    typeset -F SECONDS
> +    start=$SECONDS
> +    (zsystem flock $tst_dir/file && zselect -t 50) &
> +    zselect -t 1
> +    if zsystem flock $tst_dir/file; then
> +      elapsed=$[ $SECONDS - $start ]
> +      if [[ $elapsed -ge 0.3 && $elapsed -le 0.7 ]]; then
> +        echo "elapsed time seems OK" 1>&2
> +      else
> +        echo "elapsed time $elapsed should be ~ 0.5 second" 1>&2
> +      fi
> +    else
> +      false
> +    fi
> +  )

1. All of the `else false`es in these tests seem redundant. If the condition
   doesn't pass it'll return >0 automatically, and the test will fail if it
   doesn't get the right output anyway

2. This particular test doesn't seem reliable on my machine. Within the test
   harness, it normally takes about 0.078 seconds. Probably the fork over-head
   (which is pretty high on macOS) is greater than the amount of time you're
   giving it wait? If i change `zselect -t 1` to `zselect -t 10` it seems to
   work better... but it still feels very brittle. Very much dependent on the
   hardware, the OS, and the current resource utilisation

dana



Messages sorted by: Reverse Date, Date, Thread, Author