]> Git Repo - qemu.git/commitdiff
tests: use g_test_rand_int
authorPaolo Bonzini <[email protected]>
Thu, 12 Dec 2019 01:17:58 +0000 (02:17 +0100)
committerThomas Huth <[email protected]>
Tue, 17 Dec 2019 08:05:23 +0000 (09:05 +0100)
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 <[email protected]>
Message-Id: <1576113478[email protected]>
Reviewed-by: Thomas Huth <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Signed-off-by: Thomas Huth <[email protected]>
tests/ivshmem-test.c
tests/test-bitmap.c
tests/test-qga.c

index be9aa92a6125a966095401e77a6c96034bd76cfb..ecda25647265aa98ca9b59a7c015a5070605cc41 100644 (file)
@@ -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) {
index 087e02a26c7c4d81a0774b913b3ce4935882b315..2f5b71458a3df1d724b27023a510ed10bdb9e370 100644 (file)
@@ -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 */
index 1ca49bbced25a1ed150ebd2cae7334ed8a811bb0..d2b2435bb46e28181866a3704ad10803402cb210 100644 (file)
@@ -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;
 
     /*
This page took 0.031108 seconds and 4 git commands to generate.