qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kamil Rytarowski <n54@gmx.com>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] tests/Makefile.include non-portable use of $RANDOM
Date: Thu, 13 Jul 2017 20:42:08 +0200	[thread overview]
Message-ID: <9ba88752-aec4-24dd-d285-fe537bbfabeb@gmx.com> (raw)
In-Reply-To: <CAFEAcA9A0fBB+QE68O7aea+c6SXPaVK4+7B8DJoYE27qshtrcQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1067 bytes --]

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
> 



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2017-07-13 18:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-13 17:32 [Qemu-devel] tests/Makefile.include non-portable use of $RANDOM Peter Maydell
2017-07-13 18:42 ` Kamil Rytarowski [this message]
2017-07-13 20:16 ` Eric Blake
2017-07-13 21:15   ` Peter Maydell

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=9ba88752-aec4-24dd-d285-fe537bbfabeb@gmx.com \
    --to=n54@gmx.com \
    --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).