All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 10/18] tests/boot-sector: Drop dependence on global_qtest
Date: Wed, 14 Feb 2018 12:20:26 +0100	[thread overview]
Message-ID: <1518607234-17739-11-git-send-email-thuth@redhat.com> (raw)
In-Reply-To: <1518607234-17739-1-git-send-email-thuth@redhat.com>

From: Eric Blake <eblake@redhat.com>

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 <eblake@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 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)
 
     qtest_start(args);
 
-    boot_sector_test();
+    boot_sector_test(global_qtest);
 
     data->tables = 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 <mst@redhat.com>
- *  Victor Kaplansky <victork@redhat.com>    
+ *  Victor Kaplansky <victork@redhat.com>
  *
  * 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/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 <mst@redhat.com>
- *  Victor Kaplansky <victork@redhat.com>    
+ *  Victor Kaplansky <victork@redhat.com>
  *
  * 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/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);
 
     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;
 
     /* 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();
-- 
1.8.3.1

  parent reply	other threads:[~2018-02-14 11:21 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-14 11:20 [Qemu-devel] [PULL 00/18] qtest patches Thomas Huth
2018-02-14 11:20 ` [Qemu-devel] [PULL 01/18] tests: Clean up wait for event Thomas Huth
2018-02-14 11:20 ` [Qemu-devel] [PULL 02/18] libqtest: Use qemu_strtoul() Thomas Huth
2018-02-14 11:20 ` [Qemu-devel] [PULL 03/18] libqos: Track QTestState with QPCIBus Thomas Huth
2018-02-14 11:20 ` [Qemu-devel] [PULL 04/18] libqos: Use explicit QTestState for fw_cfg operations Thomas Huth
2018-02-14 11:20 ` [Qemu-devel] [PULL 05/18] libqos: Use explicit QTestState for rtas operations Thomas Huth
2018-02-14 11:20 ` [Qemu-devel] [PULL 06/18] libqos: Use explicit QTestState for i2c operations Thomas Huth
2018-02-14 11:20 ` [Qemu-devel] [PULL 07/18] libqos: Use explicit QTestState for ahci operations Thomas Huth
2018-02-14 11:20 ` [Qemu-devel] [PULL 08/18] libqos: Use explicit QTestState for remaining libqos operations Thomas Huth
2018-02-14 11:20 ` [Qemu-devel] [PULL 09/18] qmp-test: Drop dependence on global_qtest Thomas Huth
2018-02-14 11:20 ` Thomas Huth [this message]
2018-02-14 11:20 ` [Qemu-devel] [PULL 11/18] wdt_ib700-test: " Thomas Huth
2018-02-14 11:20 ` [Qemu-devel] [PULL 12/18] tests/boot-serial: Enable the boot-serial test on SPARC machines, too Thomas Huth
2018-02-14 11:20 ` [Qemu-devel] [PULL 13/18] tests/boot-serial: Add tests for PowerPC Mac machines Thomas Huth
2018-02-14 11:20 ` [Qemu-devel] [PULL 14/18] tests/boot-serial-test: Add support for the aarch64 virt machine Thomas Huth
2018-02-14 11:20 ` [Qemu-devel] [PULL 15/18] tests/m48t59: Fix and re-enable the test for sparc Thomas Huth
2018-02-14 11:20 ` [Qemu-devel] [PULL 16/18] tests/m48t59: Make the test independent of global_qtest Thomas Huth
2018-02-14 11:20 ` [Qemu-devel] [PULL 17/18] tests/Makefile: Derive check-qtest-ppc64-y from check-qtest-ppc-y Thomas Huth
2018-02-14 11:20 ` [Qemu-devel] [PULL 18/18] tests/m48t59: Use the m48t59 test on ppc, too Thomas Huth
2018-02-15 14:15 ` [Qemu-devel] [PULL 00/18] qtest patches Peter Maydell

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=1518607234-17739-11-git-send-email-thuth@redhat.com \
    --to=thuth@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.