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.

Reviewed-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
Reviewed-by: Willian Rampazzo <willianr@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20211105143416.148332-4-f4bug@amsat.org>
This commit is contained in:
Philippe Mathieu-Daudé 2021-02-14 18:59:10 +01:00 committed by Philippe Mathieu-Daudé
parent 9112d4fd49
commit 5334df4822
1 changed files with 18 additions and 1 deletions

View File

@ -17,7 +17,7 @@ import time
import uuid import uuid
import avocado import avocado
from avocado.utils import cloudinit, datadrainer, network, ssh, vmimage from avocado.utils import cloudinit, datadrainer, network, process, ssh, vmimage
from avocado.utils.path import find_command from avocado.utils.path import find_command
#: The QEMU build root directory. It may also be the source directory #: The QEMU build root directory. It may also be the source directory
@ -295,6 +295,23 @@ class Test(QemuBaseTest):
super().tearDown() super().tearDown()
class QemuUserTest(QemuBaseTest):
"""Facilitates user-mode emulation tests."""
def setUp(self):
self._ldpath = []
super().setUp('qemu-')
def add_ldpath(self, ldpath):
self._ldpath.append(os.path.abspath(ldpath))
def run(self, bin_path, args=[]):
qemu_args = " ".join(["-L %s" % ldpath for ldpath in self._ldpath])
bin_args = " ".join(args)
return process.run("%s %s %s %s" % (self.qemu_bin, qemu_args,
bin_path, bin_args))
class LinuxSSHMixIn: class LinuxSSHMixIn:
"""Contains utility methods for interacting with a guest via SSH.""" """Contains utility methods for interacting with a guest via SSH."""