From patchwork Thu Mar 31 18:28:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Burton X-Patchwork-Id: 6122 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id D4F3EC43219 for ; Thu, 31 Mar 2022 18:29:21 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web09.654.1648751360410980869 for ; Thu, 31 Mar 2022 11:29:20 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: ross.burton@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 12A2A13D5 for ; Thu, 31 Mar 2022 11:29:20 -0700 (PDT) Received: from oss-tx204.lab.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B8B243F718 for ; Thu, 31 Mar 2022 11:29:19 -0700 (PDT) From: Ross Burton To: openembedded-core@lists.openembedded.org Subject: [PATCH 06/23] oeqa/selftest/wic: clean up only_for_arch decorator Date: Thu, 31 Mar 2022 19:28:58 +0100 Message-Id: <20220331182915.22128-6-ross.burton@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220331182915.22128-1-ross.burton@arm.com> References: <20220331182915.22128-1-ross.burton@arm.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Thu, 31 Mar 2022 18:29:21 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/163847 There's no need to pass a recipe name when determining the target architecture, there's no need to cap the size of the lru_cache as it will only have one entry, and __name__ is set by @wraps. Signed-off-by: Ross Burton --- meta/lib/oeqa/selftest/cases/wic.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/meta/lib/oeqa/selftest/cases/wic.py b/meta/lib/oeqa/selftest/cases/wic.py index 5d7f7bf6135..317b80ea27b 100644 --- a/meta/lib/oeqa/selftest/cases/wic.py +++ b/meta/lib/oeqa/selftest/cases/wic.py @@ -22,26 +22,22 @@ from oeqa.selftest.case import OESelftestTestCase from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars, runqemu -@lru_cache(maxsize=32) -def get_host_arch(recipe): - """A cached call to get_bb_var('HOST_ARCH', )""" - return get_bb_var('HOST_ARCH', recipe) +@lru_cache() +def get_host_arch(): + return get_bb_var('HOST_ARCH') -def only_for_arch(archs, image='core-image-minimal'): +def only_for_arch(archs): """Decorator for wrapping test cases that can be run only for specific target architectures. A list of compatible architectures is passed in `archs`. - Current architecture will be determined by parsing bitbake output for - `image` recipe. """ def wrapper(func): @wraps(func) def wrapped_f(*args, **kwargs): - arch = get_host_arch(image) + arch = get_host_arch() if archs and arch not in archs: raise unittest.SkipTest("Testcase arch dependency not met: %s" % arch) return func(*args, **kwargs) - wrapped_f.__name__ = func.__name__ return wrapped_f return wrapper