aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorKautuk Consul <kconsul@linux.vnet.ibm.com>2023-04-24 10:22:42 +0100
committerAlex Bennée <alex.bennee@linaro.org>2023-04-27 14:58:23 +0100
commitab8eff7c1c4d95b841b1a318e1b406b8cf759936 (patch)
treea0bc760495c66992ec5d5a767f45a92b772e612c /tests
parente354d99afc5dacb8f823cc40032af22f641cf4ea (diff)
avocado_qemu/__init__.py: factor out the qemu-img finding
Factor out the code that finds the qemu-img binary in the QemuSystemTest class and create a new get_qemu_img() function with it. This function will get called also from the new code in tuxrun_baselines.py avocado test-case. Signed-off-by: Kautuk Consul <kconsul@linux.vnet.ibm.com> Reviewed-by: Harsh Prateek Bora <harshpb@linux.ibm.com> Suggested-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-Id: <20230421042322.684093-2-kconsul@linux.vnet.ibm.com> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20230424092249.58552-12-alex.bennee@linaro.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/avocado/avocado_qemu/__init__.py27
1 files changed, 16 insertions, 11 deletions
diff --git a/tests/avocado/avocado_qemu/__init__.py b/tests/avocado/avocado_qemu/__init__.py
index 6788837e1b..33090903f1 100644
--- a/tests/avocado/avocado_qemu/__init__.py
+++ b/tests/avocado/avocado_qemu/__init__.py
@@ -330,6 +330,19 @@ class QemuSystemTest(QemuBaseTest):
vm.add_args(*args)
return vm
+ def get_qemu_img(self):
+ self.log.debug('Looking for and selecting a qemu-img binary')
+
+ # 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')
+ if not os.path.exists(qemu_img):
+ qemu_img = find_command('qemu-img', False)
+ if qemu_img is False:
+ self.cancel('Could not find "qemu-img"')
+
+ return qemu_img
+
@property
def vm(self):
return self.get_vm(name='default')
@@ -602,17 +615,9 @@ class LinuxTest(LinuxSSHMixIn, QemuSystemTest):
return (ssh_public_key, ssh_private_key)
def download_boot(self):
- self.log.debug('Looking for and selecting a qemu-img binary to be '
- 'used to create the bootable snapshot image')
- # If qemu-img has been built, use it, otherwise the system wide one
- # will be used. If none is available, the test will cancel.
- qemu_img = os.path.join(BUILD_DIR, 'qemu-img')
- if not os.path.exists(qemu_img):
- qemu_img = find_command('qemu-img', False)
- if qemu_img is False:
- self.cancel('Could not find "qemu-img", which is required to '
- 'create the bootable image')
- vmimage.QEMU_IMG = qemu_img
+ # Set the qemu-img binary.
+ # If none is available, the test will cancel.
+ vmimage.QEMU_IMG = super().get_qemu_img()
self.log.info('Downloading/preparing boot image')
# Fedora 31 only provides ppc64le images