This patch modifies the code to leave the pass/fail decision to a user of the
test module.
The module will now return with failure only if exit code is higher than 1.
Exit code 1 is used to report that ping did not receive any reply packets
at all or fewer packets than expected are received. Ping exits with exit
code 2 on other errors.
Signed-off-by: Jan Tluka <jtluka(a)redhat.com>
---
lnst/Tests/Ping.py | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/lnst/Tests/Ping.py b/lnst/Tests/Ping.py
index 17de8abf..b6ab9d55 100644
--- a/lnst/Tests/Ping.py
+++ b/lnst/Tests/Ping.py
@@ -53,16 +53,13 @@ class Ping(BaseTestModule):
except KeyboardInterrupt:
pass
- self._res_data["stderr"] = stderr
-
- if stderr != "":
- self._res_data["msg"] = "errors reported by ping"
- logging.error(self._res_data["msg"])
- logging.error(self._res_data["stderr"])
-
- if ping_process.returncode > 0:
+ if ping_process.returncode > 1:
self._res_data["msg"] = "returncode =
{}".format(ping_process.returncode)
logging.error(self._res_data["msg"])
+ if stderr != "":
+ self._res_data["stderr"] = stderr
+ logging.error("errors reported by ping")
+ logging.error(self._res_data["stderr"])
return False
stat_pttr1 = r'(\d+) packets transmitted, (\d+) received'
--
2.21.1