Skip to content

Commit 97fab83

Browse files
golowanownashif
authored andcommitted
scripts: coverage: gcovr to ignore negative counters
Apply a workaround for an issue introduced with bc8b7dd for code coverage collection at qemu_x86 when gcov data was broken because of optimized out memcpy() in write_u64() static inline function, so gcovr parser fails with "gcovr.gcov_parser.NegativeHits: Got negative hit value in gcov line 'branch 1 taken -1'". Add gcovr command line option to ignore such errors (since v.6.0): "--gcov-ignore-parse-errors=negative_hits.warn_once_per_file" Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
1 parent 6b87eed commit 97fab83

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

scripts/pylib/twister/twisterlib/coverage.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,11 +221,11 @@ def _generate(self, outdir, coveragelog):
221221
excludes = Gcovr._interleave_list("-e", self.ignores)
222222

223223
# We want to remove tests/* and tests/ztest/test/* but save tests/ztest
224-
cmd = ["gcovr", "-r", self.base_dir, "--gcov-executable",
225-
str(self.gcov_tool), "-e", "tests/*"] + excludes + ["--json",
226-
"-o",
227-
coveragefile,
228-
outdir]
224+
cmd = ["gcovr", "-r", self.base_dir,
225+
"--gcov-ignore-parse-errors=negative_hits.warn_once_per_file",
226+
"--gcov-executable", str(self.gcov_tool),
227+
"-e", "tests/*"]
228+
cmd += excludes + ["--json", "-o", coveragefile, outdir]
229229
cmd_str = " ".join(cmd)
230230
logger.debug(f"Running {cmd_str}...")
231231
subprocess.call(cmd, stdout=coveragelog)

scripts/requirements-build-test.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ colorama
1010
ply>=3.10
1111

1212
# used for code coverage
13-
gcovr>=4.2
13+
gcovr>=6.0
1414
coverage
1515

1616
# used for west-command testing

0 commit comments

Comments
 (0)