[PATCHv10 2/4] test_ut: add a ut_ubman fixture to clean up tests
rs at ti.com
rs at ti.com
Thu Jun 4 17:50:36 CEST 2026
From: Randolph Sapp <rs at ti.com>
Add a ut_ubman fixture to clean up after certain problematic tests
without negatively affecting the current assert based testing.
Currently this catches "bootstd bootflow_cmd_boot" and "bootstd
bootflow_scan_boot" ut_subtests, as these will change the sandbox state
a little too much to be recoverable from.
Signed-off-by: Randolph Sapp <rs at ti.com>
---
v10:
- Init
---
test/py/tests/test_ut.py | 26 +++++++++++++++++++++-----
1 file changed, 21 insertions(+), 5 deletions(-)
diff --git a/test/py/tests/test_ut.py b/test/py/tests/test_ut.py
index dce5a37dd35..fa50c8008a5 100644
--- a/test/py/tests/test_ut.py
+++ b/test/py/tests/test_ut.py
@@ -631,7 +631,23 @@ def test_ut_dm_init_bootstd(ubman):
ubman.restart_uboot()
-def test_ut(ubman, ut_subtest):
+ at pytest.fixture(name="ut_ubman")
+def ut_ubman_fixture(ubman, ut_subtest):
+ """Fixture to restart the sandbox after known problematic tests.
+
+ Args:
+ ubman (ConsoleBase): U-Boot console
+ ut_subtest (str): test to be executed via command ut, e.g 'foo bar' to
+ execute command 'ut foo bar'
+ """
+
+ yield ubman
+
+ if ut_subtest in ("bootstd bootflow_cmd_boot", "bootstd bootflow_scan_boot"):
+ ubman.restart_uboot()
+
+
+def test_ut(ut_ubman, ut_subtest):
"""Execute a "ut" subtest.
The subtests are collected in function generate_ut_subtest() from linker
@@ -644,18 +660,18 @@ def test_ut(ubman, ut_subtest):
implemented in C function foo_test_bar().
Args:
- ubman (ConsoleBase): U-Boot console
+ ut_ubman (ConsoleBase): U-Boot console
ut_subtest (str): test to be executed via command ut, e.g 'foo bar' to
execute command 'ut foo bar'
"""
if ut_subtest == 'hush hush_test_simple_dollar':
# ut hush hush_test_simple_dollar prints "Unknown command" on purpose.
- with ubman.disable_check('unknown_command'):
- output = ubman.run_command('ut ' + ut_subtest)
+ with ut_ubman.disable_check('unknown_command'):
+ output = ut_ubman.run_command('ut ' + ut_subtest)
assert 'Unknown command \'quux\' - try \'help\'' in output
else:
- output = ubman.run_command('ut ' + ut_subtest)
+ output = ut_ubman.run_command('ut ' + ut_subtest)
assert output.endswith('failures: 0')
lastline = output.splitlines()[-1]
if "skipped: 0," not in lastline:
--
2.54.0
More information about the U-Boot
mailing list