Message ID | 20241211172648.2893097-12-berrange@redhat.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | tests/functional: various improvements wrt assets/scratch files | expand |
On 11/12/2024 18.26, Daniel P. Berrangé wrote: > This removes direct access of the 'BUILD_DIR' variable. > > Reviewed-by: Thomas Huth <thuth@redhat.com> > Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> > --- ... > diff --git a/tests/functional/test_virtio_gpu.py b/tests/functional/test_virtio_gpu.py > index 7654421e6b..630569bff8 100755 > --- a/tests/functional/test_virtio_gpu.py > +++ b/tests/functional/test_virtio_gpu.py > @@ -6,7 +6,6 @@ > # later. See the COPYING file in the top-level directory. > > > -from qemu_test import BUILD_DIR > from qemu_test import QemuSystemTest, Asset > from qemu_test import wait_for_console_pattern > from qemu_test import exec_command_and_wait_for_pattern > @@ -18,12 +17,8 @@ > import subprocess > > > -def pick_default_vug_bin(): > - relative_path = "./contrib/vhost-user-gpu/vhost-user-gpu" > - if is_readable_executable_file(relative_path): > - return relative_path > - > - bld_dir_path = os.path.join(BUILD_DIR, relative_path) > +def pick_default_vug_bin(test): > + bld_dir_path = test.build_file(relative_path) > if is_readable_executable_file(bld_dir_path): > return bld_dir_path FYI, while testing, I noticed that this is failing now: Traceback (most recent call last): File ".../tests/functional/test_virtio_gpu.py", line 84, in test_vhost_user_vga_virgl vug = pick_default_vug_bin(self) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File ".../tests/functional/test_virtio_gpu.py", line 21, in pick_default_vug_bin bld_dir_path = test.build_file(relative_path) ^^^^^^^^^^^^^ NameError: name 'relative_path' is not defined Thomas
On Thu, Dec 12, 2024 at 10:42:49AM +0100, Thomas Huth wrote: > On 11/12/2024 18.26, Daniel P. Berrangé wrote: > > This removes direct access of the 'BUILD_DIR' variable. > > > > Reviewed-by: Thomas Huth <thuth@redhat.com> > > Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> > > --- > ... > > diff --git a/tests/functional/test_virtio_gpu.py b/tests/functional/test_virtio_gpu.py > > index 7654421e6b..630569bff8 100755 > > --- a/tests/functional/test_virtio_gpu.py > > +++ b/tests/functional/test_virtio_gpu.py > > @@ -6,7 +6,6 @@ > > # later. See the COPYING file in the top-level directory. > > -from qemu_test import BUILD_DIR > > from qemu_test import QemuSystemTest, Asset > > from qemu_test import wait_for_console_pattern > > from qemu_test import exec_command_and_wait_for_pattern > > @@ -18,12 +17,8 @@ > > import subprocess > > -def pick_default_vug_bin(): > > - relative_path = "./contrib/vhost-user-gpu/vhost-user-gpu" > > - if is_readable_executable_file(relative_path): > > - return relative_path > > - > > - bld_dir_path = os.path.join(BUILD_DIR, relative_path) > > +def pick_default_vug_bin(test): > > + bld_dir_path = test.build_file(relative_path) > > if is_readable_executable_file(bld_dir_path): > > return bld_dir_path > > FYI, while testing, I noticed that this is failing now: > > Traceback (most recent call last): > File ".../tests/functional/test_virtio_gpu.py", line 84, in test_vhost_user_vga_virgl > vug = pick_default_vug_bin(self) > ^^^^^^^^^^^^^^^^^^^^^^^^^^ > File ".../tests/functional/test_virtio_gpu.py", line 21, in pick_default_vug_bin > bld_dir_path = test.build_file(relative_path) > ^^^^^^^^^^^^^ > NameError: name 'relative_path' is not defined I'll add the following - bld_dir_path = test.build_file(relative_path) + bld_dir_path = test.build_file("contrib", "vhost-user-gpu", "vhost-user-gpu") With regards, Daniel
diff --git a/tests/functional/qemu_test/cmd.py b/tests/functional/qemu_test/cmd.py index bebcd46dcf..c8971de00a 100644 --- a/tests/functional/qemu_test/cmd.py +++ b/tests/functional/qemu_test/cmd.py @@ -16,7 +16,6 @@ import os.path import subprocess -from .config import BUILD_DIR def which(tool): """ looks up the full path for @tool, returns None if not found @@ -205,10 +204,10 @@ def get_qemu_img(test): # If qemu-img has been built, use it, otherwise the system wide one # will be used. - qemu_img = os.path.join(BUILD_DIR, 'qemu-img') + qemu_img = test.build_file('qemu-img') if os.path.exists(qemu_img): return qemu_img qemu_img = which('qemu-img') if qemu_img is not None: return qemu_img - test.skipTest(f"qemu-img not found in {BUILD_DIR} or '$PATH'") + test.skipTest(f"qemu-img not found in build dir or '$PATH'") diff --git a/tests/functional/qemu_test/testcase.py b/tests/functional/qemu_test/testcase.py index 2174fbb155..493938240c 100644 --- a/tests/functional/qemu_test/testcase.py +++ b/tests/functional/qemu_test/testcase.py @@ -133,8 +133,8 @@ def setUp(self, bin_prefix): self.arch = self.qemu_bin.split('-')[-1] self.socketdir = None - self.outputdir = os.path.join(BUILD_DIR, 'tests', 'functional', - self.arch, self.id()) + self.outputdir = self.build_file('tests', 'functional', + self.arch, self.id()) self.workdir = os.path.join(self.outputdir, 'scratch') os.makedirs(self.workdir, exist_ok=True) diff --git a/tests/functional/test_aarch64_virt.py b/tests/functional/test_aarch64_virt.py index c967da41b4..5bc461b482 100755 --- a/tests/functional/test_aarch64_virt.py +++ b/tests/functional/test_aarch64_virt.py @@ -14,7 +14,6 @@ import os import logging -from qemu_test import BUILD_DIR from qemu_test import QemuSystemTest, Asset from qemu_test import exec_command, wait_for_console_pattern from qemu_test import get_qemu_img, run_cmd @@ -54,8 +53,8 @@ def test_alpine_virt_tcg_gic_max(self): "mte=on," "gic-version=max,iommu=smmuv3") self.vm.add_args("-smp", "2", "-m", "1024") - self.vm.add_args('-bios', os.path.join(BUILD_DIR, 'pc-bios', - 'edk2-aarch64-code.fd')) + self.vm.add_args('-bios', self.build_file('pc-bios', + 'edk2-aarch64-code.fd')) self.vm.add_args("-drive", f"file={iso_path},media=cdrom,format=raw") self.vm.add_args('-device', 'virtio-rng-pci,rng=rng0') self.vm.add_args('-object', 'rng-random,id=rng0,filename=/dev/urandom') diff --git a/tests/functional/test_virtio_gpu.py b/tests/functional/test_virtio_gpu.py index 7654421e6b..630569bff8 100755 --- a/tests/functional/test_virtio_gpu.py +++ b/tests/functional/test_virtio_gpu.py @@ -6,7 +6,6 @@ # later. See the COPYING file in the top-level directory. -from qemu_test import BUILD_DIR from qemu_test import QemuSystemTest, Asset from qemu_test import wait_for_console_pattern from qemu_test import exec_command_and_wait_for_pattern @@ -18,12 +17,8 @@ import subprocess -def pick_default_vug_bin(): - relative_path = "./contrib/vhost-user-gpu/vhost-user-gpu" - if is_readable_executable_file(relative_path): - return relative_path - - bld_dir_path = os.path.join(BUILD_DIR, relative_path) +def pick_default_vug_bin(test): + bld_dir_path = test.build_file(relative_path) if is_readable_executable_file(bld_dir_path): return bld_dir_path @@ -86,7 +81,7 @@ def test_vhost_user_vga_virgl(self): # FIXME: should check presence of vhost-user-gpu, virgl, memfd etc self.require_accelerator('kvm') - vug = pick_default_vug_bin() + vug = pick_default_vug_bin(self) if not vug: self.skipTest("Could not find vhost-user-gpu")