From: Thomas Huth <thuth@redhat.com>
To: qemu-devel@nongnu.org
Subject: Re: [PATCH] tests: use g_test_rand_int
Date: Wed, 11 Dec 2019 20:25:23 +0100 [thread overview]
Message-ID: <c61a0b0f-d4c0-6418-c7cd-568cd6d27c5b@redhat.com> (raw)
In-Reply-To: <1576074210-52834-6-git-send-email-pbonzini@redhat.com>
On 11/12/2019 15.23, Paolo Bonzini wrote:
> g_test_rand_int provides a reproducible random integer number, using a
> different number seed every time but allowing reproduction using the
> --seed command line option. It is thus better suited to tests than
> g_random_int or random.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> block/vhdx.c | 2 +-
> block/vmdk.c | 4 ++--
> tests/ivshmem-test.c | 2 +-
> tests/test-bitmap.c | 8 ++++----
> tests/test-qga.c | 4 ++--
> 5 files changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/block/vhdx.c b/block/vhdx.c
> index f02d261..36465d5 100644
> --- a/block/vhdx.c
> +++ b/block/vhdx.c
> @@ -1504,7 +1504,7 @@ static int vhdx_create_new_headers(BlockBackend *blk, uint64_t image_size,
> hdr = g_new0(VHDXHeader, 1);
>
> hdr->signature = VHDX_HEADER_SIGNATURE;
> - hdr->sequence_number = g_random_int();
> + hdr->sequence_number = g_test_rand_int();
> hdr->log_version = 0;
> hdr->version = 1;
> hdr->log_length = log_size;
> diff --git a/block/vmdk.c b/block/vmdk.c
> index 20e909d..eba96bf 100644
> --- a/block/vmdk.c
> +++ b/block/vmdk.c
> @@ -2037,7 +2037,7 @@ static int vmdk_pwritev(BlockDriverState *bs, uint64_t offset,
> /* update CID on the first write every time the virtual disk is
> * opened */
> if (!s->cid_updated) {
> - ret = vmdk_write_cid(bs, g_random_int());
> + ret = vmdk_write_cid(bs, g_test_rand_int());
> if (ret < 0) {
> return ret;
> }
> @@ -2499,7 +2499,7 @@ static int coroutine_fn vmdk_co_do_create(int64_t size,
>
> /* generate descriptor file */
> desc = g_strdup_printf(desc_template,
> - g_random_int(),
> + g_test_rand_int(),
> parent_cid,
> BlockdevVmdkSubformat_str(subformat),
> parent_desc_line,
Why do you also change this in block/ and not only in tests/ ?
Thomas
next prev parent reply other threads:[~2019-12-11 19:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-11 14:23 [PATCH] tests: use g_test_rand_int Paolo Bonzini
2019-12-11 19:25 ` Thomas Huth [this message]
2019-12-12 1:17 ` Paolo Bonzini
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=c61a0b0f-d4c0-6418-c7cd-568cd6d27c5b@redhat.com \
--to=thuth@redhat.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).