[PATCH 1/5] test/py: Provide the correct U_BOOT_SOURCE_DIR to getrole

Simon Glass sjg at chromium.org
Sat Dec 14 19:20:20 CET 2024


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 <sjg at chromium.org>
Fixes: bf89a8f1fc2 ("test: Introduce the concept of a role")

[1] https://patchwork.ozlabs.org/project/uboot/patch/20241211131858.520639-1-sjg@chromium.org/

---
This patch is intended to be applied on top of [1], which fixes a
similar issue, but only within pytest itself. It should be possible to
drop that patch and just use this one, but it is a bit nonsensical to
ask Labgrid for something which test.py already knows, so both patches
are valuable.

 test/py/conftest.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/test/py/conftest.py b/test/py/conftest.py
index 509d19b449d..acc7e5e090c 100644
--- a/test/py/conftest.py
+++ b/test/py/conftest.py
@@ -158,6 +158,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:
-- 
2.34.1



More information about the U-Boot mailing list