From 31bfa1b906d993b399d6362e8e652d382eeda42e Mon Sep 17 00:00:00 2001 From: Tobias Waldekranz Date: Wed, 15 May 2024 09:06:20 +0000 Subject: [PATCH] test: netns: Let the default ping timeout be tuned in the topology QEMU systems seem work fine with the 5s timeout, whereas some physical devices can't quite keep up with that. Let the slower systems indicate that they need a bit more time without punishing faster ones with a longer default. --- test/infamy/netns.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/infamy/netns.py b/test/infamy/netns.py index 3f8f039b..ff3388ea 100644 --- a/test/infamy/netns.py +++ b/test/infamy/netns.py @@ -5,6 +5,8 @@ import random import subprocess import time +from . import env + __libc = ctypes.CDLL(None) CLONE_NEWUSER = 0x10000000 CLONE_NEWNET = 0x40000000 @@ -19,6 +21,7 @@ class IsolatedMacVlan: def __init__(self, parent, ifname="iface", lo=True): self.sleeper = None self.parent, self.ifname, self.lo = parent, ifname, lo + self.ping_timeout = env.ENV.attr("ping_timeout", 5) def __enter__(self): self.sleeper = subprocess.Popen(["unshare", "-r", "-n", "sh", "-c", @@ -162,7 +165,9 @@ class IsolatedMacVlan: result.append(l) return result - def ping(self, daddr, timeout=5): + def ping(self, daddr, timeout=None): + timeout = timeout if timeout else self.ping_timeout + return self.run(["timeout", str(timeout), "/bin/sh"], text=True, check=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, input=f"while :; do ping -c1 -w1 {daddr} && break; done")