From nobody Fri Nov 14 18:19:08 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1760522154; cv=none; d=zohomail.com; s=zohoarc; b=YS5d/GXcXi0w+8QLgSxkFLgabB9X0sFXfNwA2j3BZoziHjY4+dlj2OXme06xC2zTOSSknRG29gzbAyP1lCOIEwf5Chdr81+sspL3gGVQsfGVKs+XrbGd8iUR2WAPGDLYmEsFLmdFJIkuM0x2x/aR8xefuR1uR8sFNKbOowi/T0s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760522154; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=eej4eXehqD6s7xgoinmY1rL3UtSYqlfMI37LVRtGDn4=; b=bOPKkghK6iIVmKRtksuaVgkkxvXK8JZip5eZA95o/wwQyUv5OYCTRFqp2+vHa6wChGa12hDpbq+9lDm/ygc2+TplqZWXOZNO4zTIRBNYFXc8iqah/82w/8O5gkA6GFnDWE7ln51y83B3Scgq/+go++UGhzJOT0iCkACFuIGRzk8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1760522154388570.2924198627074; Wed, 15 Oct 2025 02:55:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v8yDv-0003Li-OQ; Wed, 15 Oct 2025 05:55:11 -0400 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 1v8yDt-0003LS-C2 for qemu-devel@nongnu.org; Wed, 15 Oct 2025 05:55:09 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v8yDq-0004RL-4E for qemu-devel@nongnu.org; Wed, 15 Oct 2025 05:55:09 -0400 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-128-BoyrKg7vNRKUz8L0AsZb3w-1; Wed, 15 Oct 2025 05:55:00 -0400 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6F0F01956094; Wed, 15 Oct 2025 09:54:59 +0000 (UTC) Received: from thuth-p1g4.redhat.com (unknown [10.45.224.24]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1E290180044F; Wed, 15 Oct 2025 09:54:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760522102; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eej4eXehqD6s7xgoinmY1rL3UtSYqlfMI37LVRtGDn4=; b=Ql2cOt9dOYDMiHJF8VIUfJrZYb9kHvIp8HTXRVGKKG4GDq5ReiYU2P9R7u2tnO2Zda0oGb 9X1WD9PwshJmtZ0fcFR2it/5HC4ua3bSX4o65kCChjpHyUHFh4VRKclZ4cvaD3dq7GC3AT AJ1Y3u1Thn8JdqFJQPMp8GfN7B1N+uI= X-MC-Unique: BoyrKg7vNRKUz8L0AsZb3w-1 X-Mimecast-MFC-AGG-ID: BoyrKg7vNRKUz8L0AsZb3w_1760522099 From: Thomas Huth To: qemu-devel@nongnu.org, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 1/6] tests/functional: Fix problems in asset.py reported by pylint Date: Wed, 15 Oct 2025 11:54:49 +0200 Message-ID: <20251015095454.1575318-2-thuth@redhat.com> In-Reply-To: <20251015095454.1575318-1-thuth@redhat.com> References: <20251015095454.1575318-1-thuth@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1760522156917154100 Content-Type: text/plain; charset="utf-8" From: Thomas Huth The "raise" without an Exception was a real problem, the other spots are rather cosmetics. Signed-off-by: Thomas Huth --- tests/functional/qemu_test/asset.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/tests/functional/qemu_test/asset.py b/tests/functional/qemu_te= st/asset.py index f666125bfaf..ba3771027b4 100644 --- a/tests/functional/qemu_test/asset.py +++ b/tests/functional/qemu_test/asset.py @@ -111,7 +111,7 @@ def _wait_for_other_download(self, tmp_cache_file): return False =20 self.log.debug("Time out while waiting for %s!", tmp_cache_file) - raise + raise TimeoutError(f"Time out while waiting for {tmp_cache_file}") =20 def fetch(self): if not self.cache_dir.exists(): @@ -129,7 +129,7 @@ def fetch(self): self.log.info("Downloading %s to %s...", self.url, self.cache_file) tmp_cache_file =3D self.cache_file.with_suffix(".download") =20 - for retries in range(3): + for _ in range(3): try: with tmp_cache_file.open("xb") as dst: with urllib.request.urlopen(self.url) as resp: @@ -169,7 +169,7 @@ def fetch(self): # server or networking problem if e.code =3D=3D 404: raise AssetError(self, "Unable to download: " - "HTTP error %d" % e.code) + "HTTP error %d" % e.code) from e continue except URLError as e: # This is typically a network/service level error @@ -178,7 +178,7 @@ def fetch(self): self.log.error("Unable to download %s: URL error %s", self.url, e.reason) raise AssetError(self, "Unable to download: URL error %s" % - e.reason, transient=3DTrue) + e.reason, transient=3DTrue) from e except ConnectionError as e: # A socket connection failure, such as dropped conn # or refused conn @@ -189,7 +189,7 @@ def fetch(self): except Exception as e: tmp_cache_file.unlink() raise AssetError(self, "Unable to download: %s" % e, - transient=3DTrue) + transient=3DTrue) from e =20 if not os.path.exists(tmp_cache_file): raise AssetError(self, "Download retries exceeded", transient= =3DTrue) @@ -202,7 +202,6 @@ def fetch(self): self.hash.encode('utf8')) except Exception as e: self.log.debug("Unable to set xattr on %s: %s", tmp_cache_file= , e) - pass =20 if not self._check(tmp_cache_file): tmp_cache_file.unlink() @@ -211,9 +210,10 @@ def fetch(self): # Remove write perms to stop tests accidentally modifying them os.chmod(self.cache_file, stat.S_IRUSR | stat.S_IRGRP) =20 - self.log.info("Cached %s at %s" % (self.url, self.cache_file)) + self.log.info("Cached %s at %s", self.url, self.cache_file) return str(self.cache_file) =20 + @staticmethod def precache_test(test): log =3D logging.getLogger('qemu-test') log.setLevel(logging.DEBUG) @@ -224,16 +224,17 @@ def precache_test(test): handler.setFormatter(formatter) log.addHandler(handler) for name, asset in vars(test.__class__).items(): - if name.startswith("ASSET_") and type(asset) =3D=3D Asset: + if name.startswith("ASSET_") and isinstance(asset, Asset): try: asset.fetch() except AssetError as e: if not e.transient: raise - log.error("%s: skipping asset precache" % e) + log.error("%s: skipping asset precache", e) =20 log.removeHandler(handler) =20 + @staticmethod def precache_suite(suite): for test in suite: if isinstance(test, unittest.TestSuite): @@ -241,9 +242,10 @@ def precache_suite(suite): elif isinstance(test, unittest.TestCase): Asset.precache_test(test) =20 - def precache_suites(path, cacheTstamp): + @staticmethod + def precache_suites(path, cache_tstamp): loader =3D unittest.loader.defaultTestLoader tests =3D loader.loadTestsFromNames([path], None) =20 - with open(cacheTstamp, "w") as fh: + with open(cache_tstamp, "w", encoding=3D'utf-8'): Asset.precache_suite(tests) --=20 2.51.0 From nobody Fri Nov 14 18:19:08 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1760522214; cv=none; d=zohomail.com; s=zohoarc; b=KZezRON48LibrVJYWbtGVfNe5YhYVd8BH868IkmooULBsDkXO+Jw6IM1FbfadYr/AMs/9MiKlJQrYUk3cqSYuzxHdm7V2Tn7uyHRt5R0CaQvOzjCRoUpviReRsRi08P/686HgqJUfRJ1H0RFqe4viqLUYy/RLjJdtFiJ4nYfo1k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760522214; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=g8/rP+mPrJyZKSuhPFUQQMHfdewJhJO6001zJxYgTo8=; b=fTErkli9MwbSHUxxrcyLvrrB3umLXv6mux5Dz2gLfVaHptpelUlOusVPu1cAi6JX1ZNZE2ajCFiUb51gk9O0+sJJAddywX14ZririenFMDPJ9n38MgqJta/OKnBoy1L7xQ2PLOCu945+tmxy1P5FLRdnm/qrJ8HhuYIU276P3Uk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1760522214337966.9373307875312; Wed, 15 Oct 2025 02:56:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v8yDx-0003MU-2T; Wed, 15 Oct 2025 05:55:13 -0400 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 1v8yDv-0003Lm-Ap for qemu-devel@nongnu.org; Wed, 15 Oct 2025 05:55:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v8yDq-0004cO-FH for qemu-devel@nongnu.org; Wed, 15 Oct 2025 05:55:10 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-168-k3p12uI6OPe03qV0JYjf6g-1; Wed, 15 Oct 2025 05:55:02 -0400 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5AED31956080; Wed, 15 Oct 2025 09:55:01 +0000 (UTC) Received: from thuth-p1g4.redhat.com (unknown [10.45.224.24]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E15B31800452; Wed, 15 Oct 2025 09:54:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760522103; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=g8/rP+mPrJyZKSuhPFUQQMHfdewJhJO6001zJxYgTo8=; b=ZhGxXHnkSVyhjW0em0u2gXXUV4AkAXAGf9+uY2BB40/e29WHi1yjb/s+/+4GNlaOdgs0tx dhrcdU/DbjfBJ7a3B+uXxkm1GbnOF+yyDZd9JA3q3bH0zrFUqFSkgb1CvkLZG0MDFcykEb HBVPKi4yF5U8yn5AxARHsuVlXqO2fuc= X-MC-Unique: k3p12uI6OPe03qV0JYjf6g-1 X-Mimecast-MFC-AGG-ID: k3p12uI6OPe03qV0JYjf6g_1760522101 From: Thomas Huth To: qemu-devel@nongnu.org, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 2/6] tests/functional: Fix problems in decorators.py reported by pylint Date: Wed, 15 Oct 2025 11:54:50 +0200 Message-ID: <20251015095454.1575318-3-thuth@redhat.com> In-Reply-To: <20251015095454.1575318-1-thuth@redhat.com> References: <20251015095454.1575318-1-thuth@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1760522215692154100 Content-Type: text/plain; charset="utf-8" From: Thomas Huth The documentation strings should follow the function definition lines, not precede them. Signed-off-by: Thomas Huth Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- tests/functional/qemu_test/decorators.py | 176 +++++++++++------------ 1 file changed, 87 insertions(+), 89 deletions(-) diff --git a/tests/functional/qemu_test/decorators.py b/tests/functional/qe= mu_test/decorators.py index b2392958041..807418359ab 100644 --- a/tests/functional/qemu_test/decorators.py +++ b/tests/functional/qemu_test/decorators.py @@ -10,136 +10,134 @@ =20 from .cmd import which =20 -''' -Decorator to skip execution of a test if the provided -environment variables are not set. -Example: =20 - @skipIfMissingEnv("QEMU_ENV_VAR0", "QEMU_ENV_VAR1") -''' def skipIfMissingEnv(*vars_): + ''' + Decorator to skip execution of a test if the provided + environment variables are not set. + Example: + + @skipIfMissingEnv("QEMU_ENV_VAR0", "QEMU_ENV_VAR1") + ''' missing_vars =3D [] for var in vars_: - if os.getenv(var) =3D=3D None: + if os.getenv(var) is None: missing_vars.append(var) =20 - has_vars =3D True if len(missing_vars) =3D=3D 0 else False + has_vars =3D len(missing_vars) =3D=3D 0 =20 return skipUnless(has_vars, f"Missing env var(s): {', '.join(missing_v= ars)}") =20 -''' - -Decorator to skip execution of a test if the list -of command binaries is not available in $PATH. -Example: - - @skipIfMissingCommands("mkisofs", "losetup") -''' def skipIfMissingCommands(*args): + ''' + Decorator to skip execution of a test if the list + of command binaries is not available in $PATH. + Example: + + @skipIfMissingCommands("mkisofs", "losetup") + ''' has_cmds =3D True for cmd in args: - if not which(cmd): - has_cmds =3D False - break + if not which(cmd): + has_cmds =3D False + break =20 return skipUnless(has_cmds, 'required command(s) "%s" not installed' % ", ".join(args)) =20 -''' -Decorator to skip execution of a test if the current -host operating system does match one of the prohibited -ones. -Example - - @skipIfOperatingSystem("Linux", "Darwin") -''' def skipIfOperatingSystem(*args): + ''' + Decorator to skip execution of a test if the current host + operating system does match one of the prohibited ones. + Example: + + @skipIfOperatingSystem("Linux", "Darwin") + ''' return skipIf(platform.system() in args, 'running on an OS (%s) that is not able to run this test= ' % ", ".join(args)) =20 -''' -Decorator to skip execution of a test if the current -host machine does not match one of the permitted -machines. -Example - - @skipIfNotMachine("x86_64", "aarch64") -''' def skipIfNotMachine(*args): + ''' + Decorator to skip execution of a test if the current + host machine does not match one of the permitted machines. + Example: + + @skipIfNotMachine("x86_64", "aarch64") + ''' return skipUnless(platform.machine() in args, 'not running on one of the required machine(s) "%s"'= % ", ".join(args)) =20 -''' -Decorator to skip execution of flaky tests, unless -the $QEMU_TEST_FLAKY_TESTS environment variable is set. -A bug URL must be provided that documents the observed -failure behaviour, so it can be tracked & re-evaluated -in future. +def skipFlakyTest(bug_url): + ''' + Decorator to skip execution of flaky tests, unless + the $QEMU_TEST_FLAKY_TESTS environment variable is set. + A bug URL must be provided that documents the observed + failure behaviour, so it can be tracked & re-evaluated + in future. =20 -Historical tests may be providing "None" as the bug_url -but this should not be done for new test. + Historical tests may be providing "None" as the bug_url + but this should not be done for new test. =20 -Example: + Example: =20 - @skipFlakyTest("https://gitlab.com/qemu-project/qemu/-/issues/NNN") -''' -def skipFlakyTest(bug_url): + @skipFlakyTest("https://gitlab.com/qemu-project/qemu/-/issues/NNN") + ''' if bug_url is None: bug_url =3D "FIXME: reproduce flaky test and file bug report or re= move" return skipUnless(os.getenv('QEMU_TEST_FLAKY_TESTS'), f'Test is unstable: {bug_url}') =20 -''' -Decorator to skip execution of tests which are likely -to execute untrusted commands on the host, or commands -which process untrusted code, unless the -$QEMU_TEST_ALLOW_UNTRUSTED_CODE env var is set. -Example: - - @skipUntrustedTest() -''' def skipUntrustedTest(): + ''' + Decorator to skip execution of tests which are likely + to execute untrusted commands on the host, or commands + which process untrusted code, unless the + $QEMU_TEST_ALLOW_UNTRUSTED_CODE env var is set. + Example: + + @skipUntrustedTest() + ''' return skipUnless(os.getenv('QEMU_TEST_ALLOW_UNTRUSTED_CODE'), 'Test runs untrusted code / processes untrusted data= ') =20 -''' -Decorator to skip execution of tests which need large -data storage (over around 500MB-1GB mark) on the host, -unless the $QEMU_TEST_ALLOW_LARGE_STORAGE environment -variable is set +def skipBigDataTest(): + ''' + Decorator to skip execution of tests which need large + data storage (over around 500MB-1GB mark) on the host, + unless the $QEMU_TEST_ALLOW_LARGE_STORAGE environment + variable is set =20 -Example: + Example: =20 - @skipBigDataTest() -''' -def skipBigDataTest(): + @skipBigDataTest() + ''' return skipUnless(os.getenv('QEMU_TEST_ALLOW_LARGE_STORAGE'), 'Test requires large host storage space') =20 -''' -Decorator to skip execution of tests which have a really long -runtime (and might e.g. time out if QEMU has been compiled with -debugging enabled) unless the $QEMU_TEST_ALLOW_SLOW -environment variable is set +def skipSlowTest(): + ''' + Decorator to skip execution of tests which have a really long + runtime (and might e.g. time out if QEMU has been compiled with + debugging enabled) unless the $QEMU_TEST_ALLOW_SLOW + environment variable is set =20 -Example: + Example: =20 - @skipSlowTest() -''' -def skipSlowTest(): + @skipSlowTest() + ''' return skipUnless(os.getenv('QEMU_TEST_ALLOW_SLOW'), 'Test has a very long runtime and might time out') =20 -''' -Decorator to skip execution of a test if the list -of python imports is not available. -Example: - - @skipIfMissingImports("numpy", "cv2") -''' def skipIfMissingImports(*args): + ''' + Decorator to skip execution of a test if the list + of python imports is not available. + Example: + + @skipIfMissingImports("numpy", "cv2") + ''' has_imports =3D True for impname in args: try: @@ -151,15 +149,15 @@ def skipIfMissingImports(*args): return skipUnless(has_imports, 'required import(s) "%s" not installed'= % ", ".join(args)) =20 -''' -Decorator to skip execution of a test if the system's -locked memory limit is below the required threshold. -Takes required locked memory threshold in kB. -Example: - - @skipLockedMemoryTest(2_097_152) -''' def skipLockedMemoryTest(locked_memory): + ''' + Decorator to skip execution of a test if the system's + locked memory limit is below the required threshold. + Takes required locked memory threshold in kB. + Example: + + @skipLockedMemoryTest(2_097_152) + ''' # get memlock hard limit in bytes _, ulimit_memory =3D resource.getrlimit(resource.RLIMIT_MEMLOCK) =20 --=20 2.51.0 From nobody Fri Nov 14 18:19:08 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1760522258; cv=none; d=zohomail.com; s=zohoarc; b=QGE0txq51PQRGV50NjYGqJZa68zjckJNzTbcZHckJiGCWarSItbH8HQ4YEJ3v80PSXNSIki0KOcnYOryCGGxDIkQUug7K0ZpUCmBhXSS8E8laa+1e/lnZRItfXfrAU2BZ4nZfZJs+KqMunHmHxbbMuiWsoO28cQD87Ux25xAP2M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760522258; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ZWXP/RreoC01+qLMTmO6SZkRi9iXn9sDJnGu86rk9yQ=; b=LDmk1jKjYoU5txVl+aG0r8lfFipe2OaEJXLCYTtIsxAYpdlE+CMYffquo9IW14Sk3faNFWYvsyiABXcQ0W/F/aZFCuyCmIvlA3bEJoHeX6AIaIj41fNO3/Ej6XlroN1w7uLSt8V2TgxH+2nIbSSRZWlfc+lvAPifqJjIcgyOolA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1760522258776463.2746397643384; Wed, 15 Oct 2025 02:57:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v8yDx-0003Mc-TJ; Wed, 15 Oct 2025 05:55:13 -0400 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 1v8yDw-0003M9-EV for qemu-devel@nongnu.org; Wed, 15 Oct 2025 05:55:12 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v8yDs-0004cm-NW for qemu-devel@nongnu.org; Wed, 15 Oct 2025 05:55:12 -0400 Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-501-06jXwHJDNqiqvhHll-Bcrg-1; Wed, 15 Oct 2025 05:55:04 -0400 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2A9201956095; Wed, 15 Oct 2025 09:55:03 +0000 (UTC) Received: from thuth-p1g4.redhat.com (unknown [10.45.224.24]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D24FE180044F; Wed, 15 Oct 2025 09:55:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760522105; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZWXP/RreoC01+qLMTmO6SZkRi9iXn9sDJnGu86rk9yQ=; b=WxrE5rrTkuqOuNjtQRn1MoppIMC0Dz74MsOJY5oXn2Efe5v2YHz5ZnvTGMiKE4UV7i68Uj ySixnmzVsCMc1PmDIrgQDfXyO5ZFZfsbV+jCxFnwzn8DiYHSUkyYRuH5aGblO0LWdaGjLF XnoYP+gguBcZf0wHu73rMfT9+/7oOTY= X-MC-Unique: 06jXwHJDNqiqvhHll-Bcrg-1 X-Mimecast-MFC-AGG-ID: 06jXwHJDNqiqvhHll-Bcrg_1760522103 From: Thomas Huth To: qemu-devel@nongnu.org, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 3/6] tests/functional: Fix problems in linuxkerenl.py reported by pylint Date: Wed, 15 Oct 2025 11:54:51 +0200 Message-ID: <20251015095454.1575318-4-thuth@redhat.com> In-Reply-To: <20251015095454.1575318-1-thuth@redhat.com> References: <20251015095454.1575318-1-thuth@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1760522261017158500 Content-Type: text/plain; charset="utf-8" From: Thomas Huth Use proper indentation and lazy logging here. Signed-off-by: Thomas Huth --- tests/functional/qemu_test/linuxkernel.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/functional/qemu_test/linuxkernel.py b/tests/functional/q= emu_test/linuxkernel.py index 2aca0ee3cd0..a20278966be 100644 --- a/tests/functional/qemu_test/linuxkernel.py +++ b/tests/functional/qemu_test/linuxkernel.py @@ -24,12 +24,12 @@ def launch_kernel(self, kernel, initrd=3DNone, dtb=3DNo= ne, console_index=3D0, self.vm.set_console(console_index=3Dconsole_index) self.vm.add_args('-kernel', kernel) if initrd: - self.vm.add_args('-initrd', initrd) + self.vm.add_args('-initrd', initrd) if dtb: - self.vm.add_args('-dtb', dtb) + self.vm.add_args('-dtb', dtb) self.vm.launch() if wait_for: - self.wait_for_console_pattern(wait_for) + self.wait_for_console_pattern(wait_for) =20 def check_http_download(self, filename, hashsum, guestport=3D8080, pythoncmd=3D'python3 -m http.server'): @@ -39,7 +39,7 @@ def check_http_download(self, filename, hashsum, guestpor= t=3D8080, hl =3D hashlib.sha256() hostport =3D get_usernet_hostfwd_port(self.vm) url =3D f'http://localhost:{hostport}{filename}' - self.log.info(f'Downloading {url} ...') + self.log.info('Downloading %s ...', url) with urllib.request.urlopen(url) as response: while True: chunk =3D response.read(1 << 20) @@ -48,5 +48,5 @@ def check_http_download(self, filename, hashsum, guestpor= t=3D8080, hl.update(chunk) =20 digest =3D hl.hexdigest() - self.log.info(f'sha256sum of download is {digest}.') + self.log.info('sha256sum of download is %s.', digest) self.assertEqual(digest, hashsum) --=20 2.51.0 From nobody Fri Nov 14 18:19:08 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1760522248; cv=none; d=zohomail.com; s=zohoarc; b=YjRYZ48wklkHB+X4mSf6ftEdEy/DbVQUi+chvyUrzo4qS6Aid+8CogMvTNnxlgpYNvjqmnCsoCxHy/hAyRRX8+neOpY6LdVSl5VwXOae/j7+dxT9cD0SyT2gTVHk9KoUAlWFfk1X+cPmR2VSiXXStQxoB9LalsoKP/ZaD4yd9z4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760522248; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=vEQAGo9Y693yuaV4RsCErZSCvXgcmHhoL6eCDL2RdKI=; b=T4wJynP7KKCYu2x84jBN+fDC776J41E4w0KbV80AAA+phG8PRcc02CngjAgYDyBiH24/STrsqXR9Z/D0k/OXpgM8IGynPhpb8DXLAryYx3NG7+PNAXleWmy9H/+pTI1ACybzQtiuNU10Nk1daHgOwYgkD+9lUiB0lA9pvOO1TMQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1760522248535546.0984542326572; Wed, 15 Oct 2025 02:57:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v8yED-0003ZJ-Kg; Wed, 15 Oct 2025 05:55:29 -0400 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 1v8yEA-0003XW-4M for qemu-devel@nongnu.org; Wed, 15 Oct 2025 05:55:26 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v8yDw-0004dr-UC for qemu-devel@nongnu.org; Wed, 15 Oct 2025 05:55:25 -0400 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-179-vpNCYkH5NdSIkSH38zObuQ-1; Wed, 15 Oct 2025 05:55:06 -0400 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0BACA1956095; Wed, 15 Oct 2025 09:55:05 +0000 (UTC) Received: from thuth-p1g4.redhat.com (unknown [10.45.224.24]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9CE54180044F; Wed, 15 Oct 2025 09:55:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760522109; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vEQAGo9Y693yuaV4RsCErZSCvXgcmHhoL6eCDL2RdKI=; b=TzKeUjtn5R+X+jg4rvcp1nvo5tOQk/sIg9vUvA3XTQBRWL4Gr4cZbWoM9IkCAM6X+p9L2Z EQFKOJdsWbkuNwHE8NInFa6cTK5Jdy3VBEq7rRDSo7r6wm/z/WaFVuQVKR2mwyIU0oHA9G JLcRzcoM9QvAMwsZjZoFXHv0GTG/hJo= X-MC-Unique: vpNCYkH5NdSIkSH38zObuQ-1 X-Mimecast-MFC-AGG-ID: vpNCYkH5NdSIkSH38zObuQ_1760522105 From: Thomas Huth To: qemu-devel@nongnu.org, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 4/6] tests/functional: Fix problems in testcase.py reported by pylint Date: Wed, 15 Oct 2025 11:54:52 +0200 Message-ID: <20251015095454.1575318-5-thuth@redhat.com> In-Reply-To: <20251015095454.1575318-1-thuth@redhat.com> References: <20251015095454.1575318-1-thuth@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1760522250128154100 Content-Type: text/plain; charset="utf-8" From: Thomas Huth - put 3rd party "import pycotap" after the standard imports - "help" is a built-in function in Python, don't use it as a variable name - put the doc strings in the right locations (after the "def" line) - use isinstance() instead of checking via type() - use lazy logging strings Signed-off-by: Thomas Huth Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- tests/functional/qemu_test/testcase.py | 251 +++++++++++++------------ 1 file changed, 126 insertions(+), 125 deletions(-) diff --git a/tests/functional/qemu_test/testcase.py b/tests/functional/qemu= _test/testcase.py index 2c0abde3957..47fb738a595 100644 --- a/tests/functional/qemu_test/testcase.py +++ b/tests/functional/qemu_test/testcase.py @@ -14,7 +14,6 @@ import logging import os from pathlib import Path -import pycotap import shutil from subprocess import run import sys @@ -23,6 +22,8 @@ import unittest import uuid =20 +import pycotap + from qemu.machine import QEMUMachine from qemu.utils import hvf_available, kvm_available, tcg_available =20 @@ -34,50 +35,50 @@ =20 class QemuBaseTest(unittest.TestCase): =20 - ''' - @params compressed: filename, Asset, or file-like object to uncompress - @params format: optional compression format (gzip, lzma) + def uncompress(self, compressed, format=3DNone): + ''' + @params compressed: filename, Asset, or file-like object to uncomp= ress + @params format: optional compression format (gzip, lzma) =20 - Uncompresses @compressed into the scratch directory. + Uncompresses @compressed into the scratch directory. =20 - If @format is None, heuristics will be applied to guess the format - from the filename or Asset URL. @format must be non-None if @uncompres= sed - is a file-like object. + If @format is None, heuristics will be applied to guess the + format from the filename or Asset URL. @format must be non-None + if @uncompressed is a file-like object. =20 - Returns the fully qualified path to the uncompressed file - ''' - def uncompress(self, compressed, format=3DNone): - self.log.debug(f"Uncompress {compressed} format=3D{format}") - if type(compressed) =3D=3D Asset: + Returns the fully qualified path to the uncompressed file + ''' + self.log.debug("Uncompress %s format=3D%s", compressed, format) + if isinstance(compressed, Asset): compressed.fetch() =20 - (name, ext) =3D os.path.splitext(str(compressed)) + (name, _ext) =3D os.path.splitext(str(compressed)) uncompressed =3D self.scratch_file(os.path.basename(name)) =20 uncompress(compressed, uncompressed, format) =20 return uncompressed =20 - ''' - @params archive: filename, Asset, or file-like object to extract - @params format: optional archive format (tar, zip, deb, cpio) - @params sub_dir: optional sub-directory to extract into - @params member: optional member file to limit extraction to - - Extracts @archive into the scratch directory, or a directory beneath - named by @sub_dir. All files are extracted unless @member specifies - a limit. - - If @format is None, heuristics will be applied to guess the format - from the filename or Asset URL. @format must be non-None if @archive - is a file-like object. - - If @member is non-None, returns the fully qualified path to @member - ''' def archive_extract(self, archive, format=3DNone, sub_dir=3DNone, memb= er=3DNone): - self.log.debug(f"Extract {archive} format=3D{format}" + - f"sub_dir=3D{sub_dir} member=3D{member}") - if type(archive) =3D=3D Asset: + ''' + @params archive: filename, Asset, or file-like object to extract + @params format: optional archive format (tar, zip, deb, cpio) + @params sub_dir: optional sub-directory to extract into + @params member: optional member file to limit extraction to + + Extracts @archive into the scratch directory, or a directory benea= th + named by @sub_dir. All files are extracted unless @member specifies + a limit. + + If @format is None, heuristics will be applied to guess the + format from the filename or Asset URL. @format must be non-None + if @archive is a file-like object. + + If @member is non-None, returns the fully qualified path to @member + ''' + self.log.debug("Extract %s format=3D%s sub_dir=3D%s member=3D%s", + archive, format, sub_dir, member) + if isinstance(archive, Asset): archive.fetch() if sub_dir is None: archive_extract(archive, self.scratch_file(), format, member) @@ -89,110 +90,110 @@ def archive_extract(self, archive, format=3DNone, sub= _dir=3DNone, member=3DNone): return self.scratch_file(member) return None =20 - ''' - Create a temporary directory suitable for storing UNIX - socket paths. - - Returns: a tempfile.TemporaryDirectory instance - ''' def socket_dir(self): + ''' + Create a temporary directory suitable for storing UNIX + socket paths. + + Returns: a tempfile.TemporaryDirectory instance + ''' if self.socketdir is None: self.socketdir =3D tempfile.TemporaryDirectory( prefix=3D"qemu_func_test_sock_") return self.socketdir =20 - ''' - @params args list of zero or more subdirectories or file - - Construct a path for accessing a data file located - relative to the source directory that is the root for - functional tests. - - @args may be an empty list to reference the root dir - itself, may be a single element to reference a file in - the root directory, or may be multiple elements to - reference a file nested below. The path components - will be joined using the platform appropriate path - separator. - - Returns: string representing a file path - ''' def data_file(self, *args): + ''' + @params args list of zero or more subdirectories or file + + Construct a path for accessing a data file located + relative to the source directory that is the root for + functional tests. + + @args may be an empty list to reference the root dir + itself, may be a single element to reference a file in + the root directory, or may be multiple elements to + reference a file nested below. The path components + will be joined using the platform appropriate path + separator. + + Returns: string representing a file path + ''' return str(Path(Path(__file__).parent.parent, *args)) =20 - ''' - @params args list of zero or more subdirectories or file - - Construct a path for accessing a data file located - relative to the build directory root. - - @args may be an empty list to reference the build dir - itself, may be a single element to reference a file in - the build directory, or may be multiple elements to - reference a file nested below. The path components - will be joined using the platform appropriate path - separator. - - Returns: string representing a file path - ''' def build_file(self, *args): - return str(Path(BUILD_DIR, *args)) + ''' + @params args list of zero or more subdirectories or file =20 - ''' - @params args list of zero or more subdirectories or file + Construct a path for accessing a data file located + relative to the build directory root. =20 - Construct a path for accessing/creating a scratch file - located relative to a temporary directory dedicated to - this test case. The directory and its contents will be - purged upon completion of the test. + @args may be an empty list to reference the build dir + itself, may be a single element to reference a file in + the build directory, or may be multiple elements to + reference a file nested below. The path components + will be joined using the platform appropriate path + separator. =20 - @args may be an empty list to reference the scratch dir - itself, may be a single element to reference a file in - the scratch directory, or may be multiple elements to - reference a file nested below. The path components - will be joined using the platform appropriate path - separator. + Returns: string representing a file path + ''' + return str(Path(BUILD_DIR, *args)) =20 - Returns: string representing a file path - ''' def scratch_file(self, *args): + ''' + @params args list of zero or more subdirectories or file + + Construct a path for accessing/creating a scratch file + located relative to a temporary directory dedicated to + this test case. The directory and its contents will be + purged upon completion of the test. + + @args may be an empty list to reference the scratch dir + itself, may be a single element to reference a file in + the scratch directory, or may be multiple elements to + reference a file nested below. The path components + will be joined using the platform appropriate path + separator. + + Returns: string representing a file path + ''' return str(Path(self.workdir, *args)) =20 - ''' - @params args list of zero or more subdirectories or file - - Construct a path for accessing/creating a log file - located relative to a temporary directory dedicated to - this test case. The directory and its log files will be - preserved upon completion of the test. - - @args may be an empty list to reference the log dir - itself, may be a single element to reference a file in - the log directory, or may be multiple elements to - reference a file nested below. The path components - will be joined using the platform appropriate path - separator. - - Returns: string representing a file path - ''' def log_file(self, *args): + ''' + @params args list of zero or more subdirectories or file + + Construct a path for accessing/creating a log file + located relative to a temporary directory dedicated to + this test case. The directory and its log files will be + preserved upon completion of the test. + + @args may be an empty list to reference the log dir + itself, may be a single element to reference a file in + the log directory, or may be multiple elements to + reference a file nested below. The path components + will be joined using the platform appropriate path + separator. + + Returns: string representing a file path + ''' return str(Path(self.outputdir, *args)) =20 - ''' - @params plugin name - - Return the full path to the plugin taking into account any host OS - specific suffixes. - ''' def plugin_file(self, plugin_name): + ''' + @params plugin name + + Return the full path to the plugin taking into account any host OS + specific suffixes. + ''' sfx =3D dso_suffix() return os.path.join('tests', 'tcg', 'plugins', f'{plugin_name}.{sf= x}') =20 def assets_available(self): for name, asset in vars(self.__class__).items(): - if name.startswith("ASSET_") and type(asset) =3D=3D Asset: + if name.startswith("ASSET_") and isinstance(asset, Asset): if not asset.available(): - self.log.debug(f"Asset {asset.url} not available") + self.log.debug("Asset %s not available", asset.url) return False return True =20 @@ -216,9 +217,9 @@ def setUp(self): self.log.setLevel(logging.DEBUG) self._log_fh =3D logging.FileHandler(self.log_filename, mode=3D'w') self._log_fh.setLevel(logging.DEBUG) - fileFormatter =3D logging.Formatter( + file_formatter =3D logging.Formatter( '%(asctime)s - %(levelname)s: %(message)s') - self._log_fh.setFormatter(fileFormatter) + self._log_fh.setFormatter(file_formatter) self.log.addHandler(self._log_fh) =20 # Capture QEMUMachine logging @@ -256,7 +257,7 @@ def main(): res =3D unittest.main(module =3D None, testRunner =3D tr, exit =3D= False, argv=3D[sys.argv[0], path] + sys.argv[1:]) failed =3D {} - for (test, message) in res.result.errors + res.result.failures: + for (test, _message) in res.result.errors + res.result.failures: if hasattr(test, "log_filename") and not test.id() in failed: print('More information on ' + test.id() + ' could be foun= d here:' '\n %s' % test.log_filename, file=3Dsys.stderr) @@ -275,7 +276,9 @@ def setUp(self): def add_ldpath(self, ldpath): self._ldpath.append(os.path.abspath(ldpath)) =20 - def run_cmd(self, bin_path, args=3D[]): + def run_cmd(self, bin_path, args=3DNone): + if args is None: + args =3D [] return run([self.qemu_bin] + ["-L %s" % ldpath for ldpath in self._ldpath] + [bin_path] @@ -300,8 +303,8 @@ def setUp(self): self._console_log_fh =3D logging.FileHandler(self.console_log_name, mode=3D'w') self._console_log_fh.setLevel(logging.DEBUG) - fileFormatter =3D logging.Formatter('%(asctime)s: %(message)s') - self._console_log_fh.setFormatter(fileFormatter) + file_formatter =3D logging.Formatter('%(asctime)s: %(message)s') + self._console_log_fh.setFormatter(file_formatter) console_log.addHandler(self._console_log_fh) =20 def set_machine(self, machinename): @@ -339,17 +342,15 @@ def require_accelerator(self, accelerator): "available" % accelerator) =20 def require_netdev(self, netdevname): - help =3D run([self.qemu_bin, - '-M', 'none', '-netdev', 'help'], - capture_output=3DTrue, check=3DTrue, encoding=3D'utf8')= .stdout; - if help.find('\n' + netdevname + '\n') < 0: + helptxt =3D run([self.qemu_bin, '-M', 'none', '-netdev', 'help'], + capture_output=3DTrue, check=3DTrue, encoding=3D'utf= 8').stdout + if helptxt.find('\n' + netdevname + '\n') < 0: self.skipTest('no support for " + netdevname + " networking') =20 def require_device(self, devicename): - help =3D run([self.qemu_bin, - '-M', 'none', '-device', 'help'], - capture_output=3DTrue, check=3DTrue, encoding=3D'utf8')= .stdout; - if help.find(devicename) < 0: + helptxt =3D run([self.qemu_bin, '-M', 'none', '-device', 'help'], + capture_output=3DTrue, check=3DTrue, encoding=3D'utf8')= .stdout + if helptxt.find(devicename) < 0: self.skipTest('no support for device ' + devicename) =20 def _new_vm(self, name, *args): @@ -411,7 +412,7 @@ def tearDown(self): try: vm.shutdown() except Exception as ex: - self.log.error("Failed to teardown VM: %s" % ex) + self.log.error("Failed to teardown VM: %s", ex) logging.getLogger('console').removeHandler(self._console_log_fh) self._console_log_fh.close() super().tearDown() --=20 2.51.0 From nobody Fri Nov 14 18:19:08 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1760522245; cv=none; d=zohomail.com; s=zohoarc; b=S/15TimjHe7LhG9xT1tyIkPbNn59L77a1suDCP8CyqqazlpqMh+WmzgLVWnGyQ0Js58BAFRONNyOzXHvDhV8Wd9EEy67Nxq2u/hdho4e9vv7JY07Xo5MUK6xipptEGcYVCISxWPhPGc2yeEaw066dpeLehepVNtXqX0DY6S8/2g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760522245; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ByGp1tmpifRggNbAhsRl0C5D4RJXbzbp090grVB37+g=; b=hEYbSRhnDEBJ/Xh9mSDxt/2dFCrRi5agoqlAAOz4jDSMW0gulE/XiBEloSZ4XJz3nJWg0EavH9gD8fy3MEAirULGquW+7uc1Bt53UZLmvdxZqgG+asDaQti92g11n/kDERJ6LGBgYPDun/sJN3OKUwwvKLdAQtU0wMhBzAf06Bs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1760522245720682.2106287597921; Wed, 15 Oct 2025 02:57:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v8yE8-0003VS-Vh; Wed, 15 Oct 2025 05:55:25 -0400 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 1v8yE7-0003UC-JK for qemu-devel@nongnu.org; Wed, 15 Oct 2025 05:55:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v8yDx-0004eS-5m for qemu-devel@nongnu.org; Wed, 15 Oct 2025 05:55:23 -0400 Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-426-bfwk7_eAONaLNzbF3Iyzng-1; Wed, 15 Oct 2025 05:55:07 -0400 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0210519560AD; Wed, 15 Oct 2025 09:55:07 +0000 (UTC) Received: from thuth-p1g4.redhat.com (unknown [10.45.224.24]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 91AA0180044F; Wed, 15 Oct 2025 09:55:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760522111; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ByGp1tmpifRggNbAhsRl0C5D4RJXbzbp090grVB37+g=; b=YJtjJUsTGcs4Fp/KA3NpNuItLTYG5gnnI38Rbu9jdIPMzaVPDz0nkb6WkceJqgUoD+zpLj qdBfgIqEV969rh8pRQv6LnDThCFHkPMBA7hc9hEVRQVTZJoYs99oPl+SmxNee6Z1EiqAEZ lpRe7ljGi57xhTFt7fCVI3muMnEVJdQ= X-MC-Unique: bfwk7_eAONaLNzbF3Iyzng-1 X-Mimecast-MFC-AGG-ID: bfwk7_eAONaLNzbF3Iyzng_1760522107 From: Thomas Huth To: qemu-devel@nongnu.org, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 5/6] tests/functional: Fix problems in uncompress.py reported by pylint Date: Wed, 15 Oct 2025 11:54:53 +0200 Message-ID: <20251015095454.1575318-6-thuth@redhat.com> In-Reply-To: <20251015095454.1575318-1-thuth@redhat.com> References: <20251015095454.1575318-1-thuth@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1760522248065154100 Content-Type: text/plain; charset="utf-8" From: Thomas Huth - put the doc strings in the right locations (after the "def" line) - use isinstance() instead of checking via type() Signed-off-by: Thomas Huth Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- tests/functional/qemu_test/uncompress.py | 40 ++++++++++++------------ 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/tests/functional/qemu_test/uncompress.py b/tests/functional/qe= mu_test/uncompress.py index b7ef8f759b7..5bbdf8fe323 100644 --- a/tests/functional/qemu_test/uncompress.py +++ b/tests/functional/qemu_test/uncompress.py @@ -58,20 +58,20 @@ def zstd_uncompress(zstd_path, output_path): os.chmod(output_path, stat.S_IRUSR | stat.S_IWUSR) =20 =20 -''' -@params compressed: filename, Asset, or file-like object to uncompress -@params uncompressed: filename to uncompress into -@params format: optional compression format (gzip, lzma) +def uncompress(compressed, uncompressed, format=3DNone): + ''' + @params compressed: filename, Asset, or file-like object to uncompress + @params uncompressed: filename to uncompress into + @params format: optional compression format (gzip, lzma) =20 -Uncompresses @compressed into @uncompressed + Uncompresses @compressed into @uncompressed =20 -If @format is None, heuristics will be applied to guess the format -from the filename or Asset URL. @format must be non-None if @uncompressed -is a file-like object. + If @format is None, heuristics will be applied to guess the + format from the filename or Asset URL. @format must be non-None + if @uncompressed is a file-like object. =20 -Returns the fully qualified path to the uncompessed file -''' -def uncompress(compressed, uncompressed, format=3DNone): + Returns the fully qualified path to the uncompessed file + ''' if format is None: format =3D guess_uncompress_format(compressed) =20 @@ -84,19 +84,19 @@ def uncompress(compressed, uncompressed, format=3DNone): else: raise Exception(f"Unknown compression format {format}") =20 -''' -@params compressed: filename, Asset, or file-like object to guess - -Guess the format of @compressed, raising an exception if -no format can be determined -''' def guess_uncompress_format(compressed): - if type(compressed) =3D=3D Asset: + ''' + @params compressed: filename, Asset, or file-like object to guess + + Guess the format of @compressed, raising an exception if + no format can be determined + ''' + if isinstance(compressed, Asset): compressed =3D urlparse(compressed.url).path - elif type(compressed) !=3D str: + elif not isinstance(compressed, str): raise Exception(f"Unable to guess compression cformat for {compres= sed}") =20 - (name, ext) =3D os.path.splitext(compressed) + (_name, ext) =3D os.path.splitext(compressed) if ext =3D=3D ".xz": return "xz" elif ext =3D=3D ".gz": --=20 2.51.0 From nobody Fri Nov 14 18:19:08 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1760522248; cv=none; d=zohomail.com; s=zohoarc; b=c2ohwTY8/0YpkahhgDuvl4WGcJudSFQjKD1rI3v/Y43uWc5QP8LchlFAv3iDVZmDfuIuXhX7GiJlUWXnOBRwsLN8igAv13yUrEJfzCC4RC9eSfFMReTqHOLX48NEEIPV7cjidsEX/Mjl+KK3m+iFRDt7M6+voFGf11RVEWqrYOI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760522248; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=kl+SJEyI0W2R0bPxhcXqCDWlb/3fNzzvOXjJQ3VZJ9s=; b=MCrteUfyYlaXDqYlZ6uKrtVr4hh9emsxwfrh7/saobMceNJ+i7/lVSvvQcw+AdCDpBVEkIOmrPpTC4MzQzHotW1mVPoLW+QRt66JJx0reJLVvVz5m/z7OTaqYEmFDxnV13K6F2yWs4nmdxWGKP3PU34Szql5Lso+e3ovCvApjew= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 176052224832527.2311020967378; Wed, 15 Oct 2025 02:57:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v8yE8-0003Ua-Kc; Wed, 15 Oct 2025 05:55:24 -0400 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 1v8yE5-0003Qm-PC for qemu-devel@nongnu.org; Wed, 15 Oct 2025 05:55:22 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v8yDx-0004eN-5I for qemu-devel@nongnu.org; Wed, 15 Oct 2025 05:55:21 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-547-dSSiiGWBOWCuzqxNqV-apg-1; Wed, 15 Oct 2025 05:55:09 -0400 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id F3F2F1800345; Wed, 15 Oct 2025 09:55:08 +0000 (UTC) Received: from thuth-p1g4.redhat.com (unknown [10.45.224.24]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8242E1800452; Wed, 15 Oct 2025 09:55:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760522111; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kl+SJEyI0W2R0bPxhcXqCDWlb/3fNzzvOXjJQ3VZJ9s=; b=MiD3d2o8nRG15X69y3dHEqImh9zLoIdWH/6ks1vkxNa4AwF+NPoM2zhiIaNaR7xO4cj79t y907pcJJvMxUD+dLCgAfQ1GMTHflXMaAW2aNH62PKvDRoqdqIV71mkyz1//PDTUfbVbzBG 9NGYa2smNTKwIodagfHfJ/Ge7r0Jp0c= X-MC-Unique: dSSiiGWBOWCuzqxNqV-apg-1 X-Mimecast-MFC-AGG-ID: dSSiiGWBOWCuzqxNqV-apg_1760522109 From: Thomas Huth To: qemu-devel@nongnu.org, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 6/6] tests/functional: Fix problems in utils.py reported by pylint Date: Wed, 15 Oct 2025 11:54:54 +0200 Message-ID: <20251015095454.1575318-7-thuth@redhat.com> In-Reply-To: <20251015095454.1575318-1-thuth@redhat.com> References: <20251015095454.1575318-1-thuth@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1760522250034154100 Content-Type: text/plain; charset="utf-8" From: Thomas Huth - put the doc strings in the right locations (after the "def" line) - use the right indentation (4 spaces) Signed-off-by: Thomas Huth Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- tests/functional/qemu_test/utils.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/functional/qemu_test/utils.py b/tests/functional/qemu_te= st/utils.py index e7c8de81654..826c267785b 100644 --- a/tests/functional/qemu_test/utils.py +++ b/tests/functional/qemu_test/utils.py @@ -17,10 +17,10 @@ def get_usernet_hostfwd_port(vm): res =3D vm.cmd('human-monitor-command', command_line=3D'info usernet') return get_info_usernet_hostfwd_port(res) =20 -""" -Round up to next power of 2 -""" def pow2ceil(x): + """ + Round up to next power of 2 + """ return 1 if x =3D=3D 0 else 2**(x - 1).bit_length() =20 def file_truncate(path, size): @@ -28,12 +28,12 @@ def file_truncate(path, size): with open(path, 'ab+') as fd: fd.truncate(size) =20 -""" -Expand file size to next power of 2 -""" def image_pow2ceil_expand(path): - size =3D os.path.getsize(path) - size_aligned =3D pow2ceil(size) - if size !=3D size_aligned: - with open(path, 'ab+') as fd: - fd.truncate(size_aligned) + """ + Expand file size to next power of 2 + """ + size =3D os.path.getsize(path) + size_aligned =3D pow2ceil(size) + if size !=3D size_aligned: + with open(path, 'ab+') as fd: + fd.truncate(size_aligned) --=20 2.51.0