summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Bettis <jbettis@google.com>2022-08-16 12:43:37 -0600
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-08-16 20:00:48 +0000
commit5172585c588f3bef2dd5100f2088c720332e3efc (patch)
tree305dec0bb0f1e5bfa6b453cab113ab1744f5a8ba
parent571bcbd435034825efd89a4606e1138d4b584431 (diff)
downloadchrome-ec-5172585c588f3bef2dd5100f2088c720332e3efc.tar.gz
cq: Add new metric for coverage w/o tests
It isn't very useful to compare cl coverage if you include test code as covered code. Add a new metric that excludes tests, but still upload the lcov info file with tests to gerrit, so that the lines of the test that actually run show in the UI. BRANCH=None BUG=None TEST=see README.md Signed-off-by: Jeremy Bettis <jbettis@google.com> Change-Id: If7ee53ae7e95bcfa7542bc0675c24a5d4d432747 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3833918 Commit-Queue: Jeremy Bettis <jbettis@chromium.org> Commit-Queue: Simon Glass <sjg@chromium.org> Auto-Submit: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org> Tested-by: Jeremy Bettis <jbettis@chromium.org>
-rwxr-xr-xzephyr/firmware_builder.py29
1 files changed, 28 insertions, 1 deletions
diff --git a/zephyr/firmware_builder.py b/zephyr/firmware_builder.py
index 82b21d39e6..d57508f108 100755
--- a/zephyr/firmware_builder.py
+++ b/zephyr/firmware_builder.py
@@ -234,6 +234,7 @@ def test(opts):
# Twister-based tests
platform_ec = zephyr_dir.parent
+ third_party = platform_ec.parent.parent / "third_party"
run_twister(platform_ec, opts.code_coverage, ["--test-only"])
if opts.code_coverage:
@@ -347,6 +348,7 @@ def test(opts):
platform_ec / "build/**",
platform_ec / "twister-out*/**",
"/usr/include/**",
+ "/usr/lib/**",
]
print(" ".join(shlex.quote(str(x)) for x in cmd))
output = subprocess.run(
@@ -359,6 +361,32 @@ def test(opts):
).stdout
_extract_lcov_summary("ALL_MERGED", metrics, output)
+ # Create an info file without any test code, just for the metric.
+ cmd = [
+ "/usr/bin/lcov",
+ "-o",
+ build_dir / "lcov_no_tests.info",
+ "--rc",
+ "lcov_branch_coverage=1",
+ "-r",
+ build_dir / "lcov.info",
+ platform_ec / "test/**",
+ zephyr_dir / "test/**",
+ zephyr_dir / "emul/**",
+ third_party / "main/subsys/emul/**",
+ third_party / "main/subsys/testsuite/**",
+ ]
+ print(" ".join(shlex.quote(str(x)) for x in cmd))
+ output = subprocess.run(
+ cmd,
+ cwd=zephyr_dir,
+ check=True,
+ stdout=subprocess.PIPE,
+ universal_newlines=True,
+ stdin=subprocess.DEVNULL,
+ ).stdout
+ _extract_lcov_summary("ALL_FILTERED", metrics, output)
+
subprocess.run(
[
"/usr/bin/genhtml",
@@ -376,7 +404,6 @@ def test(opts):
stdin=subprocess.DEVNULL,
)
- third_party = platform_ec.parent.parent / "third_party"
for board in SPECIAL_BOARDS:
# Merge board coverage with tests
cmd = [