diff options
author | Jeremy Bettis <jbettis@google.com> | 2021-12-01 12:16:29 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-12-01 23:08:41 +0000 |
commit | 9e6cf67e91c7432aef9609b2a9778125b07146b1 (patch) | |
tree | ef9128d83c10b75a9a54d86656151ebfb87ab3ed | |
parent | 5d6dfc1e5f91583c7e26d27073a6401224fe32c5 (diff) | |
download | chrome-ec-9e6cf67e91c7432aef9609b2a9778125b07146b1.tar.gz |
zephyr: Change order of coverage merges
Change `zmake configure --coverage --build` to only build the
all.libraries target (instead of failing as it does now), and generate
an lcov file.
Change `zmake coverage` to skip non-test projects. It hasn't actually
been useful to have a coverage report that includes all projects.
Change .gitlab-ci.yml commands from
build tests & boards coverage, merge, remove zephyr dirs, remove
non-board files, generate report
to build tests, merge, remove zephyr dirs, build board coverage, remove
zephyr dirs, merge with tests, remove non-board files, generate report.
This should increase coverage numbers, because we won't include #ifdefs
that both the board and tests don't use, but other boards do use. This
does not fix the problem of a test having an #ifdef that the board
doesn't have, but those should be smaller, and easier to fix.
Before: https://gitlab.com/zephyr-ec/ec/-/pipelines/420506965/builds
After: https://gitlab.com/zephyr-ec/ec/-/pipelines/420547936/builds
BRANCH=None
BUG=b:207689703
TEST=Pushed to gitlab coverage branch
Change-Id: Ifad0d098e5db9ef0ee55b760aaa7a8da9d006387
Signed-off-by: Jeremy Bettis <jbettis@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3310533
Tested-by: Jeremy Bettis <jbettis@chromium.org>
Auto-Submit: Jeremy Bettis <jbettis@chromium.org>
Commit-Queue: Tristan Honscheid <honscheid@google.com>
Reviewed-by: Tristan Honscheid <honscheid@google.com>
-rw-r--r-- | .gitlab-ci.yml | 29 | ||||
-rw-r--r-- | zephyr/zmake/zmake/zmake.py | 45 |
2 files changed, 51 insertions, 23 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6fe0eda1b1..e1956e46e2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -89,16 +89,37 @@ seed_cache: # Users of this template must set: # $PROJECT to the project to build. E.g., "lazor" +# Builds the project with coverage enabled, removes the non-ec files. +# Then merges with the tests, excludes all files not used by this project, +# and generates a report. .coverage_template: &coverage_template stage: test needs: ["merged_coverage", "zephyr_coverage"] script: - - grep "SF:" "build/zcoverage/${PROJECT}.info" | sort -u | sed -e 's|^SF:||' | xargs lcov -o build/no_zephyr_${PROJECT}.info -e build/merged_no_zephyr.info - - /usr/bin/genhtml -q -o build/no_zephyr_${PROJECT}_rpt -t "${PROJECT} coverage w/o zephyr" -p ${EC_DIR} -s build/no_zephyr_${PROJECT}.info + - zmake --zephyr-base "${ZEPHYR_BASE}" + --modules-dir "${MODULES_DIR}" -l DEBUG configure -b --coverage + -B "${BUILD_DIR}/${PROJECT}" -t ${TOOLCHAIN:-zephyr} + "${PROJECT}" + - lcov -o "${BUILD_DIR}/${PROJECT}/merged.info" + -a "${BUILD_DIR}/${PROJECT}/lcov.info" -a build/merged.info + - lcov -o "${BUILD_DIR}/${PROJECT}/no_zephyr.info" + -r "${BUILD_DIR}/${PROJECT}/lcov.info" "${ZEPHYR_BASE}/**" + "${MODULES_DIR}/*" "zephyr/drivers/*" '/usr/include/x86_64-linux-gnu/*' + - lcov -o "${BUILD_DIR}/${PROJECT}/merged_no_zephyr.info" + -r "${BUILD_DIR}/${PROJECT}/merged.info" "${ZEPHYR_BASE}/**" + "${MODULES_DIR}/*" "zephyr/drivers/*" '/usr/include/x86_64-linux-gnu/*' + - grep "SF:" "${BUILD_DIR}/${PROJECT}/no_zephyr.info" | sort -u | + sed -e 's|^SF:||' | xargs lcov + -o "${BUILD_DIR}/${PROJECT}/filtered_no_zephyr.info" + -e "${BUILD_DIR}/${PROJECT}/merged_no_zephyr.info" + - /usr/bin/genhtml -q -o "${BUILD_DIR}/${PROJECT}/filtered_no_zephyr_rpt" + -t "${PROJECT} coverage w/o zephyr" + -p ${EC_DIR} + -s "${BUILD_DIR}/${PROJECT}/filtered_no_zephyr.info" artifacts: paths: - - build/*.info - - build/*_rpt + - build/${PROJECT}/*.info + - build/${PROJECT}/*_rpt expire_in: 1 week coverage: '/lines\.*: \d+\.\d+%/' diff --git a/zephyr/zmake/zmake/zmake.py b/zephyr/zmake/zmake/zmake.py index 713c6773e3..3165209a10 100644 --- a/zephyr/zmake/zmake/zmake.py +++ b/zephyr/zmake/zmake/zmake.py @@ -362,7 +362,15 @@ class Zmake: is_configured=True, ) elif build_after_configure: - return self.build(build_dir=build_dir) + if coverage: + return self._coverage_compile_only( + project=project, + build_dir=build_dir, + lcov_file=build_dir / "lcov.info", + is_configured=True, + ) + else: + return self.build(build_dir=build_dir) def build(self, build_dir, output_files_out=None, fail_on_warnings=False): """Build a pre-configured build directory.""" @@ -617,17 +625,20 @@ class Zmake: return 0 - def _coverage_compile_only(self, project, build_dir, lcov_file): + def _coverage_compile_only( + self, project, build_dir, lcov_file, is_configured=False + ): self.logger.info("Building %s in %s", project.config.project_name, build_dir) - rv = self._configure( - project=project, - build_dir=build_dir, - build_after_configure=False, - test_after_configure=False, - coverage=True, - ) - if rv: - return rv + if not is_configured: + rv = self._configure( + project=project, + build_dir=build_dir, + build_after_configure=False, + test_after_configure=False, + coverage=True, + ) + if rv: + return rv # Compute the version string. version_string = zmake.version.get_version_string( @@ -652,7 +663,7 @@ class Zmake: dirs = {} gcov = "gcov.sh-not-found" for build_name, build_config in build_project.iter_builds(): - self.logger.info("Building %s:%s all.libraries.", build_dir, build_name) + self.logger.info("ls build/.", build_dir, build_name) dirs[build_name] = build_dir / "build-{}".format(build_name) gcov = dirs[build_name] / "gcov.sh" proc = self.jobserver.popen( @@ -725,21 +736,17 @@ class Zmake: lcov_file = pathlib.Path(build_dir) / "{}.info".format( project.config.project_name ) - all_lcov_files.append(lcov_file) if is_test: # Configure and run the test. + all_lcov_files.append(lcov_file) self.executor.append( func=lambda: self._coverage_run_test( project, project_build_dir, lcov_file ) ) else: - # Configure and compile the non-test project. - self.executor.append( - func=lambda: self._coverage_compile_only( - project, project_build_dir, lcov_file - ) - ) + # Don't build non-test projects + self.logger.info("Skipping project %s", project.config.project_name) if self._sequential: rv = self.executor.wait() if rv: |