From: Ondrej Lichtner <olichtne(a)redhat.com>
When the measured netperf result is 0, the confidence is reported as
"-nan" which resulted in tracebacks when parsing the value with a regex
for numbers.
This commit fixes that by checking if the regex passed and returning 0
in cases when the regex doesn't fit the string.
Fixes #170
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
test_modules/Netperf.py | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/test_modules/Netperf.py b/test_modules/Netperf.py
index d09bdfc..746bdac 100644
--- a/test_modules/Netperf.py
+++ b/test_modules/Netperf.py
@@ -235,12 +235,17 @@ class Netperf(TestGeneric):
def _parse_confidence_omni(self, output):
pattern_throughput_confid = "THROUGHPUT_CONFID=([-]?\d+\.\d+)"
pattern_confidence_level = "CONFIDENCE_LEVEL=(\d+)"
- throughput_confid = float(re.search(pattern_throughput_confid, output).group(1))
- confidence_level = int(re.search(pattern_confidence_level, output).group(1))
- real_confidence = (confidence_level, throughput_confid/2)
+ throughput_confid = re.search(pattern_throughput_confid, output)
+ confidence_level = re.search(pattern_confidence_level, output)
- return real_confidence
+ if throughput_confid is not None and confidence_level is not None:
+ throughput_confid = throughput_confid.group(1)
+ confidence_level = confidence_level.group(1)
+ real_confidence = (confidence_level, throughput_confid/2)
+ return real_confidence
+ else:
+ return (0, 0.0)
def _parse_confidence_non_omni(self, output):
normal_pattern = r'\+/-(\d+\.\d*)% @ (\d+)% conf\.'
--
2.9.0