]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
tests/qtest: Add missing checks for the availability of machines
authorThomas Huth <thuth@redhat.com>
Tue, 30 Sep 2025 09:04:44 +0000 (11:04 +0200)
committerFabiano Rosas <farosas@suse.de>
Wed, 1 Oct 2025 20:09:21 +0000 (17:09 -0300)
When QEMU has been compiled with "--without-default-devices", the
machines might not be available in the binary. Let's properly check
for the machines before running the tests to avoid that they are
failing in this case.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20250930090444.234431-1-thuth@redhat.com
Signed-off-by: Fabiano Rosas <farosas@suse.de>
tests/qtest/bios-tables-test.c
tests/qtest/cpu-plug-test.c
tests/qtest/riscv-csr-test.c

index 4fa8ac5096a6e88514c654a71dd041f508930851..6b892ef23e1a767b29e221b4c41b98475b7545bc 100644 (file)
@@ -2864,7 +2864,7 @@ int main(int argc, char *argv[])
                            test_acpi_riscv64_virt_tcg_acpi_spcr);
         }
     } else if (strcmp(arch, "loongarch64") == 0) {
-        if (has_tcg) {
+        if (has_tcg && qtest_has_machine("virt")) {
             qtest_add_func("acpi/virt", test_acpi_loongarch64_virt);
             qtest_add_func("acpi/virt/topology",
                            test_acpi_loongarch64_virt_topology);
index 44d704680b146ab7f33b34b8b2eceb660b051b1b..0aa4ccc5b61910d27c0daedeb24dc2a5c2592372 100644 (file)
@@ -190,7 +190,7 @@ int main(int argc, char **argv)
         qtest_cb_for_every_machine(add_pseries_test_case, g_test_quick());
     } else if (g_str_equal(arch, "s390x")) {
         qtest_cb_for_every_machine(add_s390x_test_case, g_test_quick());
-    } else if (g_str_equal(arch, "loongarch64")) {
+    } else if (g_str_equal(arch, "loongarch64") && qtest_has_machine("virt")) {
         add_loongarch_test_case("virt");
     }
 
index ff5c29e6c6f29cff8678c0a8a97a4466312fd981..bb1b0ffed3080f004a3ea4d23dd0ef3154482329 100644 (file)
@@ -50,7 +50,9 @@ int main(int argc, char **argv)
 {
     g_test_init(&argc, &argv, NULL);
 
-    qtest_add_func("/cpu/csr", run_test_csr);
+    if (qtest_has_machine("virt")) {
+        qtest_add_func("/cpu/csr", run_test_csr);
+    }
 
     return g_test_run();
 }