Skip to content

Commit

Permalink
scripts: coverage: gcovr to ignore negative counters
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
golowanow authored and nashif committed Nov 3, 2023
1 parent 6b87eed commit 97fab83
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions scripts/pylib/twister/twisterlib/coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,11 @@ def _generate(self, outdir, coveragelog):
excludes = Gcovr._interleave_list("-e", self.ignores)

# We want to remove tests/* and tests/ztest/test/* but save tests/ztest
cmd = ["gcovr", "-r", self.base_dir, "--gcov-executable",
str(self.gcov_tool), "-e", "tests/*"] + excludes + ["--json",
"-o",
coveragefile,
outdir]
cmd = ["gcovr", "-r", self.base_dir,
"--gcov-ignore-parse-errors=negative_hits.warn_once_per_file",
"--gcov-executable", str(self.gcov_tool),
"-e", "tests/*"]
cmd += excludes + ["--json", "-o", coveragefile, outdir]
cmd_str = " ".join(cmd)
logger.debug(f"Running {cmd_str}...")
subprocess.call(cmd, stdout=coveragelog)
Expand Down
2 changes: 1 addition & 1 deletion scripts/requirements-build-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ colorama
ply>=3.10

# used for code coverage
gcovr>=4.2
gcovr>=6.0
coverage

# used for west-command testing
Expand Down

0 comments on commit 97fab83

Please sign in to comment.