From: Ondrej Lichtner <olichtne(a)redhat.com>
Before returning any sort of PacketAssert "recipe template" result we
need to check the actual PacketAssert test module success or failure, if
the remote job returns a failure this means that it failed to measure
anything meaningful and that there are no results available.
Because of this we should return an empty object that tells the
evaluate_and_report method to skip a normal evaluation and just
immediately report a failing result.
This fixes a traceback crashing issue where trying to read "p_recv" was
not possible when the PacketAssert test module failed.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/RecipeCommon/PacketAssert.py | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/lnst/RecipeCommon/PacketAssert.py b/lnst/RecipeCommon/PacketAssert.py
index 689250e..ae52803 100644
--- a/lnst/RecipeCommon/PacketAssert.py
+++ b/lnst/RecipeCommon/PacketAssert.py
@@ -59,11 +59,18 @@ def packet_assert_test_stop(self):
self.started_job.kill(signal=signal.SIGINT)
self.started_job.wait()
- result = self.started_job.result
+ if not self.started_job.passed:
+ result = {}
+ else:
+ result = self.started_job.result
self.started_job = None
return result
def packet_assert_evaluate_and_report(self, packet_assert_config, results):
+ if not results:
+ self.add_result(False, "Packet assert results unavailable")
+ return
+
if results["p_recv"] >= packet_assert_config.p_min and \
(results["p_recv"] <= packet_assert_config.p_max or
not packet_assert_config.p_max):
--
2.29.2