* [RFC PATCH] tests/functional: Generic method to check required devices availability
@ 2025-02-19 14:24 Philippe Mathieu-Daudé
2025-04-14 6:15 ` Thomas Huth
0 siblings, 1 reply; 2+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-02-19 14:24 UTC (permalink / raw)
To: qemu-devel
Cc: Daniel P. Berrangé, Alex Bennée,
Philippe Mathieu-Daudé, John Snow, Thomas Huth, qemu-arm,
Peter Maydell, Cleber Rosa
Not all binaries contain the same set of devices. Since some
tests depend on specific devices, we need to check their
availability in the binary.
QemuSystemTest::require_device() allows for system tests to
explicitly check for a particular device. Add a similar
check_required_devices() method which check all devices
requested on the command line. If a device is missing, the
test is skipped.
Example running test_aarch64_virt.py on macOS:
ok 1 test_aarch64_virt.Aarch64VirtMachine.test_aarch64_virt_with_gpu # SKIP no support for device virtio-gpu-gl-pci
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
Just an idea to see if we can avoid manual require_device() calls.
However not having a device in binary might also be a bug, so RFC...
---
python/qemu/machine/machine.py | 10 ++++++++++
tests/functional/qemu_test/testcase.py | 8 ++++++++
tests/functional/test_aarch64_virt.py | 2 ++
3 files changed, 20 insertions(+)
diff --git a/python/qemu/machine/machine.py b/python/qemu/machine/machine.py
index ebb58d5b68c..ff1ff066823 100644
--- a/python/qemu/machine/machine.py
+++ b/python/qemu/machine/machine.py
@@ -468,6 +468,16 @@ def launch(self) -> None:
# that exception. However, we still want to clean up.
raise
+ def get_command_arguments(self, command) -> List[str]:
+ """
+ Return a list of arguments used with one kind of command
+ """
+ args = []
+ for index, element in enumerate(self._args):
+ if element == command:
+ args += [self._args[index + 1]]
+ return args
+
def _launch(self) -> None:
"""
Launch the VM and establish a QMP connection
diff --git a/tests/functional/qemu_test/testcase.py b/tests/functional/qemu_test/testcase.py
index 869f3949fe9..7e3288f452c 100644
--- a/tests/functional/qemu_test/testcase.py
+++ b/tests/functional/qemu_test/testcase.py
@@ -335,6 +335,14 @@ def require_device(self, devicename):
if help.find(devicename) < 0:
self.skipTest('no support for device ' + devicename)
+ def check_required_devices(self):
+ """
+ Check the devices requested on the command line are available
+ in the binary. To be used before the VM launch() call.
+ """
+ for device in self.vm.get_command_arguments('-device'):
+ self.require_device(device.split(',')[0])
+
def _new_vm(self, name, *args):
vm = QEMUMachine(self.qemu_bin,
name=name,
diff --git a/tests/functional/test_aarch64_virt.py b/tests/functional/test_aarch64_virt.py
index 95f5ce8b4c0..589680a44c5 100755
--- a/tests/functional/test_aarch64_virt.py
+++ b/tests/functional/test_aarch64_virt.py
@@ -180,6 +180,8 @@ def test_aarch64_virt_with_gpu(self):
f"file.filename={image_path}")
self.vm.add_args("-snapshot")
+ self.check_required_devices()
+
try:
self.vm.launch()
except VMLaunchFailure as excp:
--
2.47.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [RFC PATCH] tests/functional: Generic method to check required devices availability
2025-02-19 14:24 [RFC PATCH] tests/functional: Generic method to check required devices availability Philippe Mathieu-Daudé
@ 2025-04-14 6:15 ` Thomas Huth
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Huth @ 2025-04-14 6:15 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Daniel P. Berrangé, Alex Bennée, John Snow, qemu-arm,
Peter Maydell, Cleber Rosa
On 19/02/2025 15.24, Philippe Mathieu-Daudé wrote:
> Not all binaries contain the same set of devices. Since some
> tests depend on specific devices, we need to check their
> availability in the binary.
>
> QemuSystemTest::require_device() allows for system tests to
> explicitly check for a particular device. Add a similar
> check_required_devices() method which check all devices
> requested on the command line. If a device is missing, the
> test is skipped.
>
> Example running test_aarch64_virt.py on macOS:
>
> ok 1 test_aarch64_virt.Aarch64VirtMachine.test_aarch64_virt_with_gpu # SKIP no support for device virtio-gpu-gl-pci
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> Just an idea to see if we can avoid manual require_device() calls.
> However not having a device in binary might also be a bug, so RFC...
I'm also a little bit torn by this question ... let's keep it explicit for
now, but if the require_device() calls get too annoying one day, we can
reconsider.
Thomas
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-04-14 6:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-19 14:24 [RFC PATCH] tests/functional: Generic method to check required devices availability Philippe Mathieu-Daudé
2025-04-14 6:15 ` Thomas Huth
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).