mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-15 17:34:43 +00:00
test/py: Allow tests to be filtered by role
Some test can only be run by a particular board in a lab, e.g. because they are loaded with an OS image used by the test. Add a way to specify this in tests. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
4c6774c606
commit
9a04b9a439
2 changed files with 23 additions and 0 deletions
|
@ -334,6 +334,7 @@ def pytest_configure(config):
|
|||
ubconfig.dtb = build_dir + '/arch/sandbox/dts/test.dtb'
|
||||
ubconfig.connection_ok = True
|
||||
ubconfig.timing = config.getoption('timing')
|
||||
ubconfig.role = config.getoption('role')
|
||||
|
||||
env_vars = (
|
||||
'board_type',
|
||||
|
@ -760,6 +761,26 @@ def setup_singlethread(item):
|
|||
if worker_id and worker_id != 'master':
|
||||
pytest.skip('must run single-threaded')
|
||||
|
||||
def setup_role(item):
|
||||
"""Process any 'role' marker for a test.
|
||||
|
||||
Skip this test if the role does not match.
|
||||
|
||||
Args:
|
||||
item (pytest.Item): The pytest test item
|
||||
"""
|
||||
required_roles = []
|
||||
for roles in item.iter_markers('role'):
|
||||
role = roles.args[0]
|
||||
if role.startswith('!'):
|
||||
if ubconfig.role == role[1:]:
|
||||
pytest.skip(f'role "{ubconfig.role}" not supported')
|
||||
return
|
||||
else:
|
||||
required_roles.append(role)
|
||||
if required_roles and ubconfig.role not in required_roles:
|
||||
pytest.skip(f'board "{ubconfig.role}" not supported')
|
||||
|
||||
def start_test_section(item):
|
||||
anchors[item.name] = log.start_section(item.name)
|
||||
|
||||
|
@ -781,6 +802,7 @@ def pytest_runtest_setup(item):
|
|||
setup_buildconfigspec(item)
|
||||
setup_requiredtool(item)
|
||||
setup_singlethread(item)
|
||||
setup_role(item)
|
||||
|
||||
def pytest_runtest_protocol(item, nextitem):
|
||||
"""pytest hook: Called to execute a test.
|
||||
|
|
|
@ -12,3 +12,4 @@ markers =
|
|||
requiredtool: U-Boot: Required host tools for a test.
|
||||
slow: U-Boot: Specific test will run slowly.
|
||||
singlethread: Cannot run in parallel
|
||||
role: U-Boot: Indicates the lab 'role' which can execute this test
|
||||
|
|
Loading…
Add table
Reference in a new issue