]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
tests/vm: Introduce get_qemu_packages_from_lcitool_json() helper
authorPhilippe Mathieu-Daudé <philmd@linaro.org>
Tue, 11 Jul 2023 14:49:21 +0000 (16:49 +0200)
committerThomas Huth <thuth@redhat.com>
Tue, 18 Jul 2023 07:36:28 +0000 (09:36 +0200)
Add the get_qemu_packages_from_lcitool_json() helper which return
such package list from a lcitool env var file in JSON format.

Suggested-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-Id: <20230711144922.67491-4-philmd@linaro.org>
Signed-off-by: Thomas Huth <thuth@redhat.com>
tests/vm/basevm.py

index 23229e23d1617c69b7d007b69648af590cf27128..a97e23b0ce05c607b2d2afef92efcbb7990eff58 100644 (file)
@@ -27,6 +27,7 @@ import shutil
 import multiprocessing
 import traceback
 import shlex
+import json
 
 from qemu.machine import QEMUMachine
 from qemu.utils import get_info_usernet_hostfwd_port, kvm_available
@@ -501,6 +502,16 @@ class BaseVM(object):
                               stderr=self._stdout)
         return os.path.join(cidir, "cloud-init.iso")
 
+    def get_qemu_packages_from_lcitool_json(self, json_path=None):
+        """Parse a lcitool variables json file and return the PKGS list."""
+        if json_path is None:
+            json_path = os.path.join(
+                os.path.dirname(__file__), "generated", self.name + ".json"
+            )
+        with open(json_path, "r") as fh:
+            return json.load(fh)["pkgs"]
+
+
 def get_qemu_path(arch, build_path=None):
     """Fetch the path to the qemu binary."""
     # If QEMU environment variable set, it takes precedence