
From: Simon Glass <sjg@chromium.org> Add a new restart_board() function which handles restarting the board. Provide an parameter which indicates whether the reset has already happened. Make use of this from restart_uboot() Change one test over to use this function and add a new 'reset' test for sandbox. Signed-off-by: Simon Glass <sjg@chromium.org> --- test/py/console_base.py | 19 +++++++++++++++++-- test/py/tests/test_efi_selftest.py | 2 +- test/py/tests/test_reset.py | 8 ++++++++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/test/py/console_base.py b/test/py/console_base.py index 3e8f2cda1c6..e5f9b0e26e0 100644 --- a/test/py/console_base.py +++ b/test/py/console_base.py @@ -544,8 +544,23 @@ class ConsoleBase(object): def restart_uboot(self): """Shut down and restart U-Boot.""" - self.cleanup_spawn() - self.ensure_spawned(False) + self.restart_board() + + def restart_board(self, need_reset=True): + """Restart a board so it is ready for use + + If a reset is needed the board is re-spawned. If the reset has already + happened it checks for a reboot happening on the console + + Args: + need_reset (bool): True if a reset should be initiated, False if it + has already happened + """ + if need_reset: + self.cleanup_spawn() + self.ensure_spawned(False) + else: + self.run_command(cmd='', send_nl=False, wait_for_reboot=True) def restart_and_expect_reset(self): """Shut down and restart U-Boot, expecting it to reset itself! diff --git a/test/py/tests/test_efi_selftest.py b/test/py/tests/test_efi_selftest.py index 12cbe5caa9b..bd44e0088e8 100644 --- a/test/py/tests/test_efi_selftest.py +++ b/test/py/tests/test_efi_selftest.py @@ -58,7 +58,7 @@ def test_efi_selftest_watchdog_reboot(ubman): ubman.run_command(cmd='bootefi selftest', wait_for_prompt=False) if ubman.p.expect(['resetting', 'U-Boot']): raise Exception('Reset failed in \'watchdog reboot\' test') - ubman.run_command(cmd='', send_nl=False, wait_for_reboot=True) + ubman.restart_uboot(need_reset=False) @pytest.mark.buildconfigspec('cmd_bootefi_selftest') def test_efi_selftest_text_input(ubman): diff --git a/test/py/tests/test_reset.py b/test/py/tests/test_reset.py index af079a70664..c85c96ef690 100644 --- a/test/py/tests/test_reset.py +++ b/test/py/tests/test_reset.py @@ -59,5 +59,13 @@ def test_reset_w(ubman): setup_reset_env(ubman) ubman.run_command('reset -w', wait_for_reboot=True) + # Checks U-Boot's command-prompt functionality after reset + test_000_version.test_version(ubman) + +@pytest.mark.buildconfigspec('sandbox') +def test_reset_sandbox(ubman): + """Test the reset command for sandbox""" + ubman.restart_board(need_reset=True) + # Checks the u-boot command prompt's functionality after reset test_000_version.test_version(ubman) -- 2.43.0