[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v5 18/44] tests/functional: Add a function for extracting files f
|
From: |
Thomas Huth |
|
Subject: |
[PATCH v5 18/44] tests/functional: Add a function for extracting files from an archive |
|
Date: |
Fri, 30 Aug 2024 15:38:12 +0200 |
Some Avocado-based tests use the "archive" module from avocado.utils
to extract files from an archive. To be able to use these tests
without Avocado, we have to provide our own function for extracting
files. Fortunately, there is already the tarfile module that will
provide us with this functionality, so let's just add a nice wrapper
function around that.
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Tested-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
tests/functional/qemu_test/utils.py | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
create mode 100644 tests/functional/qemu_test/utils.py
diff --git a/tests/functional/qemu_test/utils.py
b/tests/functional/qemu_test/utils.py
new file mode 100644
index 0000000000..4eb5e5d5e5
--- /dev/null
+++ b/tests/functional/qemu_test/utils.py
@@ -0,0 +1,21 @@
+# Utilities for python-based QEMU tests
+#
+# Copyright 2024 Red Hat, Inc.
+#
+# Authors:
+# Thomas Huth <thuth@redhat.com>
+#
+# This work is licensed under the terms of the GNU GPL, version 2 or
+# later. See the COPYING file in the top-level directory.
+
+import tarfile
+
+def archive_extract(archive, dest_dir, member=None):
+ with tarfile.open(archive) as tf:
+ if hasattr(tarfile, 'data_filter'):
+ tf.extraction_filter = getattr(tarfile, 'data_filter',
+ (lambda member, path: member))
+ if member:
+ tf.extract(member=member, path=dest_dir)
+ else:
+ tf.extractall(path=dest_dir)
--
2.46.0
- [PATCH v5 08/44] tests/functional: Add base classes for the upcoming pytest-based tests, (continued)
- [PATCH v5 08/44] tests/functional: Add base classes for the upcoming pytest-based tests, Thomas Huth, 2024/08/30
- [PATCH v5 09/44] tests/functional: Set up logging, Thomas Huth, 2024/08/30
- [PATCH v5 10/44] tests/Makefile.include: Increase the level of indentation in the help text, Thomas Huth, 2024/08/30
- [PATCH v5 11/44] tests/functional: Prepare the meson build system for the functional tests, Thomas Huth, 2024/08/30
- [PATCH v5 12/44] tests/functional: Convert simple avocado tests into standalone python tests, Thomas Huth, 2024/08/30
- [PATCH v5 14/44] tests/functional: add a module for handling asset download & caching, Thomas Huth, 2024/08/30
- [PATCH v5 13/44] tests/functional: Convert avocado tests that just need a small adjustment, Thomas Huth, 2024/08/30
- [PATCH v5 15/44] tests/functional: enable pre-emptive caching of assets, Thomas Huth, 2024/08/30
- [PATCH v5 16/44] tests/functional: Allow asset downloading with concurrent threads, Thomas Huth, 2024/08/30
- [PATCH v5 17/44] tests/functional: Convert some tests that download files via fetch_asset(), Thomas Huth, 2024/08/30
- [PATCH v5 18/44] tests/functional: Add a function for extracting files from an archive,
Thomas Huth <=
- [PATCH v5 19/44] tests/functional: Convert some avocado tests that needed avocado.utils.archive, Thomas Huth, 2024/08/30
- [PATCH v5 21/44] tests/functional: Convert the x86_cpu_model_versions test, Thomas Huth, 2024/08/30
- [PATCH v5 22/44] tests/functional: Convert the microblaze avocado tests into standalone tests, Thomas Huth, 2024/08/30
- [PATCH v5 20/44] tests/functional: Convert the s390x avocado tests into standalone tests, Thomas Huth, 2024/08/30
- [PATCH v5 24/44] tests/functional: Convert the virtio_gpu avocado test into a standalone test, Thomas Huth, 2024/08/30
- [PATCH v5 23/44] tests/functional: Convert the riscv_opensbi avocado test into a standalone test, Thomas Huth, 2024/08/30
- [PATCH v5 25/44] tests/functional: Convert most ppc avocado tests into standalone tests, Thomas Huth, 2024/08/30
- [PATCH v5 26/44] tests/functional: Convert the ppc_amiga avocado test into a standalone test, Thomas Huth, 2024/08/30
- [PATCH v5 27/44] tests/functional: Convert the ppc_hv avocado test into a standalone test, Thomas Huth, 2024/08/30
- [PATCH v5 28/44] tests/functional: Convert the m68k nextcube test with tesseract, Thomas Huth, 2024/08/30