[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 20/31] tests/functional: let cpio_extract accept filenames
From: |
Daniel P . Berrangé |
Subject: |
[PATCH v2 20/31] tests/functional: let cpio_extract accept filenames |
Date: |
Wed, 11 Dec 2024 17:26:36 +0000 |
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.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
tests/functional/qemu_test/archive.py | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/tests/functional/qemu_test/archive.py
b/tests/functional/qemu_test/archive.py
index a6fc97a557..bc448dee4a 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):
--
2.46.0
- Re: [PATCH v2 13/31] tests/functional: switch over to using self.scratch_file(), (continued)
- [PATCH v2 15/31] tests/functional: remove redundant 'rmtree' call, Daniel P . Berrangé, 2024/12/11
- [PATCH v2 16/31] tests/functional: move archive handling into new archive.py file, Daniel P . Berrangé, 2024/12/11
- [PATCH v2 17/31] tests/functional: move uncompress handling into new uncompress.py file, Daniel P . Berrangé, 2024/12/11
- [PATCH v2 18/31] tests/functional: add common zip_extract helper, Daniel P . Berrangé, 2024/12/11
- [PATCH v2 19/31] tests/functional: add common deb_extract helper, Daniel P . Berrangé, 2024/12/11
- [PATCH v2 20/31] tests/functional: let cpio_extract accept filenames,
Daniel P . Berrangé <=
- [PATCH v2 22/31] tests/functional: add 'archive_extract' to QemuBaseTest, Daniel P . Berrangé, 2024/12/11
- [PATCH v2 21/31] tests/functional: add a generalized archive_extract, Daniel P . Berrangé, 2024/12/11
- [PATCH v2 24/31] tests/functional: add a generalized uncompress helper, Daniel P . Berrangé, 2024/12/11
- [PATCH v2 25/31] tests/functional: add 'uncompress' to QemuBaseTest, Daniel P . Berrangé, 2024/12/11
- [PATCH v2 23/31] tests/functional: convert tests to new archive_extract helper, Daniel P . Berrangé, 2024/12/11