summaryrefslogtreecommitdiff
path: root/zephyr/zmake
diff options
context:
space:
mode:
authorJeremy Bettis <jbettis@google.com>2021-08-30 12:24:04 -0600
committerCommit Bot <commit-bot@chromium.org>2021-08-31 04:21:58 +0000
commit463618c732f55a80ca533cd601ebea8bfef3494c (patch)
treea3aba3e33bad7fa323508dae3f07d49ee9ec096b /zephyr/zmake
parent79a2b10cc1588a5b5b0b06b93b7fc67c6759546c (diff)
downloadchrome-ec-463618c732f55a80ca533cd601ebea8bfef3494c.tar.gz
zephyr: Build a script to call gcov
In chroot, you can always use llvm-cov to parse the coverage files, but in zephyr sdk, you have to use the right gcov binary for each toolchain. Use cmake to build a gcov shell script, and call it from zmake coverage. BUG=None TEST=zmake coverage in chroot and gitlab BRANCH=None Signed-off-by: Jeremy Bettis <jbettis@google.com> Change-Id: I6203445f0a412193e8280bb5cdf7994d5346fdbd Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3130622 Tested-by: Jeremy Bettis <jbettis@chromium.org> Auto-Submit: Jeremy Bettis <jbettis@chromium.org> Commit-Queue: Yuval Peress <peress@chromium.org> Reviewed-by: Yuval Peress <peress@chromium.org>
Diffstat (limited to 'zephyr/zmake')
-rw-r--r--zephyr/zmake/zmake/zmake.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/zephyr/zmake/zmake/zmake.py b/zephyr/zmake/zmake/zmake.py
index 301ee5c431..70f58ed129 100644
--- a/zephyr/zmake/zmake/zmake.py
+++ b/zephyr/zmake/zmake/zmake.py
@@ -513,7 +513,8 @@ class Zmake:
shutil.rmtree(tmpdir)
return rv
- def _run_lcov(self, build_dir, lcov_file, initial=False):
+ def _run_lcov(self, build_dir, lcov_file, initial=False, gcov=""):
+ gcov = os.path.abspath(gcov)
with self.jobserver.get_job():
if initial:
self.logger.info("Running (initial) lcov on %s.", build_dir)
@@ -522,7 +523,7 @@ class Zmake:
cmd = [
"/usr/bin/lcov",
"--gcov-tool",
- self.module_paths["ec"] / "util/llvm-gcov.sh",
+ gcov,
"-q",
"-o",
"-",
@@ -606,9 +607,11 @@ class Zmake:
procs = []
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)
dirs[build_name] = build_dir / "build-{}".format(build_name)
+ gcov = dirs[build_name] / "gcov.sh"
proc = self.jobserver.popen(
["/usr/bin/ninja", "-C", dirs[build_name], "all.libraries"],
# Ninja will connect as a job client instead and claim
@@ -638,7 +641,7 @@ class Zmake:
if proc.wait():
raise OSError(get_process_failure_msg(proc))
- return self._run_lcov(build_dir, lcov_file, initial=True)
+ return self._run_lcov(build_dir, lcov_file, initial=True, gcov=gcov)
def _coverage_run_test(self, project, build_dir, lcov_file):
self.logger.info("Running test %s in %s", project.project_dir, build_dir)
@@ -651,7 +654,10 @@ class Zmake:
)
if rv:
return rv
- return self._run_lcov(build_dir, lcov_file, initial=False)
+ gcov = "gcov.sh-not-found"
+ for build_name, build_config in project.iter_builds():
+ gcov = build_dir / "build-{}".format(build_name) / "gcov.sh"
+ return self._run_lcov(build_dir, lcov_file, initial=False, gcov=gcov)
def coverage(self, build_dir):
"""Builds all targets with coverage enabled, and then runs the tests."""