[PATCH 0/3] buildman: Enable code coverage in CI
From: Simon Glass <simon.glass@canonical.com> This little series fixes a few things in buildman so that we can check the code coverage, although only a few files have 100% at this point. Simon Glass (3): buildman: Fix coverage test configuration buildman: Fix flaky test_kconfig_change test CI: Add buildman coverage test .gitlab-ci.yml | 10 ++++++++++ tools/buildman/func_test.py | 7 +++++-- tools/buildman/main.py | 9 +++++++-- 3 files changed, 22 insertions(+), 4 deletions(-) -- 2.43.0 base-commit: 986b6352c345adfbe7d93fd7b8b86ed1fa198c6a branch: bmk
From: Simon Glass <simon.glass@canonical.com> Exclude tools/qconfig.py from coverage since it's a separate tool with its own tests. Add allow_failures for core buildman modules that don't have 100% test coverage yet (builder.py, builderthread.py, cfgutil.py, control.py, toolchain.py). This fixes the --coverage test returning error code 1. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- tools/buildman/main.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/buildman/main.py b/tools/buildman/main.py index 3c9820b262a..22be946b37d 100755 --- a/tools/buildman/main.py +++ b/tools/buildman/main.py @@ -63,8 +63,13 @@ def run_test_coverage(): 'tools/buildman/buildman', None, ['tools/patman/*.py', 'tools/u_boot_pylib/*', '*test_fdt.py', 'tools/buildman/kconfiglib.py', 'tools/buildman/*test*.py', - 'tools/buildman/main.py'], - '/tmp/b', single_thread='-T1') + 'tools/buildman/main.py', 'tools/qconfig.py'], + '/tmp/b', single_thread='-T1', + allow_failures=['tools/buildman/builder.py', + 'tools/buildman/builderthread.py', + 'tools/buildman/cfgutil.py', + 'tools/buildman/control.py', + 'tools/buildman/toolchain.py']) def run_buildman(): -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> When CI has fewer CPUs than boards, one thread may process multiple boards. The .config from the first board persists in the thread's work directory, causing kconfig_changed_since() to return True for the next board's first commit, triggering an extra reconfig. Fix by forcing -T4 to ensure each board gets its own thread with an isolated work directory. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- tools/buildman/func_test.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/buildman/func_test.py b/tools/buildman/func_test.py index e748d302561..31cff04a060 100644 --- a/tools/buildman/func_test.py +++ b/tools/buildman/func_test.py @@ -1285,10 +1285,13 @@ something: me config_exists[0] = True return exists - # Run buildman with kconfig checking enabled + # Run buildman with kconfig checking enabled. Use -T4 to ensure each + # board gets its own thread, avoiding .config leaking between boards + # when a thread processes multiple boards (which happens with <4 CPUs) with mock.patch.object(builderthread, 'kconfig_changed_since', mock_kconfig_changed): - self._RunControl('-b', TEST_BRANCH, '-c2', '-o', self._output_dir) + self._RunControl('-b', TEST_BRANCH, '-c2', '-o', self._output_dir, + '-T4') # Verify kconfig_changed_since was called self.assertGreater(call_count[0], 0) -- 2.43.0
From: Simon Glass <simon.glass@canonical.com> Add a CI job to run buildman's test coverage check. This ensures test coverage doesn't regress when changes are made to buildman. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- .gitlab-ci.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 06cdb6500be..eec57710cbb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -305,6 +305,16 @@ Run binman, buildman, dtoc, hwids_to_dtsi, Kconfig, patman and pickman suites: python3 -m pytest ./test/scripts/test_release_version.py; make testconfig +Run buildman coverage: + extends: .test_suites + script: + - git config --global --add safe.directory "${CI_PROJECT_DIR}"; + python3 -m venv /tmp/venv; + . /tmp/venv/bin/activate; + pip install -r tools/buildman/requirements.txt + -r tools/u_boot_pylib/requirements.txt; + ./tools/buildman/buildman --coverage + # Check for any pylint regressions Run pylint: extends: .test_suites -- 2.43.0
participants (1)
-
Simon Glass