From nobody Sun May 5 18:58:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1576074867; cv=none; d=zohomail.com; s=zohoarc; b=huOdSvkdwDqJM/qNuH7leTiQaSRoHGAEZgd/WySlYQUvOvexqiJ7QqikxRN5RrrgmUkQcUNUmRPEm9StVJk2NYNw8lCQ2+Ka5yXN8KZADcRk6yqJ9FxR+WmHf4Pkf6xKghffVRcFMQcJauTs0qg4ifJ5n821kNvr3NonAlevP7E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576074867; h=Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:Sender:Subject:To; bh=DDlSLM0gJZ7KaXQqepJKvC61+c7na5da89NPclbedsE=; b=nZA2FnDb4qA2jQYVV8RtO/iX0CzcsknWkfTBmBuAu13Enf/TLIdFxOxS2lJQTTXxxOJ11W8Zuag+MPBD7+B8g8BAokdToDQmFOdgjE13NB9ITk2mw9irE46GR6T7ugppdL61K+C21D+L7WMetojzd37Oh1I2Yu/J1EWZbUIVPHU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 157607486706338.1275223953437; Wed, 11 Dec 2019 06:34:27 -0800 (PST) Received: from localhost ([::1]:43276 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1if34L-0006sp-8D for importer@patchew.org; Wed, 11 Dec 2019 09:34:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33878) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1if2tw-0005QN-RL for qemu-devel@nongnu.org; Wed, 11 Dec 2019 09:23:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1if2tv-0003FU-Km for qemu-devel@nongnu.org; Wed, 11 Dec 2019 09:23:40 -0500 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:52735) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1if2tv-0003DM-61; Wed, 11 Dec 2019 09:23:39 -0500 Received: by mail-wm1-x341.google.com with SMTP id p9so7297080wmc.2; Wed, 11 Dec 2019 06:23:38 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id g23sm2503783wmk.14.2019.12.11.06.23.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Dec 2019 06:23:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id; bh=DDlSLM0gJZ7KaXQqepJKvC61+c7na5da89NPclbedsE=; b=oKiMEdf0K3rS4kJfQSAf5sHlJWePOIoEwbuFS5wrtEaA8F8+KLXiZ4Gt5ZCXOGazac 3SaReoLWacgYVCFaEr3qm+oTMUdFE/l+NbIFk7qKx8XTnJOhEXtpIq3D1llLBKmzV99K IRepDLHbUH62dMk2RhzA29hDFl2bTXsQCO1ccSNdc/dLHXB03PsCmvQvUapEpFBjEYX9 veruvGuTnHSoq/5oel4Tu05+maYkPM09mvVQHqPm6DXOEk/vE/SpQ1s+l1LCe11YvK7d jM+ru+ChEiyUKrN0bcn5A4ocRq2fJ3ySQQBtLPfNhVUXKMSMUMe5Omom3hnOgKEAGuIS nJhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=DDlSLM0gJZ7KaXQqepJKvC61+c7na5da89NPclbedsE=; b=uS8zBjKvJVoBxsUoJ4fuggrx7PWj27+WxspVy0QJb2mPSCygBGFZXInjyFeKuglRKv LU3ZYA1r9mUQ2NGmSClypHXpelRxoMBXWkqWwHfnEakW3U6TSWwv/USI3rdYnmjD/vzR cRsB4XF64UrK3BZlALJoW5YdDe1HjMe6r4P+HBM0EPu0UsF2UjGWXvTForfnixDWjlYh kMOpuQ27iWljkMOgWByNE2Qx5mcnsOd6MaV6XvbFWdkMQ8RGy4YCbkhLXGMyg/dLbCQw hYLGI306wHiDLVP2SwB25w7tisMV3uBpDfV290ElJYJybESDaE7UkgeG24Cjeszyqw5l izJQ== X-Gm-Message-State: APjAAAXJTV4ceR1ChxCsML/uZ0SK1na8RylsvfYLBLoI1t1YZvf/55o0 nRqOKsfQj2GYdoDP7QNauL4ouvBf X-Google-Smtp-Source: APXvYqzd1YLGsmpelVZJQnbeosTTRhrZNd8xFPZ6Z9W5lBZtYWciJR57Gt/KLX4u2UIrlmkub5FjgA== X-Received: by 2002:a1c:9cce:: with SMTP id f197mr9239wme.133.1576074217391; Wed, 11 Dec 2019 06:23:37 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH] tests: use g_test_rand_int Date: Wed, 11 Dec 2019 15:23:27 +0100 Message-Id: <1576074210-52834-6-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::341 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-trivial@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- 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 =3D g_new0(VHDXHeader, 1); =20 hdr->signature =3D VHDX_HEADER_SIGNATURE; - hdr->sequence_number =3D g_random_int(); + hdr->sequence_number =3D g_test_rand_int(); hdr->log_version =3D 0; hdr->version =3D 1; hdr->log_length =3D 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 =3D vmdk_write_cid(bs, g_random_int()); + ret =3D 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 siz= e, =20 /* generate descriptor file */ desc =3D g_strdup_printf(desc_template, - g_random_int(), + g_test_rand_int(), parent_cid, BlockdevVmdkSubformat_str(subformat), parent_desc_line, diff --git a/tests/ivshmem-test.c b/tests/ivshmem-test.c index be9aa92..ecda256 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; =20 - name =3D g_strdup_printf("/qtest-%u-%u", getpid(), g_random_int()); + name =3D g_strdup_printf("/qtest-%u-%u", getpid(), g_test_rand_int= ()); *fd =3D 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 087e02a..2f5b714 100644 --- a/tests/test-bitmap.c +++ b/tests/test-bitmap.c @@ -22,10 +22,10 @@ static void check_bitmap_copy_with_offset(void) bmap2 =3D bitmap_new(BMAP_SIZE); bmap3 =3D bitmap_new(BMAP_SIZE); =20 - bmap1[0] =3D random(); - bmap1[1] =3D random(); - bmap1[2] =3D random(); - bmap1[3] =3D random(); + bmap1[0] =3D g_test_rand_int(); + bmap1[1] =3D g_test_rand_int(); + bmap1[2] =3D g_test_rand_int(); + bmap1[3] =3D g_test_rand_int(); total =3D BITS_PER_LONG * 4; =20 /* Shift 115 bits into bmap2 */ diff --git a/tests/test-qga.c b/tests/test-qga.c index 1ca49bb..d2b2435 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 =3D fix; - guint32 v, r =3D g_random_int(); + guint32 v, r =3D g_test_rand_int(); unsigned char c; QDict *ret; =20 @@ -186,7 +186,7 @@ static void test_qga_sync_delimited(gconstpointer fix) static void test_qga_sync(gconstpointer fix) { const TestFixture *fixture =3D fix; - guint32 v, r =3D g_random_int(); + guint32 v, r =3D g_test_rand_int(); QDict *ret; =20 /* --=20 1.8.3.1