diff options
author | Thomas Huth <thuth@redhat.com> | 2024-08-30 15:38:14 +0200 |
---|---|---|
committer | Thomas Huth <thuth@redhat.com> | 2024-09-04 11:14:33 +0200 |
commit | e2e9fd256ee8e8a3cdc4ce969d582632c34e3447 (patch) | |
tree | b73d38bdfa15fbe10a5b3c4c412e88c42e5a53d1 /tests/functional/qemu_test/utils.py | |
parent | e3fc99b1644c4b11189ff71ad5e7e8434dd41d58 (diff) |
tests/functional: Convert the s390x avocado tests into standalone tests
These tests use archive.lzma_uncompress() from the Avocado utils,
so provide a small helper function for this, based on the
standard lzma module from Python instead.
And while we're at it, replace the MD5 hashes in the topology test
with proper SHA256 hashes, since MD5 should not be used anymore
nowadays.
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20240830133841.142644-21-thuth@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Diffstat (limited to 'tests/functional/qemu_test/utils.py')
-rw-r--r-- | tests/functional/qemu_test/utils.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/functional/qemu_test/utils.py b/tests/functional/qemu_test/utils.py index 4eb5e5d5e5..a12dac51b6 100644 --- a/tests/functional/qemu_test/utils.py +++ b/tests/functional/qemu_test/utils.py @@ -8,6 +8,9 @@ # 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 lzma +import os +import shutil import tarfile def archive_extract(archive, dest_dir, member=None): @@ -19,3 +22,14 @@ def archive_extract(archive, dest_dir, member=None): tf.extract(member=member, path=dest_dir) else: tf.extractall(path=dest_dir) + +def lzma_uncompress(xz_path, output_path): + if os.path.exists(output_path): + return + with lzma.open(xz_path, 'rb') as lzma_in: + try: + with open(output_path, 'wb') as raw_out: + shutil.copyfileobj(lzma_in, raw_out) + except: + os.remove(output_path) + raise |