Compare commits

...

12 Commits

Author SHA1 Message Date
Fabiano Rosas
eab13108cd tests/qtest: bios-tables-test: Skip if missing configs
If we build with --without-default-devices, CONFIG_HPET and
CONFIG_PARALLEL are set to N, which makes the respective devices go
missing from acpi tables.

Signed-off-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Thomas Huth <thuth@redhat.com>
2023-02-13 18:01:07 -03:00
Fabiano Rosas
750400c56f tests/qemu-iotests: Require virtio-scsi-pci
Check that virtio-scsi-pci is present in the QEMU build before running
the tests.

Signed-off-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Thomas Huth <thuth@redhat.com>
2023-02-13 18:01:07 -03:00
Fabiano Rosas
f5ef199312 tests/qtest: Do not include hexloader-test if loader device is not present
Signed-off-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Thomas Huth <thuth@redhat.com>
2023-02-13 18:01:07 -03:00
Fabiano Rosas
c789207417 tests/qtest: Check for devices in bios-tables-test
Do not include tests that require devices that are not available in
the QEMU build.

Signed-off-by: Fabiano Rosas <farosas@suse.de>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
2023-02-13 18:01:07 -03:00
Fabiano Rosas
3bf0b7dd7b tests/qtest: drive_del-test: Skip tests that require missing devices
Signed-off-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Thomas Huth <thuth@redhat.com>
2023-02-13 18:01:07 -03:00
Fabiano Rosas
3864d5e5c6 tests/qtest: Skip unplug tests that use missing devices
Signed-off-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Thomas Huth <thuth@redhat.com>
2023-02-13 18:01:07 -03:00
Fabiano Rosas
8a840ab4c2 tests/qtest: Fix coding style in device-plug-test.c
We should not mix declarations and statements in QEMU code.

Signed-off-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Thomas Huth <thuth@redhat.com>
2023-02-13 18:01:07 -03:00
Fabiano Rosas
d32f29f651 tests/qtest: hd-geo-test: Check for missing devices
Don't include tests that require devices not available in the QEMU
binary.

Signed-off-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Thomas Huth <thuth@redhat.com>
2023-02-13 18:01:07 -03:00
Fabiano Rosas
696cf0c1cd tests/qtest: Don't build virtio-serial-test.c if device not present
The virtconsole device might not be present in the QEMU build that is
being tested.

Signed-off-by: Fabiano Rosas <farosas@suse.de>
2023-02-13 18:01:07 -03:00
Fabiano Rosas
ef92be0914 tests/qtest: Add dependence on PCIE_PORT for virtio-net-failover.c
This test depends on the presence of the pcie-root-port device. Add a
build time dependency.

Signed-off-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Thomas Huth <thuth@redhat.com>
2023-02-13 18:01:07 -03:00
Fabiano Rosas
f85bfa0bcb tests/qtest: Do not run lsi53c895a test if device is not present
The tests are built once for all the targets, so as long as one QEMU
binary is built with CONFIG_LSI_SCSI_PCI=y, this test will
run. However some binaries might not include the device. So check this
again in runtime.

Signed-off-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Thomas Huth <thuth@redhat.com>
2023-02-13 18:01:07 -03:00
Fabiano Rosas
ecbd3f095e tests/qtest: Skip PXE tests for missing devices
Check if the devices we're trying to add are present in the QEMU
binary. They could have been removed from the build via Kconfig or the
--without-default-devices option.

Signed-off-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Thomas Huth <thuth@redhat.com>
2023-02-13 18:01:07 -03:00
8 changed files with 214 additions and 31 deletions

View File

@@ -40,6 +40,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
_supported_fmt qcow2
_supported_proto file fuse
_require_drivers null-co
_require_devices virtio-scsi-pci
if [ "$QEMU_DEFAULT_MACHINE" != "pc" ]; then
_notrun "Requires a PC machine"

View File

@@ -1008,6 +1008,12 @@ static void test_acpi_q35_multif_bridge(void)
.machine = MACHINE_Q35,
.variant = ".multi-bridge",
};
if (!qtest_has_device("pcie-root-port")) {
g_test_skip("Device pcie-root-port is not available");
goto out;
}
test_vm_prepare("-S"
" -device virtio-balloon,id=balloon0,addr=0x4.0x2"
" -device pcie-root-port,id=rp0,multifunction=on,"
@@ -1043,6 +1049,7 @@ static void test_acpi_q35_multif_bridge(void)
/* check that reboot/reset doesn't change any ACPI tables */
qtest_qmp_send(data.qts, "{'execute':'system_reset' }");
process_acpi_tables(&data);
out:
free_test_data(&data);
}
@@ -1396,6 +1403,11 @@ static void test_acpi_tcg_dimm_pxm(const char *machine)
{
test_data data;
if (!qtest_has_device("nvdimm")) {
g_test_skip("Device nvdimm is not available");
return;
}
memset(&data, 0, sizeof(data));
data.machine = machine;
data.variant = ".dimmpxm";
@@ -1444,6 +1456,11 @@ static void test_acpi_virt_tcg_memhp(void)
.scan_len = 256ULL * 1024 * 1024,
};
if (!qtest_has_device("nvdimm")) {
g_test_skip("Device nvdimm is not available");
goto out;
}
data.variant = ".memhp";
test_acpi_one(" -machine nvdimm=on"
" -cpu cortex-a57"
@@ -1457,7 +1474,7 @@ static void test_acpi_virt_tcg_memhp(void)
" -device pc-dimm,id=dimm0,memdev=ram2,node=0"
" -device nvdimm,id=dimm1,memdev=nvm0,node=1",
&data);
out:
free_test_data(&data);
}
@@ -1475,6 +1492,11 @@ static void test_acpi_microvm_tcg(void)
{
test_data data;
if (!qtest_has_device("virtio-blk-device")) {
g_test_skip("Device virtio-blk-device is not available");
return;
}
test_acpi_microvm_prepare(&data);
test_acpi_one(" -machine microvm,acpi=on,ioapic2=off,rtc=off",
&data);
@@ -1485,6 +1507,11 @@ static void test_acpi_microvm_usb_tcg(void)
{
test_data data;
if (!qtest_has_device("virtio-blk-device")) {
g_test_skip("Device virtio-blk-device is not available");
return;
}
test_acpi_microvm_prepare(&data);
data.variant = ".usb";
test_acpi_one(" -machine microvm,acpi=on,ioapic2=off,usb=on,rtc=off",
@@ -1496,6 +1523,11 @@ static void test_acpi_microvm_rtc_tcg(void)
{
test_data data;
if (!qtest_has_device("virtio-blk-device")) {
g_test_skip("Device virtio-blk-device is not available");
return;
}
test_acpi_microvm_prepare(&data);
data.variant = ".rtc";
test_acpi_one(" -machine microvm,acpi=on,ioapic2=off,rtc=on",
@@ -1507,6 +1539,11 @@ static void test_acpi_microvm_pcie_tcg(void)
{
test_data data;
if (!qtest_has_device("virtio-blk-device")) {
g_test_skip("Device virtio-blk-device is not available");
return;
}
test_acpi_microvm_prepare(&data);
data.variant = ".pcie";
data.tcg_only = true; /* need constant host-phys-bits */
@@ -1519,6 +1556,11 @@ static void test_acpi_microvm_ioapic2_tcg(void)
{
test_data data;
if (!qtest_has_device("virtio-blk-device")) {
g_test_skip("Device virtio-blk-device is not available");
return;
}
test_acpi_microvm_prepare(&data);
data.variant = ".ioapic2";
test_acpi_one(" -machine microvm,acpi=on,ioapic2=on,rtc=off",
@@ -1558,6 +1600,12 @@ static void test_acpi_virt_tcg_pxb(void)
.ram_start = 0x40000000ULL,
.scan_len = 128ULL * 1024 * 1024,
};
if (!qtest_has_device("pcie-root-port")) {
g_test_skip("Device pcie-root-port is not available");
goto out;
}
/*
* While using -cdrom, the cdrom would auto plugged into pxb-pcie,
* the reason is the bus of pxb-pcie is also root bus, it would lead
@@ -1576,7 +1624,7 @@ static void test_acpi_virt_tcg_pxb(void)
" -cpu cortex-a57"
" -device pxb-pcie,bus_nr=128",
&data);
out:
free_test_data(&data);
}
@@ -1764,6 +1812,12 @@ static void test_acpi_microvm_acpi_erst(void)
gchar *params;
test_data data;
if (!qtest_has_device("virtio-blk-device")) {
g_test_skip("Device virtio-blk-device is not available");
g_free(tmp_path);
return;
}
test_acpi_microvm_prepare(&data);
data.variant = ".pcie";
data.tcg_only = true; /* need constant host-phys-bits */
@@ -1824,6 +1878,11 @@ static void test_acpi_q35_viot(void)
.variant = ".viot",
};
if (!qtest_has_device("virtio-iommu")) {
g_test_skip("Device virtio-iommu is not available");
goto out;
}
/*
* To keep things interesting, two buses bypass the IOMMU.
* VIOT should only describes the other two buses.
@@ -1834,6 +1893,7 @@ static void test_acpi_q35_viot(void)
"-device pxb-pcie,bus_nr=0x20,id=pcie.200,bus=pcie.0,bypass_iommu=on "
"-device pxb-pcie,bus_nr=0x30,id=pcie.300,bus=pcie.0",
&data);
out:
free_test_data(&data);
}
@@ -1894,8 +1954,10 @@ static void test_acpi_virt_viot(void)
.scan_len = 128ULL * 1024 * 1024,
};
test_acpi_one("-cpu cortex-a57 "
"-device virtio-iommu-pci", &data);
if (qtest_has_device("virtio-iommu")) {
test_acpi_one("-cpu cortex-a57 "
"-device virtio-iommu-pci", &data);
}
free_test_data(&data);
}
@@ -2004,6 +2066,11 @@ static void test_acpi_microvm_oem_fields(void)
test_data data;
char *args;
if (!qtest_has_device("virtio-blk-device")) {
g_test_skip("Device virtio-blk-device is not available");
return;
}
test_acpi_microvm_prepare(&data);
args = test_acpi_create_args(&data,

View File

@@ -64,15 +64,21 @@ static void process_device_remove(QTestState *qtest, const char *id)
static void test_pci_unplug_request(void)
{
QTestState *qtest;
const char *arch = qtest_get_arch();
const char *machine_addition = "";
if (!qtest_has_device("virtio-mouse-pci")) {
g_test_skip("Device virtio-mouse-pci not available");
return;
}
if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
machine_addition = "-machine pc";
}
QTestState *qtest = qtest_initf("%s -device virtio-mouse-pci,id=dev0",
machine_addition);
qtest = qtest_initf("%s -device virtio-mouse-pci,id=dev0",
machine_addition);
process_device_remove(qtest, "dev0");
@@ -81,11 +87,17 @@ static void test_pci_unplug_request(void)
static void test_q35_pci_unplug_request(void)
{
QTestState *qtest;
QTestState *qtest = qtest_initf("-machine q35 "
"-device pcie-root-port,id=p1 "
"-device pcie-pci-bridge,bus=p1,id=b1 "
"-device virtio-mouse-pci,bus=b1,id=dev0");
if (!qtest_has_device("virtio-mouse-pci")) {
g_test_skip("Device virtio-mouse-pci not available");
return;
}
qtest = qtest_initf("-machine q35 "
"-device pcie-root-port,id=p1 "
"-device pcie-pci-bridge,bus=p1,id=b1 "
"-device virtio-mouse-pci,bus=b1,id=dev0");
process_device_remove(qtest, "dev0");
@@ -94,14 +106,20 @@ static void test_q35_pci_unplug_request(void)
static void test_pci_unplug_json_request(void)
{
QTestState *qtest;
const char *arch = qtest_get_arch();
const char *machine_addition = "";
if (!qtest_has_device("virtio-mouse-pci")) {
g_test_skip("Device virtio-mouse-pci not available");
return;
}
if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
machine_addition = "-machine pc";
}
QTestState *qtest = qtest_initf(
qtest = qtest_initf(
"%s -device \"{'driver': 'virtio-mouse-pci', 'id': 'dev0'}\"",
machine_addition);
@@ -112,6 +130,7 @@ static void test_pci_unplug_json_request(void)
static void test_q35_pci_unplug_json_request(void)
{
QTestState *qtest;
const char *port = "-device \"{'driver': 'pcie-root-port', "
"'id': 'p1'}\"";
@@ -123,8 +142,12 @@ static void test_q35_pci_unplug_json_request(void)
"'bus': 'b1', "
"'id': 'dev0'}\"";
QTestState *qtest = qtest_initf("-machine q35 %s %s %s",
port, bridge, device);
if (!qtest_has_device("virtio-mouse-pci")) {
g_test_skip("Device virtio-mouse-pci not available");
return;
}
qtest = qtest_initf("-machine q35 %s %s %s", port, bridge, device);
process_device_remove(qtest, "dev0");

View File

@@ -16,6 +16,8 @@
#include "qapi/qmp/qdict.h"
#include "qapi/qmp/qlist.h"
static const char *qvirtio_get_dev_type(void);
static bool look_for_drive0(QTestState *qts, const char *command, const char *key)
{
QDict *response;
@@ -40,6 +42,19 @@ static bool look_for_drive0(QTestState *qts, const char *command, const char *ke
return found;
}
/*
* This covers the possible absence of a device due to QEMU build
* options.
*/
static bool has_device_builtin(const char *dev)
{
gchar *device = g_strdup_printf("%s-%s", dev, qvirtio_get_dev_type());
bool rc = qtest_has_device(device);
g_free(device);
return rc;
}
static bool has_drive(QTestState *qts)
{
return look_for_drive0(qts, "query-block", "device");
@@ -208,6 +223,11 @@ static void test_drive_del_device_del(void)
{
QTestState *qts;
if (!has_device_builtin("virtio-scsi")) {
g_test_skip("Device virtio-scsi is not available");
return;
}
/* Start with a drive used by a device that unplugs instantaneously */
qts = qtest_initf("-drive if=none,id=drive0,file=null-co://,"
"file.read-zeroes=on,format=raw"
@@ -232,6 +252,11 @@ static void test_cli_device_del(void)
const char *arch = qtest_get_arch();
const char *machine_addition = "";
if (!has_device_builtin("virtio-blk")) {
g_test_skip("Device virtio-blk is not available");
return;
}
if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
machine_addition = "-machine pc";
}
@@ -256,6 +281,11 @@ static void test_cli_device_del_q35(void)
{
QTestState *qts;
if (!has_device_builtin("virtio-blk")) {
g_test_skip("Device virtio-blk is not available");
return;
}
/*
* -drive/-device and device_del. Start with a drive used by a
* device that unplugs after reset.
@@ -277,6 +307,11 @@ static void test_empty_device_del(void)
{
QTestState *qts;
if (!has_device_builtin("virtio-scsi")) {
g_test_skip("Device virtio-scsi is not available");
return;
}
/* device_del with no drive plugged. */
qts = qtest_initf("-device virtio-scsi-%s -device scsi-cd,id=dev0",
qvirtio_get_dev_type());
@@ -291,6 +326,11 @@ static void test_device_add_and_del(void)
const char *arch = qtest_get_arch();
const char *machine_addition = "";
if (!has_device_builtin("virtio-blk")) {
g_test_skip("Device virtio-blk is not available");
return;
}
if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
machine_addition = "-machine pc";
}
@@ -330,6 +370,11 @@ static void test_device_add_and_del_q35(void)
{
QTestState *qts;
if (!has_device_builtin("virtio-blk")) {
g_test_skip("Device virtio-blk is not available");
return;
}
/*
* -drive/device_add and device_del. Start with a drive used by a
* device that unplugs after reset.
@@ -352,6 +397,11 @@ static void test_drive_add_device_add_and_del(void)
const char *arch = qtest_get_arch();
const char *machine_addition = "";
if (!has_device_builtin("virtio-blk")) {
g_test_skip("Device virtio-blk is not available");
return;
}
if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
machine_addition = "-machine pc";
}
@@ -374,6 +424,11 @@ static void test_drive_add_device_add_and_del_q35(void)
{
QTestState *qts;
if (!has_device_builtin("virtio-blk")) {
g_test_skip("Device virtio-blk is not available");
return;
}
qts = qtest_init("-machine q35 -device pcie-root-port,id=p1 "
"-device pcie-pci-bridge,bus=p1,id=b1");
@@ -395,6 +450,11 @@ static void test_blockdev_add_device_add_and_del(void)
const char *arch = qtest_get_arch();
const char *machine_addition = "";
if (!has_device_builtin("virtio-blk")) {
g_test_skip("Device virtio-blk is not available");
return;
}
if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
machine_addition = "-machine pc";
}
@@ -417,6 +477,11 @@ static void test_blockdev_add_device_add_and_del_q35(void)
{
QTestState *qts;
if (!has_device_builtin("virtio-blk")) {
g_test_skip("Device virtio-blk is not available");
return;
}
qts = qtest_init("-machine q35 -device pcie-root-port,id=p1 "
"-device pcie-pci-bridge,bus=p1,id=b1");

View File

@@ -112,6 +112,10 @@ static void test_lsi_do_dma_empty_queue(void)
int main(int argc, char **argv)
{
if (!qtest_has_device("lsi53c895a")) {
return 0;
}
g_test_init(&argc, &argv, NULL);
qtest_add_func("fuzz/lsi53c895a/lsi_do_dma_empty_queue",

View File

@@ -1090,30 +1090,42 @@ int main(int argc, char **argv)
qtest_add_func("hd-geo/override/ide", test_override_ide);
if (qtest_has_device("lsi53c895a")) {
qtest_add_func("hd-geo/override/scsi", test_override_scsi);
qtest_add_func("hd-geo/override/scsi_2_controllers",
test_override_scsi_2_controllers);
if (qtest_has_device("virtio-scsi-pci")) {
qtest_add_func("hd-geo/override/scsi_2_controllers",
test_override_scsi_2_controllers);
}
}
qtest_add_func("hd-geo/override/virtio_blk", test_override_virtio_blk);
qtest_add_func("hd-geo/override/zero_chs", test_override_zero_chs);
qtest_add_func("hd-geo/override/scsi_hot_unplug",
test_override_scsi_hot_unplug);
qtest_add_func("hd-geo/override/virtio_hot_unplug",
test_override_virtio_hot_unplug);
if (qtest_has_device("virtio-scsi-pci")) {
qtest_add_func("hd-geo/override/scsi_hot_unplug",
test_override_scsi_hot_unplug);
}
if (qtest_has_device("virtio-blk-pci")) {
qtest_add_func("hd-geo/override/virtio_hot_unplug",
test_override_virtio_hot_unplug);
qtest_add_func("hd-geo/override/virtio_blk",
test_override_virtio_blk);
}
if (qtest_has_machine("q35")) {
qtest_add_func("hd-geo/override/sata", test_override_sata);
qtest_add_func("hd-geo/override/virtio_blk_q35",
test_override_virtio_blk_q35);
qtest_add_func("hd-geo/override/zero_chs_q35",
test_override_zero_chs_q35);
if (qtest_has_device("lsi53c895a")) {
qtest_add_func("hd-geo/override/scsi_q35",
test_override_scsi_q35);
}
qtest_add_func("hd-geo/override/scsi_hot_unplug_q35",
test_override_scsi_hot_unplug_q35);
qtest_add_func("hd-geo/override/virtio_hot_unplug_q35",
test_override_virtio_hot_unplug_q35);
if (qtest_has_device("virtio-scsi-pci")) {
qtest_add_func("hd-geo/override/scsi_hot_unplug_q35",
test_override_scsi_hot_unplug_q35);
}
if (qtest_has_device("virtio-blk-pci")) {
qtest_add_func("hd-geo/override/virtio_hot_unplug_q35",
test_override_virtio_hot_unplug_q35);
qtest_add_func("hd-geo/override/virtio_blk_q35",
test_override_virtio_blk_q35);
}
}
} else {
g_test_message("QTEST_QEMU_IMG not set or qemu-img missing; "

View File

@@ -73,11 +73,14 @@ qtests_i386 = \
(config_all_devices.has_key('CONFIG_ESP_PCI') ? ['am53c974-test'] : []) + \
(config_host.has_key('CONFIG_POSIX') and \
config_all_devices.has_key('CONFIG_ACPI_ERST') ? ['erst-test'] : []) + \
(config_all_devices.has_key('CONFIG_VIRTIO_NET') and \
(config_all_devices.has_key('CONFIG_PCIE_PORT') and \
config_all_devices.has_key('CONFIG_VIRTIO_NET') and \
config_all_devices.has_key('CONFIG_Q35') and \
config_all_devices.has_key('CONFIG_VIRTIO_PCI') and \
slirp.found() ? ['virtio-net-failover'] : []) + \
(unpack_edk2_blobs ? ['bios-tables-test'] : []) + \
(unpack_edk2_blobs and \
config_all_devices.has_key('CONFIG_HPET') and \
config_all_devices.has_key('CONFIG_PARALLEL') ? ['bios-tables-test'] : []) + \
qtests_pci + \
qtests_cxl + \
['fdc-test',
@@ -196,11 +199,11 @@ qtests_arm = \
(config_all_devices.has_key('CONFIG_PFLASH_CFI02') ? ['pflash-cfi02-test'] : []) + \
(config_all_devices.has_key('CONFIG_ASPEED_SOC') ? qtests_aspeed : []) + \
(config_all_devices.has_key('CONFIG_NPCM7XX') ? qtests_npcm7xx : []) + \
(config_all_devices.has_key('CONFIG_GENERIC_LOADER') ? ['hexloader-test'] : []) + \
['arm-cpu-features',
'microbit-test',
'test-arm-mptimer',
'boot-serial-test',
'hexloader-test']
'boot-serial-test']
# TODO: once aarch64 TCG is fixed on ARM 32 bit host, make bios-tables-test unconditional
qtests_aarch64 = \
@@ -254,10 +257,14 @@ qos_test_ss.add(
'virtio-net-test.c',
'virtio-rng-test.c',
'virtio-scsi-test.c',
'virtio-serial-test.c',
'virtio-iommu-test.c',
'vmxnet3-test.c',
)
if config_all_devices.has_key('CONFIG_VIRTIO_SERIAL')
qos_test_ss.add(files('virtio-serial-test.c'))
endif
if config_host.has_key('CONFIG_POSIX')
qos_test_ss.add(files('e1000e-test.c'))
endif

View File

@@ -108,6 +108,10 @@ static void test_batch(const testdef_t *tests, bool ipv6)
const testdef_t *test = &tests[i];
char *testname;
if (!qtest_has_device(test->model)) {
continue;
}
testname = g_strdup_printf("pxe/ipv4/%s/%s",
test->machine, test->model);
qtest_add_data_func(testname, test, test_pxe_ipv4);