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.bru...@rwth-aachen.de> --- test/py/u_boot_utils.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/test/py/u_boot_utils.py b/test/py/u_boot_utils.py index 2ba4baed07..b9a72ab1de 100644 --- a/test/py/u_boot_utils.py +++ b/test/py/u_boot_utils.py @@ -153,11 +153,11 @@ 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: - u_boot_console: A console connection to U-Boot. + u_boot_console_or_log: A console connection to U-Boot, or a LogFile. 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"'] @@ -171,25 +171,33 @@ 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) + if hasattr(u_boot_console_or_log, 'get_runner'): + get_runner = u_boot_console_or_log.get_runner + else: + get_runner = u_boot_console_or_log.log.get_runner + runner = get_runner(cmd[0], sys.stdout) output = runner.run(cmd, ignore_errors=ignore_errors) runner.close() return output -def run_and_log_expect_exception(u_boot_console, cmd, retcode, msg): +def run_and_log_expect_exception(u_boot_console_or_log, cmd, retcode, msg): """Run a command that is expected to fail. This runs a command and checks that it fails with the expected return code and exception method. If not, an exception is raised. Args: - u_boot_console: A console connection to U-Boot. + u_boot_console_or_log: A console connection to U-Boot, or a LogFile. cmd: The command to run, as an array of argv[]. retcode: Expected non-zero return code from the command. msg: String that should be contained within the command's output. """ + if hasattr(u_boot_console_or_log, 'get_runner'): + get_runner = u_boot_console_or_log.get_runner + else: + get_runner = u_boot_console_or_log.log.get_runner + runner = get_runner(cmd[0], sys.stdout) try: - runner = u_boot_console.log.get_runner(cmd[0], sys.stdout) runner.run(cmd) except Exception as e: assert(retcode == runner.exit_status) -- 2.11.0 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot