Convert the intel_iommu avocado test
v3 cover Convert the intel_iommu avocado test
The first patch introduces a helper function for retrieving the hostfwd ports from QEMU.
We then use this helper function to run a HTTP server in the guest in the second patch to exercise the network of the guest.
v3:
- Use the new hostfwd helper function instead of trying to probe for an unused port on the host
- Use a constant for the guest port 8080
Thomas Huth (2):
tests/functional: Add a helper function for retrieving the hostfwd
port
tests/functional: Convert the intel_iommu avocado test
MAINTAINERS | 1 +
tests/functional/meson.build | 2 +
tests/functional/qemu_test/utils.py | 7 +
tests/functional/test_info_usernet.py | 8 +-
.../test_intel_iommu.py} | 191 +++++++++++-------
5 files changed, 135 insertions(+), 74 deletions(-)
rename tests/{avocado/intel_iommu.py => functional/test_intel_iommu.py} (26%)
mode change 100644 => 100755Signature · 1 line
2.47.1
PATCH v3 1/2 tests/functional: Add a helper function for retrieving the hostfwd port
It's just a wrapper around get_info_usernet_hostfwd_port from the qemu module that is also calling the right monitor command for retrieving the information from QEMU.
--- tests/functional/qemu_test/utils.py | 7 +++++++ tests/functional/test_info_usernet.py | 8 +++----- 2 files changed, 10 insertions(+), 5 deletions(-)
tests/functional/qemu_test/utils.py +7 -0
@@ -10,6 +10,13 @@ import os +from qemu.utils import get_info_usernet_hostfwd_port + + +def get_usernet_hostfwd_port(vm): + res = vm.cmd('human-monitor-command', command_line='info usernet') + return get_info_usernet_hostfwd_port(res) + """ Round up to next power of 2 """
tests/functional/test_info_usernet.py +3 -5
@@ -11,8 +11,7 @@ # later. See the COPYING file in the top-level directory. from qemu_test import QemuSystemTest - -from qemu.utils import get_info_usernet_hostfwd_port +from qemu_test.utils import get_usernet_hostfwd_port class InfoUsernet(QemuSystemTest):
@@ -22,9 +21,8 @@ def test_hostfwd(self): self.set_machine('none') self.vm.add_args('-netdev', 'user,id=vnet,hostfwd=:127.0.0.1:0-:22') self.vm.launch() - res = self.vm.cmd('human-monitor-command', - command_line='info usernet') - port = get_info_usernet_hostfwd_port(res) + + port = get_usernet_hostfwd_port(self.vm) self.assertIsNotNone(port, ('"info usernet" output content does not seem to ' 'contain the redirected port'))
Signature · 1 line
2.47.1
PATCH v3 2/2 tests/functional: Convert the intel_iommu avocado test
In reply to Thomas HuthConvert the intel_iommu test to the new functional framework. This test needs some changes since we neither support the old 'LinuxTest' class in the functional framework yet, nor a way to use SSH for running commands in the guest. So we now directly download a Fedora kernel and initrd and set up the serial console for executing the commands and for looking for the results. Instead of configuring the cloud image via cloud-init, we now simply mount the file system manually from an initrd rescue shell.
While the old test was exercising the network with a "dnf install" command (which is not the best option for the CI since this depends on third party servers), the new code is now setting up a little HTTP server in the guest and transfers a file from the guest to the host instead.
The test should now run much faster and more reliable (since we don't depend on the third party servers for "dnf install" anymore), so we can also drop the @skipUnless decorator now.
---
MAINTAINERS | 1 +
tests/functional/meson.build | 2 +
.../test_intel_iommu.py} | 191 +++++++++++-------
3 files changed, 125 insertions(+), 69 deletions(-)
rename tests/{avocado/intel_iommu.py => functional/test_intel_iommu.py} (26%)
mode change 100644 => 100755MAINTAINERS +1 -0
@@ -3682,6 +3682,7 @@ S: Supported F: hw/i386/intel_iommu.c F: hw/i386/intel_iommu_internal.h F: include/hw/i386/intel_iommu.h +F: tests/functional/test_intel_iommu.py AMD-Vi Emulation S: Orphan
tests/functional/meson.build +2 -0
@@ -31,6 +31,7 @@ test_timeouts = { 'arm_raspi2' : 120, 'arm_tuxrun' : 240, 'arm_sx1' : 360, + 'intel_iommu': 300, 'mips_malta' : 120, 'netdev_ethtool' : 180, 'ppc_40p' : 240,
@@ -248,6 +249,7 @@ tests_x86_64_system_quick = [ tests_x86_64_system_thorough = [ 'acpi_bits', + 'intel_iommu', 'linux_initrd', 'multiprocess', 'netdev_ethtool',
tests/functional/test_intel_iommu.py renamed from tests/avocado/intel_iommu.py +122 -69
241 lines not on this page · raw message
Signature · 1 line
2.47.1
Quoted 4 lines · Thomas Huth
The first patch introduces a helper function for retrieving the hostfwd ports from QEMU.
We then use this helper function to run a HTTP server in the guest in the second patch to exercise the network of the guest.
Good stuff
Quoted 21 lines
v3:
- Use the new hostfwd helper function instead of trying to probe for an unused port on the host
- Use a constant for the guest port 8080Thomas Huth (2):
tests/functional: Add a helper function for retrieving the hostfwd
port
tests/functional: Convert theintel_iommuavocado testMAINTAINERS | 1 + tests/functional/meson.build | 2 + tests/functional/qemu_test/utils.py | 7 + tests/functional/test_info_usernet.py | 8 +- .../test_intel_iommu.py} | 191 +++++++++++------- 5 files changed, 135 insertions(+), 74 deletions(-) rename tests/{avocado/intel_iommu.py => functional/test_intel_iommu.py} (26%) mode change 100644 => 100755Signature · 1 line
2.47.1