All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: "Philippe Mathieu-Daudé" <philmd@redhat.com>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	qemu-devel@nongnu.org, "Laurent Vivier" <lvivier@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH] tests/qtest/virtio-net-failover: Use g_random_int() instead of g_test_rand_int()
Date: Tue, 21 Dec 2021 11:32:02 +0100	[thread overview]
Message-ID: <656b10c3-4edc-96bd-48b6-3302ddd7cb7c@redhat.com> (raw)
In-Reply-To: <72a60ec5-156b-d73e-9150-91c79eb92fc7@redhat.com>

On 20/12/2021 21.02, Philippe Mathieu-Daudé wrote:
> On 12/20/21 20:26, Richard Henderson wrote:
>> On 12/20/21 2:27 AM, Thomas Huth wrote:
>>>        const gchar *tmpdir = g_get_tmp_dir();
>>>        gchar *tmpfile = g_strdup_printf("%s/failover_test_migrate-%u-%u",
>>> -                                     tmpdir, getpid(),
>>> g_test_rand_int());
>>> +                                     tmpdir, getpid(), g_random_int());
>>
>> Random numbers plus pid are irrelevant, because you still don't have
>> guaranteed uniqueness -- think stale files in /tmp.
>>
>> Use g_file_open_tmp.
> 
> Another use in test_socket_unix_abstract(),
> tests/unit/test-util-sockets.c.

Using g_file_open_tmp is certainly better ... but the tests are currently 
written in a way where they require the file name of the temporary file - so 
switching to g_file_open_tmp() (which only provides a file handle) certainly 
would need some rewrite here... Thus I'd suggest to go first with this patch 
to silence the Assert messages, and then to clean this up properly later.

  Thomas



  reply	other threads:[~2021-12-21 10:33 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-20 10:27 [PATCH] tests/qtest/virtio-net-failover: Use g_random_int() instead of g_test_rand_int() Thomas Huth
2021-12-20 11:54 ` Laurent Vivier
2021-12-20 13:16 ` Philippe Mathieu-Daudé
2021-12-20 19:26 ` Richard Henderson
2021-12-20 20:02   ` Philippe Mathieu-Daudé
2021-12-21 10:32     ` Thomas Huth [this message]
2021-12-21 19:32       ` Richard Henderson
2021-12-22  7:02         ` Thomas Huth

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=656b10c3-4edc-96bd-48b6-3302ddd7cb7c@redhat.com \
    --to=thuth@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.