From d5674412ba32b6fb0fc6dfd6d1fcddadf75cbfaa Mon Sep 17 00:00:00 2001 From: Thomas Huth Date: Fri, 30 Aug 2024 15:38:24 +0200 Subject: tests/functional: Convert the rx_gdbsim avocado test into a standalone test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Provide a "gzip_uncompress" function based on the standard "gzip" module to avoid the usage of avocado.utils here. Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé Message-ID: <20240830133841.142644-31-thuth@redhat.com> Signed-off-by: Thomas Huth --- tests/functional/qemu_test/utils.py | 12 ++++++++++++ 1 file changed, 12 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 a12dac51b6..99eae5fc45 100644 --- a/tests/functional/qemu_test/utils.py +++ b/tests/functional/qemu_test/utils.py @@ -8,6 +8,7 @@ # 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 gzip import lzma import os import shutil @@ -23,6 +24,17 @@ def archive_extract(archive, dest_dir, member=None): else: tf.extractall(path=dest_dir) +def gzip_uncompress(gz_path, output_path): + if os.path.exists(output_path): + return + with gzip.open(gz_path, 'rb') as gz_in: + try: + with open(output_path, 'wb') as raw_out: + shutil.copyfileobj(gz_in, raw_out) + except: + os.remove(output_path) + raise + def lzma_uncompress(xz_path, output_path): if os.path.exists(output_path): return -- cgit v1.2.3