qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2] tests/functional: Convert the intel_iommu avocado test


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH v2] tests/functional: Convert the intel_iommu avocado test
Date: Tue, 10 Dec 2024 14:23:05 +0100
User-agent: Mozilla Thunderbird

On 10/12/24 13:56, Thomas Huth wrote:
Convert 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.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
  v2:
  - Download the cloud image qcow2 and use it as file system
    to exercise the virtio-block device
  - Instead of removing the "dnf install", transfer a file
    via virtio-net to the host
  - This needs find_free_port() now:
  Based-on: <20241204071911.664057-1-thuth@redhat.com>

  MAINTAINERS                          |   1 +
  tests/avocado/intel_iommu.py         | 122 -------------------
  tests/functional/meson.build         |   2 +
  tests/functional/test_intel_iommu.py | 176 +++++++++++++++++++++++++++
  4 files changed, 179 insertions(+), 122 deletions(-)
  delete mode 100644 tests/avocado/intel_iommu.py
  create mode 100755 tests/functional/test_intel_iommu.py


+        # Check virtio-net via HTTP:
+        exec_command_and_wait_for_pattern(self, 'dhclient eth0', prompt)
+        exec_command_and_wait_for_pattern(self,
+                                    'python3 -m http.server 8080 & sleep 1',
+                                    'Serving HTTP on 0.0.0.0 port 8080')
+        hl = hashlib.sha256()
+        url = f'http://localhost:{freeport}{filename}'
+        self.log.info(f'Downloading {url} ...')
+        with urllib.request.urlopen(url) as response:
+            while True:
+                chunk = response.read(1 << 20)
+                if not chunk:
+                    break
+                hl.update(chunk)
+
+        digest = hl.hexdigest()
+        self.log.info(f'sha256sum of download is {digest}.')
+        self.assertEqual(digest, hashsum)

Nice :)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]