
From: Simon Glass <sjg@chromium.org> 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> --- test/py/console_base.py | 10 ++++++++++ test/py/tests/test_net_boot.py | 12 ++++-------- test/py/tests/test_zynqmp_rpu.py | 3 +-- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/test/py/console_base.py b/test/py/console_base.py index cbfd10fdf3d..3fbde86996c 100644 --- a/test/py/console_base.py +++ b/test/py/console_base.py @@ -637,6 +637,16 @@ class ConsoleBase(): pass self.p = None + def shutdown_required(self): + """Called to shut down the running U-Boot + + Some tests make changes to U-Boot which cannot be undone within the + test, such as booting an operating system. This function shuts down + U-Boot so that a new one will be started for any future tests + """ + self.drain_console() + self.cleanup_spawn() + def restart_uboot(self, expect_reset=False): """Shut down and restart U-Boot.""" self.cleanup_spawn() diff --git a/test/py/tests/test_net_boot.py b/test/py/tests/test_net_boot.py index 93ef1edf033..34fac8e3b94 100644 --- a/test/py/tests/test_net_boot.py +++ b/test/py/tests/test_net_boot.py @@ -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() diff --git a/test/py/tests/test_zynqmp_rpu.py b/test/py/tests/test_zynqmp_rpu.py index cda8c9203b7..479dca83d6d 100644 --- a/test/py/tests/test_zynqmp_rpu.py +++ b/test/py/tests/test_zynqmp_rpu.py @@ -218,5 +218,4 @@ def test_zynqmp_rpu_app_load_negative(ubman): disable_cpus(ubman, cpu_nums) # This forces the console object to be shutdown, so any subsequent test # will reset the board back into U-Boot. - ubman.drain_console() - ubman.cleanup_spawn() + ubman.shutdown_required() -- 2.43.0