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 <jbettis@google.com>
This commit is contained in:
parent
1385f02979
commit
e88499cf8e
1 changed files with 18 additions and 4 deletions
|
@ -301,20 +301,29 @@ class Lcov(CoverageTool):
|
||||||
invalid_chars = re.compile(r"[^A-Za-z0-9_]")
|
invalid_chars = re.compile(r"[^A-Za-z0-9_]")
|
||||||
cmd.append("--test-name")
|
cmd.append("--test-name")
|
||||||
cmd.append(invalid_chars.sub("_", next(iter(self.instances))))
|
cmd.append(invalid_chars.sub("_", next(iter(self.instances))))
|
||||||
self.run_lcov(cmd, coveragelog)
|
ret = self.run_lcov(cmd, coveragelog)
|
||||||
|
if ret:
|
||||||
|
logger.error("LCOV capture report stage failed with %s", ret)
|
||||||
|
return ret, {}
|
||||||
|
|
||||||
# We want to remove tests/* and tests/ztest/test/* but save tests/ztest
|
# We want to remove tests/* and tests/ztest/test/* but save tests/ztest
|
||||||
cmd = ["--extract", coveragefile,
|
cmd = ["--extract", coveragefile,
|
||||||
os.path.join(self.base_dir, "tests", "ztest", "*"),
|
os.path.join(self.base_dir, "tests", "ztest", "*"),
|
||||||
"--output-file", ztestfile]
|
"--output-file", ztestfile]
|
||||||
self.run_lcov(cmd, coveragelog)
|
ret = self.run_lcov(cmd, coveragelog)
|
||||||
|
if ret:
|
||||||
|
logger.error("LCOV extract report stage failed with %s", ret)
|
||||||
|
return ret, {}
|
||||||
|
|
||||||
files = []
|
files = []
|
||||||
if os.path.exists(ztestfile) and os.path.getsize(ztestfile) > 0:
|
if os.path.exists(ztestfile) and os.path.getsize(ztestfile) > 0:
|
||||||
cmd = ["--remove", ztestfile,
|
cmd = ["--remove", ztestfile,
|
||||||
os.path.join(self.base_dir, "tests/ztest/test/*"),
|
os.path.join(self.base_dir, "tests/ztest/test/*"),
|
||||||
"--output-file", ztestfile]
|
"--output-file", ztestfile]
|
||||||
self.run_lcov(cmd, coveragelog)
|
ret = self.run_lcov(cmd, coveragelog)
|
||||||
|
if ret:
|
||||||
|
logger.error("LCOV remove ztest report stage failed with %s", ret)
|
||||||
|
return ret, {}
|
||||||
|
|
||||||
files = [coveragefile, ztestfile]
|
files = [coveragefile, ztestfile]
|
||||||
else:
|
else:
|
||||||
|
@ -322,7 +331,10 @@ class Lcov(CoverageTool):
|
||||||
|
|
||||||
for i in self.ignores:
|
for i in self.ignores:
|
||||||
cmd = ["--remove", coveragefile, i, "--output-file", coveragefile]
|
cmd = ["--remove", coveragefile, i, "--output-file", coveragefile]
|
||||||
self.run_lcov(cmd, coveragelog)
|
ret = self.run_lcov(cmd, coveragelog)
|
||||||
|
if ret:
|
||||||
|
logger.error("LCOV remove ignores report stage failed with %s", ret)
|
||||||
|
return ret, {}
|
||||||
|
|
||||||
if 'html' not in self.output_formats.split(','):
|
if 'html' not in self.output_formats.split(','):
|
||||||
return 0, {}
|
return 0, {}
|
||||||
|
@ -334,6 +346,8 @@ class Lcov(CoverageTool):
|
||||||
cmd.append("--show-details")
|
cmd.append("--show-details")
|
||||||
cmd += files
|
cmd += files
|
||||||
ret = self.run_command(cmd, coveragelog)
|
ret = self.run_command(cmd, coveragelog)
|
||||||
|
if ret:
|
||||||
|
logger.error("LCOV genhtml report stage failed with %s", ret)
|
||||||
|
|
||||||
# TODO: Add LCOV summary coverage report.
|
# TODO: Add LCOV summary coverage report.
|
||||||
return ret, { 'report': coveragefile, 'ztest': ztestfile, 'summary': None }
|
return ret, { 'report': coveragefile, 'ztest': ztestfile, 'summary': None }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue