Skip to content

Commit aa44166

Browse files
nashiffabiobaltieri
authored andcommitted
twister: coverage: cleanup how we set gcov tool
Make sure we set the gcov tool in a consistent way and avoid issues where path is set as Path instead of a string. Signed-off-by: Anas Nashif <[email protected]>
1 parent c05a483 commit aa44166

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

scripts/pylib/twister/twisterlib/coverage.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def _generate(self, outdir, coveragelog):
190190
branch_coverage = "lcov_branch_coverage=1"
191191
ignore_errors = []
192192

193-
cmd = ["lcov", "--gcov-tool", str(self.gcov_tool),
193+
cmd = ["lcov", "--gcov-tool", self.gcov_tool,
194194
"--capture", "--directory", outdir,
195195
"--rc", branch_coverage,
196196
"--output-file", coveragefile]
@@ -293,7 +293,7 @@ def _generate(self, outdir, coveragelog):
293293
# We want to remove tests/* and tests/ztest/test/* but save tests/ztest
294294
cmd = ["gcovr", "-r", self.base_dir,
295295
"--gcov-ignore-parse-errors=negative_hits.warn_once_per_file",
296-
"--gcov-executable", str(self.gcov_tool),
296+
"--gcov-executable", self.gcov_tool,
297297
"-e", "tests/*"]
298298
cmd += excludes + mode_options + ["--json", "-o", coveragefile, outdir]
299299
cmd_str = " ".join(cmd)
@@ -333,6 +333,7 @@ def _generate(self, outdir, coveragelog):
333333

334334
def run_coverage(testplan, options):
335335
use_system_gcov = False
336+
gcov_tool = None
336337

337338
for plat in options.coverage_platform:
338339
_plat = testplan.get_platform(plat)
@@ -353,19 +354,21 @@ def run_coverage(testplan, options):
353354
os.symlink(llvm_cov, gcov_lnk)
354355
except OSError:
355356
shutil.copy(llvm_cov, gcov_lnk)
356-
options.gcov_tool = gcov_lnk
357+
gcov_tool = gcov_lnk
357358
elif use_system_gcov:
358-
options.gcov_tool = "gcov"
359+
gcov_tool = "gcov"
359360
elif os.path.exists(zephyr_sdk_gcov_tool):
360-
options.gcov_tool = zephyr_sdk_gcov_tool
361+
gcov_tool = zephyr_sdk_gcov_tool
361362
else:
362363
logger.error(f"Can't find a suitable gcov tool. Use --gcov-tool or set ZEPHYR_SDK_INSTALL_DIR.")
363364
sys.exit(1)
365+
else:
366+
gcov_tool = str(options.gcov_tool)
364367

365368
logger.info("Generating coverage files...")
366-
logger.info(f"Using gcov tool: {options.gcov_tool}")
369+
logger.info(f"Using gcov tool: {gcov_tool}")
367370
coverage_tool = CoverageTool.factory(options.coverage_tool)
368-
coverage_tool.gcov_tool = str(options.gcov_tool)
371+
coverage_tool.gcov_tool = gcov_tool
369372
coverage_tool.base_dir = os.path.abspath(options.coverage_basedir)
370373
# Apply output format default
371374
if options.coverage_formats is not None:

0 commit comments

Comments
 (0)