diff options
author | Simon Glass <sjg@chromium.org> | 2016-07-31 17:35:05 -0600 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2016-08-05 20:55:20 -0400 |
commit | ec70f8a911885a6ca798ca01f99d0d367a6e07e7 (patch) | |
tree | 59bc1898a5cd4929a773713bcb6e16510c4f2f2e /test/py/u_boot_utils.py | |
parent | 72f52268942c3500b1a15db5e59ab406b58a9260 (diff) | |
download | u-boot-ec70f8a911885a6ca798ca01f99d0d367a6e07e7.tar.gz u-boot-ec70f8a911885a6ca798ca01f99d0d367a6e07e7.tar.bz2 u-boot-ec70f8a911885a6ca798ca01f99d0d367a6e07e7.zip |
test: Drop the cmd() function
Instead of this, use the existing run_and_log() function, enhanced to
support a command string as well as a list of arguments.
Suggested-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test/py/u_boot_utils.py')
-rw-r--r-- | test/py/u_boot_utils.py | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/test/py/u_boot_utils.py b/test/py/u_boot_utils.py index e74e34231f..2ba4baed07 100644 --- a/test/py/u_boot_utils.py +++ b/test/py/u_boot_utils.py @@ -158,7 +158,9 @@ def run_and_log(u_boot_console, cmd, ignore_errors=False): Args: u_boot_console: A console connection to U-Boot. - cmd: The command to run, as an array of argv[]. + cmd: The command to run, as an array of argv[], or a string. + If a string, note that it is split up so that quoted spaces + will not be preserved. E.g. "fred and" becomes ['"fred', 'and"'] ignore_errors: Indicate whether to ignore errors. If True, the function will simply return if the command cannot be executed or exits with an error code, otherwise an exception will be raised if such @@ -167,24 +169,13 @@ def run_and_log(u_boot_console, cmd, ignore_errors=False): Returns: The output as a string. """ - + if isinstance(cmd, str): + cmd = cmd.split() runner = u_boot_console.log.get_runner(cmd[0], sys.stdout) output = runner.run(cmd, ignore_errors=ignore_errors) 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. - - Returns: - The output as a string. - """ - return run_and_log(u_boot_console, cmd_str.split()) - def run_and_log_expect_exception(u_boot_console, cmd, retcode, msg): """Run a command that is expected to fail. |