[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 25/38] tests/functional: add 'uncompress' to QemuBaseTest
From: |
Thomas Huth |
Subject: |
[PULL 25/38] tests/functional: add 'uncompress' to QemuBaseTest |
Date: |
Wed, 18 Dec 2024 12:09:45 +0100 |
From: Daniel P. Berrangé <berrange@redhat.com>
This helper wrappers utils.uncompress, forcing the use of the scratch
directory, to ensure any uncompressed files are cleaned at test
termination.
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20241217155953.3950506-26-berrange@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
tests/functional/qemu_test/testcase.py | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/tests/functional/qemu_test/testcase.py
b/tests/functional/qemu_test/testcase.py
index 19fb1d0c07..d0bb3141d5 100644
--- a/tests/functional/qemu_test/testcase.py
+++ b/tests/functional/qemu_test/testcase.py
@@ -29,6 +29,7 @@
from .asset import Asset
from .cmd import run_cmd
from .config import BUILD_DIR
+from .uncompress import uncompress
class QemuBaseTest(unittest.TestCase):
@@ -40,6 +41,30 @@ class QemuBaseTest(unittest.TestCase):
log = None
logdir = None
+ '''
+ @params compressed: filename, Asset, or file-like object to uncompress
+ @params format: optional compression format (gzip, lzma)
+
+ Uncompresses @compressed into the scratch directory.
+
+ If @format is None, heuristics will be applied to guess the format
+ from the filename or Asset URL. @format must be non-None if @uncompressed
+ is a file-like object.
+
+ Returns the fully qualified path to the uncompressed file
+ '''
+ def uncompress(self, compressed, format=None):
+ self.log.debug(f"Uncompress {compressed} format={format}")
+ if type(compressed) == Asset:
+ compressed.fetch()
+
+ (name, ext) = os.path.splitext(str(compressed))
+ uncompressed = self.scratch_file(os.path.basename(name))
+
+ uncompress(compressed, uncompressed, format)
+
+ return uncompressed
+
'''
@params archive: filename, Asset, or file-like object to extract
@params format: optional archive format (tar, zip, deb, cpio)
--
2.47.1
- [PULL 16/38] tests/functional: move archive handling into new archive.py file, (continued)
- [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, 2024/12/18
- [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 <=
- [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
- [PULL 30/38] tests/functional: skip tests if assets are not available, Thomas Huth, 2024/12/18
- [PULL 31/38] tests/functional: ignore errors when caching assets, except for 404, Thomas Huth, 2024/12/18
- [PULL 33/38] tests/functional: Convert the quanta-gsj avocado test, Thomas Huth, 2024/12/18
- [PULL 32/38] MAINTAINERS: add myself as reviewer for functional test suite, Thomas Huth, 2024/12/18
- [PULL 35/38] tests/functional: Add a helper function for retrieving the hostfwd port, Thomas Huth, 2024/12/18
- [PULL 34/38] tests/functional: Convert the arm virt avocado test, Thomas Huth, 2024/12/18