From patchwork Wed Jan 8 12:10:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 855705 Delivered-To: patch@linaro.org Received: by 2002:adf:8b05:0:b0:385:e875:8a9e with SMTP id n5csp690235wra; Wed, 8 Jan 2025 04:27:01 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCV5jALLRdCl/d2lacQQm7FM+PFZNeHcW3SRUukaY0gDZ/b0953fOGVObpgj4EUc0qS4PVNUdg==@linaro.org X-Google-Smtp-Source: AGHT+IE6HeJNQRSpVkcHtnibnR55Y+LnTHdZP72XqeRAefhIC+b3PtMz5gDQyuUuktRTzq71prw3 X-Received: by 2002:a05:622a:608f:b0:46c:72bf:622a with SMTP id d75a77b69052e-46c72bf6399mr30830471cf.36.1736339220976; Wed, 08 Jan 2025 04:27:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1736339220; cv=none; d=google.com; s=arc-20240605; b=CvpGdJt+HuLqdmY5HVkqF9YSCbbIps0sVJYgjC4AiQds0Lo6b78aYxBiNhjPAZONs8 cgiVLCuQ3e4tTBl+3MtvK3s37ye5pyWEuraBtDoePDgBzDeSYSd4RHsoz5uikXjwVqNt bfXFhKyPYcLAVd/AxF4DCeJ67LnO65YObzwSTHjwIcRoVqP5c+FAf6piWEEYyveoY7CU IDASt/Vl44nfpdWRiNrm5fRBdEzjXzgSeELsj+ZwY3OikeBG2sjb8dZGQXWE2B22cV85 h49/xZSwHn7oos64WXpiIWUueEraL4XhsSC/nEzSvemhdlJkGTvzYuacMeM3iufg4/Js ItSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=EjWlxLDtIKZu+r0Qe9WGwm1PQIRFhNqusOHCdU7ZfOU=; fh=l95L5Maua5HG0vXtrda7YXM3hY8pWBBFNczXRFh+wJU=; b=Gn8Ip1xnBnW5lbQ167RiwPozY9YX9Cx5RKeykw757wSZ8qkoazZ9/Awt/gGJBlEYxh t+U7UjWOjBkqbMPW9XLwKtCQ26ieh0tHLJHfWYHMdLh2BX8f7rOGHjK8WMkGu4vuRKkE xBBHKbfzqNaApeRie5cp/L55sEBiA1RBjfY0wolOQxgEmbBIkBQu9SnceGvpOx0Wns4U uaVb3lT81L3EtqCSGzPBNQa3JhaMCG6ilcSpaTTzvbxvNH1opMqZu96C2ak6/GfdK6po YZ7NeNxDMBvIvghx7QsZDjKaJ5WeGHmt9uBuOsoUqwo6mT2ThRReOrOtuM3skhsfA7Qh B7Jw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=poEYslHW; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-46a3ebfeaf9si468413301cf.630.2025.01.08.04.27.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 08 Jan 2025 04:27:00 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=poEYslHW; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tVV75-0004xm-M5; Wed, 08 Jan 2025 07:24:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tVV0y-00021n-0x for qemu-devel@nongnu.org; Wed, 08 Jan 2025 07:18:25 -0500 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tVV0k-0002UL-70 for qemu-devel@nongnu.org; Wed, 08 Jan 2025 07:18:22 -0500 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-436637e8c8dso168765625e9.1 for ; Wed, 08 Jan 2025 04:18:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736338688; x=1736943488; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=EjWlxLDtIKZu+r0Qe9WGwm1PQIRFhNqusOHCdU7ZfOU=; b=poEYslHWA0SSTUngEFXTmEX+xoVS1FLIHIa/r5peunxq9vYFCLoJbRESghKN0xV1Ge OVSmSnfDHLVDjCqFNWsS2kqwOPzeBfPHUNzhad9oVhS90TKAPxZQ2ySyjt5KCjyyKBEB WD+iip/Awuk4FXY1pBapMNmEiabUZjnfN/K+fTFl65zYSx9CcFusEd9U7boFxdyGU3C6 ty+x955rivoSPdQB2K/7ZYLUX3QF12IRmt5ioCTe8kj2sn4Qzu4K3Vuu5C9nlFVRCTfm C2v+IlZbQeUTB6rDgqCu/bSayefgAhAFNwof7H235JKjQqP0FjnrWYaHLPPdO10d4hdO P+3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736338688; x=1736943488; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EjWlxLDtIKZu+r0Qe9WGwm1PQIRFhNqusOHCdU7ZfOU=; b=G9FCkmN6dVgjM+WXnorWgDf3OuNSX9pVxKrek3BbE/643s+vFuAm2R09+9xbZ6Pze1 jv/kTQ4DxywqJukZSv0h01Z2yExSZJql+faUaa8DkK3E3BnS/QPF8rJlRf0/3foNn3of gTEj6BsGV3Uz4F4VsZ4QFbEdpFCxWHYfsAkLP7c+TXNxq7Vf1dtc4H0xpdR0j+n5cvPk LJPL8VbszpzKTDl6GP6hXFurtgBAdrVHhj7j4AzmRGSi8Cp9k0sTKofPDoDkoELTroUa dd1ENpLp0idtcmdCRMkWpu2ef7rc8MW5hzp+6cXl1oYMmMzcUxhXmPdY29udp/8OmGdm qI/A== X-Gm-Message-State: AOJu0Yygv//PzkZ2oYq0nh7ArD0IEN/K2PfRFGdGeZ3CRTDoHyizUSmd XOhWgOd/qvVvKQpDJePSv5tWAv4N4QA6+scCuH/geBHu+SmRr/b2ivQ0oGAzcVw= X-Gm-Gg: ASbGnctV8Qz5/gMnLVZ4z+7YpsOWBVhvqhEVCrIEsM3k5kHK72zLn075mpb2sCj3L1A iNxRGxlvB5PkEX3Co4wOYsBU0j1RW244/LxT2ovBnZTfbJo07gbVs0rYRIuKH8j2bzhBhM3mW82 +5RFtdd9ALj/J2pPcWdfcFE2xM6vcqPE8NaIxNYjJN4GWc2SjG6uc2rczXWTeZwx/ctZNzvsESN AXQ4U0A+rg4NE6c/GIyee12ZUjZkAX+j7bwKOte4HxzhkpfwVdAdj0= X-Received: by 2002:a05:600c:348a:b0:436:488f:4d8 with SMTP id 5b1f17b1804b1-436e2699f29mr19182615e9.11.1736338688652; Wed, 08 Jan 2025 04:18:08 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a75a47943sm6642217f8f.87.2025.01.08.04.18.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jan 2025 04:18:05 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 6FD665FBAC; Wed, 8 Jan 2025 12:10:56 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Halil Pasic , Aurelien Jarno , qemu-riscv@nongnu.org, Radoslaw Biernacki , Daniel Henrique Barboza , =?utf-8?q?Alex_Benn=C3=A9e?= , Marcel Apfelbaum , Richard Henderson , Beraldo Leal , Fabiano Rosas , Mark Cave-Ayland , Laurent Vivier , Nicholas Piggin , Marcin Juszkiewicz , Christian Borntraeger , Wainer dos Santos Moschetta , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Ed Maste , Jiaxun Yang , Bernhard Beschow , Bin Meng , qemu-ppc@nongnu.org, qemu-arm@nongnu.org, Laurent Vivier , Joel Stanley , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , John Snow , "Michael S. Tsirkin" , Pavel Dovgalyuk , Alistair Francis , Liu Zhiwei , Harsh Prateek Bora , Leif Lindholm , Cleber Rosa , Thomas Huth , Paolo Bonzini , qemu-s390x@nongnu.org, Eric Farman , Weiwei Li , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Markus Armbruster , Daniel Henrique Barboza , Palmer Dabbelt , Peter Maydell , Li-Wen Hsu Subject: [PATCH v4 19/32] tests/functional: add zstd support to uncompress utility Date: Wed, 8 Jan 2025 12:10:41 +0000 Message-Id: <20250108121054.1126164-20-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250108121054.1126164-1-alex.bennee@linaro.org> References: <20250108121054.1126164-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Rather than using the python library (which has a different API anyway) lets just call the binary. zstdtools is already in out qemu.yml so all test containers should have it around. Tests should still use @skipIfMissingCommands('zstd') to gracefully handle when only minimal dependencies have been installed. Signed-off-by: Alex Bennée Reviewed-by: Daniel P. Berrangé Reviewed-by: Thomas Huth --- v4 - add chmod step to helper - also handle .zst extension --- tests/functional/qemu_test/uncompress.py | 26 ++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/functional/qemu_test/uncompress.py b/tests/functional/qemu_test/uncompress.py index 6d02ded066..911d74ec23 100644 --- a/tests/functional/qemu_test/uncompress.py +++ b/tests/functional/qemu_test/uncompress.py @@ -10,8 +10,10 @@ import gzip import lzma import os +import stat import shutil from urllib.parse import urlparse +from subprocess import check_call, CalledProcessError from .asset import Asset @@ -38,6 +40,24 @@ def lzma_uncompress(xz_path, output_path): os.remove(output_path) raise + +def zstd_uncompress(zstd_path, output_path): + if os.path.exists(output_path): + return + + try: + check_call(['zstd', "-f", "-d", zstd_path, + "-o", output_path]) + except CalledProcessError as e: + os.remove(output_path) + raise Exception( + f"Unable to decompress zstd file {zstd_path} with {e}") from e + + # zstd copies source archive permissions for the output + # file, so must make this writable for QEMU + os.chmod(output_path, stat.S_IRUSR | stat.S_IWUSR) + + ''' @params compressed: filename, Asset, or file-like object to uncompress @params uncompressed: filename to uncompress into @@ -59,6 +79,8 @@ def uncompress(compressed, uncompressed, format=None): lzma_uncompress(str(compressed), uncompressed) elif format == "gz": gzip_uncompress(str(compressed), uncompressed) + elif format == "zstd": + zstd_uncompress(str(compressed), uncompressed) else: raise Exception(f"Unknown compression format {format}") @@ -79,5 +101,9 @@ def guess_uncompress_format(compressed): return "xz" elif ext == ".gz": return "gz" + elif ext == ".zstd": + return "zstd" + elif ext == ".zst": + return "zstd" else: raise Exception(f"Unknown compression format for {compressed}")