oeqa/selftest/wic: clean up only_for_arch decorator

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.

(From OE-Core rev: e8e6c679f6eb74cb25c124a18af88dd5c2e2c833)

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Ross Burton 2022-03-31 19:28:58 +01:00 committed by Richard Purdie
parent 8d01207fd7
commit e9c8d638f9

View File

@ -22,26 +22,22 @@ from oeqa.selftest.case import OESelftestTestCase
from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars, runqemu from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars, runqemu
@lru_cache(maxsize=32) @lru_cache()
def get_host_arch(recipe): def get_host_arch():
"""A cached call to get_bb_var('HOST_ARCH', <recipe>)""" return get_bb_var('HOST_ARCH')
return get_bb_var('HOST_ARCH', recipe)
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 """Decorator for wrapping test cases that can be run only for specific target
architectures. A list of compatible architectures is passed in `archs`. 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): def wrapper(func):
@wraps(func) @wraps(func)
def wrapped_f(*args, **kwargs): def wrapped_f(*args, **kwargs):
arch = get_host_arch(image) arch = get_host_arch()
if archs and arch not in archs: if archs and arch not in archs:
raise unittest.SkipTest("Testcase arch dependency not met: %s" % arch) raise unittest.SkipTest("Testcase arch dependency not met: %s" % arch)
return func(*args, **kwargs) return func(*args, **kwargs)
wrapped_f.__name__ = func.__name__
return wrapped_f return wrapped_f
return wrapper return wrapper