diff options
author | Kevin Rocard <kevinx.rocard@intel.com> | 2013-06-10 15:20:10 +0200 |
---|---|---|
committer | David Wagner <david.wagner@intel.com> | 2014-02-12 17:03:59 +0100 |
commit | 556538e2bda03b54bdd82c5813a5286e90a39f67 (patch) | |
tree | ae3ec957ed2b1de9f1c4aba59a76739f7e25f07c /tools | |
parent | 97dbd35c75ee252a674aff3d66293d55fc0b35a5 (diff) | |
download | external_parameter-framework-556538e2bda03b54bdd82c5813a5286e90a39f67.zip external_parameter-framework-556538e2bda03b54bdd82c5813a5286e90a39f67.tar.gz external_parameter-framework-556538e2bda03b54bdd82c5813a5286e90a39f67.tar.bz2 |
[Coverage] Support criterion incoherent state
BZ: 115218
In case of incoherent log (corrupted), some transitions described
in the log are not permitted by the internal criterion state machine.
Resulting in raising an exception and stopping the program.
Add an optional parameter to ignore integrity.
Change-Id: I288c0e482b223aa0023e09fb158036b39d0ed8bf
Signed-off-by: Kevin Rocard <kevinx.rocard@intel.com>
Reviewed-on: http://android.intel.com:8080/112711
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 | 41 |
1 files changed, 30 insertions, 11 deletions
diff --git a/tools/coverage.py b/tools/coverage.py index f62fd9a..5a00f45 100755 --- a/tools/coverage.py +++ b/tools/coverage.py @@ -594,7 +594,18 @@ class Criterion(Element): tag = "Criterion" inclusivenessTranslate = {True: "Inclusive", False: "Exclusive"} - def __init__(self, name, isInclusif, stateNamesList, currentStateNamesList): + class ChangeRequestToNonAccessibleState(CustomError): + def __init__(self, requestedState, detail): + self.requestedState = requestedState + self.detail = detail + + def __str__(self): + return ("Change request to non accessible state %s. Detail: %s" % + (self.requestedState, self.detail)) + + def __init__(self, name, isInclusif, + stateNamesList, currentStateNamesList, + ignoreIntegrity=False): super().__init__(name) self.isInclusif = isInclusif @@ -602,21 +613,21 @@ class Criterion(Element): self.addChild(CriterionState(state)) self.currentState = [] + self.initStateNamesList = list(currentStateNamesList) + self.changeState(self.initStateNamesList, ignoreIntegrity) - # Set current state as provided - self.currentState = [self.getChildFromName(childName) - for childName in currentStateNamesList] - - def childUsed(self, child): - self.currentState = child - super().childUsed(child) + def reset(self): + # Set current state as provided at initialisation + self.changeState(self.initStateNamesList, ignoreIntegrity=True) - def changeState(self, subStateNames): + def changeState(self, subStateNames, ignoreIntegrity=False): self.debug("Changing state from: %s to: %s" % ( list(self._getElementNames(self.currentState)), subStateNames)) - assert(len(subStateNames) > 0 or self.isInclusif) + if not ignoreIntegrity and not self.isIntegre(subStateNames): + raise self.ChangeRequestToNonAccessibleState(subStateNames, + "An exclusive criterion must have a non empty state") newCurrentState = [] for subStateName in subStateNames : @@ -629,9 +640,17 @@ class Criterion(Element): self._incNbUse() self._tellParentThatChildUsed() + def isIntegre(self, subStateNames): + return self.isInclusif or len(subStateNames) == 1 + + def childUsed(self, child): + self.currentState = child + super().childUsed(child) + def export(self): subStateNames = self._getElementNames(self.currentState) - return Criterion(self.name, self.isInclusif, subStateNames, subStateNames) + return Criterion(self.name, self.isInclusif, subStateNames, subStateNames, + ignoreIntegrity=True) def stateIncludes(self, subStateName): subStateCurrentNames = list(self._getElementNames(self.currentState)) |