test/py: Add a way to start sandbox without a device tree

This is useful sometimes when running a specific test. Add support for it
in the existing restart_uboot_with_flags() function.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass 2022-04-27 13:47:56 -06:00 committed by Tom Rini
parent 55a8bb94f9
commit ee93f6129d

View File

@ -27,6 +27,7 @@ class ConsoleSandbox(ConsoleBase):
super(ConsoleSandbox, self).__init__(log, config, max_fifo_fill=1024) super(ConsoleSandbox, self).__init__(log, config, max_fifo_fill=1024)
self.sandbox_flags = [] self.sandbox_flags = []
self.use_dtb = True
def get_spawn(self): def get_spawn(self):
"""Connect to a fresh U-Boot instance. """Connect to a fresh U-Boot instance.
@ -53,16 +54,13 @@ class ConsoleSandbox(ConsoleBase):
cmd = [] cmd = []
if self.config.gdbserver: if self.config.gdbserver:
cmd += ['gdbserver', self.config.gdbserver] cmd += ['gdbserver', self.config.gdbserver]
cmd += [ cmd += [self.config.build_dir + fname, '-v']
self.config.build_dir + fname, if self.use_dtb:
'-v', cmd += ['-d', self.config.dtb]
'-d',
self.config.dtb
]
cmd += self.sandbox_flags cmd += self.sandbox_flags
return Spawn(cmd, cwd=self.config.source_dir) return Spawn(cmd, cwd=self.config.source_dir)
def restart_uboot_with_flags(self, flags, expect_reset=False): def restart_uboot_with_flags(self, flags, expect_reset=False, use_dtb=True):
"""Run U-Boot with the given command-line flags """Run U-Boot with the given command-line flags
Args: Args:
@ -70,6 +68,7 @@ class ConsoleSandbox(ConsoleBase):
expect_reset: Boolean indication whether this boot is expected expect_reset: Boolean indication whether this boot is expected
to be reset while the 1st boot process after main boot before to be reset while the 1st boot process after main boot before
prompt. False by default. prompt. False by default.
use_dtb: True to use a device tree file, False to run without one
Returns: Returns:
A u_boot_spawn.Spawn object that is attached to U-Boot. A u_boot_spawn.Spawn object that is attached to U-Boot.
@ -77,9 +76,11 @@ class ConsoleSandbox(ConsoleBase):
try: try:
self.sandbox_flags = flags self.sandbox_flags = flags
self.use_dtb = use_dtb
return self.restart_uboot(expect_reset) return self.restart_uboot(expect_reset)
finally: finally:
self.sandbox_flags = [] self.sandbox_flags = []
self.use_dtb = True
def kill(self, sig): def kill(self, sig):
"""Send a specific Unix signal to the sandbox process. """Send a specific Unix signal to the sandbox process.