It is possible that the argument parsing went wrong, check that qstate is valid after qtest_init. As a nice side effect, even the nop tests will check at least that the device/option is still supported by Qemu.
Signed-off-by: Marcel Apfelbaum <marce...@redhat.com> --- tests/acpi-test.c | 4 +++- tests/blockdev-test.c | 4 +++- tests/boot-order-test.c | 4 +++- tests/e1000-test.c | 5 ++++- tests/eepro100-test.c | 1 + tests/endianness-test.c | 15 ++++++++++++--- tests/fdc-test.c | 5 ++++- tests/fw_cfg-test.c | 2 ++ tests/hd-geo-test.c | 20 ++++++++++++++++---- tests/i440fx-test.c | 10 ++++++++-- tests/ide-test.c | 5 ++++- tests/ipoctal232-test.c | 5 ++++- tests/m48t59-test.c | 1 + tests/ne2000-test.c | 5 ++++- tests/pcnet-test.c | 5 ++++- tests/qdev-monitor-test.c | 4 +++- tests/qom-test.c | 10 ++++++++-- tests/rtc-test.c | 4 +++- tests/rtl8139-test.c | 5 ++++- tests/tmp105-test.c | 4 +++- tests/tpci200-test.c | 5 ++++- tests/virtio-net-test.c | 5 ++++- tests/vmxnet3-test.c | 5 ++++- 23 files changed, 106 insertions(+), 27 deletions(-) diff --git a/tests/acpi-test.c b/tests/acpi-test.c index 31f5359..cbcc849 100644 --- a/tests/acpi-test.c +++ b/tests/acpi-test.c @@ -551,6 +551,7 @@ static void test_acpi_asl(test_data *data) static void test_acpi_one(const char *params, test_data *data) { + QTestState *s; char *args; uint8_t signature_low; uint8_t signature_high; @@ -564,7 +565,8 @@ static void test_acpi_one(const char *params, test_data *data) args = g_strdup_printf("-net none -display none %s -drive file=%s%s,", params ? params : "", disk, device); - qtest_start(args); + s = qtest_start(args); + g_assert(qtest_state_valid(s)); /* Wait at most 1 minute */ #define TEST_DELAY (1 * G_USEC_PER_SEC / 10) diff --git a/tests/blockdev-test.c b/tests/blockdev-test.c index c940e00..d0a8bbf 100644 --- a/tests/blockdev-test.c +++ b/tests/blockdev-test.c @@ -16,11 +16,13 @@ static void test_drive_add_empty(void) { + QTestState *s; QDict *response; const char *response_return; /* Start with an empty drive */ - qtest_start("-drive if=none,id=drive0"); + s = qtest_start("-drive if=none,id=drive0"); + g_assert(qtest_state_valid(s)); /* Delete the drive */ response = qmp("{\"execute\": \"human-monitor-command\"," diff --git a/tests/boot-order-test.c b/tests/boot-order-test.c index 360a691..10f995d 100644 --- a/tests/boot-order-test.c +++ b/tests/boot-order-test.c @@ -31,6 +31,7 @@ static void test_a_boot_order(const char *machine, uint64_t expected_boot, uint64_t expected_reboot) { + QTestState *s; char *args; uint64_t actual; @@ -38,7 +39,8 @@ static void test_a_boot_order(const char *machine, machine ? " -M " : "", machine ?: "", test_args); - qtest_start(args); + s = qtest_start(args); + g_assert(qtest_state_valid(s)); actual = read_boot_order(); g_assert_cmphex(actual, ==, expected_boot); qmp_discard_response("{ 'execute': 'system_reset' }"); diff --git a/tests/e1000-test.c b/tests/e1000-test.c index a8ba2fc..2dfc18f 100644 --- a/tests/e1000-test.c +++ b/tests/e1000-test.c @@ -19,12 +19,15 @@ static void nop(void) int main(int argc, char **argv) { + QTestState *s; int ret; g_test_init(&argc, &argv, NULL); qtest_add_func("/e1000/nop", nop); - qtest_start("-device e1000"); + s = qtest_start("-device e1000"); + g_assert(qtest_state_valid(s)); + ret = g_test_run(); qtest_end(); diff --git a/tests/eepro100-test.c b/tests/eepro100-test.c index bf82526..19623c0 100644 --- a/tests/eepro100-test.c +++ b/tests/eepro100-test.c @@ -20,6 +20,7 @@ static void test_device(gconstpointer data) args = g_strdup_printf("-device %s", model); s = qtest_start(args); + g_assert(qtest_state_valid(s)); /* Tests only initialization so far. TODO: Implement functional tests */ diff --git a/tests/endianness-test.c b/tests/endianness-test.c index 92e17d2..6ffe6a2 100644 --- a/tests/endianness-test.c +++ b/tests/endianness-test.c @@ -118,6 +118,7 @@ static void isa_outl(const TestCase *test, uint16_t addr, uint32_t value) static void test_endianness(gconstpointer data) { + QTestState *s; const TestCase *test = data; char *args; @@ -125,7 +126,9 @@ static void test_endianness(gconstpointer data) test->machine, test->superio ? " -device " : "", test->superio ?: ""); - qtest_start(args); + s = qtest_start(args); + g_assert(qtest_state_valid(s)); + isa_outl(test, 0xe0, 0x87654321); g_assert_cmphex(isa_inl(test, 0xe0), ==, 0x87654321); g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8765); @@ -193,6 +196,7 @@ static void test_endianness(gconstpointer data) static void test_endianness_split(gconstpointer data) { + QTestState *s; const TestCase *test = data; char *args; @@ -200,7 +204,9 @@ static void test_endianness_split(gconstpointer data) test->machine, test->superio ? " -device " : "", test->superio ?: ""); - qtest_start(args); + s = qtest_start(args); + g_assert(qtest_state_valid(s)); + isa_outl(test, 0xe8, 0x87654321); g_assert_cmphex(isa_inl(test, 0xe0), ==, 0x87654321); g_assert_cmphex(isa_inw(test, 0xe2), ==, 0x8765); @@ -240,6 +246,7 @@ static void test_endianness_split(gconstpointer data) static void test_endianness_combine(gconstpointer data) { + QTestState *s; const TestCase *test = data; char *args; @@ -247,7 +254,9 @@ static void test_endianness_combine(gconstpointer data) test->machine, test->superio ? " -device " : "", test->superio ?: ""); - qtest_start(args); + s = qtest_start(args); + g_assert(qtest_state_valid(s)); + isa_outl(test, 0xe0, 0x87654321); g_assert_cmphex(isa_inl(test, 0xe8), ==, 0x87654321); g_assert_cmphex(isa_inw(test, 0xea), ==, 0x8765); diff --git a/tests/fdc-test.c b/tests/fdc-test.c index 37096dc..cadada8 100644 --- a/tests/fdc-test.c +++ b/tests/fdc-test.c @@ -517,6 +517,7 @@ static void fuzz_registers(void) int main(int argc, char **argv) { + QTestState *s; const char *arch = qtest_get_arch(); int fd; int ret; @@ -537,7 +538,9 @@ int main(int argc, char **argv) /* Run the tests */ g_test_init(&argc, &argv, NULL); - qtest_start(NULL); + s = qtest_start(NULL); + g_assert(qtest_state_valid(s)); + qtest_irq_intercept_in(global_qtest, "ioapic"); qtest_add_func("/fdc/cmos", test_cmos); qtest_add_func("/fdc/no_media_on_start", test_no_media_on_start); diff --git a/tests/fw_cfg-test.c b/tests/fw_cfg-test.c index 5c8f8d6..da03789 100644 --- a/tests/fw_cfg-test.c +++ b/tests/fw_cfg-test.c @@ -127,6 +127,8 @@ int main(int argc, char **argv) cmdline = g_strdup_printf("-uuid 4600cb32-38ec-4b2f-8acb-81c6ea54f2d8 "); s = qtest_start(cmdline); + g_assert(qtest_state_valid(s)); + g_free(cmdline); ret = g_test_run(); diff --git a/tests/hd-geo-test.c b/tests/hd-geo-test.c index c84d1e7..636e4e2 100644 --- a/tests/hd-geo-test.c +++ b/tests/hd-geo-test.c @@ -239,16 +239,20 @@ static int setup_ide(int argc, char *argv[], int argv_sz, */ static void test_ide_none(void) { + QTestState *s; char *argv[256]; setup_common(argv, ARRAY_SIZE(argv)); - qtest_start(g_strjoinv(" ", argv)); + s = qtest_start(g_strjoinv(" ", argv)); + g_assert(qtest_state_valid(s)); + test_cmos(); qtest_end(); } static void test_ide_mbr(bool use_device, MBRcontents mbr) { + QTestState *s; char *argv[256]; int argc; Backend i; @@ -260,7 +264,9 @@ static void test_ide_mbr(bool use_device, MBRcontents mbr) dev = use_device ? (is_hd(cur_ide[i]) ? "ide-hd" : "ide-cd") : NULL; argc = setup_ide(argc, argv, ARRAY_SIZE(argv), i, dev, i, mbr, ""); } - qtest_start(g_strjoinv(" ", argv)); + s = qtest_start(g_strjoinv(" ", argv)); + g_assert(qtest_state_valid(s)); + test_cmos(); qtest_end(); } @@ -315,6 +321,7 @@ static void test_ide_device_mbr_chs(void) static void test_ide_drive_user(const char *dev, bool trans) { + QTestState *s; char *argv[256], *opts; int argc; int secs = img_secs[backend_small]; @@ -332,7 +339,9 @@ static void test_ide_drive_user(const char *dev, bool trans) 0, dev ? opts : NULL, backend_small, mbr_chs, dev ? "" : opts); g_free(opts); - qtest_start(g_strjoinv(" ", argv)); + s = qtest_start(g_strjoinv(" ", argv)); + g_assert(qtest_state_valid(s)); + test_cmos(); qtest_end(); } @@ -374,6 +383,7 @@ static void test_ide_device_user_chst(void) */ static void test_ide_drive_cd_0(void) { + QTestState *s; char *argv[256]; int argc, ide_idx; Backend i; @@ -385,7 +395,9 @@ static void test_ide_drive_cd_0(void) argc = setup_ide(argc, argv, ARRAY_SIZE(argv), ide_idx, NULL, i, mbr_blank, ""); } - qtest_start(g_strjoinv(" ", argv)); + s = qtest_start(g_strjoinv(" ", argv)); + g_assert(qtest_state_valid(s)); + test_cmos(); qtest_end(); } diff --git a/tests/i440fx-test.c b/tests/i440fx-test.c index ad232b5..b6f1add 100644 --- a/tests/i440fx-test.c +++ b/tests/i440fx-test.c @@ -41,10 +41,13 @@ typedef struct FirmwareTestFixture { static QPCIBus *test_start_get_bus(const TestData *s) { + QTestState *state; char *cmdline; cmdline = g_strdup_printf("-smp %d", s->num_cpus); - qtest_start(cmdline); + state = qtest_start(cmdline); + g_assert(qtest_state_valid(state)); + g_free(cmdline); return qpci_init_pc(); } @@ -334,6 +337,7 @@ static char *create_blob_file(void) static void test_i440fx_firmware(FirmwareTestFixture *fixture, gconstpointer user_data) { + QTestState *s; char *fw_pathname, *cmdline; uint8_t *buf; size_t i, isa_bios_size; @@ -346,7 +350,9 @@ static void test_i440fx_firmware(FirmwareTestFixture *fixture, fixture->is_bios ? "-bios" : "-pflash", fw_pathname); g_test_message("qemu cmdline: %s", cmdline); - qtest_start(cmdline); + s = qtest_start(cmdline); + g_assert(qtest_state_valid(s)); + g_free(cmdline); /* QEMU has loaded the firmware (because qtest_start() only returns after diff --git a/tests/ide-test.c b/tests/ide-test.c index 4a0d97f..94c4a38 100644 --- a/tests/ide-test.c +++ b/tests/ide-test.c @@ -109,6 +109,7 @@ static char tmp_path[] = "/tmp/qtest.XXXXXX"; static void ide_test_start(const char *cmdline_fmt, ...) { + QTestState *s; va_list ap; char *cmdline; @@ -116,7 +117,9 @@ static void ide_test_start(const char *cmdline_fmt, ...) cmdline = g_strdup_vprintf(cmdline_fmt, ap); va_end(ap); - qtest_start(cmdline); + s = qtest_start(cmdline); + g_assert(qtest_state_valid(s)); + qtest_irq_intercept_in(global_qtest, "ioapic"); guest_malloc = pc_alloc_init(); } diff --git a/tests/ipoctal232-test.c b/tests/ipoctal232-test.c index 3ac1714..6d7323c 100644 --- a/tests/ipoctal232-test.c +++ b/tests/ipoctal232-test.c @@ -19,12 +19,15 @@ static void nop(void) int main(int argc, char **argv) { + QTestState *s; int ret; g_test_init(&argc, &argv, NULL); qtest_add_func("/ipoctal232/tpci200/nop", nop); - qtest_start("-device tpci200,id=ipack0 -device ipoctal232,bus=ipack0.0"); + s = qtest_start("-device tpci200,id=ipack0 -device ipoctal232,bus=ipack0.0"); + g_assert(qtest_state_valid(s)); + ret = g_test_run(); qtest_end(); diff --git a/tests/m48t59-test.c b/tests/m48t59-test.c index 71b4f28..bda53e8 100644 --- a/tests/m48t59-test.c +++ b/tests/m48t59-test.c @@ -251,6 +251,7 @@ int main(int argc, char **argv) g_test_init(&argc, &argv, NULL); s = qtest_start("-rtc clock=vm"); + g_assert(qtest_state_valid(s)); qtest_add_func("/rtc/bcd/check-time", bcd_check_time); qtest_add_func("/rtc/fuzz-registers", fuzz_registers); diff --git a/tests/ne2000-test.c b/tests/ne2000-test.c index 61a678a..85671d9 100644 --- a/tests/ne2000-test.c +++ b/tests/ne2000-test.c @@ -19,12 +19,15 @@ static void pci_nop(void) int main(int argc, char **argv) { + QTestState *s; int ret; g_test_init(&argc, &argv, NULL); qtest_add_func("/ne2000/pci/nop", pci_nop); - qtest_start("-device ne2k_pci"); + s = qtest_start("-device ne2k_pci"); + g_assert(qtest_state_valid(s)); + ret = g_test_run(); qtest_end(); diff --git a/tests/pcnet-test.c b/tests/pcnet-test.c index 84af4f3..0c9db5b 100644 --- a/tests/pcnet-test.c +++ b/tests/pcnet-test.c @@ -19,12 +19,15 @@ static void pci_nop(void) int main(int argc, char **argv) { + QTestState *s; int ret; g_test_init(&argc, &argv, NULL); qtest_add_func("/pcnet/pci/nop", pci_nop); - qtest_start("-device pcnet"); + s = qtest_start("-device pcnet"); + g_assert(qtest_state_valid(s)); + ret = g_test_run(); qtest_end(); diff --git a/tests/qdev-monitor-test.c b/tests/qdev-monitor-test.c index ba7f9cc..5f1ba62 100644 --- a/tests/qdev-monitor-test.c +++ b/tests/qdev-monitor-test.c @@ -17,10 +17,12 @@ static void test_device_add(void) { + QTestState *s; QDict *response; QDict *error; - qtest_start("-drive if=none,id=drive0"); + s = qtest_start("-drive if=none,id=drive0"); + g_assert(qtest_state_valid(s)); /* Make device_add fail. If this leaks the virtio-blk-pci device then a * reference to drive0 will also be held (via qdev properties). diff --git a/tests/qom-test.c b/tests/qom-test.c index b6671fb..3b1a30e 100644 --- a/tests/qom-test.c +++ b/tests/qom-test.c @@ -45,12 +45,15 @@ static bool is_blacklisted(const char *arch, const char *mach) static void test_machine(gconstpointer data) { + QTestState *s; const char *machine = data; char *args; QDict *response; args = g_strdup_printf("-machine %s", machine); - qtest_start(args); + s = qtest_start(args); + g_assert(qtest_state_valid(s)); + response = qmp("{ 'execute': 'quit' }"); g_assert(qdict_haskey(response, "return")); qtest_end(); @@ -59,6 +62,7 @@ static void test_machine(gconstpointer data) static void add_machine_test_cases(void) { + QTestState *s; const char *arch = qtest_get_arch(); QDict *response, *minfo; QList *list; @@ -67,7 +71,9 @@ static void add_machine_test_cases(void) QString *qstr; const char *mname, *path; - qtest_start("-machine none"); + s = qtest_start("-machine none"); + g_assert(qtest_state_valid(s)); + response = qmp("{ 'execute': 'query-machines' }"); g_assert(response); list = qdict_get_qlist(response, "return"); diff --git a/tests/rtc-test.c b/tests/rtc-test.c index 4243624..9668c4a 100644 --- a/tests/rtc-test.c +++ b/tests/rtc-test.c @@ -548,12 +548,14 @@ static void register_b_set_flag(void) int main(int argc, char **argv) { - QTestState *s = NULL; + QTestState *s; int ret; g_test_init(&argc, &argv, NULL); s = qtest_start("-rtc clock=vm"); + g_assert(qtest_state_valid(s)); + qtest_irq_intercept_in(s, "ioapic"); qtest_add_func("/rtc/check-time/bcd", bcd_check_time); diff --git a/tests/rtl8139-test.c b/tests/rtl8139-test.c index f6a1be3..cfb9feb 100644 --- a/tests/rtl8139-test.c +++ b/tests/rtl8139-test.c @@ -19,12 +19,15 @@ static void nop(void) int main(int argc, char **argv) { + QTestState *s; int ret; g_test_init(&argc, &argv, NULL); qtest_add_func("/rtl8139/nop", nop); - qtest_start("-device rtl8139"); + s = qtest_start("-device rtl8139"); + g_assert(qtest_state_valid(s)); + ret = g_test_run(); qtest_end(); diff --git a/tests/tmp105-test.c b/tests/tmp105-test.c index 0834219..565a225 100644 --- a/tests/tmp105-test.c +++ b/tests/tmp105-test.c @@ -55,12 +55,14 @@ static void send_and_receive(void) int main(int argc, char **argv) { - QTestState *s = NULL; + QTestState *s; int ret; g_test_init(&argc, &argv, NULL); s = qtest_start("-machine n800"); + g_assert(qtest_state_valid(s)); + i2c = omap_i2c_create(OMAP2_I2C_1_BASE); addr = N8X0_ADDR; diff --git a/tests/tpci200-test.c b/tests/tpci200-test.c index 9ae0127..dd4e248 100644 --- a/tests/tpci200-test.c +++ b/tests/tpci200-test.c @@ -19,12 +19,15 @@ static void nop(void) int main(int argc, char **argv) { + QTestState *s; int ret; g_test_init(&argc, &argv, NULL); qtest_add_func("/tpci200/nop", nop); - qtest_start("-device tpci200"); + s = qtest_start("-device tpci200"); + g_assert(qtest_state_valid(s)); + ret = g_test_run(); qtest_end(); diff --git a/tests/virtio-net-test.c b/tests/virtio-net-test.c index df99343..e0b0bc5 100644 --- a/tests/virtio-net-test.c +++ b/tests/virtio-net-test.c @@ -19,12 +19,15 @@ static void pci_nop(void) int main(int argc, char **argv) { + QTestState *s; int ret; g_test_init(&argc, &argv, NULL); qtest_add_func("/virtio/net/pci/nop", pci_nop); - qtest_start("-device virtio-net-pci"); + s = qtest_start("-device virtio-net-pci"); + g_assert(qtest_state_valid(s)); + ret = g_test_run(); qtest_end(); diff --git a/tests/vmxnet3-test.c b/tests/vmxnet3-test.c index a2ebed3..9546f24 100644 --- a/tests/vmxnet3-test.c +++ b/tests/vmxnet3-test.c @@ -19,12 +19,15 @@ static void nop(void) int main(int argc, char **argv) { + QTestState *s; int ret; g_test_init(&argc, &argv, NULL); qtest_add_func("/vmxnet3/nop", nop); - qtest_start("-device vmxnet3"); + s = qtest_start("-device vmxnet3"); + g_assert(qtest_state_valid(s)); + ret = g_test_run(); qtest_end(); -- 1.8.3.1