qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>, qemu-devel@nongnu.org
Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org>, "Li Qiang" <liq3ea@163.com>
Subject: [Qemu-devel] [PULL 08/25] tests/boot-order: Make test independent of global_qtest
Date: Mon, 14 Jan 2019 11:02:03 +0100	[thread overview]
Message-ID: <1547460140-1473-9-git-send-email-thuth@redhat.com> (raw)
In-Reply-To: <1547460140-1473-1-git-send-email-thuth@redhat.com>

Pass around the QTestState from function to function, so that we can finally
get rid of the out-of-favor global_qtest variable in this file, too.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tests/boot-order-test.c | 59 ++++++++++++++++++++++++-------------------------
 1 file changed, 29 insertions(+), 30 deletions(-)

diff --git a/tests/boot-order-test.c b/tests/boot-order-test.c
index c60ebcf..a725bce 100644
--- a/tests/boot-order-test.c
+++ b/tests/boot-order-test.c
@@ -17,7 +17,7 @@
 #include "standard-headers/linux/qemu_fw_cfg.h"
 
 /* TODO actually test the results and get rid of this */
-#define qmp_discard_response(...) qobject_unref(qmp(__VA_ARGS__))
+#define qmp_discard_response(qs, ...) qobject_unref(qtest_qmp(qs, __VA_ARGS__))
 
 typedef struct {
     const char *args;
@@ -27,31 +27,30 @@ typedef struct {
 
 static void test_a_boot_order(const char *machine,
                               const char *test_args,
-                              uint64_t (*read_boot_order)(void),
+                              uint64_t (*read_boot_order)(QTestState *),
                               uint64_t expected_boot,
                               uint64_t expected_reboot)
 {
     uint64_t actual;
+    QTestState *qts;
 
-    global_qtest = qtest_initf("-nodefaults%s%s %s",
-                               machine ? " -M " : "",
-                               machine ?: "",
-                               test_args);
-    actual = read_boot_order();
+    qts = qtest_initf("-nodefaults%s%s %s", machine ? " -M " : "",
+                      machine ?: "", test_args);
+    actual = read_boot_order(qts);
     g_assert_cmphex(actual, ==, expected_boot);
-    qmp_discard_response("{ 'execute': 'system_reset' }");
+    qmp_discard_response(qts, "{ 'execute': 'system_reset' }");
     /*
      * system_reset only requests reset.  We get a RESET event after
      * the actual reset completes.  Need to wait for that.
      */
-    qmp_eventwait("RESET");
-    actual = read_boot_order();
+    qtest_qmp_eventwait(qts, "RESET");
+    actual = read_boot_order(qts);
     g_assert_cmphex(actual, ==, expected_reboot);
-    qtest_quit(global_qtest);
+    qtest_quit(qts);
 }
 
 static void test_boot_orders(const char *machine,
-                             uint64_t (*read_boot_order)(void),
+                             uint64_t (*read_boot_order)(QTestState *),
                              const boot_order_test *tests)
 {
     int i;
@@ -64,16 +63,16 @@ static void test_boot_orders(const char *machine,
     }
 }
 
-static uint8_t read_mc146818(uint16_t port, uint8_t reg)
+static uint8_t read_mc146818(QTestState *qts, uint16_t port, uint8_t reg)
 {
-    outb(port, reg);
-    return inb(port + 1);
+    qtest_outb(qts, port, reg);
+    return qtest_inb(qts, port + 1);
 }
 
-static uint64_t read_boot_order_pc(void)
+static uint64_t read_boot_order_pc(QTestState *qts)
 {
-    uint8_t b1 = read_mc146818(0x70, 0x38);
-    uint8_t b2 = read_mc146818(0x70, 0x3d);
+    uint8_t b1 = read_mc146818(qts, 0x70, 0x38);
+    uint8_t b2 = read_mc146818(qts, 0x70, 0x3d);
 
     return b1 | (b2 << 8);
 }
@@ -109,16 +108,16 @@ static void test_pc_boot_order(void)
     test_boot_orders(NULL, read_boot_order_pc, test_cases_pc);
 }
 
-static uint8_t read_m48t59(uint64_t addr, uint16_t reg)
+static uint8_t read_m48t59(QTestState *qts, uint64_t addr, uint16_t reg)
 {
-    writeb(addr, reg & 0xff);
-    writeb(addr + 1, reg >> 8);
-    return readb(addr + 3);
+    qtest_writeb(qts, addr, reg & 0xff);
+    qtest_writeb(qts, addr + 1, reg >> 8);
+    return qtest_readb(qts, addr + 3);
 }
 
-static uint64_t read_boot_order_prep(void)
+static uint64_t read_boot_order_prep(QTestState *qts)
 {
-    return read_m48t59(0x80000000 + 0x74, 0x34);
+    return read_m48t59(qts, 0x80000000 + 0x74, 0x34);
 }
 
 static const boot_order_test test_cases_prep[] = {
@@ -133,9 +132,9 @@ static void test_prep_boot_order(void)
     test_boot_orders("prep", read_boot_order_prep, test_cases_prep);
 }
 
-static uint64_t read_boot_order_pmac(void)
+static uint64_t read_boot_order_pmac(QTestState *qts)
 {
-    QFWCFG *fw_cfg = mm_fw_cfg_init(global_qtest, 0xf0000510);
+    QFWCFG *fw_cfg = mm_fw_cfg_init(qts, 0xf0000510);
 
     return qfw_cfg_get_u16(fw_cfg, FW_CFG_BOOT_DEVICE);
 }
@@ -158,9 +157,9 @@ static void test_pmac_newworld_boot_order(void)
     test_boot_orders("mac99", read_boot_order_pmac, test_cases_fw_cfg);
 }
 
-static uint64_t read_boot_order_sun4m(void)
+static uint64_t read_boot_order_sun4m(QTestState *qts)
 {
-    QFWCFG *fw_cfg = mm_fw_cfg_init(global_qtest, 0xd00000510ULL);
+    QFWCFG *fw_cfg = mm_fw_cfg_init(qts, 0xd00000510ULL);
 
     return qfw_cfg_get_u16(fw_cfg, FW_CFG_BOOT_DEVICE);
 }
@@ -170,9 +169,9 @@ static void test_sun4m_boot_order(void)
     test_boot_orders("SS-5", read_boot_order_sun4m, test_cases_fw_cfg);
 }
 
-static uint64_t read_boot_order_sun4u(void)
+static uint64_t read_boot_order_sun4u(QTestState *qts)
 {
-    QFWCFG *fw_cfg = io_fw_cfg_init(global_qtest, 0x510);
+    QFWCFG *fw_cfg = io_fw_cfg_init(qts, 0x510);
 
     return qfw_cfg_get_u16(fw_cfg, FW_CFG_BOOT_DEVICE);
 }
-- 
1.8.3.1

  parent reply	other threads:[~2019-01-14 10:02 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-14 10:01 [Qemu-devel] [PULL 00/25] ivshmem deprecation, qtests, typedefs and gnu99 Thomas Huth
2019-01-14 10:01 ` [Qemu-devel] [PULL 01/25] hw/misc/ivshmem: Remove deprecated "ivshmem" legacy device Thomas Huth
2019-01-14 10:01 ` [Qemu-devel] [PULL 02/25] tests: vhost-user-test: initialize 'fd' in chr_read Thomas Huth
2019-01-14 10:01 ` [Qemu-devel] [PULL 03/25] vhost-user: fix ioeventfd_enabled Thomas Huth
2019-01-14 10:01 ` [Qemu-devel] [PULL 04/25] util: check the return value of fcntl in qemu_set_{block, nonblock} Thomas Huth
2019-01-14 10:02 ` [Qemu-devel] [PULL 05/25] tests/Makefile: Use some more CONFIG switches for x86 tests Thomas Huth
2019-01-14 10:02 ` [Qemu-devel] [PULL 06/25] tests/Makefile: Use some more CONFIG switches for ppc tests Thomas Huth
2019-01-14 10:02 ` [Qemu-devel] [PULL 07/25] tests/endianesss: Make test independent of global_qtest Thomas Huth
2019-01-14 10:02 ` Thomas Huth [this message]
2019-01-14 10:02 ` [Qemu-devel] [PULL 09/25] tests/pnv-xscom: " Thomas Huth
2019-01-14 10:02 ` [Qemu-devel] [PULL 10/25] hw/input/ps2: Remove PS2State from "qemu/typedefs.h" Thomas Huth
2019-01-14 10:02 ` [Qemu-devel] [PULL 11/25] hw/pcmcia: Remove PCMCIACardState " Thomas Huth
2019-01-14 10:02 ` [Qemu-devel] [PULL 12/25] hw/ssi: Remove SSIBus " Thomas Huth
2019-01-14 10:02 ` [Qemu-devel] [PULL 13/25] hw/ide/ahci: Remove AllwinnerAHCIState " Thomas Huth
2019-01-14 10:02 ` [Qemu-devel] [PULL 14/25] hw/i2c/smbus: Remove SMBusDevice " Thomas Huth
2019-01-14 10:02 ` [Qemu-devel] [PULL 15/25] hw/bt: Remove HCIInfo " Thomas Huth
2019-01-14 10:02 ` [Qemu-devel] [PULL 16/25] hw/char/serial: Remove SerialState " Thomas Huth
2019-01-14 10:02 ` [Qemu-devel] [PULL 17/25] hw/i386: Remove PCMachineClass " Thomas Huth
2019-01-14 10:02 ` [Qemu-devel] [PULL 18/25] audio: Remove AudioState " Thomas Huth
2019-01-14 10:02 ` [Qemu-devel] [PULL 19/25] ui/console: Remove QemuDmaBuf " Thomas Huth
2019-01-14 10:02 ` [Qemu-devel] [PULL 20/25] ui/console: Remove DisplayState/DisplaySurface " Thomas Huth
2019-01-14 10:02 ` [Qemu-devel] [PULL 21/25] linux-user: Fix compilation with clang 3.4 Thomas Huth
2019-01-14 10:02 ` [Qemu-devel] [PULL 22/25] ppc: Move spapr-related prototypes from xics.h into a seperate header file Thomas Huth
2019-01-14 10:02 ` [Qemu-devel] [PULL 23/25] ppc: Fix duplicated typedefs to be able to compile with Clang in gnu99 mode Thomas Huth
2019-01-14 10:02 ` [Qemu-devel] [PULL 24/25] configure: Force the C standard to gnu99 Thomas Huth
2019-01-14 10:02 ` [Qemu-devel] [PULL 25/25] tests/hexloader-test: Don't pass -nographic to the QEMU under test Thomas Huth
2019-01-14 12:52 ` [Qemu-devel] [PULL 00/25] ivshmem deprecation, qtests, typedefs and gnu99 Peter Maydell
2019-01-14 12:58   ` Thomas Huth

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=1547460140-1473-9-git-send-email-thuth@redhat.com \
    --to=thuth@redhat.com \
    --cc=f4bug@amsat.org \
    --cc=liq3ea@163.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).