tests/qtest: Check for the availability of virtio-ccw devices before using them

The devices might not have been compiled into the QEMU binary, so we
have to check before we can use them.

Message-Id: <20230512124033.502654-16-thuth@redhat.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
This commit is contained in:
Thomas Huth 2023-05-11 15:41:59 +02:00
parent 9a67171461
commit 65331bf5d1
2 changed files with 21 additions and 8 deletions

View file

@ -156,7 +156,14 @@ static void test_q35_pci_unplug_json_request(void)
static void test_ccw_unplug(void)
{
QTestState *qtest = qtest_initf("-device virtio-balloon-ccw,id=dev0");
QTestState *qtest;
if (!qtest_has_device("virtio-balloon-ccw")) {
g_test_skip("Device virtio-balloon-ccw not available");
return;
}
qtest = qtest_initf("-device virtio-balloon-ccw,id=dev0");
qtest_qmp_device_del_send(qtest, "dev0");
wait_device_deleted_event(qtest, "dev0");

View file

@ -76,13 +76,19 @@ static void virtio_scsi_hotplug(void)
int main(int argc, char **argv)
{
g_test_init(&argc, &argv, NULL);
qtest_add_func("/virtio/console/nop", virtconsole_nop);
qtest_add_func("/virtio/serialport/nop", virtserialport_nop);
qtest_add_func("/virtio/serial/nop", virtio_serial_nop);
qtest_add_func("/virtio/serial/hotplug", virtio_serial_hotplug);
qtest_add_func("/virtio/rng/nop", virtio_rng_nop);
qtest_add_func("/virtio/scsi/nop", virtio_scsi_nop);
qtest_add_func("/virtio/scsi/hotplug", virtio_scsi_hotplug);
if (qtest_has_device("virtio-serial-ccw")) {
qtest_add_func("/virtio/console/nop", virtconsole_nop);
qtest_add_func("/virtio/serialport/nop", virtserialport_nop);
qtest_add_func("/virtio/serial/nop", virtio_serial_nop);
qtest_add_func("/virtio/serial/hotplug", virtio_serial_hotplug);
}
if (qtest_has_device("virtio-rng-ccw")) {
qtest_add_func("/virtio/rng/nop", virtio_rng_nop);
}
if (qtest_has_device("virtio-rng-ccw")) {
qtest_add_func("/virtio/scsi/nop", virtio_scsi_nop);
qtest_add_func("/virtio/scsi/hotplug", virtio_scsi_hotplug);
}
return g_test_run();
}