summaryrefslogtreecommitdiffstats
path: root/tests/boot-order-test.c
diff options
context:
space:
mode:
authorPeter Maydell2019-01-22 10:48:40 +0100
committerPeter Maydell2019-01-22 10:48:40 +0100
commit851aa0a5a89b2812965ab2fdef30f19eea605201 (patch)
tree89eb81e5a4f28d1c4bf3c8446ba1947877938128 /tests/boot-order-test.c
parentMerge remote-tracking branch 'remotes/marcel/tags/rdma-pull-request' into sta... (diff)
parenttests: remove rule for nonexisting qdev-monitor-test (diff)
downloadqemu-851aa0a5a89b2812965ab2fdef30f19eea605201.tar.gz
qemu-851aa0a5a89b2812965ab2fdef30f19eea605201.tar.xz
qemu-851aa0a5a89b2812965ab2fdef30f19eea605201.zip
Merge remote-tracking branch 'remotes/huth-gitlab/tags/pull-request-2019-01-22' into staging
- Use more CONFIG Makefile switches for qtests - Get rid of global_qtests in some more qtests - typedef cleanups - Fixes for compiling with Clang - Force C standard to gnu99 - Don't use -nographic in qtests # gpg: Signature made Tue 22 Jan 2019 06:18:41 GMT # gpg: using RSA key 2ED9D774FE702DB5 # gpg: Good signature from "Thomas Huth <th.huth@gmx.de>" # gpg: aka "Thomas Huth <thuth@redhat.com>" # gpg: aka "Thomas Huth <huth@tuxfamily.org>" # gpg: aka "Thomas Huth <th.huth@posteo.de>" # Primary key fingerprint: 27B8 8847 EEE0 2501 18F3 EAB9 2ED9 D774 FE70 2DB5 * remotes/huth-gitlab/tags/pull-request-2019-01-22: (26 commits) tests: remove rule for nonexisting qdev-monitor-test tests/hexloader-test: Don't pass -nographic to the QEMU under test configure: Force the C standard to gnu99 seccomp: Work-around GCC 4.x bug in gnu99 mode block: Work-around a bug in libiscsi 1.9.0 when used in gnu99 mode linux-user: Fix compilation with clang 3.4 virtio-net: Fix VirtIONet typedef redefinition ppc: Fix duplicated typedefs to be able to compile with Clang in gnu99 mode ppc: Move spapr-related prototypes from xics.h into a seperate header file ui/console: Remove PixelFormat from qemu/typedefs.h ui/console: Remove MouseTransformInfo from qemu/typedefs.h ui/console: Remove DisplayState/DisplaySurface from "qemu/typedefs.h" ui/console: Remove QemuDmaBuf from "qemu/typedefs.h" audio: Remove AudioState from "qemu/typedefs.h" hw/i386: Remove PCMachineClass from "qemu/typedefs.h" hw/char/serial: Remove SerialState from "qemu/typedefs.h" hw/bt: Remove HCIInfo from "qemu/typedefs.h" hw/i2c/smbus: Remove SMBusDevice from "qemu/typedefs.h" hw/ide/ahci: Remove AllwinnerAHCIState from "qemu/typedefs.h" hw/pcmcia: Remove PCMCIACardState from "qemu/typedefs.h" ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'tests/boot-order-test.c')
-rw-r--r--tests/boot-order-test.c59
1 files changed, 29 insertions, 30 deletions
diff --git a/tests/boot-order-test.c b/tests/boot-order-test.c
index c60ebcf9d9..a725bce729 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);
}