diff options
author | Kevin Rocard <kevinx.rocard@intel.com> | 2013-06-10 16:01:21 +0200 |
---|---|---|
committer | David Wagner <david.wagner@intel.com> | 2014-02-12 17:04:00 +0100 |
commit | 9050c81c8f9a63aa95e7230705e00585bd0ecec5 (patch) | |
tree | 3a5e0c6bd76d16921f552e1caca02cc7a4f22d46 /tools | |
parent | ea87422e14735633cb8e28de114a18e22eaa82fb (diff) | |
download | external_parameter-framework-9050c81c8f9a63aa95e7230705e00585bd0ecec5.zip external_parameter-framework-9050c81c8f9a63aa95e7230705e00585bd0ecec5.tar.gz external_parameter-framework-9050c81c8f9a63aa95e7230705e00585bd0ecec5.tar.bz2 |
[coverage] Add flags to ignore errors
BZ: 115218
2 errors can be raised when parsing PFW logs:
- criterion that change their state that is not allowed. The PFW
allows an exclusive criterion to be in the none state.
- configuration not applicable according to the criterion states
that are however applied. It happens in case of log corruption
(log lines missing).
The user should be able to ignore those 2 errors if low coverage
accuracy is allowed.
Add the flags:
--ignore-incoherent-criterion-state
--ignore-ineligible-configuration-application
Change-Id: I1a25b47a05e974d711b735e344f9352904c8771b
Signed-off-by: Kevin Rocard <kevinx.rocard@intel.com>
Reviewed-on: http://android.intel.com:8080/112714
Reviewed-by: Denneulin, Guillaume <guillaume.denneulin@intel.com>
Reviewed-by: Gonzalve, Sebastien <sebastien.gonzalve@intel.com>
Reviewed-by: cactus <cactus@intel.com>
Tested-by: Dixon, CharlesX <charlesx.dixon@intel.com>
Reviewed-by: buildbot <buildbot@intel.com>
Tested-by: buildbot <buildbot@intel.com>
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/coverage.py | 57 |
1 files changed, 51 insertions, 6 deletions
diff --git a/tools/coverage.py b/tools/coverage.py index 9ce94e6..ead5e08 100755 --- a/tools/coverage.py +++ b/tools/coverage.py @@ -707,10 +707,11 @@ class ParsePFWlog(): MATCH = "match" ACTION = "action" - def __init__(self, domains, criteria): + def __init__(self, domains, criteria, ErrorsToIgnore=()): self.domains = domains; self.criteria = criteria; + self.ErrorsToIgnore = ErrorsToIgnore configApplicationRegext = r""".*Applying configuration "(.*)" from domain "([^"]*)""" matchConfigApplicationLine = re.compile(configApplicationRegext).match @@ -811,22 +812,41 @@ class ParsePFWlog(): def _digest(self, lineLogType, lineLog): + match = lineLogType[self.MATCH](lineLog) if match : lineLogType[self.ACTION](match) return True return False + def parsePFWlog(self, lines): - for lineLog in lines: + for lineNb, lineLog in enumerate(lines): logger.debug("Parsing line :%s" % lineLog.rstrip()) digested = (self._digest(lineLogType, lineLog) for lineLogType in self.lineLogTypes) - if not any(digested): - logger.debug("Line does not match, dropped") + try: + success = any(digested) + + # Catch some exception in order to print the current parsing line, + # then raise the exception again if not continue of error + except CustomError as ex: + logger.error('Error raised while parsing line %s: "%s"' % + (lineNb, repr(lineLog))) + + # If exception is a subclass of ErrorsToIgnore, log it and continue + # otherwise raise it again. + if not issubclass(type(ex), self.ErrorsToIgnore): + raise ex + else: + logger.error('Ignoring exception:"%s", ' + 'can not guarantee database integrity' % ex) + else: + if not success: + logger.debug("Line does not match, dropped") class Root(Element): @@ -937,6 +957,21 @@ class ArgumentParser: help="raw coverage output report" ) + myArgParser.add_argument( + '--ignore-incoherent-criterion-state', + dest="incoherentCriterionFlag", + action='store_true', + help="ignore criterion transition to incoherent state" + ) + + myArgParser.add_argument( + '--ignore-ineligible-configuration-application', + dest="ineligibleConfigurationApplicationFlag", + action='store_true', + help="ignore application of configuration with a false rule " + "(not applicable configuration)" + ) + # Process command line arguments options = myArgParser.parse_args() @@ -952,6 +987,16 @@ class ArgumentParser: levelCapped = min(options.debugLevel, len(self.levelTranslate) - 1) self.debugLevel = self.levelTranslate[levelCapped] + # Setting ignore options + errorToIgnore = [] + if options.ineligibleConfigurationApplicationFlag : + errorToIgnore.append(Configuration.IneligibleConfigurationAppliedError) + + if options.incoherentCriterionFlag: + errorToIgnore.append(Criterion.ChangeRequestToNonAccessibleState) + + self.errorToIgnore = tuple(errorToIgnore) + def main(): @@ -978,7 +1023,7 @@ def main(): root = Root("Coverage", dom) # Parse PFW events - parser = ParsePFWlog(root.domains, root.criteria) + parser = ParsePFWlog(root.domains, root.criteria, commandLineArguments.errorToIgnore) try: parser.parsePFWlog(commandLineArguments.inputFile.readlines()) @@ -996,7 +1041,7 @@ def main(): outputFile.write(root.exportToXML().toprettyxml()) -# Execute main function if the python interpreter is running this module as the main program if __name__ == "__main__" : + """ Execute main if the python interpreter is running this module as the main program """ main() |