From 1e8007c997e17539620d6d42af81ecf72b33d3e2 Mon Sep 17 00:00:00 2001 From: danpetry Date: Tue, 9 Apr 2019 15:53:19 +0200 Subject: [PATCH 1/2] Update for new ipv6 ping format Update ping command for format introduced in PR 9523 --- testutils/mixins.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testutils/mixins.py b/testutils/mixins.py index f24c577b..f8352276 100644 --- a/testutils/mixins.py +++ b/testutils/mixins.py @@ -33,8 +33,8 @@ def add_nib_route(self, iface, route, ip_addr): def ping(self, count, dest_addr, payload_size, delay): self.pexpect.sendline( - "ping6 {} {} {} {}".format( - count, dest_addr, payload_size, delay)) + "ping6 -c {} -i {} -s {} {} ".format( + count, delay, payload_size, dest_addr)) packet_loss = None for i in range(count+1): exp = self.pexpect.expect( From 5c172730ea31dc5da29a55b1b96850f0677134da Mon Sep 17 00:00:00 2001 From: danpetry Date: Tue, 9 Apr 2019 16:48:08 +0200 Subject: [PATCH 2/2] Handle duplicate echos Depending on the user configuration, the tapbr0 interface can also echo. This leads to the final message from the pinging native instance including the word "duplicate", and also means the pinging native instance receives two times as many replies as sends. This handles this without failing. --- testutils/mixins.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/testutils/mixins.py b/testutils/mixins.py index f8352276..d71e45a6 100644 --- a/testutils/mixins.py +++ b/testutils/mixins.py @@ -36,14 +36,13 @@ def ping(self, count, dest_addr, payload_size, delay): "ping6 -c {} -i {} -s {} {} ".format( count, delay, payload_size, dest_addr)) packet_loss = None - for i in range(count+1): + while True: exp = self.pexpect.expect( - ["bytes from", "([\\d]+) packets transmitted, ([\\d]+) " - "received, ([\\d]+)% packet loss", "timeout", + ["bytes from", "([\\d]+)% packet loss", "timeout", pexpect.TIMEOUT], timeout=10) if exp == 1: - packet_loss = int(self.pexpect.match.group(3)) + packet_loss = int(self.pexpect.match.group(1)) break if exp == 2: print("x", end="", flush=True)