summary refs log tree commit diff stats
path: root/tests/functional/qemu_test/archive.py
diff options
context:
space:
mode:
authorDaniel P. Berrangé <berrange@redhat.com>2024-12-17 15:59:40 +0000
committerThomas Huth <thuth@redhat.com>2024-12-17 19:39:53 +0100
commit512fe088b12885ddf035124cb5ff8315cfe0de06 (patch)
tree8cd096ac00518a141b7b1aad7c69fa34e3152018 /tests/functional/qemu_test/archive.py
parent379ee839f9ae374302c4b9f444c9f804ec7a2796 (diff)
downloadfocaccia-qemu-512fe088b12885ddf035124cb5ff8315cfe0de06.tar.gz
focaccia-qemu-512fe088b12885ddf035124cb5ff8315cfe0de06.zip
tests/functional: add common deb_extract helper
This mirrors the existing archive_extract, cpio_extract and zip_extract
helpers

Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20241217155953.3950506-20-berrange@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Diffstat (limited to 'tests/functional/qemu_test/archive.py')
-rw-r--r--tests/functional/qemu_test/archive.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/functional/qemu_test/archive.py b/tests/functional/qemu_test/archive.py
index 06b66701c0..a6fc97a557 100644
--- a/tests/functional/qemu_test/archive.py
+++ b/tests/functional/qemu_test/archive.py
@@ -12,6 +12,8 @@ import subprocess
 import tarfile
 import zipfile
 
+from .cmd import run_cmd
+
 
 def tar_extract(archive, dest_dir, member=None):
     with tarfile.open(archive) as tf:
@@ -37,3 +39,14 @@ def zip_extract(archive, dest_dir, member=None):
             zf.extract(member=member, path=dest_dir)
         else:
             zf.extractall(path=dest_dir)
+
+def deb_extract(archive, dest_dir, member=None):
+    cwd = os.getcwd()
+    os.chdir(dest_dir)
+    try:
+        (stdout, stderr, ret) = run_cmd(['ar', 't', archive])
+        file_path = stdout.split()[2]
+        run_cmd(['ar', 'x', archive, file_path])
+        tar_extract(file_path, dest_dir, member)
+    finally:
+        os.chdir(cwd)