[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] tests/Makefile.include non-portable use of $RANDOM
From: |
Kamil Rytarowski |
Subject: |
Re: [Qemu-devel] tests/Makefile.include non-portable use of $RANDOM |
Date: |
Thu, 13 Jul 2017 20:42:08 +0200 |
User-agent: |
Mozilla/5.0 (X11; NetBSD amd64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0 |
On 13.07.2017 19:32, Peter Maydell wrote:
> Currently our test makefile does
>
> MALLOC_PERTURB_=$${MALLOC_PERTURB_:-$$((RANDOM % 255 + 1))}
>
> This works on bash, but $RANDOM is bash-specific.
> On dash, it doesn't do what we want, but it does do something:
>
> $ echo $((RANDOM % 255 + 1))
> 1
>
> On NetBSD the shell complains:
> # echo $((RANDOM % 255 + 1))
> -sh: arith: syntax error: "RANDOM % 255 + 1"
>
> and so 'make check' doesn't work.
>
> Any suggestions for something more portable?
> https://unix.stackexchange.com/questions/140750/generate-random-numbers-in-specific-range
> suggests
> awk 'BEGIN{srand(); print int(1+rand()*256)}'
> and of course there are similar things possible with perl et al.
>
> Or we could just have the makefile check whether we have bash,
> and if not then set
> RANDOM=4
>
> (thus putting NetBSD into the same boat as all our dash users).
>
> Opinions?
>
From the NetBSD point of view, please skip it. We support $RANDOM in
NetBSD 8.0_BETA.
> thanks
> -- PMM
>
signature.asc
Description: OpenPGP digital signature