Reland "firmware: add code_coverage to proto."
This is a reland of 00e6c482eec830e9842e724692364fcff88ed675
Original change's description:
> firmware: add code_coverage to proto.
>
> Also freshen python bindings.
>
> BUG=b:179680444
> TEST=CQ
>
> Cq-Depend: chromium:2698243
> Change-Id: Iedcbb39e0f5610b95191098a95fb8635d451a1a0
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/2698176
> Commit-Queue: LaMont Jones <lamontjones@chromium.org>
> Commit-Queue: Michael Mortensen <mmortensen@google.com>
> Tested-by: LaMont Jones <lamontjones@chromium.org>
> Auto-Submit: LaMont Jones <lamontjones@chromium.org>
> Reviewed-by: Michael Mortensen <mmortensen@google.com>
Cq-Include-Trybots: chromeos/cq:firmware-zephyr-cq
Bug: b:179680444
Change-Id: I05f536ec070805252e9b54ba807606d7a237e3fb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/2702720
Reviewed-by: Sean Kau <skau@chromium.org>
Commit-Queue: LaMont Jones <lamontjones@chromium.org>
Tested-by: LaMont Jones <lamontjones@chromium.org>
diff --git a/api/controller/firmware.py b/api/controller/firmware.py
index b8b8e7e..1ff88f0 100644
--- a/api/controller/firmware.py
+++ b/api/controller/firmware.py
@@ -24,7 +24,7 @@
from chromite.lib import osutils
-def _call_entry(fw_loc, metric_proto, subcmd, **kwargs):
+def _call_entry(fw_loc, metric_proto, subcmd, *args, **kwargs):
"""Calls into firmware_builder.py with the specified subcmd."""
if fw_loc == common_pb2.PLATFORM_EC:
@@ -40,7 +40,7 @@
'firmware_builder.py')
with tempfile.NamedTemporaryFile() as tmpfile:
- cmd = [entry_point, '--metrics', tmpfile.name]
+ cmd = [entry_point, '--metrics', tmpfile.name] + list(args)
for key, value in kwargs.items():
cmd += [f'--{key.replace("_", "-")}', value]
cmd += [subcmd]
@@ -80,8 +80,9 @@
def BuildAllTotFirmware(input_proto, output_proto, _config):
"""Build all of the firmware targets at the specified location."""
+ args = ['--code-coverage'] if input_proto.code_coverage else []
return _call_entry(input_proto.firmware_location, output_proto.metrics,
- 'build')
+ 'build', *args)
def _TestAllTotFirmwareResponse(_input_proto, output_proto, _config):
@@ -98,8 +99,9 @@
def TestAllTotFirmware(input_proto, output_proto, _config):
"""Runs all of the firmware tests at the specified location."""
+ args = ['--code-coverage'] if input_proto.code_coverage else []
return _call_entry(input_proto.firmware_location, output_proto.metrics,
- 'test')
+ 'test', *args)
def _BuildAllFirmwareResponse(_input_proto, output_proto, _config):
@@ -121,8 +123,9 @@
def BuildAllFirmware(input_proto, output_proto, _config):
"""Build all of the firmware targets at the specified location."""
+ args = ['--code-coverage'] if input_proto.code_coverage else []
return _call_entry(input_proto.firmware_location, output_proto.metrics,
- 'build')
+ 'build', *args)
def _TestAllFirmwareResponse(_input_proto, output_proto, _config):
@@ -139,8 +142,9 @@
def TestAllFirmware(input_proto, output_proto, _config):
"""Runs all of the firmware tests at the specified location."""
+ args = ['--code-coverage'] if input_proto.code_coverage else []
return _call_entry(input_proto.firmware_location, output_proto.metrics,
- 'test')
+ 'test', *args)
def _BundleFirmwareArtifactsResponse(_input_proto, output_proto, _config):
@@ -162,10 +166,14 @@
with osutils.TempDir(delete=False) as tmpdir:
info = input_proto.artifacts.output_artifacts[0]
metadata_path = os.path.join(tmpdir, 'firmware_metadata.jsonpb')
+ args = []
+ if input_proto.artifacts.FIRMWARE_LCOV in info.artifact_types:
+ args += ['--code-coverage']
resp = _call_entry(
info.location,
None,
'bundle',
+ *args,
output_dir=tmpdir,
metadata=metadata_path)
tarball_paths = []