From: Ondrej Lichtner <olichtne(a)redhat.com>
When all test runs fail calculation the average will result in division
by zero. This commit fixes that.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
test_modules/Netperf.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/test_modules/Netperf.py b/test_modules/Netperf.py
index ab4bafe..b930596 100644
--- a/test_modules/Netperf.py
+++ b/test_modules/Netperf.py
@@ -194,7 +194,10 @@ class Netperf(TestGeneric):
if runs > 1:
res_data["results"] = results
- rate = sum(rates)/len(rates)
+ if len(rates) > 0:
+ rate = sum(rates)/len(rates)
+ else:
+ rate = 0.0
rate_std_deviation = std_deviation(rates)
res_data["rate"] = rate
res_data["rate_std_deviation"] = rate_std_deviation
--
2.1.0