]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
tests/avocado: Do not run tests that require libslirp if it is not available
authorThomas Huth <thuth@redhat.com>
Wed, 24 Aug 2022 15:11:21 +0000 (17:11 +0200)
committerThomas Huth <thuth@redhat.com>
Mon, 29 Aug 2022 13:28:51 +0000 (15:28 +0200)
Some avocado tests blindly assume that QEMU has been compiled with libslirp
enabled and fail badly if it is missing. Add a proper check to cancel the
tests in this case.

Message-Id: <20220824151122.704946-6-thuth@redhat.com>
Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Signed-off-by: Thomas Huth <thuth@redhat.com>
tests/avocado/avocado_qemu/__init__.py
tests/avocado/info_usernet.py
tests/avocado/replay_linux.py

index 9d17a287cf6eb9ab50388fab6f9cdbedeaa3fbdf..3b5b8e7f2d0f0559575fda813b80ea8b45fb0056 100644 (file)
@@ -299,6 +299,12 @@ class QemuSystemTest(QemuBaseTest):
             self.cancel("%s accelerator does not seem to be "
                         "available" % accelerator)
 
+    def require_netdev(self, netdevname):
+        netdevhelp = run_cmd([self.qemu_bin,
+                             '-M', 'none', '-netdev', 'help'])[0];
+        if netdevhelp.find('\n' + netdevname + '\n') < 0:
+            self.cancel('no support for user networking')
+
     def _new_vm(self, name, *args):
         self._sd = tempfile.TemporaryDirectory(prefix="avo_qemu_sock_")
         vm = QEMUMachine(self.qemu_bin, base_temp_dir=self.workdir,
@@ -550,6 +556,7 @@ class LinuxTest(LinuxSSHMixIn, QemuSystemTest):
 
     def setUp(self, ssh_pubkey=None, network_device_type='virtio-net'):
         super().setUp()
+        self.require_netdev('user')
         self._set_distro()
         self.vm.add_args('-smp', self.smp)
         self.vm.add_args('-m', self.memory)
index dc01f74150cb69b67d18d80d21631a11a87c97f2..b862a47dba08f42881d866ac913028c2a60a2c4a 100644 (file)
@@ -16,6 +16,7 @@ from qemu.utils import get_info_usernet_hostfwd_port
 class InfoUsernet(QemuSystemTest):
 
     def test_hostfwd(self):
+        self.require_netdev('user')
         self.vm.add_args('-netdev', 'user,id=vnet,hostfwd=:127.0.0.1:0-:22')
         self.vm.launch()
         res = self.vm.command('human-monitor-command',
index e1f9981a3430aa1602d6866f7b64abf79350ca20..a76dd507fc1c808c5953afbca12140e6ae4c93a7 100644 (file)
@@ -55,6 +55,7 @@ class ReplayLinux(LinuxTest):
             '%s,drive=disk%s-rr%s' % (device, id, bus_string))
 
     def launch_and_wait(self, record, args, shift):
+        self.require_netdev('user')
         vm = self.get_vm()
         vm.add_args('-smp', '1')
         vm.add_args('-m', '1024')