From a7203db963d22f550665de48964b67e9fb4f8adf Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Sat, 7 Dec 2019 23:33:18 +0100 Subject: [PATCH] test/run/qemu: support compressed images Uncompress, strip the extension and pass to qemu as usual. Signed-off-by: Tom Gundersen --- test/run | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/run b/test/run index 0e544998c..4bbc76e2e 100755 --- a/test/run +++ b/test/run @@ -117,6 +117,18 @@ def qemu_boot_image(image_file): vm.kill() +@contextlib.contextmanager +def qemu_extract_boot_image(image_file): + with tempfile.TemporaryDirectory() as dir: + basename = os.path.basename(image_file) + uncompressed, _ = os.path.splitext(basename) + print(f"uncompressing {image_file} to {dir}/{uncompressed}") + subprocess.run(["cp", "-a", image_file, f"{dir}/"], check=True) + subprocess.run(["unxz", f"{dir}/{basename}"]) + with qemu_boot_image(f"{dir}/{uncompressed}"): + yield + + @contextlib.contextmanager def nspawn_boot_container(image_file): cmd = ["systemd-nspawn", "--boot", "--register=no", "-M", "boottest", "--image", image_file] @@ -259,6 +271,10 @@ def main(): with qemu_boot_image(f"{store}/refs/{output_id}/{image_fname}"): if run_ssh_test(f"{keydir}/id_rsa") == 1: failed = True + elif test_type == "qemu-extract": + with qemu_extract_boot_image(f"{store}/refs/{output_id}/{image_fname}"): + if run_ssh_test(f"{keydir}/id_rsa") == 1: + failed = True elif test_type == "nspawn": with nspawn_boot_container(f"{store}/refs/{output_id}/{image_fname}"): if run_ssh_test(f"{keydir}/id_rsa") == 1: