test/py: Handle expected reboot while booting sandbox

Add expected_reset optional argument to ConsoleBase::ensure_spawned(),
ConsoleBase::restart_uboot() and ConsoleSandbox::restart_uboot_with_flags()
so that it can handle a reset while the 1st boot process after main
boot logo before prompt correctly.

Signed-off-by: Masami Hiramatsu <masami.hiramatsu@linaro.org>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
This commit is contained in:
Masami Hiramatsu
2022-02-16 15:16:02 +09:00
committed by Heinrich Schuchardt
parent 06396e2e66
commit e7233c9c93
2 changed files with 33 additions and 22 deletions

View File

@@ -57,11 +57,14 @@ class ConsoleSandbox(ConsoleBase):
cmd += self.sandbox_flags
return Spawn(cmd, cwd=self.config.source_dir)
def restart_uboot_with_flags(self, flags):
def restart_uboot_with_flags(self, flags, expect_reset=False):
"""Run U-Boot with the given command-line flags
Args:
flags: List of flags to pass, each a string
expect_reset: Boolean indication whether this boot is expected
to be reset while the 1st boot process after main boot before
prompt. False by default.
Returns:
A u_boot_spawn.Spawn object that is attached to U-Boot.
@@ -69,7 +72,7 @@ class ConsoleSandbox(ConsoleBase):
try:
self.sandbox_flags = flags
return self.restart_uboot()
return self.restart_uboot(expect_reset)
finally:
self.sandbox_flags = []