[Concept,03/17] ulib: test: Add localqemu marker to skip tests in lab
Commit Message
From: Simon Glass <simon.glass@canonical.com>
Some tests launch their own QEMU process via subprocess rather than
using the lab's managed U-Boot instance. In lab mode the locally
launched QEMU produces empty output, causing assertion failures.
There isn't really any point in running these tests on the lab since
they run happily in CI.
Add a 'localqemu' pytest marker and the corresponding setup_localqemu()
hook in conftest.py that skips marked tests when ubconfig.role is set.
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---
doc/develop/pytest/usage.rst | 9 +++++++++
test/py/conftest.py | 15 +++++++++++++++
test/py/pytest.ini | 1 +
test/py/tests/test_ulib.py | 1 +
4 files changed, 26 insertions(+)
@@ -596,3 +596,12 @@ option not to be set. The following annotation requires CONFIG_RISCV=n:
.. code-block:: python
@pytest.mark.notbuildconfigspec('riscv')
+
+The localqemu marker indicates that a test launches its own QEMU process
+rather than using the lab's managed U-Boot instance. Tests with this marker
+are automatically skipped when running in lab mode (i.e. when ``--role`` is
+set), since the locally launched QEMU is not available in that environment:
+
+.. code-block:: python
+
+ @pytest.mark.localqemu
@@ -818,6 +818,20 @@ def setup_role(item):
if required_roles and ubconfig.role not in required_roles:
pytest.skip(f'board "{ubconfig.role}" not supported')
+def setup_localqemu(item):
+ """Process any 'localqemu' marker for a test.
+
+ Skip this test if running in lab mode (i.e. role is set), since the
+ test launches its own QEMU rather than using the lab's U-Boot.
+
+ Args:
+ item (pytest.Item): The pytest test item
+ """
+ for _ in item.iter_markers('localqemu'):
+ if ubconfig.role:
+ pytest.skip('test requires local QEMU (not supported in lab)')
+ return
+
def start_test_section(item):
anchors[item.name] = log.start_section(item.name)
@@ -840,6 +854,7 @@ def pytest_runtest_setup(item):
setup_requiredtool(item)
setup_singlethread(item)
setup_role(item)
+ setup_localqemu(item)
def pytest_runtest_protocol(item, nextitem):
"""pytest hook: Called to execute a test.
@@ -14,3 +14,4 @@ markers =
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
+ localqemu: U-Boot: Test launches its own QEMU, skip in lab mode
@@ -210,6 +210,7 @@ def test_ulib_api_header(ubman):
assert 'ub_snprintf(char *buf, size_t size, const char *fmt, ...)' in out
assert 'ub_vprintf(const char *fmt, va_list args)' in out
+@pytest.mark.localqemu
@pytest.mark.boardspec('qemu-x86')
@pytest.mark.buildconfigspec("examples")
def test_ulib_demo_rom(ubman):