summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xzephyr/firmware_builder.py24
-rw-r--r--zephyr/zmake/zmake/zmake.py21
2 files changed, 40 insertions, 5 deletions
diff --git a/zephyr/firmware_builder.py b/zephyr/firmware_builder.py
index 540274105b..79ee6a3201 100755
--- a/zephyr/firmware_builder.py
+++ b/zephyr/firmware_builder.py
@@ -74,7 +74,22 @@ def write_metadata(opts, info):
def bundle_coverage(opts):
"""Bundles the artifacts from code coverage into its own tarball."""
- raise NotImplementedError
+ info = firmware_pb2.FirmwareArtifactInfo()
+ info.bcs_version_info.version_string = opts.bcs_version
+ bundle_dir = get_bundle_dir(opts)
+ zephyr_dir = pathlib.Path(__file__).parent
+ platform_ec = zephyr_dir.resolve().parent
+ build_dir = platform_ec / 'build/zephyr-coverage'
+ tarball_name = 'coverage.tbz2'
+ tarball_path = bundle_dir / tarball_name
+ cmd = ['tar', 'cvfj', tarball_path, 'lcov.info']
+ subprocess.run(cmd, cwd=build_dir, check=True)
+ meta = info.objects.add()
+ meta.file_name = tarball_name
+ meta.lcov_info.type = firmware_pb2.FirmwareArtifactInfo.LcovTarballInfo.LcovType.LCOV
+
+ write_metadata(opts, info)
+
def bundle_firmware(opts):
@@ -116,6 +131,13 @@ def test(opts):
with open(opts.metrics, 'w') as f:
f.write(json_format.MessageToJson(metrics))
+ if opts.code_coverage:
+ zephyr_dir = pathlib.Path(__file__).parent
+ platform_ec = zephyr_dir.resolve().parent
+ build_dir = platform_ec / 'build/zephyr-coverage'
+ return subprocess.run(
+ ['zmake', '-D', 'coverage', build_dir], cwd=platform_ec).returncode
+
return subprocess.run(['zmake', '-D', 'testall', '--fail-fast']).returncode
diff --git a/zephyr/zmake/zmake/zmake.py b/zephyr/zmake/zmake/zmake.py
index 0b1a57866c..f341de3030 100644
--- a/zephyr/zmake/zmake/zmake.py
+++ b/zephyr/zmake/zmake/zmake.py
@@ -461,7 +461,6 @@ class Zmake:
if initial:
cmd += ['-i']
proc = self.jobserver.popen(cmd,
- claim_job=False,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
encoding='utf-8',
@@ -506,7 +505,6 @@ class Zmake:
['/usr/bin/ninja', '-C', dirs[build_name], 'all.libraries'],
# Ninja will connect as a job client instead and claim
# many jobs.
- claim_job=False,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
encoding='utf-8',
@@ -574,7 +572,6 @@ class Zmake:
proc = self.jobserver.popen(
[self.module_paths['ec'] /
'util/getversion.sh'],
- claim_job=False,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
encoding='utf-8',
@@ -588,6 +585,23 @@ class Zmake:
if proc.wait():
raise OSError(get_process_failure_msg(proc))
+ # Merge info files into a single lcov.info
+ self.logger.info("Merging coverage data into %s.",
+ build_dir / 'lcov.info')
+ cmd = ['/usr/bin/lcov', '-o', build_dir / 'lcov.info']
+ for info in all_lcov_files:
+ cmd += ['-a', info]
+ proc = self.jobserver.popen(
+ cmd,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ encoding='utf-8',
+ errors='replace')
+ zmake.multiproc.log_output(self.logger, logging.ERROR, proc.stderr)
+ zmake.multiproc.log_output(self.logger, logging.DEBUG, proc.stdout)
+ if proc.wait():
+ raise OSError(get_process_failure_msg(proc))
+
# Merge into a nice html report
self.logger.info("Creating coverage report %s.",
build_dir / 'coverage_rpt')
@@ -596,7 +610,6 @@ class Zmake:
build_dir / 'coverage_rpt', '-t',
"Zephyr EC Unittest {}".format(version), '-p',
self.checkout / 'src', '-s'] + all_lcov_files,
- claim_job=False,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
encoding='utf-8',