[elbe-devel] [PATCH 10/11] elbepack: test_xml: prepare for more flexible initvm selection

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


Prepare the argument parsing for new initvm types.

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

diff --git a/conftest.py b/conftest.py
index 33d1c49b3c4b..5e0b28a88e2e 100644
--- a/conftest.py
+++ b/conftest.py
@@ -13,8 +13,9 @@ def pytest_addoption(parser):
         '--runslow', action='store_true', default=False, help='run slow tests'
     )
     parser.addoption(
-        '--elbe-use-existing-initvm', action='store_true', default=False,
-        help='reuse existing elbe initvm',
+        '--elbe-use-initvm', action='store', default='libvirt',
+        choices=('libvirt', 'existing'),
+        help='use specific initvm',
     )
 
 
diff --git a/elbepack/tests/test_xml.py b/elbepack/tests/test_xml.py
index dcf1dfba321f..5abeb8516559 100644
--- a/elbepack/tests/test_xml.py
+++ b/elbepack/tests/test_xml.py
@@ -20,6 +20,7 @@ here = pathlib.Path(__file__).parent
 @pytest.fixture(scope='module')
 def initvm(tmp_path_factory, request):
     initvm_dir = tmp_path_factory.mktemp('initvm-') / 'initvm'
+    use_initvm = request.config.getoption('--elbe-use-initvm')
 
     def initvm_func(subcmd, *args):
         run_elbe_subcommand(['initvm', subcmd, '--directory', initvm_dir, *args])
@@ -30,7 +31,7 @@ def initvm(tmp_path_factory, request):
         with contextlib.suppress(Exception):
             initvm_func('destroy')
 
-    if request.config.getoption('--elbe-use-existing-initvm'):
+    if use_initvm == 'existing':
         yield initvm_func
         return
 

-- 
2.46.0



More information about the elbe-devel mailing list