[PATCH RFC next 01/18] test/py: add pytest --make-args argument for additional Make arguments

Quentin Schulz foss+uboot at 0leil.net
Mon May 4 15:20:28 CEST 2026


From: Quentin Schulz <quentin.schulz at cherry.de>

We manually execute make commands within some tests, sometimes from
"dirty" build directories.

One example is the test_env_initial_env_file test which calls
make u-boot-initial-env
in a build directory that has already been populated possibly before
pytest is run (which is the case in our GitLab CI/CD).

In "sandbox with clang test.py" and "sandbox64 with clang test.py" we
build before pytest with clang-20 but pytest will call make without
setting HOSTCC or CC to clang-20, which results in clang flags being
used with gcc. Right now, it isn't triggering a build issue because we
use cc-disable-warning to disable the warning only if it's available, so
the clang flags aren't added. However, in a few commits we'll bump
scripts/Makefile.extrawarn to a newer version from the Linux kernel
(6.1) and it won't be used anymore, thus triggering fails.

Add an option to specify make arguments such that a user can provide
HOSTCC and CC for when the build directory to reuse has been built with
clang.

Signed-off-by: Quentin Schulz <quentin.schulz at cherry.de>
---
 test/py/conftest.py                 | 6 ++++--
 test/py/tests/test_cleanup_build.py | 4 ++--
 test/py/tests/test_env.py           | 4 ++--
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/test/py/conftest.py b/test/py/conftest.py
index 215aaa56534..a26aaee7b2f 100644
--- a/test/py/conftest.py
+++ b/test/py/conftest.py
@@ -95,6 +95,8 @@ def pytest_addoption(parser):
         help="Assume that U-Boot is ready and don't wait for a prompt")
     parser.addoption('--timing', default=False, action='store_true',
                      help='Show info on test timing')
+    parser.addoption('--make-args', action='append', default=[],
+                     help='Provide arguments to pass to the "make" command, e.g. HOSTCC=clang-20')
 
 
 def run_build(config, source_dir, build_dir, board_type, log):
@@ -120,8 +122,8 @@ def run_build(config, source_dir, build_dir, board_type, log):
         else:
             o_opt = ''
         cmds = (
-            ['make', o_opt, '-s', board_type + '_defconfig'],
-            ['make', o_opt, '-s', '-j{}'.format(os.cpu_count())],
+            ['make', *config.getoption('make_args'), o_opt, '-s', board_type + '_defconfig'],
+            ['make', *config.getoption('make_args'), o_opt, '-s', '-j{}'.format(os.cpu_count())],
         )
         name = 'make'
 
diff --git a/test/py/tests/test_cleanup_build.py b/test/py/tests/test_cleanup_build.py
index aca90cb1107..10568a68ef5 100644
--- a/test/py/tests/test_cleanup_build.py
+++ b/test/py/tests/test_cleanup_build.py
@@ -32,12 +32,12 @@ def tmp_copy_of_builddir(u_boot_config, tmp_path):
 
 
 @pytest.fixture(scope="module")
-def run_make(u_boot_log):
+def run_make(pytestconfig, u_boot_log):
     """Provide function to run and log make without connecting to u-boot console."""
     runner = u_boot_log.get_runner("make", sys.stdout)
 
     def _run_make(build_dir, target):
-        cmd = ["make", f"O={build_dir}", target]
+        cmd = ["make", *pytestconfig.getoption("make_args"), f"O={build_dir}", target]
         runner.run(cmd)
 
     yield _run_make
diff --git a/test/py/tests/test_env.py b/test/py/tests/test_env.py
index f8713a59ba9..0e52c5d2a13 100644
--- a/test/py/tests/test_env.py
+++ b/test/py/tests/test_env.py
@@ -175,7 +175,7 @@ def validate_set(state_test_env, var, value):
     assert response == ('%s=%s' % (var, value))
 
 @pytest.mark.boardspec('sandbox')
-def test_env_initial_env_file(ubman):
+def test_env_initial_env_file(pytestconfig, ubman):
     """Test that the u-boot-initial-env make target works"""
     builddir = 'O=' + ubman.config.build_dir
     envfile = ubman.config.build_dir + '/u-boot-initial-env'
@@ -186,7 +186,7 @@ def test_env_initial_env_file(ubman):
     except:
         pass
 
-    utils.run_and_log(ubman, ['make', builddir, 'u-boot-initial-env'])
+    utils.run_and_log(ubman, ['make', *pytestconfig.getoption('make_args'), builddir, 'u-boot-initial-env'])
 
     assert os.path.exists(envfile)
 

-- 
2.54.0



More information about the U-Boot mailing list