diff options
author | Cleber Rosa <crosa@redhat.com> | 2021-02-03 12:23:51 -0500 |
---|---|---|
committer | Cleber Rosa <crosa@redhat.com> | 2021-02-15 22:23:40 -0500 |
commit | efe30d5011b7a667e3edac22ffd5318bc55c14b2 (patch) | |
tree | fe7b22474cfcca5fba367f867af6d47bfb778081 /tests/acceptance/avocado_qemu | |
parent | 6dd7457916e17f7674e96d02b66a376b0f923fcc (diff) | |
download | qemu-efe30d5011b7a667e3edac22ffd5318bc55c14b2.zip qemu-efe30d5011b7a667e3edac22ffd5318bc55c14b2.tar.gz qemu-efe30d5011b7a667e3edac22ffd5318bc55c14b2.tar.bz2 |
Acceptance Tests: introduce method for requiring an accelerator
Some tests explicitly require a QEMU accelerator to be available.
Given that this depends on some runtime aspects not known before
the test is started, such as the currently set QEMU binary, it's
left to be checked also at runtime.
Signed-off-by: Cleber Rosa <crosa@redhat.com>
Message-Id: <20210203172357.1422425-17-crosa@redhat.com>
Reviewed-by: Beraldo Leal <bleal@redhat.com>
Reviewed-by: Willian Rampazzo <willianr@redhat.com>
Signed-off-by: Cleber Rosa <crosa@redhat.com>
Diffstat (limited to 'tests/acceptance/avocado_qemu')
-rw-r--r-- | tests/acceptance/avocado_qemu/__init__.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/avocado_qemu/__init__.py index b06692a..687c5dc 100644 --- a/tests/acceptance/avocado_qemu/__init__.py +++ b/tests/acceptance/avocado_qemu/__init__.py @@ -39,6 +39,8 @@ else: sys.path.append(os.path.join(SOURCE_DIR, 'python')) +from qemu.accel import kvm_available +from qemu.accel import tcg_available from qemu.machine import QEMUMachine def is_readable_executable_file(path): @@ -162,6 +164,28 @@ class Test(avocado.Test): return vals.pop() return None + def require_accelerator(self, accelerator): + """ + Requires an accelerator to be available for the test to continue + + It takes into account the currently set qemu binary. + + If the check fails, the test is canceled. If the check itself + for the given accelerator is not available, the test is also + canceled. + + :param accelerator: name of the accelerator, such as "kvm" or "tcg" + :type accelerator: str + """ + checker = {'tcg': tcg_available, + 'kvm': kvm_available}.get(accelerator) + if checker is None: + self.cancel("Don't know how to check for the presence " + "of accelerator %s" % accelerator) + if not checker(qemu_bin=self.qemu_bin): + self.cancel("%s accelerator does not seem to be " + "available" % accelerator) + def setUp(self): self._vms = {} |