From: Peter Maydell <peter.maydell@linaro.org>
To: QEMU Developers <qemu-devel@nongnu.org>
Cc: Kamil Rytarowski <n54@gmx.com>,
"patches@linaro.org" <patches@linaro.org>
Subject: Re: [Qemu-devel] [PATCH] tests: Handle $RANDOM not being supported by the shell
Date: Thu, 20 Jul 2017 16:34:40 +0100 [thread overview]
Message-ID: <CAFEAcA_WAvAei161UpsFSmjzW_TrmRhmcU4WQmDw=msajaQg0w@mail.gmail.com> (raw)
In-Reply-To: <1500029117-6387-1-git-send-email-peter.maydell@linaro.org>
On 14 July 2017 at 11:45, Peter Maydell <peter.maydell@linaro.org> wrote:
> In various places in our test makefiles and scripts we use the
> shell $RANDOM to create a random number. This is a bash
> specific extension, and doesn't work on other shells.
> With dash the shell doesn't complain, it just effectively
> always evaluates $RANDOM to 0:
> echo $((RANDOM + 32768)) => 32768
>
> However, on NetBSD the shell will complain:
> "-sh: arith: syntax error: "RANDOM + 32768"
>
> which means that "make check" fails.
>
> Switch to using "${RANDOM:-0}" instead of $RANDOM,
> which will portably either give us a random number or zero.
> This means that on non-bash shells we don't get such
> good test coverage via the MALLOC_PERTURB_ setting, but
> we were already in that situation for non-bash shells.
>
> Our only other uses of $RANDOM (in tests/qemu-iotests/check
> and tests/qemu-iotests/162) are in shell scripts which use
> a #!/bin/bash line so they are always run under bash.
>
> Suggested-by: Eric Blake <eblake@redhat.com>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> tests/Makefile.include | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
Applied, thanks.
-- PMM
prev parent reply other threads:[~2017-07-20 15:35 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-14 10:45 [Qemu-devel] [PATCH] tests: Handle $RANDOM not being supported by the shell Peter Maydell
2017-07-14 11:27 ` Kamil Rytarowski
2017-07-14 11:50 ` Kamil Rytarowski
2017-07-14 12:02 ` Eric Blake
2017-07-14 11:41 ` Fam Zheng
2017-07-14 12:03 ` Eric Blake
2017-07-17 9:43 ` Stefan Hajnoczi
2017-07-20 11:26 ` Markus Armbruster
2017-07-20 15:34 ` Peter Maydell [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAFEAcA_WAvAei161UpsFSmjzW_TrmRhmcU4WQmDw=msajaQg0w@mail.gmail.com' \
--to=peter.maydell@linaro.org \
--cc=n54@gmx.com \
--cc=patches@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).