[elbe-devel] [PATCH 11/11] elbepack: test_xml: add support for QEMU initvms

Thomas Weißschuh thomas.weissschuh at linutronix.de
Thu Aug 8 11:38:22 CEST 2024


QEMU initvms are sometimes more convenient to use,
as they don't need a fill libvirtd running.
It also makes it easier to test that codepath.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
 conftest.py                | 2 +-
 elbepack/tests/test_xml.py | 9 ++++++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/conftest.py b/conftest.py
index 5e0b28a88e2e..f6ccf30d9990 100644
--- a/conftest.py
+++ b/conftest.py
@@ -14,7 +14,7 @@ def pytest_addoption(parser):
     )
     parser.addoption(
         '--elbe-use-initvm', action='store', default='libvirt',
-        choices=('libvirt', 'existing'),
+        choices=('libvirt', 'qemu', 'existing'),
         help='use specific initvm',
     )
 
diff --git a/elbepack/tests/test_xml.py b/elbepack/tests/test_xml.py
index 5abeb8516559..203e665d73db 100644
--- a/elbepack/tests/test_xml.py
+++ b/elbepack/tests/test_xml.py
@@ -22,8 +22,15 @@ def initvm(tmp_path_factory, request):
     initvm_dir = tmp_path_factory.mktemp('initvm-') / 'initvm'
     use_initvm = request.config.getoption('--elbe-use-initvm')
 
+    if use_initvm == 'libvirt':
+        qemu_arg = []
+    elif use_initvm == 'qemu':
+        qemu_arg = ['--qemu']
+    else:
+        raise ValueError(use_initvm)
+
     def initvm_func(subcmd, *args):
-        run_elbe_subcommand(['initvm', subcmd, '--directory', initvm_dir, *args])
+        run_elbe_subcommand(['initvm', subcmd, '--directory', initvm_dir, *qemu_arg, *args])
 
     def destroy_initvm():
         with contextlib.suppress(Exception):

-- 
2.46.0



More information about the elbe-devel mailing list