test/run/qemu: support compressed images

Uncompress, strip the extension and pass to qemu as usual.

Signed-off-by: Tom Gundersen <teg@jklm.no>
This commit is contained in:
Tom Gundersen 2019-12-07 23:33:18 +01:00 committed by Lars Karlitski
parent 404ad2023d
commit a7203db963

View file

@ -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: