[U-Boot] [PATCH 2/3] test/py: Allow to pass u_boot_log instead of console for run_and_log
Stefan Brüns
stefan.bruens at rwth-aachen.de
Sat Nov 5 17:45:33 CET 2016
The runner actually has no console dependency, only on the log provided
by the console. Accept both u_boot_console or a multiplexed_log.
Signed-off-by: Stefan Brüns <stefan.bruens at rwth-aachen.de>
---
test/py/u_boot_utils.py | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/test/py/u_boot_utils.py b/test/py/u_boot_utils.py
index 2ba4bae..c80cf07 100644
--- a/test/py/u_boot_utils.py
+++ b/test/py/u_boot_utils.py
@@ -153,7 +153,7 @@ def wait_until_file_open_fails(fn, ignore_errors):
return
raise Exception('File can still be opened')
-def run_and_log(u_boot_console, cmd, ignore_errors=False):
+def run_and_log(u_boot_console_or_log, cmd, ignore_errors=False):
"""Run a command and log its output.
Args:
@@ -171,7 +171,10 @@ def run_and_log(u_boot_console, cmd, ignore_errors=False):
"""
if isinstance(cmd, str):
cmd = cmd.split()
- runner = u_boot_console.log.get_runner(cmd[0], sys.stdout)
+ try:
+ runner = u_boot_console_or_log.get_runner(cmd[0], sys.stdout)
+ except:
+ runner = u_boot_console_or_log.log.get_runner(cmd[0], sys.stdout)
output = runner.run(cmd, ignore_errors=ignore_errors)
runner.close()
return output
@@ -189,7 +192,10 @@ def run_and_log_expect_exception(u_boot_console, cmd, retcode, msg):
msg: String that should be contained within the command's output.
"""
try:
+ runner = u_boot_console.get_runner(cmd[0], sys.stdout)
+ except:
runner = u_boot_console.log.get_runner(cmd[0], sys.stdout)
+ try:
runner.run(cmd)
except Exception as e:
assert(retcode == runner.exit_status)
--
2.10.1
More information about the U-Boot
mailing list