From 01dc13adfb7486cb05e655d0b58f5490a0d046ea Mon Sep 17 00:00:00 2001 From: Thomas Petazzoni Date: Sat, 18 Oct 2025 21:42:59 +0200 Subject: [PATCH] support/testing/infra: improve run_cmd_on_host() to show stdout/stderr When run_cmd_on_host() runs a command that fails, we only get an exception with no details to debug what happened. Let's improve that by catching the exception, and printing the command output. This requires redirecting stderr to stdout (instead of /dev/null) and asking to get the output in text format. Signed-off-by: Thomas Petazzoni Signed-off-by: Julien Olivain --- support/testing/infra/__init__.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/support/testing/infra/__init__.py b/support/testing/infra/__init__.py index 1f003f24c6..52308395a3 100644 --- a/support/testing/infra/__init__.py +++ b/support/testing/infra/__init__.py @@ -59,11 +59,20 @@ def download(dldir, filename): def run_cmd_on_host(builddir, cmd): """Call subprocess.check_output and return the text output.""" - out = subprocess.check_output(cmd, - stderr=open(os.devnull, "w"), - cwd=builddir, - env={"LANG": "C"}, - universal_newlines=True) + try: + out = subprocess.check_output(cmd, + cwd=builddir, + env={"LANG": "C"}, + stderr=subprocess.STDOUT, + text=True, + universal_newlines=True) + except subprocess.CalledProcessError as e: + print(f"Command failed with return code {e.returncode}") + print("=== STDOUT/STDERR ===") + print(e.output) + print("=====================") + raise + return out