Skip to contentSkip to conversation

test/py: multiplexed_log.py: Clean up and correct RunAndLog()

PATCH In review Tom Rini 1 participant 2 messages Oct 24, 2025 – Nov 7, 2025

lore
Share & tools
lore

Tom Rini

author
#0 lore raw

PATCH 1/1 test/py: multiplexed_log.py: Clean up and correct RunAndLog()

The general python documentation for the subprocess class recommends that run() be used in all cases that it can handle. What we do in RunAndLog is simple enough that run() is easy to switch to. In fact, looking at this exposed a problem we have today, which is that we had combined stdout and stderr but then looked at both stdout and stderr as if they were separate. Stop combining them.

---
 test/py/multiplexed_log.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
test/py/multiplexed_log.py +4 -4
index 63237594bb40..68dc183e4638 100644
@@ -138,10 +138,10 @@ class RunAndLog(object):
         self.logfile.write(self, msg)
 
         try:
-            p = subprocess.Popen(cmd, cwd=cwd,
-                stdin=subprocess.PIPE if stdin else None,
-                stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=env)
-            (stdout, stderr) = p.communicate(input=stdin)
+            p = subprocess.run(cmd, cwd=cwd, capture_output=True, input=stdin,
+                               env=env)
+            stdout = p.stdout
+            stderr = p.stderr
             if stdout is not None:
                 stdout = stdout.decode('utf-8')
             if stderr is not None:
Signature · 1 line
2.43.0
author
#1 lore raw
Quoted 8 lines · Tom Rini

The general python documentation for the subprocess class recommends that run() be used in all cases that it can handle. What we do in RunAndLog is simple enough that run() is easy to switch to. In fact, looking at this exposed a problem we have today, which is that we had combined stdout and stderr but then looked at both stdout and stderr as if they were separate. Stop combining them.

[...]

Applied to u-boot/master, thanks!

[1/1] test/py: multiplexed_log.py: Clean up and correct RunAndLog()

      commit: 20b822dd4f01a7489f888460f70d7830e0513965
Signature · 1 line
Tom