support/testing: infra: add host bin dir to PATH when running host command

Some host commands need to call other host commands: For example,
"mkimage" from host-uboot-tools needs to run "dtc". This would fail or
call system commands without adding the host bin dir to PATH.

Signed-off-by: Fiona Klute <fiona.klute@gmx.de>
[Julien: use python functions/constants to build path]
Signed-off-by: Julien Olivain <ju.o@free.fr>
This commit is contained in:
Fiona Klute
2025-11-16 21:20:52 +01:00
committed by Julien Olivain
parent 39b925a0a6
commit befb6ae81d

View File

@@ -60,9 +60,14 @@ def download(dldir, filename):
def run_cmd_on_host(builddir, cmd):
"""Call subprocess.check_output and return the text output."""
try:
host_bin = os.path.join(builddir, "host", "bin")
br_path = host_bin + os.pathsep + os.environ["PATH"]
out = subprocess.check_output(cmd,
cwd=builddir,
env={"LANG": "C"},
env={
"LANG": "C",
"PATH": br_path
},
stderr=subprocess.STDOUT,
text=True,
universal_newlines=True)