diff mbox series

[RFC,1/2] Acceptance Tests: add QemuImgTest base class

Message ID 20181109221213.7310-2-crosa@redhat.com (mailing list archive)
State New, archived
Headers show
Series Acceptance tests for qemu-img | expand

Commit Message

Cleber Rosa Nov. 9, 2018, 10:12 p.m. UTC
Testing other utilities such as qemu-img do not require the same
infrastructure that testing QEMU itself does.  Let's add a base class
that just sets the suitable qemu-img binary to be used during test.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
---
 tests/acceptance/avocado_qemu/__init__.py | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
diff mbox series

Patch

diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/avocado_qemu/__init__.py
index 1e54fd5932..dfd147b7e2 100644
--- a/tests/acceptance/avocado_qemu/__init__.py
+++ b/tests/acceptance/avocado_qemu/__init__.py
@@ -40,6 +40,20 @@  def pick_default_qemu_bin():
         return qemu_bin_from_src_dir_path
 
 
+def pick_default_qemu_img_bin():
+    """
+    Picks the path of a QEMU binary, starting either in the current working
+    directory or in the source tree root directory.
+    """
+    qemu_img_bin_local = os.path.abspath("qemu-img")
+    if is_readable_executable_file(qemu_img_bin_local):
+        return qemu_img_bin_local
+
+    qemu_img_bin_from_src_dir_path = os.path.join(SRC_ROOT_DIR, "qemu-img")
+    if is_readable_executable_file(qemu_img_bin_from_src_dir_path):
+        return qemu_img_bin_from_src_dir_path
+
+
 class Test(avocado.Test):
     def setUp(self):
         self.vm = None
@@ -52,3 +66,9 @@  class Test(avocado.Test):
     def tearDown(self):
         if self.vm is not None:
             self.vm.shutdown()
+
+
+class QemuImgTest(avocado.Test):
+    def setUp(self):
+        self.qemu_img_bin = self.params.get('qemu_img_bin',
+                                            default=pick_default_qemu_img_bin())