diff mbox series

[U-Boot,v3,12/21] test/py: Add a way to pass flags to sandbox

Message ID 20181116014409.147279-13-sjg@chromium.org
State Accepted
Delegated to: Tom Rini
Headers show
Series spl: Add features for passing info from SPL to U-Boot proper | expand

Commit Message

Simon Glass Nov. 16, 2018, 1:44 a.m. UTC
It is sometimes useful to restart sandbox with some particular flags to
test certain functionality. Add a new method to ConsoleSandbox to handle
this, without changing the existing APIs.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Stephen Warren <swarren@nvidia.com>
---

Changes in v3: None
Changes in v2:
- Add back a blank line, and put one in the new function too

 test/py/u_boot_console_sandbox.py | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

Comments

Tom Rini Nov. 26, 2018, 6:44 p.m. UTC | #1
On Thu, Nov 15, 2018 at 06:44:00PM -0700, Simon Glass wrote:

> It is sometimes useful to restart sandbox with some particular flags to
> test certain functionality. Add a new method to ConsoleSandbox to handle
> this, without changing the existing APIs.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Acked-by: Stephen Warren <swarren@nvidia.com>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/test/py/u_boot_console_sandbox.py b/test/py/u_boot_console_sandbox.py
index 778f6d0983d..836f5a9e2b8 100644
--- a/test/py/u_boot_console_sandbox.py
+++ b/test/py/u_boot_console_sandbox.py
@@ -24,6 +24,7 @@  class ConsoleSandbox(ConsoleBase):
         """
 
         super(ConsoleSandbox, self).__init__(log, config, max_fifo_fill=1024)
+        self.sandbox_flags = []
 
     def get_spawn(self):
         """Connect to a fresh U-Boot instance.
@@ -51,8 +52,25 @@  class ConsoleSandbox(ConsoleBase):
             '-d',
             self.config.dtb
         ]
+        cmd += self.sandbox_flags
         return Spawn(cmd, cwd=self.config.source_dir)
 
+    def restart_uboot_with_flags(self, flags):
+        """Run U-Boot with the given command-line flags
+
+        Args:
+            flags: List of flags to pass, each a string
+
+        Returns:
+            A u_boot_spawn.Spawn object that is attached to U-Boot.
+        """
+
+        try:
+            self.sandbox_flags = flags
+            return self.restart_uboot()
+        finally:
+            self.sandbox_flags = []
+
     def kill(self, sig):
         """Send a specific Unix signal to the sandbox process.