]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
test_ut: add a ut_ubman fixture to clean up tests
authorRandolph Sapp <rs@ti.com>
Thu, 4 Jun 2026 15:50:36 +0000 (10:50 -0500)
committerTom Rini <trini@konsulko.com>
Mon, 15 Jun 2026 17:04:39 +0000 (11:04 -0600)
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@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
test/py/tests/test_ut.py

index dce5a37dd350641a2633be2231debeb20a13db94..fa50c8008a589086dd7c66080f0c4fe9fc699fd7 100644 (file)
@@ -631,7 +631,23 @@ def test_ut_dm_init_bootstd(ubman):
     ubman.restart_uboot()
 
 
-def test_ut(ubman, ut_subtest):
+@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: