Skip to contentSkip to conversation

tests/functional: Fix tests failing when TCG is not available on macOS

PATCH Superseded Philippe Mathieu-Daudé 2 participants 7 messages Dec 2, 2024 – Dec 3, 2024

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover tests/functional: Fix tests failing when TCG is not available on macOS

Explicit the QTest accelerator to have these 2 tests pass on macOS when only HVF is built in.

Philippe Mathieu-Daudé (2):
tests/functional/test_version: Use QTest accelerator tests/functional/test_empty_cpu_model: Use QTest accelerator

 tests/functional/test_empty_cpu_model.py | 2 +-
 tests/functional/test_version.py         | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
2.45.2
#1 lore raw

PATCH 1/2 tests/functional/test_version: Use QTest accelerator

When testing with a HVF-only binary, we get:

3/12 qemu:func-quick+func-aarch64 / func-aarch64-version ERROR 0.29s exit status 1
stderr:
Traceback (most recent call last):
File "tests/functional/test_version.py", line 22, in test_qmp_human_info_version
self.vm.launch()
File "machine/machine.py", line 461, in launch
raise VMLaunchFailure(
qemu.machine.machine.VMLaunchFailure: ConnectError: Failed to establish session: EOFError
Exit code: 1
Command: build/qemu-system-aarch64 -display none -vga none -chardev socket,id=mon,fd=5 -mon chardev=mon,mode=control -machine none -nodefaults
Output: qemu-system-aarch64: No accelerator selected and no default accelerator available

Explicit the QTest accelerator to be able to run the HMP command.

---
 tests/functional/test_version.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/functional/test_version.py +1 -1
index 3ab3b67f7e3..477d3908d8a 100755
@@ -17,7 +17,7 @@
 class Version(QemuSystemTest):
 
     def test_qmp_human_info_version(self):
-        self.set_machine('none')
+        self.set_machine('none,accel=qtest')
         self.vm.add_args('-nodefaults')
         self.vm.launch()
         res = self.vm.cmd('human-monitor-command',
Signature · 1 line
2.45.2
#2 lore raw

PATCH 2/2 tests/functional/test_empty_cpu_model: Use QTest accelerator

In reply to Philippe Mathieu-Daudé

When testing with a HVF-only binary, we get:

3/12 qemu:func-quick+func-aarch64 / func-aarch64-empty_cpu_model ERROR 0.62s exit status 1
stderr:
Traceback (most recent call last):
File "tests/functional/test_empty_cpu_model.py", line 21, in test
self.assertRegex(self.vm.get_log(), r'-cpu option cannot be empty')
AssertionError: Regex didn't match: '-cpu option cannot be empty' not found in 'qemu-system-aarch64: No accelerator selected and no default accelerator available\n'

Explicit the QTest accelerator to be able to run the test.

---
 tests/functional/test_empty_cpu_model.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/functional/test_empty_cpu_model.py +1 -1
index 0081b06d85a..16ce1892d84 100755
@@ -13,7 +13,7 @@
 
 class EmptyCPUModel(QemuSystemTest):
     def test(self):
-        self.vm.add_args('-S', '-display', 'none', '-machine', 'none', '-cpu', '')
+        self.vm.add_args('-S', '-display', 'none', '-machine', 'none,accel=qtest', '-cpu', '')
         self.vm.set_qmp_monitor(enabled=False)
         self.vm.launch()
         self.vm.wait()
Signature · 1 line
2.45.2
#3 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 2 lines · Philippe Mathieu-Daudé

Explicit the QTest accelerator to have these 2 tests pass on macOS when only HVF is built in.

Could we maybe rather add something like this at the top of tests/functional/meson.build :

if 'CONFIG_TCG' not in config_all and 'CONFIG_KVM' not in config_all
subdir_done()
endif

?

Thomas

#4 lore raw
Quoted 9 lines · Thomas Huth
Quoted 2 lines · Philippe Mathieu-Daudé

Explicit the QTest accelerator to have these 2 tests pass on macOS when only HVF is built in.

Could we maybe rather add something like this at the top of tests/ functional/meson.build :

if 'CONFIG_TCG' not in config_all and 'CONFIG_KVM' not in config_all
  subdir_done()
endif

I'd rather not:
- these tests don't need anything of TCG/KVM/HVF
- we can run functional tests using QTest [*]

[*] I'm actually using that to test my qemu-system-any
binary which has HW models but no vCPU nor accelerator right now (except QTest).

#5 lore raw
Quoted 7 lines · Philippe Mathieu-Daudé
Quoted 6 lines · Thomas Huth
Quoted 2 lines · Philippe Mathieu-Daudé

Explicit the QTest accelerator to have these 2 tests pass on macOS when only HVF is built in.

Could we maybe rather add something like this at the top of tests/ functional/meson.build :

Quoted 7 lines
Quoted 3 lines

if 'CONFIG_TCG' not in config_all and 'CONFIG_KVM' not in config_all subdir_done()
endif

I'd rather not:
- these tests don't need anything of TCG/KVM/HVF
- we can run functional tests using QTest [*]

Ok, but then please switch to "-accel qtest" instead of "-machine ...,accel=qtest" since the latter is legacy and might go away sometime in the future.

Thanks,
Thomas

#6 lore raw
Quoted 12 lines · Thomas Huth
Quoted 11 lines · Philippe Mathieu-Daudé
Quoted 9 lines · Thomas Huth
Quoted 2 lines · Philippe Mathieu-Daudé

Explicit the QTest accelerator to have these 2 tests pass on macOS when only HVF is built in.

Could we maybe rather add something like this at the top of tests/ functional/meson.build :

if 'CONFIG_TCG' not in config_all and 'CONFIG_KVM' not in config_all subdir_done()
endif

Quoted 5 lines
Quoted 3 lines

I'd rather not:
- these tests don't need anything of TCG/KVM/HVF
- we can run functional tests using QTest [*]

Ok, but then please switch to "-accel qtest" instead of "- machine ...,accel=qtest" since the latter is legacy and might go away sometime in the future.

Doh I thought it was the opposite :/ Sure!

Quoted 4 lines

 Thanks,
  Thomas