test/py: Add a proper function to shut down U-Boot

Some tests boot out of U-Boot or perform such other action that it can
no-longer be used for tests. Provide a function to handle this, rather
than having tests do it themselves.

Signed-off-by: Simon Glass <sjg@chromium.org>
Series-to: u-boot
Cover-letter:
test/py: Some code tidy-updates
This series includes various improvements to the test/py close:

- Fix some pylint warnings
- Log the PYTHONPATH when no py hooks are found
- Improve how the pattern list is handled
- Move 'expect' handling into ConsoleBase
- Add an exported function to shutdown U-Boot in tests
- A few other minor things
END
This commit is contained in:
Simon Glass
2025-06-14 04:39:24 -06:00
parent 09b52857bb
commit 43c42430af
3 changed files with 15 additions and 10 deletions

View File

@@ -194,8 +194,7 @@ def test_net_tftpboot_boot(ubman):
# This forces the console object to be shutdown, so any subsequent
# test will reset the board back into U-Boot. We want to force this
# no matter whether the kernel boot passed or failed.
ubman.drain_console()
ubman.cleanup_spawn()
ubman.shutdown_required()
def setup_pxe_boot(ubman):
f = ubman.config.env.get('env__net_pxe_bootable_file', None)
@@ -257,8 +256,7 @@ def test_net_pxe_boot(ubman):
ubman.run_command(pxe_boot_cmd, wait_for_prompt=False)
ubman.wait_for(pattern)
finally:
ubman.drain_console()
ubman.cleanup_spawn()
ubman.shutdown_required()
@pytest.mark.buildconfigspec('cmd_pxe')
def test_net_pxe_boot_config(ubman):
@@ -336,8 +334,7 @@ def test_net_pxe_boot_config(ubman):
ubman.wait_for(pattern)
finally:
ubman.drain_console()
ubman.cleanup_spawn()
ubman.shutdown_required()
@pytest.mark.buildconfigspec('cmd_pxe')
def test_net_pxe_boot_config_invalid(ubman):
@@ -396,5 +393,4 @@ def test_net_pxe_boot_config_invalid(ubman):
ubman.wait_for(pattern)
finally:
ubman.drain_console()
ubman.cleanup_spawn()
ubman.shutdown_required()