summary refs log tree commit diff stats
path: root/tests/functional/qemu_test/testcase.py
diff options
context:
space:
mode:
authorPhilippe Mathieu-Daudé <philmd@linaro.org>2024-08-30 15:38:31 +0200
committerThomas Huth <thuth@redhat.com>2024-09-04 12:28:00 +0200
commit99465d3fe451964f1bb3c355054cd7ced05dcf88 (patch)
tree1ff1d8ba99ab41b727bd4568b0e73fc65174dfe1 /tests/functional/qemu_test/testcase.py
parentbce9e4841548b79ad264dd8acf0104c560331ea7 (diff)
downloadfocaccia-qemu-99465d3fe451964f1bb3c355054cd7ced05dcf88.tar.gz
focaccia-qemu-99465d3fe451964f1bb3c355054cd7ced05dcf88.zip
tests/functional: Add QemuUserTest class
Per commit 5334df4822 ("tests/avocado: Introduce
QemuUserTest base class"):

  Similarly to the 'System' Test base class with methods
  for testing system emulation, the QemuUserTest class
  contains methods useful to test user-mode emulation.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20240822104238.75045-2-philmd@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20240830133841.142644-38-thuth@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Diffstat (limited to 'tests/functional/qemu_test/testcase.py')
-rw-r--r--tests/functional/qemu_test/testcase.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/functional/qemu_test/testcase.py b/tests/functional/qemu_test/testcase.py
index 18314be9d1..aa0146265a 100644
--- a/tests/functional/qemu_test/testcase.py
+++ b/tests/functional/qemu_test/testcase.py
@@ -13,6 +13,7 @@
 
 import logging
 import os
+import subprocess
 import pycotap
 import sys
 import unittest
@@ -70,6 +71,22 @@ class QemuBaseTest(unittest.TestCase):
         unittest.main(module = None, testRunner = tr, argv=["__dummy__", path])
 
 
+class QemuUserTest(QemuBaseTest):
+
+    def setUp(self):
+        super().setUp('qemu-')
+        self._ldpath = []
+
+    def add_ldpath(self, ldpath):
+        self._ldpath.append(os.path.abspath(ldpath))
+
+    def run_cmd(self, bin_path, args=[]):
+        return subprocess.run([self.qemu_bin]
+                              + ["-L %s" % ldpath for ldpath in self._ldpath]
+                              + [bin_path]
+                              + args,
+                              text=True, capture_output=True)
+
 class QemuSystemTest(QemuBaseTest):
     """Facilitates system emulation tests."""