From e2e9fd256ee8e8a3cdc4ce969d582632c34e3447 Mon Sep 17 00:00:00 2001 From: Thomas Huth Date: Fri, 30 Aug 2024 15:38:14 +0200 Subject: tests/functional: Convert the s390x avocado tests into standalone tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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é Message-ID: <20240830133841.142644-21-thuth@redhat.com> Signed-off-by: Thomas Huth --- tests/functional/qemu_test/utils.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests/functional/qemu_test/utils.py') 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 -- cgit v1.2.3