[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 20/38] tests/functional: let cpio_extract accept filenames
From: |
Thomas Huth |
Subject: |
[PULL 20/38] tests/functional: let cpio_extract accept filenames |
Date: |
Wed, 18 Dec 2024 12:09:40 +0100 |
From: Daniel P. Berrangé <berrange@redhat.com>
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>
---
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.47.1
- [PULL 10/38] tests/functional: add helpers for building file paths, (continued)
- [PULL 10/38] tests/functional: add helpers for building file paths, Thomas Huth, 2024/12/18
- [PULL 09/38] tests/functional: drop 'has_cmd' and 'has_cmds' helpers, Thomas Huth, 2024/12/18
- [PULL 11/38] tests/functional: switch over to using self.log_file(...), Thomas Huth, 2024/12/18
- [PULL 12/38] tests/functional: switch over to using self.build_file(...), Thomas Huth, 2024/12/18
- [PULL 13/38] tests/functional: switch over to using self.data_file(...), Thomas Huth, 2024/12/18
- [PULL 15/38] tests/functional: remove redundant 'rmtree' call, Thomas Huth, 2024/12/18
- [PULL 16/38] tests/functional: move archive handling into new archive.py file, Thomas Huth, 2024/12/18
- [PULL 17/38] tests/functional: move uncompress handling into new uncompress.py file, Thomas Huth, 2024/12/18
- [PULL 14/38] tests/functional: switch over to using self.scratch_file(), Thomas Huth, 2024/12/18
- [PULL 18/38] tests/functional: add common zip_extract helper, Thomas Huth, 2024/12/18
- [PULL 20/38] tests/functional: let cpio_extract accept filenames,
Thomas Huth <=
- [PULL 19/38] tests/functional: add common deb_extract helper, Thomas Huth, 2024/12/18
- [PULL 21/38] tests/functional: add a generalized archive_extract, Thomas Huth, 2024/12/18
- [PULL 22/38] tests/functional: add 'archive_extract' to QemuBaseTest, Thomas Huth, 2024/12/18
- [PULL 23/38] tests/functional: convert tests to new archive_extract helper, Thomas Huth, 2024/12/18
- [PULL 24/38] tests/functional: add a generalized uncompress helper, Thomas Huth, 2024/12/18
- [PULL 25/38] tests/functional: add 'uncompress' to QemuBaseTest, Thomas Huth, 2024/12/18
- [PULL 26/38] tests/functional: convert tests to new uncompress helper, Thomas Huth, 2024/12/18
- [PULL 28/38] tests/functional: replace 'run_cmd' with subprocess helpers, Thomas Huth, 2024/12/18
- [PULL 27/38] tests/functional: drop back compat imports from utils.py, Thomas Huth, 2024/12/18
- [PULL 29/38] tests/functional: remove now unused 'run_cmd' helper, Thomas Huth, 2024/12/18