improve statistics export in CPAchecker wrapper.
Before: we match every substring.
After: we match only at line-starts, and we warn if there are multiple matches.
@@ -207,13 +207,17 @@ class Tool(benchexec.tools.template.BaseTool):
def get_value_from_output(self, lines, identifier):
# search for the text in output and get its value,
- # stop after the first line, that contains the searched text
+ # search the first line, that starts with the searched text
+ # warn if there are more lines (multiple statistics from sequential analysis?)
+ match = None
for line in lines:
- if identifier in line:
+ if line.lstrip().startswith(identifier):
startPosition = line.find(':') + 1
endPosition = line.find('(', startPosition) # bracket maybe not found -> (-1)
if (endPosition == -1):
- return line[startPosition:].strip()
+ endPosition = len(line)
+ if match is None:
+ match = line[startPosition: endPosition].strip()
else:
- return line[startPosition: endPosition].strip()
- return None
+ logging.warning("skipping repeated match for identifier '{0}': '{1}'".format(identifier, line))
+ return match
