Skip to content

Commit e88499c

Browse files
jeremybettiskartben
authored andcommitted
twister: Check lcov exit codes
Don't ignore lcov exit codes, but instead log and return if one of the lcov commands fails. Signed-off-by: Jeremy Bettis <[email protected]>
1 parent 1385f02 commit e88499c

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

scripts/pylib/twister/twisterlib/coverage.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -301,28 +301,40 @@ def _generate(self, outdir, coveragelog, build_dirs=None):
301301
invalid_chars = re.compile(r"[^A-Za-z0-9_]")
302302
cmd.append("--test-name")
303303
cmd.append(invalid_chars.sub("_", next(iter(self.instances))))
304-
self.run_lcov(cmd, coveragelog)
304+
ret = self.run_lcov(cmd, coveragelog)
305+
if ret:
306+
logger.error("LCOV capture report stage failed with %s", ret)
307+
return ret, {}
305308

306309
# We want to remove tests/* and tests/ztest/test/* but save tests/ztest
307310
cmd = ["--extract", coveragefile,
308311
os.path.join(self.base_dir, "tests", "ztest", "*"),
309312
"--output-file", ztestfile]
310-
self.run_lcov(cmd, coveragelog)
313+
ret = self.run_lcov(cmd, coveragelog)
314+
if ret:
315+
logger.error("LCOV extract report stage failed with %s", ret)
316+
return ret, {}
311317

312318
files = []
313319
if os.path.exists(ztestfile) and os.path.getsize(ztestfile) > 0:
314320
cmd = ["--remove", ztestfile,
315321
os.path.join(self.base_dir, "tests/ztest/test/*"),
316322
"--output-file", ztestfile]
317-
self.run_lcov(cmd, coveragelog)
323+
ret = self.run_lcov(cmd, coveragelog)
324+
if ret:
325+
logger.error("LCOV remove ztest report stage failed with %s", ret)
326+
return ret, {}
318327

319328
files = [coveragefile, ztestfile]
320329
else:
321330
files = [coveragefile]
322331

323332
for i in self.ignores:
324333
cmd = ["--remove", coveragefile, i, "--output-file", coveragefile]
325-
self.run_lcov(cmd, coveragelog)
334+
ret = self.run_lcov(cmd, coveragelog)
335+
if ret:
336+
logger.error("LCOV remove ignores report stage failed with %s", ret)
337+
return ret, {}
326338

327339
if 'html' not in self.output_formats.split(','):
328340
return 0, {}
@@ -334,6 +346,8 @@ def _generate(self, outdir, coveragelog, build_dirs=None):
334346
cmd.append("--show-details")
335347
cmd += files
336348
ret = self.run_command(cmd, coveragelog)
349+
if ret:
350+
logger.error("LCOV genhtml report stage failed with %s", ret)
337351

338352
# TODO: Add LCOV summary coverage report.
339353
return ret, { 'report': coveragefile, 'ztest': ztestfile, 'summary': None }

0 commit comments

Comments
 (0)