diff options
author | Daniel P. Berrangé <berrange@redhat.com> | 2024-12-17 15:59:41 +0000 |
---|---|---|
committer | Thomas Huth <thuth@redhat.com> | 2024-12-17 19:39:53 +0100 |
commit | c055f1d26fbcc18de02e59569f3e2a224595835a (patch) | |
tree | 9e616ff45e5524b24f790a19283b593803fb26ec | |
parent | 512fe088b12885ddf035124cb5ff8315cfe0de06 (diff) | |
download | qemu-c055f1d26fbcc18de02e59569f3e2a224595835a.zip qemu-c055f1d26fbcc18de02e59569f3e2a224595835a.tar.gz qemu-c055f1d26fbcc18de02e59569f3e2a224595835a.tar.bz2 |
tests/functional: let cpio_extract accept filenames
Currently cpio_extract differs from tar_extract/zip_extract
in that it only allows a file-like object as input. Adapt it
to also support filenames.
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20241217155953.3950506-21-berrange@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
-rw-r--r-- | tests/functional/qemu_test/archive.py | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/tests/functional/qemu_test/archive.py b/tests/functional/qemu_test/archive.py index a6fc97a..bc448de 100644 --- a/tests/functional/qemu_test/archive.py +++ b/tests/functional/qemu_test/archive.py @@ -8,7 +8,7 @@ # Thomas Huth <thuth@redhat.com> import os -import subprocess +from subprocess import check_call, run, DEVNULL import tarfile import zipfile @@ -25,12 +25,18 @@ def tar_extract(archive, dest_dir, member=None): else: tf.extractall(path=dest_dir) -def cpio_extract(cpio_handle, output_path): +def cpio_extract(archive, output_path): cwd = os.getcwd() os.chdir(output_path) - subprocess.run(['cpio', '-i'], - input=cpio_handle.read(), - stderr=subprocess.DEVNULL) + # Not passing 'check=True' as cpio exits with non-zero + # status if the archive contains any device nodes :-( + if type(archive) == str: + run(['cpio', '-i', '-F', archive], + stdout=DEVNULL, stderr=DEVNULL) + else: + run(['cpio', '-i'], + input=archive.read(), + stdout=DEVNULL, stderr=DEVNULL) os.chdir(cwd) def zip_extract(archive, dest_dir, member=None): |