From patchwork Mon Sep 11 17:20:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Blake X-Patchwork-Id: 812507 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xrb9F0t7fz9s7F for ; Tue, 12 Sep 2017 03:52:17 +1000 (AEST) Received: from localhost ([::1]:59492 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1drSsZ-0002Jh-5T for incoming@patchwork.ozlabs.org; Mon, 11 Sep 2017 13:52:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38711) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1drSOe-0007cn-79 for qemu-devel@nongnu.org; Mon, 11 Sep 2017 13:21:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1drSOd-0001KE-77 for qemu-devel@nongnu.org; Mon, 11 Sep 2017 13:21:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:64535) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1drSOc-0001Jo-VY for qemu-devel@nongnu.org; Mon, 11 Sep 2017 13:21:19 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0F2BBCC9B8; Mon, 11 Sep 2017 17:21:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0F2BBCC9B8 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=eblake@redhat.com Received: from red.redhat.com (ovpn-120-44.rdu2.redhat.com [10.10.120.44]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3CCB95F91A; Mon, 11 Sep 2017 17:21:14 +0000 (UTC) From: Eric Blake To: qemu-devel@nongnu.org Date: Mon, 11 Sep 2017 12:20:07 -0500 Message-Id: <20170911172022.4738-24-eblake@redhat.com> In-Reply-To: <20170911172022.4738-1-eblake@redhat.com> References: <20170911172022.4738-1-eblake@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 11 Sep 2017 17:21:18 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v7 23/38] 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: , Cc: thuth@redhat.com, Ben Warren , "Michael S. Tsirkin" , armbru@redhat.com, Igor Mammedov , pbonzini@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 --- tests/boot-sector.h | 6 ++++-- tests/bios-tables-test.c | 2 +- tests/boot-sector.c | 8 ++++---- tests/pxe-test.c | 2 +- tests/vmgenid-test.c | 2 +- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/tests/boot-sector.h b/tests/boot-sector.h index 35d61c7e2b..6ee6bb4d97 100644 --- a/tests/boot-sector.h +++ b/tests/boot-sector.h @@ -5,7 +5,7 @@ * * Authors: * Michael S. Tsirkin - * Victor Kaplansky + * Victor Kaplansky * * This work is licensed under the terms of the GNU GPL, version 2 or later. * See the COPYING file in the top-level directory. @@ -14,11 +14,13 @@ #ifndef TEST_BOOT_SECTOR_H #define TEST_BOOT_SECTOR_H +#include "libqtest.h" + /* Create boot disk file. fname must be a suitable string for mkstemp() */ int boot_sector_init(char *fname); /* Loop until signature in memory is OK. */ -void boot_sector_test(void); +void boot_sector_test(QTestState *qts); /* unlink boot disk file. */ void boot_sector_cleanup(const char *fname); diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c index 564da45f65..bde62bf1cf 100644 --- a/tests/bios-tables-test.c +++ b/tests/bios-tables-test.c @@ -632,7 +632,7 @@ static void test_acpi_one(const char *params, test_data *data) qtest_start(args); - boot_sector_test(); + boot_sector_test(global_qtest); test_acpi_rsdp_address(data); test_acpi_rsdp_table(data); diff --git a/tests/boot-sector.c b/tests/boot-sector.c index 9ee85370b0..8c8ac7f124 100644 --- a/tests/boot-sector.c +++ b/tests/boot-sector.c @@ -5,7 +5,7 @@ * * Authors: * Michael S. Tsirkin - * Victor Kaplansky + * Victor Kaplansky * * This work is licensed under the terms of the GNU GPL, version 2 or later. * See the COPYING file in the top-level directory. @@ -130,7 +130,7 @@ int boot_sector_init(char *fname) } /* 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 = 0; i < TEST_CYCLES; ++i) { - signature_low = readb(SIGNATURE_ADDR); - signature_high = readb(SIGNATURE_ADDR + 1); + signature_low = qtest_readb(qts, SIGNATURE_ADDR); + signature_high = qtest_readb(qts, SIGNATURE_ADDR + 1); signature = (signature_high << 8) | signature_low; if (signature == SIGNATURE) { break; diff --git a/tests/pxe-test.c b/tests/pxe-test.c index 0d70afccd6..e2d3853534 100644 --- a/tests/pxe-test.c +++ b/tests/pxe-test.c @@ -31,7 +31,7 @@ static void test_pxe_one(const char *params, bool ipv6) ipv6 ? "on" : "off", params); 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 918c82c82a..0ea98b86d7 100644 --- a/tests/vmgenid-test.c +++ b/tests/vmgenid-test.c @@ -47,7 +47,7 @@ static uint32_t acpi_find_vgia(void) int i; /* Wait for guest firmware to finish and start the payload. */ - boot_sector_test(); + boot_sector_test(global_qtest); /* Tables should be initialized now. */ rsdp_offset = acpi_find_rsdp_address();