mirror of
https://github.com/espressif/openthread.git
synced 2026-09-11 19:50:05 +00:00
[ping-sender] let ping return statistics in OTCI (#6370)
- Ping command in CLI will print Done in the end, after printing replies and statistics. The old behavior is, ping command prints Done before any replies. - In OTCI, let ping function return statistics. - Support timeout parameter in ping command. - Fix a bug that the arguments are not properly passed to ping in node.py. - Adjust timeouts in tests.
This commit is contained in:
@@ -120,23 +120,23 @@ class Cert_5_6_9_NetworkDataForwarding(thread_cert.TestCase):
|
||||
self.nodes[ROUTER2].register_netdata()
|
||||
self.simulator.go(15)
|
||||
|
||||
self.assertFalse(self.nodes[SED].ping('2001:2:0:2::1'))
|
||||
self.assertFalse(self.nodes[SED].ping('2001:2:0:2::1', timeout=10))
|
||||
|
||||
self.assertFalse(self.nodes[SED].ping('2007::1'))
|
||||
self.assertFalse(self.nodes[SED].ping('2007::1', timeout=10))
|
||||
|
||||
self.nodes[ROUTER2].remove_prefix('2001:2:0:1::/64')
|
||||
self.nodes[ROUTER2].add_prefix('2001:2:0:1::/64', 'paros', 'high')
|
||||
self.nodes[ROUTER2].register_netdata()
|
||||
self.simulator.go(15)
|
||||
|
||||
self.assertFalse(self.nodes[SED].ping('2007::1'))
|
||||
self.assertFalse(self.nodes[SED].ping('2007::1', timeout=10))
|
||||
|
||||
self.nodes[ROUTER2].remove_prefix('2001:2:0:1::/64')
|
||||
self.nodes[ROUTER2].add_prefix('2001:2:0:1::/64', 'paros', 'med')
|
||||
self.nodes[ROUTER2].register_netdata()
|
||||
self.simulator.go(15)
|
||||
|
||||
self.assertFalse(self.nodes[SED].ping('2007::1'))
|
||||
self.assertFalse(self.nodes[SED].ping('2007::1', timeout=10))
|
||||
|
||||
def verify(self, pv):
|
||||
pkts = pv.pkts
|
||||
|
||||
@@ -208,8 +208,8 @@ class Cert_9_2_09_PendingPartition(thread_cert.TestCase):
|
||||
|
||||
leader_addr = self.nodes[LEADER].get_ip6_address(config.ADDRESS_TYPE.ML_EID)
|
||||
router1_addr = self.nodes[ROUTER1].get_ip6_address(config.ADDRESS_TYPE.ML_EID)
|
||||
self.assertTrue(self.nodes[ROUTER2].ping(leader_addr))
|
||||
self.assertTrue(self.nodes[COMMISSIONER].ping(router1_addr))
|
||||
self.assertTrue(self.nodes[ROUTER2].ping(leader_addr, timeout=10))
|
||||
self.assertTrue(self.nodes[COMMISSIONER].ping(router1_addr, timeout=10))
|
||||
|
||||
def verify(self, pv):
|
||||
pkts = pv.pkts
|
||||
|
||||
@@ -1751,28 +1751,23 @@ class NodeImpl:
|
||||
return self._expect_results(
|
||||
r'\|\s(\S+)\s+\|\s(\S+)\s+\|\s([0-9a-fA-F]{4})\s\|\s([0-9a-fA-F]{16})\s\|\s(\d+)')
|
||||
|
||||
def ping(self, ipaddr, num_responses=1, size=None, timeout=5):
|
||||
cmd = 'ping %s' % ipaddr
|
||||
if size is not None:
|
||||
cmd += ' %d' % size
|
||||
def ping(self, ipaddr, num_responses=1, size=8, timeout=5, count=1, interval=1, hoplimit=64):
|
||||
cmd = f'ping {ipaddr} {size} {count} {interval} {hoplimit} {timeout}'
|
||||
|
||||
self.send_command(cmd)
|
||||
|
||||
end = self.simulator.now() + timeout
|
||||
wait_allowance = 3
|
||||
end = self.simulator.now() + timeout + wait_allowance
|
||||
|
||||
responders = {}
|
||||
|
||||
result = True
|
||||
# ncp-sim doesn't print Done
|
||||
done = (self.node_type == 'ncp-sim')
|
||||
|
||||
# ncp-sim doesn't print statistics
|
||||
received_statistics = (self.node_type == 'ncp-sim')
|
||||
is_multicast = ipaddress.IPv6Address(ipaddr).is_multicast
|
||||
while len(responders) < num_responses or not done or (not is_multicast and not received_statistics):
|
||||
while len(responders) < num_responses or not done:
|
||||
self.simulator.go(1)
|
||||
try:
|
||||
i = self._expect([r'from (\S+):', r'Done', r'packets transmitted'], timeout=0.1)
|
||||
i = self._expect([r'from (\S+):', r'Done'], timeout=0.1)
|
||||
except (pexpect.TIMEOUT, socket.timeout):
|
||||
if self.simulator.now() < end:
|
||||
continue
|
||||
@@ -1785,8 +1780,6 @@ class NodeImpl:
|
||||
responders[self.pexpect.match.groups()[0]] = 1
|
||||
elif i == 1:
|
||||
done = True
|
||||
elif i == 2:
|
||||
received_statistics = True
|
||||
return result
|
||||
|
||||
def reset(self):
|
||||
|
||||
Reference in New Issue
Block a user