aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Rocard <kevinx.rocard@intel.com>2013-06-14 17:09:32 +0200
committerDavid Wagner <david.wagner@intel.com>2014-02-12 17:04:01 +0100
commit2e40452ca53b4eef0e4a254951dee968a07f1797 (patch)
tree488cd95b06091127d426e15cfb8914ba80db2067
parenta2d6452283924def8f9d46337ac7c2e2bcf6c352 (diff)
downloadexternal_parameter-framework-2e40452ca53b4eef0e4a254951dee968a07f1797.zip
external_parameter-framework-2e40452ca53b4eef0e4a254951dee968a07f1797.tar.gz
external_parameter-framework-2e40452ca53b4eef0e4a254951dee968a07f1797.tar.bz2
[Coverage] Change coverage calculation algorithm
BZ: 115218 The coverage was the number of children used divided by the number of children. This was a mistake as a child could have been used despite that all it's descendants might not have been. With this patch the coverage of an element is the coverage children average. Change-Id: I52c9990bec0ed006c70a27aa174898b96829baf5 Signed-off-by: Kevin Rocard <kevinx.rocard@intel.com> Reviewed-on: http://android.intel.com:8080/114693 Reviewed-by: Denneulin, Guillaume <guillaume.denneulin@intel.com> Reviewed-by: De Chivre, Renaud <renaud.de.chivre@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>
-rwxr-xr-xtools/coverage.py24
1 files changed, 14 insertions, 10 deletions
diff --git a/tools/coverage.py b/tools/coverage.py
index 0cd2a5d..a6d6fa6 100755
--- a/tools/coverage.py
+++ b/tools/coverage.py
@@ -135,22 +135,26 @@ class Element():
def _getCoverage(self):
+ """Return the coverage of the element between 0 and 1
- coverageDependance = list(self._getCoverageDependance())
+ If the element has no coverage dependency (usually child) return 0 or 1.
+ otherwise the element coverage is the dependency coverage average"""
+ coverageDependanceElements = list(self._getCoverageDependanceElements())
- nbcoverageDependence = len(coverageDependance)
+ nbcoverageDependence = len(coverageDependanceElements)
if nbcoverageDependence == 0:
- # Coverage makes no sense without any dependence
- return None
+ if self.nbUse == 0:
+ return 0
+ else:
+ return 1
- nbcoverageDependanceUsed = len([element
- for element in coverageDependance
- if element.hasBeenUsed()])
+ coverageDependenceValues = (depElement._getCoverage()
+ for depElement in coverageDependanceElements)
- return nbcoverageDependanceUsed / nbcoverageDependence
+ return sum(coverageDependenceValues) / nbcoverageDependence
- def _getCoverageDependance(self):
+ def _getCoverageDependanceElements(self):
return self.children
def _coverageFormating(self, coverage):
@@ -437,7 +441,7 @@ class RootRule(DomPopulatedElement, Rule):
# A configuration can only have one or no rule
assert(len(self.children) <= 1)
- def _getCoverageDependance(self):
+ def _getCoverageDependanceElements(self):
return self._getDescendants()