diff mbox

[U-Boot,10/14] test/py: Add a helper to run a list of U-Boot commands

Message ID 1467560446-10628-11-git-send-email-sjg@chromium.org
State Accepted
Commit 73a9054d0f33dc4612a13200c6f3af00d2a1fcda
Delegated to: Tom Rini
Headers show

Commit Message

Simon Glass July 3, 2016, 3:40 p.m. UTC
Some tests want to execute a sequence of commands. Add a helper for this.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 test/py/u_boot_console_base.py | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Comments

Teddy Reed July 3, 2016, 9:12 p.m. UTC | #1
Hi Simon,

On Sun, Jul 3, 2016 at 8:40 AM, Simon Glass <sjg@chromium.org> wrote:
> Some tests want to execute a sequence of commands. Add a helper for this.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>

Reviewed-by: Teddy Reed <teddy.reed@gmail.com>

> ---
>
>  test/py/u_boot_console_base.py | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
>
> diff --git a/test/py/u_boot_console_base.py b/test/py/u_boot_console_base.py
> index 815fa64..b5aad7c 100644
> --- a/test/py/u_boot_console_base.py
> +++ b/test/py/u_boot_console_base.py
> @@ -216,6 +216,22 @@ class ConsoleBase(object):
>              self.cleanup_spawn()
>              raise
>
> +    def run_command_list(self, cmds):
> +        """Run a list of commands.
> +
> +        This is a helper function to call run_command() with default arguments
> +        for each command in a list.
> +
> +        Args:
> +            cmd: List of commands (each a string)

nit, in most other docstrings, these Args and Return lines have punctuation.

> +        Returns:
> +            Combined output of all commands, as a string
> +        """
> +        output = ''
> +        for cmd in cmds:
> +            output += self.run_command(cmd)

Although this fits the prototypes for other run_* functions, a list of
output strings is much easier to test and reason about. :/

> +        return output
> +
>      def ctrlc(self):
>          """Send a CTRL-C character to U-Boot.
>
> --
> 2.8.0.rc3.226.g39d4020
>
> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
Tom Rini July 16, 2016, 1:50 p.m. UTC | #2
On Sun, Jul 03, 2016 at 09:40:42AM -0600, Simon Glass wrote:

> Some tests want to execute a sequence of commands. Add a helper for this.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Reviewed-by: Teddy Reed <teddy.reed@gmail.com>

Applied to u-boot/master, thanks!
Tom Rini July 16, 2016, 1:50 p.m. UTC | #3
On Sun, Jul 03, 2016 at 09:40:42AM -0600, Simon Glass wrote:

> Some tests want to execute a sequence of commands. Add a helper for this.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Reviewed-by: Teddy Reed <teddy.reed@gmail.com>

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

Patch

diff --git a/test/py/u_boot_console_base.py b/test/py/u_boot_console_base.py
index 815fa64..b5aad7c 100644
--- a/test/py/u_boot_console_base.py
+++ b/test/py/u_boot_console_base.py
@@ -216,6 +216,22 @@  class ConsoleBase(object):
             self.cleanup_spawn()
             raise
 
+    def run_command_list(self, cmds):
+        """Run a list of commands.
+
+        This is a helper function to call run_command() with default arguments
+        for each command in a list.
+
+        Args:
+            cmd: List of commands (each a string)
+        Returns:
+            Combined output of all commands, as a string
+        """
+        output = ''
+        for cmd in cmds:
+            output += self.run_command(cmd)
+        return output
+
     def ctrlc(self):
         """Send a CTRL-C character to U-Boot.