@@ -523,17 +523,6 @@ static inline QTestState *qtest_start(const char *args)
}
/**
- * qtest_end:
- *
- * Shut down the QEMU process started by qtest_start().
- */
-static inline void qtest_end(void)
-{
- qtest_quit(global_qtest);
- global_qtest = NULL;
-}
-
-/**
* qmp:
* @fmt...: QMP message to send to qemu
*
@@ -246,6 +246,10 @@ QTestState *qtest_init(const char *extra_args)
void qtest_quit(QTestState *s)
{
+ if (global_qtest) {
+ assert(s == global_qtest);
+ global_qtest = NULL;
+ }
g_hook_destroy_link(&abrt_hooks, g_hook_find_data(&abrt_hooks, TRUE, s));
/* Uninstall SIGABRT handler on last instance */
@@ -979,6 +983,6 @@ void qtest_cb_for_every_machine(void (*cb)(const char *machine))
cb(mname);
}
- qtest_end();
+ qtest_quit(global_qtest);
QDECREF(response);
}
@@ -25,7 +25,7 @@ int main(int argc, char **argv)
qtest_start("-device AC97");
ret = g_test_run();
- qtest_end();
+ qtest_quit(global_qtest);
return ret;
}
@@ -134,7 +134,7 @@ static void test_device_intro_list(void)
help = hmp("device_add help");
g_free(help);
- qtest_end();
+ qtest_quit(global_qtest);
}
/*
@@ -189,21 +189,21 @@ static void test_qom_list_fields(void)
QDECREF(all_types);
QDECREF(non_abstract);
- qtest_end();
+ qtest_quit(global_qtest);
}
static void test_device_intro_none(void)
{
qtest_start(common_args);
test_one_device("nonexistent");
- qtest_end();
+ qtest_quit(global_qtest);
}
static void test_device_intro_abstract(void)
{
qtest_start(common_args);
test_one_device("device");
- qtest_end();
+ qtest_quit(global_qtest);
}
static void test_device_intro_concrete(void)
@@ -223,7 +223,7 @@ static void test_device_intro_concrete(void)
}
QDECREF(types);
- qtest_end();
+ qtest_quit(global_qtest);
}
static void test_abstract_interfaces(void)
@@ -257,7 +257,7 @@ static void test_abstract_interfaces(void)
QDECREF(all_types);
QDECREF(index);
- qtest_end();
+ qtest_quit(global_qtest);
}
int main(int argc, char **argv)
@@ -13,38 +13,38 @@
static void pci_cirrus(void)
{
qtest_start("-vga none -device cirrus-vga");
- qtest_end();
+ qtest_quit(global_qtest);
}
static void pci_stdvga(void)
{
qtest_start("-vga none -device VGA");
- qtest_end();
+ qtest_quit(global_qtest);
}
static void pci_secondary(void)
{
qtest_start("-vga none -device secondary-vga");
- qtest_end();
+ qtest_quit(global_qtest);
}
static void pci_multihead(void)
{
qtest_start("-vga none -device VGA -device secondary-vga");
- qtest_end();
+ qtest_quit(global_qtest);
}
static void pci_virtio_gpu(void)
{
qtest_start("-vga none -device virtio-gpu-pci");
- qtest_end();
+ qtest_quit(global_qtest);
}
#ifdef CONFIG_VIRTIO_VGA
static void pci_virtio_vga(void)
{
qtest_start("-vga none -device virtio-vga");
- qtest_end();
+ qtest_quit(global_qtest);
}
#endif
@@ -55,7 +55,7 @@ static void test_drive_without_dev(void)
*/
drive_add();
- qtest_end();
+ qtest_quit(global_qtest);
}
static void test_after_failed_device_add(void)
@@ -86,7 +86,7 @@ static void test_after_failed_device_add(void)
*/
drive_add();
- qtest_end();
+ qtest_quit(global_qtest);
}
static void test_drive_del_device_del(void)
@@ -103,7 +103,7 @@ static void test_drive_del_device_del(void)
drive_del();
device_del();
- qtest_end();
+ qtest_quit(global_qtest);
}
int main(int argc, char **argv)
@@ -408,7 +408,7 @@ static void data_test_clear(e1000e_device *d)
pc_alloc_uninit(test_alloc);
g_free(d->pci_dev);
qpci_free_pc(test_bus);
- qtest_end();
+ qtest_quit(global_qtest);
}
static void test_e1000e_init(gconstpointer data)
@@ -463,7 +463,7 @@ static void test_e1000e_hotplug(gconstpointer data)
qpci_plug_device_test(global_qtest, "e1000e", "e1000e_net", slot, NULL);
qpci_unplug_device_test(global_qtest, "e1000e_net", slot);
- qtest_end();
+ qtest_quit(global_qtest);
}
int main(int argc, char **argv)
@@ -25,7 +25,7 @@ int main(int argc, char **argv)
qtest_start("-device ES1370");
ret = g_test_run();
- qtest_end();
+ qtest_quit(global_qtest);
return ret;
}
@@ -583,7 +583,7 @@ int main(int argc, char **argv)
ret = g_test_run();
/* Cleanup */
- qtest_end();
+ qtest_quit(global_qtest);
unlink(test_image);
return ret;
@@ -245,7 +245,7 @@ static void test_ide_none(void)
g_strfreev(argv);
g_free(args);
test_cmos();
- qtest_end();
+ qtest_quit(global_qtest);
}
static void test_ide_mbr(bool use_device, MBRcontents mbr)
@@ -267,7 +267,7 @@ static void test_ide_mbr(bool use_device, MBRcontents mbr)
g_strfreev(argv);
g_free(args);
test_cmos();
- qtest_end();
+ qtest_quit(global_qtest);
}
/*
@@ -343,7 +343,7 @@ static void test_ide_drive_user(const char *dev, bool trans)
g_strfreev(argv);
g_free(args);
test_cmos();
- qtest_end();
+ qtest_quit(global_qtest);
}
/*
@@ -400,7 +400,7 @@ static void test_ide_drive_cd_0(void)
g_strfreev(argv);
g_free(args);
test_cmos();
- qtest_end();
+ qtest_quit(global_qtest);
}
int main(int argc, char **argv)
@@ -136,7 +136,7 @@ static void test_i440fx_defaults(gconstpointer opaque)
g_free(dev);
qpci_free_pc(bus);
- qtest_end();
+ qtest_quit(global_qtest);
}
#define PAM_RE 1
@@ -275,7 +275,7 @@ static void test_i440fx_pam(gconstpointer opaque)
g_free(dev);
qpci_free_pc(bus);
- qtest_end();
+ qtest_quit(global_qtest);
}
#define BLOB_SIZE ((size_t)65536)
@@ -373,7 +373,7 @@ static void test_i440fx_firmware(FirmwareTestFixture *fixture,
}
g_free(buf);
- qtest_end();
+ qtest_quit(global_qtest);
}
static void add_firmware_test(const char *testpath,
@@ -25,7 +25,7 @@ int main(int argc, char **argv)
qtest_start("-machine q35 -device i82801b11-bridge,bus=pcie.0,addr=1e.0");
ret = g_test_run();
- qtest_end();
+ qtest_quit(global_qtest);
return ret;
}
@@ -134,7 +134,7 @@ static void ide_test_quit(void)
{
pc_alloc_uninit(guest_malloc);
guest_malloc = NULL;
- qtest_end();
+ qtest_quit(global_qtest);
}
static QPCIDevice *get_pci_device(QPCIBar *bmdma_bar, QPCIBar *ide_bar)
@@ -19,14 +19,14 @@
static void ich6_test(void)
{
qtest_start("-device intel-hda,id=" HDA_ID CODEC_DEVICES);
- qtest_end();
+ qtest_quit(global_qtest);
}
static void ich9_test(void)
{
qtest_start("-machine q35 -device ich9-intel-hda,bus=pcie.0,addr=1b.0,id="
HDA_ID CODEC_DEVICES);
- qtest_end();
+ qtest_quit(global_qtest);
}
int main(int argc, char **argv)
@@ -26,7 +26,7 @@ int main(int argc, char **argv)
"chassis=1,multifunction=on");
ret = g_test_run();
- qtest_end();
+ qtest_quit(global_qtest);
return ret;
}
@@ -25,7 +25,7 @@ int main(int argc, char **argv)
qtest_start("-device tpci200,id=ipack0 -device ipoctal232,bus=ipack0.0");
ret = g_test_run();
- qtest_end();
+ qtest_quit(global_qtest);
return ret;
}
@@ -25,7 +25,7 @@ int main(int argc, char **argv)
qtest_start("-device ne2k_pci");
ret = g_test_run();
- qtest_end();
+ qtest_quit(global_qtest);
return ret;
}
@@ -32,7 +32,7 @@ static void test_mon_explicit(const void *data)
g_assert(strstr(s, "node 1 cpus: 4 5 6 7"));
g_free(s);
- qtest_end();
+ qtest_quit(global_qtest);
g_free(cli);
}
@@ -49,7 +49,7 @@ static void test_mon_default(const void *data)
g_assert(strstr(s, "node 1 cpus: 1 3 5 7"));
g_free(s);
- qtest_end();
+ qtest_quit(global_qtest);
g_free(cli);
}
@@ -68,7 +68,7 @@ static void test_mon_partial(const void *data)
g_assert(strstr(s, "node 1 cpus: 4 5"));
g_free(s);
- qtest_end();
+ qtest_quit(global_qtest);
g_free(cli);
}
@@ -113,7 +113,7 @@ static void test_query_cpus(const void *data)
}
QDECREF(resp);
- qtest_end();
+ qtest_quit(global_qtest);
g_free(cli);
}
@@ -166,7 +166,7 @@ static void pc_numa_cpu(const void *data)
}
QDECREF(resp);
- qtest_end();
+ qtest_quit(global_qtest);
g_free(cli);
}
@@ -211,7 +211,7 @@ static void spapr_numa_cpu(const void *data)
}
QDECREF(resp);
- qtest_end();
+ qtest_quit(global_qtest);
g_free(cli);
}
@@ -254,7 +254,7 @@ static void aarch64_numa_cpu(const void *data)
}
QDECREF(resp);
- qtest_end();
+ qtest_quit(global_qtest);
g_free(cli);
}
@@ -26,7 +26,7 @@ int main(int argc, char **argv)
"-device nvme,drive=drv0,serial=foo");
ret = g_test_run();
- qtest_end();
+ qtest_quit(global_qtest);
return ret;
}
@@ -44,7 +44,7 @@ static void test_pc_with_cpu_add(gconstpointer data)
QDECREF(response);
}
- qtest_end();
+ qtest_quit(global_qtest);
g_free(args);
}
@@ -67,7 +67,7 @@ static void test_pc_without_cpu_add(gconstpointer data)
g_assert(qdict_haskey(response, "error"));
QDECREF(response);
- qtest_end();
+ qtest_quit(global_qtest);
g_free(args);
}
@@ -25,7 +25,7 @@ int main(int argc, char **argv)
qtest_start("-device pcnet");
ret = g_test_run();
- qtest_end();
+ qtest_quit(global_qtest);
return ret;
}
@@ -40,7 +40,7 @@ int main(int argc, char **argv)
qtest_start("-device pvpanic");
ret = g_test_run();
- qtest_end();
+ qtest_quit(global_qtest);
return ret;
}
@@ -119,7 +119,7 @@ static void test_smram_lock(void)
g_free(pcidev);
qpci_free_pc(pcibus);
- qtest_end();
+ qtest_quit(global_qtest);
}
static void test_tseg_size(const void *data)
@@ -185,7 +185,7 @@ static void test_tseg_size(const void *data)
g_free(pcidev);
qpci_free_pc(pcibus);
- qtest_end();
+ qtest_quit(global_qtest);
}
int main(int argc, char **argv)
@@ -188,7 +188,7 @@ static void test_query(const void *data)
}
QDECREF(resp);
- qtest_end();
+ qtest_quit(global_qtest);
}
static bool query_is_blacklisted(const char *cmd)
@@ -232,7 +232,7 @@ static void qmp_schema_init(QmpSchema *schema)
visit_free(qiv);
QDECREF(resp);
- qtest_end();
+ qtest_quit(global_qtest);
schema->hash = g_hash_table_new(g_str_hash, g_str_equal);
@@ -102,7 +102,7 @@ static void test_machine(gconstpointer data)
g_assert(qdict_haskey(response, "return"));
QDECREF(response);
- qtest_end();
+ qtest_quit(global_qtest);
g_free(args);
g_free((void *)machine);
}
@@ -205,7 +205,7 @@ int main(int argc, char **argv)
ret = g_test_run();
- qtest_end();
+ qtest_quit(global_qtest);
return ret;
}
@@ -29,7 +29,7 @@ int main(int argc, char **argv)
ret = g_test_run();
- qtest_end();
+ qtest_quit(global_qtest);
return ret;
}
@@ -49,7 +49,7 @@ static void test_end(TestData *d)
{
g_free(d->dev);
qpci_free_pc(d->bus);
- qtest_end();
+ qtest_quit(global_qtest);
}
static void test_init(TestData *d)
@@ -1099,7 +1099,7 @@ tests_with_prescaler_arg:
qtest_start("-machine vexpress-a9");
ret = g_test_run();
- qtest_end();
+ qtest_quit(global_qtest);
return ret;
}
@@ -86,7 +86,7 @@ int main(int argc, char **argv)
qtest_add_func("/netfilter/mirror", test_mirror);
ret = g_test_run();
- qtest_end();
+ qtest_quit(global_qtest);
return ret;
}
@@ -135,7 +135,7 @@ static void test_redirector_tx(void)
close(recv_sock);
unlink(sock_path0);
unlink(sock_path1);
- qtest_end();
+ qtest_quit(global_qtest);
}
static void test_redirector_rx(void)
@@ -204,7 +204,7 @@ static void test_redirector_rx(void)
g_free(recv_buf);
unlink(sock_path0);
unlink(sock_path1);
- qtest_end();
+ qtest_quit(global_qtest);
}
int main(int argc, char **argv)
@@ -127,7 +127,7 @@ static void test_machine(gconstpointer data)
test_info_commands();
test_commands();
- qtest_end();
+ qtest_quit(global_qtest);
g_free(args);
g_free((void *)data);
}
@@ -202,7 +202,7 @@ int main(int argc, char **argv)
qtest_start(args);
ret = g_test_run();
- qtest_end();
+ qtest_quit(global_qtest);
g_free(args);
return ret;
@@ -64,7 +64,7 @@ static void test_cpuid_prop(const void *data)
value = qobject_to_qnum(qom_get(path, args->property));
g_assert(qnum_get_try_int(value, &val));
g_assert_cmpint(val, ==, args->expected_value);
- qtest_end();
+ qtest_quit(global_qtest);
QDECREF(value);
g_free(path);
@@ -137,7 +137,7 @@ static void test_feature_flag(const void *data)
filtered = qobject_to_qlist(qom_get(path, "filtered-features"));
value = get_feature_word(present, args->in_eax, args->in_ecx, args->reg);
value |= get_feature_word(filtered, args->in_eax, args->in_ecx, args->reg);
- qtest_end();
+ qtest_quit(global_qtest);
g_assert(!!(value & (1U << args->bitnr)) == args->expected_value);
@@ -195,7 +195,7 @@ static void test_plus_minus_subprocess(void)
g_assert_true(qom_get_bool(path, "sse4-2"));
g_assert_true(qom_get_bool(path, "sse4.2"));
- qtest_end();
+ qtest_quit(global_qtest);
g_free(path);
}
@@ -25,7 +25,7 @@ int main(int argc, char **argv)
qtest_start("-device tpci200");
ret = g_test_run();
- qtest_end();
+ qtest_quit(global_qtest);
return ret;
}
@@ -172,7 +172,7 @@ int main(int argc, char **argv)
ret = g_test_run();
test_deinit();
- qtest_end();
+ qtest_quit(global_qtest);
return ret;
}
@@ -33,7 +33,7 @@ int main(int argc, char **argv)
qtest_start("-device pci-ohci,id=ohci");
ret = g_test_run();
- qtest_end();
+ qtest_quit(global_qtest);
return ret;
}
@@ -83,7 +83,7 @@ int main(int argc, char **argv)
qtest_start("-device nec-usb-xhci,id=xhci"
" -drive id=drive0,if=none,file=null-co://,format=raw");
ret = g_test_run();
- qtest_end();
+ qtest_quit(global_qtest);
return ret;
}
@@ -25,7 +25,7 @@ int main(int argc, char **argv)
qtest_start("-device virtio-balloon-pci");
ret = g_test_run();
- qtest_end();
+ qtest_quit(global_qtest);
return ret;
}
@@ -102,7 +102,7 @@ static void arm_test_start(void)
static void test_end(void)
{
- qtest_end();
+ qtest_quit(global_qtest);
}
static QVirtioPCIDevice *virtio_blk_pci_init(QPCIBus *bus, int slot)
@@ -15,14 +15,14 @@ static void console_pci_nop(void)
{
qtest_start("-device virtio-serial-pci,id=vser0 "
"-device virtconsole,bus=vser0.0");
- qtest_end();
+ qtest_quit(global_qtest);
}
static void serialport_pci_nop(void)
{
qtest_start("-device virtio-serial-pci,id=vser0 "
"-device virtserialport,bus=vser0.0");
- qtest_end();
+ qtest_quit(global_qtest);
}
int main(int argc, char **argv)
@@ -30,7 +30,7 @@
static void test_end(void)
{
- qtest_end();
+ qtest_quit(global_qtest);
}
#ifndef _WIN32
@@ -41,7 +41,7 @@ int main(int argc, char **argv)
qtest_start("-device virtio-rng-pci");
ret = g_test_run();
- qtest_end();
+ qtest_quit(global_qtest);
return ret;
}
@@ -52,7 +52,7 @@ int main(int argc, char **argv)
qtest_start("-device virtio-serial-pci");
ret = g_test_run();
- qtest_end();
+ qtest_quit(global_qtest);
return ret;
}
@@ -25,7 +25,7 @@ int main(int argc, char **argv)
qtest_start("-device vmxnet3");
ret = g_test_run();
- qtest_end();
+ qtest_quit(global_qtest);
return ret;
}
Rather than have two similar shutdown functions, where one requires the use of global_qtest in the header, it is better to have a single shutdown function that still takes care of cleaning up global_qtest if it is set. All callers are updated. Signed-off-by: Eric Blake <eblake@redhat.com> --- tests/libqtest.h | 11 ----------- tests/libqtest.c | 6 +++++- tests/ac97-test.c | 2 +- tests/device-introspect-test.c | 12 ++++++------ tests/display-vga-test.c | 12 ++++++------ tests/drive_del-test.c | 6 +++--- tests/e1000e-test.c | 4 ++-- tests/es1370-test.c | 2 +- tests/fdc-test.c | 2 +- tests/hd-geo-test.c | 8 ++++---- tests/i440fx-test.c | 6 +++--- tests/i82801b11-test.c | 2 +- tests/ide-test.c | 2 +- tests/intel-hda-test.c | 4 ++-- tests/ioh3420-test.c | 2 +- tests/ipoctal232-test.c | 2 +- tests/ne2000-test.c | 2 +- tests/numa-test.c | 14 +++++++------- tests/nvme-test.c | 2 +- tests/pc-cpu-test.c | 4 ++-- tests/pcnet-test.c | 2 +- tests/pvpanic-test.c | 2 +- tests/q35-test.c | 4 ++-- tests/qmp-test.c | 4 ++-- tests/qom-test.c | 2 +- tests/rtl8139-test.c | 2 +- tests/spapr-phb-test.c | 2 +- tests/tco-test.c | 2 +- tests/test-arm-mptimer.c | 2 +- tests/test-filter-mirror.c | 2 +- tests/test-filter-redirector.c | 4 ++-- tests/test-hmp.c | 2 +- tests/test-netfilter.c | 2 +- tests/test-x86-cpuid-compat.c | 6 +++--- tests/tpci200-test.c | 2 +- tests/usb-hcd-ehci-test.c | 2 +- tests/usb-hcd-ohci-test.c | 2 +- tests/usb-hcd-xhci-test.c | 2 +- tests/virtio-balloon-test.c | 2 +- tests/virtio-blk-test.c | 2 +- tests/virtio-console-test.c | 4 ++-- tests/virtio-net-test.c | 2 +- tests/virtio-rng-test.c | 2 +- tests/virtio-serial-test.c | 2 +- tests/vmxnet3-test.c | 2 +- 45 files changed, 80 insertions(+), 87 deletions(-)