qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] tests/qtest/virtio-net-failover: Use g_random_int() instead


From: Thomas Huth
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
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.0

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 via email to

[Prev in Thread] Current Thread [Next in Thread]