From ba87a2fcfbfb79813983f106c212684907ca6c55 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 14 Dec 2024 11:20:20 -0700 Subject: test/py: Provide the correct U_BOOT_SOURCE_DIR to getrole The u-boot-test-getrole script runs before the normal environment variables have been set up. This is unavoidable since the script is providing necessary information to test.py This means that U_BOOT_SOURCE_DIR is not set in the environment. As a result, Labgrid uses its default source path, configured in its environment variable. While this may happen to work, it is not correct. Also, it causes problems when running from Gitlab, where the runner may not have access to that source path. Provide the required source path in U_BOOT_SOURCE_DIR so that Labgrid does the right thing. Signed-off-by: Simon Glass Fixes: bf89a8f1fc2 ("test: Introduce the concept of a role") [1] https://patchwork.ozlabs.org/project/uboot/patch/20241211131858.520639-1-sjg@chromium.org/ --- test/py/conftest.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'test/py/conftest.py') diff --git a/test/py/conftest.py b/test/py/conftest.py index 6b7ed0586e2..44b22761a8b 100644 --- a/test/py/conftest.py +++ b/test/py/conftest.py @@ -161,6 +161,10 @@ def get_details(config): env['U_BOOT_BUILD_DIR'] = build_dir if build_dir_extra: env['U_BOOT_BUILD_DIR_EXTRA'] = build_dir_extra + + # Make sure the script sees that it is being run from pytest + env['U_BOOT_SOURCE_DIR'] = source_dir + proc = subprocess.run(cmd, capture_output=True, encoding='utf-8', env=env) if proc.returncode: -- cgit v1.2.3 From 64d5a0550a148c9266f5f66538f0d56bb2278bef Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 14 Dec 2024 11:20:21 -0700 Subject: test/py: Handle u-boot-test-getrole failure This script can fail if there is no toolchain available for the board. At present this is not handled very nicely, in that only the error output is reported. It is much more useful to see everything, so combine stdout and stderr and report them both. Signed-off-by: Simon Glass --- test/py/conftest.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'test/py/conftest.py') diff --git a/test/py/conftest.py b/test/py/conftest.py index 44b22761a8b..3bd333bfd24 100644 --- a/test/py/conftest.py +++ b/test/py/conftest.py @@ -165,10 +165,11 @@ def get_details(config): # Make sure the script sees that it is being run from pytest env['U_BOOT_SOURCE_DIR'] = source_dir - proc = subprocess.run(cmd, capture_output=True, encoding='utf-8', + proc = subprocess.run(cmd, stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, encoding='utf-8', env=env) if proc.returncode: - raise ValueError(proc.stderr) + raise ValueError(f"Error {proc.returncode} running {cmd}: '{proc.stderr} '{proc.stdout}'") # For debugging # print('conftest: lab:', proc.stdout) vals = {} -- cgit v1.2.3