diff options
author | Simon Glass <sjg@chromium.org> | 2022-08-07 02:51:47 +0300 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2022-09-13 01:06:36 +0300 |
commit | cc85d905cd28581ccad51f1f4579962ee08989ae (patch) | |
tree | 45d512207026728d4411f56feadb5958b521f45e | |
parent | 44384c70f9e93faa1a494bbf96a9b6c273a996ca (diff) | |
download | u-boot-cc85d905cd28581ccad51f1f4579962ee08989ae.tar.xz |
test/py: Allow tests to be marked single-threaded only
Add a new 'singlethread' marker to allow tests to be skipped when running
in parallel.
Signed-off-by: Simon Glass <sjg@chromium.org>
-rw-r--r-- | test/py/conftest.py | 17 | ||||
-rw-r--r-- | test/py/pytest.ini | 1 |
2 files changed, 18 insertions, 0 deletions
diff --git a/test/py/conftest.py b/test/py/conftest.py index 2ba34479e0..dbe1acd9e3 100644 --- a/test/py/conftest.py +++ b/test/py/conftest.py @@ -521,6 +521,22 @@ def setup_requiredtool(item): if not tool_is_in_path(tool): pytest.skip('tool "%s" not in $PATH' % tool) +def setup_singlethread(item): + """Process any 'singlethread' marker for a test. + + Skip this test if running in parallel. + + Args: + item: The pytest test item. + + Returns: + Nothing. + """ + for single in item.iter_markers('singlethread'): + worker_id = os.environ.get("PYTEST_XDIST_WORKER") + if worker_id and worker_id != 'master': + pytest.skip('must run single-threaded') + def start_test_section(item): anchors[item.name] = log.start_section(item.name) @@ -541,6 +557,7 @@ def pytest_runtest_setup(item): setup_boardspec(item) setup_buildconfigspec(item) setup_requiredtool(item) + setup_singlethread(item) def pytest_runtest_protocol(item, nextitem): """pytest hook: Called to execute a test. diff --git a/test/py/pytest.ini b/test/py/pytest.ini index e93d010f1f..26d83f83e0 100644 --- a/test/py/pytest.ini +++ b/test/py/pytest.ini @@ -11,3 +11,4 @@ markers = notbuildconfigspec: U-Boot: Describes required disabled Kconfig options. requiredtool: U-Boot: Required host tools for a test. slow: U-Boot: Specific test will run slowly. + singlethread: Cannot run in parallel |