tests: Actually loop if ping fails

The usage of run_and_expect doesn't work if the function
being called as the run part asserts.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This commit is contained in:
Donald Sharp 2023-05-30 15:20:56 -04:00
parent 147c7a2de3
commit 22c10bbdaa

View File

@ -98,7 +98,8 @@ def check_ping4(name, dest_addr, expect_connected):
tgen = get_topogen()
output = tgen.gears[name].run("ping {} -c 1 -w 1".format(dest_addr))
logger.info(output)
assert match in output, "ping fail"
if match not in output:
return "ping fail"
match = ", {} packet loss".format("0%" if expect_connected else "100%")
logger.info("[+] check {} {} {}".format(name, dest_addr, match))