[U-Boot] [PATCH 08/14] test/py: Add an option to execute a string containing a command

Teddy Reed
2016-07-03T20:25:20Z

Hi Simon,

On Sun, Jul 3, 2016 at 8:40 AM, Simon Glass <sjg@chromium.org> wrote:
> It is sometimes inconvenient to convert a string into a list for execution
> with run_and_log(). Provide a helper function to do this.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>

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

> ---
>
> test/py/u_boot_utils.py | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/test/py/u_boot_utils.py b/test/py/u_boot_utils.py
> index 5dc0f71..5d638d9 100644
> --- a/test/py/u_boot_utils.py
> +++ b/test/py/u_boot_utils.py
> @@ -173,6 +173,18 @@ def run_and_log(u_boot_console, cmd, ignore_errors=False):
> runner.close()
> return output
>
> +def cmd(u_boot_console, cmd_str):
> + """Run a single command string and log its output.
> +
> + Args:
> + u_boot_console: A console connection to U-Boot.
> + cmd: The command to run, as a string.

cmd_str

> +
> + Returns:
> + The output as a string.
> + """
> + return run_and_log(u_boot_console, cmd_str.split())

The default behavior for `string.split` is to remove most whitespace
tokens and use any, or any consecutive set, as a delimiter.

In the case of:

$ cmd_str = 'here "are three" arguments'
$ cmd_str.split()
['here', '"are', 'three"', 'arguments']

If this is an acceptable side-effect or handled elsewhere, it seems reasonable.

> +
> ram_base = None
> def find_ram_base(u_boot_console):
> """Find the running U-Boot's RAM location.
> --
> 2.8.0.rc3.226.g39d4020
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot

--
Teddy Reed V