qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: qemu-devel@nongnu.org, "Peter Maydell" <peter.maydell@linaro.org>,
	"Stefan Hajnoczi" <stefanha@redhat.com>,
	"Alex Bennée" <alex.bennee@linaro.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Subject: [PULL 10/10] tests: use g_test_rand_int
Date: Thu, 12 Dec 2019 19:54:24 +0100	[thread overview]
Message-ID: <20191212185424.4675-11-thuth@redhat.com> (raw)
In-Reply-To: <20191212185424.4675-1-thuth@redhat.com>

From: Paolo Bonzini <pbonzini@redhat.com>

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>
Message-Id: <1576113478-42926-1-git-send-email-pbonzini@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tests/ivshmem-test.c | 2 +-
 tests/test-bitmap.c  | 8 ++++----
 tests/test-qga.c     | 4 ++--
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/tests/ivshmem-test.c b/tests/ivshmem-test.c
index be9aa92a61..ecda256472 100644
--- a/tests/ivshmem-test.c
+++ b/tests/ivshmem-test.c
@@ -443,7 +443,7 @@ static gchar *mktempshm(int size, int *fd)
     while (true) {
         gchar *name;
 
-        name = g_strdup_printf("/qtest-%u-%u", getpid(), g_random_int());
+        name = g_strdup_printf("/qtest-%u-%u", getpid(), g_test_rand_int());
         *fd = shm_open(name, O_CREAT|O_RDWR|O_EXCL,
                        S_IRWXU|S_IRWXG|S_IRWXO);
         if (*fd > 0) {
diff --git a/tests/test-bitmap.c b/tests/test-bitmap.c
index 087e02a26c..2f5b71458a 100644
--- a/tests/test-bitmap.c
+++ b/tests/test-bitmap.c
@@ -22,10 +22,10 @@ static void check_bitmap_copy_with_offset(void)
     bmap2 = bitmap_new(BMAP_SIZE);
     bmap3 = bitmap_new(BMAP_SIZE);
 
-    bmap1[0] = random();
-    bmap1[1] = random();
-    bmap1[2] = random();
-    bmap1[3] = random();
+    bmap1[0] = g_test_rand_int();
+    bmap1[1] = g_test_rand_int();
+    bmap1[2] = g_test_rand_int();
+    bmap1[3] = g_test_rand_int();
     total = BITS_PER_LONG * 4;
 
     /* Shift 115 bits into bmap2 */
diff --git a/tests/test-qga.c b/tests/test-qga.c
index 1ca49bbced..d2b2435bb4 100644
--- a/tests/test-qga.c
+++ b/tests/test-qga.c
@@ -143,7 +143,7 @@ static void qmp_assertion_message_error(const char     *domain,
 static void test_qga_sync_delimited(gconstpointer fix)
 {
     const TestFixture *fixture = fix;
-    guint32 v, r = g_random_int();
+    guint32 v, r = g_test_rand_int();
     unsigned char c;
     QDict *ret;
 
@@ -186,7 +186,7 @@ static void test_qga_sync_delimited(gconstpointer fix)
 static void test_qga_sync(gconstpointer fix)
 {
     const TestFixture *fixture = fix;
-    guint32 v, r = g_random_int();
+    guint32 v, r = g_test_rand_int();
     QDict *ret;
 
     /*
-- 
2.18.1



  parent reply	other threads:[~2019-12-12 19:06 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-12 18:54 [PULL 00/10] Bluetooth removal, and qtest & misc patches Thomas Huth
2019-12-12 18:54 ` [PULL 01/10] hw/arm/nseries: Replace the bluetooth chardev with a "null" chardev Thomas Huth
2019-12-12 18:54 ` [PULL 02/10] hw/usb: Remove the USB bluetooth dongle device Thomas Huth
2019-12-12 18:54 ` [PULL 03/10] Remove the core bluetooth code Thomas Huth
2019-12-12 18:54 ` [PULL 04/10] Remove libbluetooth / bluez from the CI tests Thomas Huth
2019-12-12 18:54 ` [PULL 05/10] tests: fix modules-test 'duplicate test case' error Thomas Huth
2019-12-12 18:54 ` [PULL 06/10] pseries: disable migration-test if /dev/kvm cannot be used Thomas Huth
2019-12-12 18:54 ` [PULL 07/10] hw/misc/ivshmem: Bury dead legacy INTx code Thomas Huth
2019-12-12 18:54 ` [PULL 08/10] glib: use portable g_setenv() Thomas Huth
2019-12-12 18:54 ` [PULL 09/10] tests/Makefile: Fix check-report.* targets shown in check-help Thomas Huth
2019-12-12 18:54 ` Thomas Huth [this message]
2019-12-16 10:27 ` [PULL 00/10] Bluetooth removal, and qtest & misc patches Peter Maydell
2019-12-16 12:08   ` Thomas Huth
2019-12-16 12:29     ` 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=20191212185424.4675-11-thuth@redhat.com \
    --to=thuth@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /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).