From: Ondrej Lichtner <olichtne(a)redhat.com>
When measured rate was 0, a division by zero can occur while checking if
the result deviation was too high. This commit fixes the issue, by
automatically rejecting 0 throughput results as FAIL.
Fixes: eca3a19a12 ("Netperf: add option max_deviation")
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
test_modules/Netperf.py | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/test_modules/Netperf.py b/test_modules/Netperf.py
index 853c502..5ab0815 100644
--- a/test_modules/Netperf.py
+++ b/test_modules/Netperf.py
@@ -502,6 +502,16 @@ class Netperf(TestGeneric):
return (False, res_data)
res_val = False
+ res_data["msg"] = "Measured rate was %.2f +-%.2f %s" %\
+ (rate_pretty["rate"],
+ rate_dev_pretty["rate"],
+ rate_pretty["unit"])
+ if rate > 0.0:
+ res_val = True
+ else:
+ res_val = False
+ return (res_val, res_data)
+
if self._max_deviation is not None:
if self._max_deviation["type"] == "percent":
percentual_deviation = (rate_deviation / rate) * 100
@@ -556,15 +566,6 @@ class Netperf(TestGeneric):
threshold_dev_pretty["rate"],
threshold_pretty["unit"])
return (res_val, res_data)
- else:
- if rate > 0.0:
- res_val = True
- else:
- res_val = False
- res_data["msg"] = "Measured rate was %.2f +-%.2f %s" %\
- (rate_pretty["rate"],
- rate_dev_pretty["rate"],
- rate_pretty["unit"])
return (res_val, res_data)
def run(self):
--
2.10.0