summaryrefslogtreecommitdiff
path: root/test/py/multiplexed_log.py
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2021-11-28 20:38:01 -0500
committerTom Rini <trini@konsulko.com>2021-11-28 20:38:13 -0500
commitc087b5ad974441d1408c028eb7087d86b6d127e9 (patch)
tree1d5efba0d146dcd1a6a449963ea738cc6e4ff73e /test/py/multiplexed_log.py
parent1943f2a2a7c58b76812fcad2d3012036af7464ce (diff)
parent452e8c9086a9f95739582da5ccc2130e4bf1ae8b (diff)
Merge tag 'dm-pull-28nov21' of https://source.denx.de/u-boot/custodians/u-boot-dm into next
SPI flash documentation and tidy-ups Various driver model enhancements Fix up some missing unit tests with pytest
Diffstat (limited to 'test/py/multiplexed_log.py')
-rw-r--r--test/py/multiplexed_log.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/test/py/multiplexed_log.py b/test/py/multiplexed_log.py
index 545a7743022..6688207fb31 100644
--- a/test/py/multiplexed_log.py
+++ b/test/py/multiplexed_log.py
@@ -109,7 +109,7 @@ class RunAndLog(object):
"""Clean up any resources managed by this object."""
pass
- def run(self, cmd, cwd=None, ignore_errors=False):
+ def run(self, cmd, cwd=None, ignore_errors=False, stdin=None):
"""Run a command as a sub-process, and log the results.
The output is available at self.output which can be useful if there is
@@ -123,6 +123,7 @@ class RunAndLog(object):
function will simply return if the command cannot be executed
or exits with an error code, otherwise an exception will be
raised if such problems occur.
+ stdin: Input string to pass to the command as stdin (or None)
Returns:
The output as a string.
@@ -135,8 +136,9 @@ class RunAndLog(object):
try:
p = subprocess.Popen(cmd, cwd=cwd,
- stdin=None, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
- (stdout, stderr) = p.communicate()
+ stdin=subprocess.PIPE if stdin else None,
+ stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ (stdout, stderr) = p.communicate(input=stdin)
if stdout is not None:
stdout = stdout.decode('utf-8')
if stderr is not None:
@@ -163,7 +165,7 @@ class RunAndLog(object):
if output and not output.endswith('\n'):
output += '\n'
if exit_status and not exception and not ignore_errors:
- exception = Exception('Exit code: ' + str(exit_status))
+ exception = ValueError('Exit code: ' + str(exit_status))
if exception:
output += str(exception) + '\n'
self.logfile.write(self, output)