tests/qtest/cdrom-test: Improve the machine detection in the cdrom test

When configuring QEMU with the --without-default-devices switch, these
tests are currently failing since they assume that the "pc" and "q35"
machines are always available. Add some proper checks to make the test
work without these machines, too.

Message-ID: <20240905191434.694440-3-thuth@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
This commit is contained in:
Thomas Huth 2024-09-05 21:14:28 +02:00
parent ea9cdbcf3a
commit d822b883d7

View File

@ -135,13 +135,35 @@ static void add_x86_tests(void)
return; return;
} }
qtest_add_data_func("cdrom/boot/default", "-cdrom ", test_cdboot); if (qtest_has_machine("pc")) {
if (qtest_has_device("virtio-scsi-ccw")) { qtest_add_data_func("cdrom/boot/default", "-cdrom ", test_cdboot);
qtest_add_data_func("cdrom/boot/virtio-scsi", if (qtest_has_device("virtio-scsi-ccw")) {
"-device virtio-scsi -device scsi-cd,drive=cdr " qtest_add_data_func("cdrom/boot/virtio-scsi",
"-blockdev file,node-name=cdr,filename=", "-device virtio-scsi -device scsi-cd,drive=cdr "
test_cdboot); "-blockdev file,node-name=cdr,filename=",
test_cdboot);
}
if (qtest_has_device("am53c974")) {
qtest_add_data_func("cdrom/boot/am53c974",
"-device am53c974 -device scsi-cd,drive=cd1 "
"-drive if=none,id=cd1,format=raw,file=",
test_cdboot);
}
if (qtest_has_device("dc390")) {
qtest_add_data_func("cdrom/boot/dc390",
"-device dc390 -device scsi-cd,drive=cd1 "
"-blockdev file,node-name=cd1,filename=",
test_cdboot);
}
if (qtest_has_device("lsi53c895a")) {
qtest_add_data_func("cdrom/boot/lsi53c895a",
"-device lsi53c895a -device scsi-cd,drive=cd1 "
"-blockdev file,node-name=cd1,filename=",
test_cdboot);
}
} }
/* /*
* Unstable CI test under load * Unstable CI test under load
* See https://lists.gnu.org/archive/html/qemu-devel/2019-02/msg05509.html * See https://lists.gnu.org/archive/html/qemu-devel/2019-02/msg05509.html
@ -150,35 +172,20 @@ static void add_x86_tests(void)
qtest_add_data_func("cdrom/boot/isapc", "-M isapc " qtest_add_data_func("cdrom/boot/isapc", "-M isapc "
"-drive if=ide,media=cdrom,file=", test_cdboot); "-drive if=ide,media=cdrom,file=", test_cdboot);
} }
if (qtest_has_device("am53c974")) {
qtest_add_data_func("cdrom/boot/am53c974", if (qtest_has_machine("q35")) {
"-device am53c974 -device scsi-cd,drive=cd1 " if (qtest_has_device("megasas")) {
"-drive if=none,id=cd1,format=raw,file=", qtest_add_data_func("cdrom/boot/megasas", "-M q35 "
test_cdboot); "-device megasas -device scsi-cd,drive=cd1 "
} "-blockdev file,node-name=cd1,filename=",
if (qtest_has_device("dc390")) { test_cdboot);
qtest_add_data_func("cdrom/boot/dc390", }
"-device dc390 -device scsi-cd,drive=cd1 " if (qtest_has_device("megasas-gen2")) {
"-blockdev file,node-name=cd1,filename=", qtest_add_data_func("cdrom/boot/megasas-gen2", "-M q35 "
test_cdboot); "-device megasas-gen2 -device scsi-cd,drive=cd1 "
} "-blockdev file,node-name=cd1,filename=",
if (qtest_has_device("lsi53c895a")) { test_cdboot);
qtest_add_data_func("cdrom/boot/lsi53c895a", }
"-device lsi53c895a -device scsi-cd,drive=cd1 "
"-blockdev file,node-name=cd1,filename=",
test_cdboot);
}
if (qtest_has_device("megasas")) {
qtest_add_data_func("cdrom/boot/megasas", "-M q35 "
"-device megasas -device scsi-cd,drive=cd1 "
"-blockdev file,node-name=cd1,filename=",
test_cdboot);
}
if (qtest_has_device("megasas-gen2")) {
qtest_add_data_func("cdrom/boot/megasas-gen2", "-M q35 "
"-device megasas-gen2 -device scsi-cd,drive=cd1 "
"-blockdev file,node-name=cd1,filename=",
test_cdboot);
} }
} }