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>
This commit is contained in:
Thomas Huth 2024-08-30 15:38:14 +02:00
parent e3fc99b164
commit e2e9fd256e
5 changed files with 94 additions and 95 deletions

View file

@ -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