Skip to content

Commit d459853

Browse files
marcowidmerkartben
authored andcommitted
twister: coverage: set gcov working directory
gcovr runs gcov to generate temporary coverage files into the gcov working directory. The working directory defaults to gcovr's -r argument. When running twister with the --coverage-per-instance argument, multiple gcovr instances may run in parallel. Since they all share the same gcov working directory, they may interfere with each other, resulting in errors like this: AssertionError: Sanity check failed, output file spinlock.h##4167b923a06cc9590c8eef372f016a6d.gcov doesn't exist but no error from GCOV detected. To fix this, specify a separate gcov working directory for every test through gcovr's --gcov-object-directory option. Signed-off-by: Marco Widmer <[email protected]>
1 parent 3329fef commit d459853

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

scripts/pylib/twister/twisterlib/coverage.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@ def collect_coverage(self, outdir, coverage_file, ztest_file, coveragelog):
414414
cmd = ["gcovr", "-r", self.base_dir,
415415
"--gcov-ignore-parse-errors=negative_hits.warn_once_per_file",
416416
"--gcov-executable", self.gcov_tool,
417+
"--gcov-object-directory", outdir,
417418
"-e", "tests/*"]
418419
cmd += excludes + self.options + ["--json", "-o", coverage_file, outdir]
419420
cmd_str = " ".join(cmd)
@@ -427,6 +428,7 @@ def collect_coverage(self, outdir, coverage_file, ztest_file, coveragelog):
427428

428429
cmd = ["gcovr", "-r", self.base_dir] + self.options
429430
cmd += ["--gcov-executable", self.gcov_tool,
431+
"--gcov-object-directory", outdir,
430432
"-f", "tests/ztest", "-e", "tests/ztest/test/*",
431433
"--json", "-o", ztest_file, outdir]
432434
cmd_str = " ".join(cmd)

0 commit comments

Comments
 (0)