From nobody Sat Oct 25 08:29:47 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518607750279215.64341468659632; Wed, 14 Feb 2018 03:29:10 -0800 (PST) Received: from localhost ([::1]:37567 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elvFJ-00058T-4E for importer@patchew.org; Wed, 14 Feb 2018 06:29:05 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43559) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elv7T-0006Ru-5R for qemu-devel@nongnu.org; Wed, 14 Feb 2018 06:21:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1elv7P-0007Bu-Rr for qemu-devel@nongnu.org; Wed, 14 Feb 2018 06:20:59 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:57178 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1elv7P-0007Bo-Mt for qemu-devel@nongnu.org; Wed, 14 Feb 2018 06:20:55 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 579A6EAE91; Wed, 14 Feb 2018 11:20:55 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-116-136.ams2.redhat.com [10.36.116.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7E14D2024CA4; Wed, 14 Feb 2018 11:20:54 +0000 (UTC) From: Thomas Huth To: Peter Maydell , qemu-devel@nongnu.org Date: Wed, 14 Feb 2018 12:20:26 +0100 Message-Id: <1518607234-17739-11-git-send-email-thuth@redhat.com> In-Reply-To: <1518607234-17739-1-git-send-email-thuth@redhat.com> References: <1518607234-17739-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Wed, 14 Feb 2018 11:20:55 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Wed, 14 Feb 2018 11:20:55 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'thuth@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 10/18] tests/boot-sector: Drop dependence on global_qtest X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Eric Blake As a general rule, we prefer avoiding implicit global state because it makes code harder to safely copy and paste without thinking about the global state. Adjust the helper code to use explicit state instead, and update all callers. Fix some trailing whitespace while touching the file. Signed-off-by: Eric Blake Reviewed-by: Thomas Huth Acked-by: Michael S. Tsirkin Signed-off-by: Thomas Huth --- tests/bios-tables-test.c | 2 +- tests/boot-sector.c | 8 ++++---- tests/boot-sector.h | 6 ++++-- tests/pxe-test.c | 2 +- tests/vmgenid-test.c | 2 +- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c index 2b332ed..65b271a 100644 --- a/tests/bios-tables-test.c +++ b/tests/bios-tables-test.c @@ -668,7 +668,7 @@ static void test_acpi_one(const char *params, test_data= *data) =20 qtest_start(args); =20 - boot_sector_test(); + boot_sector_test(global_qtest); =20 data->tables =3D g_array_new(false, true, sizeof(AcpiSdtTable)); test_acpi_rsdp_address(data); diff --git a/tests/boot-sector.c b/tests/boot-sector.c index be29d5b..c373f0e 100644 --- a/tests/boot-sector.c +++ b/tests/boot-sector.c @@ -5,7 +5,7 @@ * * Authors: * Michael S. Tsirkin - * Victor Kaplansky =20 + * Victor Kaplansky * * This work is licensed under the terms of the GNU GPL, version 2 or late= r. * See the COPYING file in the top-level directory. @@ -130,7 +130,7 @@ int boot_sector_init(char *fname) } =20 /* Loop until signature in memory is OK. */ -void boot_sector_test(void) +void boot_sector_test(QTestState *qts) { uint8_t signature_low; uint8_t signature_high; @@ -146,8 +146,8 @@ void boot_sector_test(void) * instruction. */ for (i =3D 0; i < TEST_CYCLES; ++i) { - signature_low =3D readb(SIGNATURE_ADDR); - signature_high =3D readb(SIGNATURE_ADDR + 1); + signature_low =3D qtest_readb(qts, SIGNATURE_ADDR); + signature_high =3D qtest_readb(qts, SIGNATURE_ADDR + 1); signature =3D (signature_high << 8) | signature_low; if (signature =3D=3D SIGNATURE) { break; diff --git a/tests/boot-sector.h b/tests/boot-sector.h index 35d61c7..6ee6bb4 100644 --- a/tests/boot-sector.h +++ b/tests/boot-sector.h @@ -5,7 +5,7 @@ * * Authors: * Michael S. Tsirkin - * Victor Kaplansky =20 + * Victor Kaplansky * * This work is licensed under the terms of the GNU GPL, version 2 or late= r. * See the COPYING file in the top-level directory. @@ -14,11 +14,13 @@ #ifndef TEST_BOOT_SECTOR_H #define TEST_BOOT_SECTOR_H =20 +#include "libqtest.h" + /* Create boot disk file. fname must be a suitable string for mkstemp() */ int boot_sector_init(char *fname); =20 /* Loop until signature in memory is OK. */ -void boot_sector_test(void); +void boot_sector_test(QTestState *qts); =20 /* unlink boot disk file. */ void boot_sector_cleanup(const char *fname); diff --git a/tests/pxe-test.c b/tests/pxe-test.c index 5ca8480..6e36796 100644 --- a/tests/pxe-test.c +++ b/tests/pxe-test.c @@ -71,7 +71,7 @@ static void test_pxe_one(const testdef_t *test, bool ipv6) test->model); =20 qtest_start(args); - boot_sector_test(); + boot_sector_test(global_qtest); qtest_quit(global_qtest); g_free(args); } diff --git a/tests/vmgenid-test.c b/tests/vmgenid-test.c index 7190e68..2ec274e 100644 --- a/tests/vmgenid-test.c +++ b/tests/vmgenid-test.c @@ -45,7 +45,7 @@ static uint32_t acpi_find_vgia(void) int i; =20 /* Wait for guest firmware to finish and start the payload. */ - boot_sector_test(); + boot_sector_test(global_qtest); =20 /* Tables should be initialized now. */ rsdp_offset =3D acpi_find_rsdp_address(); --=20 1.8.3.1