diff --git a/tests/scripts/thread-cert/border_router/test_multi_ail.py b/tests/scripts/thread-cert/border_router/test_multi_ail.py index 665e3d092..66642fd7f 100755 --- a/tests/scripts/thread-cert/border_router/test_multi_ail.py +++ b/tests/scripts/thread-cert/border_router/test_multi_ail.py @@ -108,6 +108,14 @@ class TwoBorderRoutersOnTwoInfrastructures(thread_cert.TestCase): self.assertFalse(br1.ping(br2_infra_link_local, interface=br1_infra_link_local)) self.assertFalse(br2.ping(br1_infra_link_local, interface=br2_infra_link_local)) + # br peers + self.assertEqual(br1.get_br_peers_rloc16s(), [br2.get_addr16()]) + self.assertEqual(br2.get_br_peers_rloc16s(), [br1.get_addr16()]) + + # br routers + self.assertEqual(br1.get_br_routers_ip_addresses(), []) + self.assertEqual(br2.get_br_routers_ip_addresses(), []) + if __name__ == '__main__': unittest.main(verbosity=2) diff --git a/tests/scripts/thread-cert/node.py b/tests/scripts/thread-cert/node.py index 1e8ed91a1..9139541c8 100755 --- a/tests/scripts/thread-cert/node.py +++ b/tests/scripts/thread-cert/node.py @@ -2221,6 +2221,9 @@ class NodeImpl: self.send_command(cmd) self._expect_done() + # + # BR commands + # def enable_br(self): self.send_command('br enable') self._expect_done() @@ -2234,6 +2237,35 @@ class NodeImpl: self.send_command(cmd) return self._expect_command_output()[0] + def get_br_peers(self) -> List[str]: + # Example output of `br peers` command: + # rloc16:0xa800 age:00:00:50 + # rloc16:0x6800 age:00:00:51 + # Done + self.send_command('br peers') + return self._expect_command_output() + + def get_br_peers_rloc16s(self) -> List[int]: + """parse `br peers` output and return the list of RLOC16s""" + return [ + int(pair.split(':')[1], 16) + for line in self.get_br_peers() + for pair in line.split() + if pair.split(':')[0] == 'rloc16' + ] + + def get_br_routers(self) -> List[str]: + # Example output of `br routers` command: + # fe80:0:0:0:42:acff:fe14:3 (M:0 O:0 Stub:1) ms-since-rx:144160 reachable:yes age:00:17:36 (peer BR) + # fe80:0:0:0:42:acff:fe14:2 (M:0 O:0 Stub:1) ms-since-rx:45179 reachable:yes age:00:17:36 + # Done + self.send_command('br routers') + return self._expect_command_output() + + def get_br_routers_ip_addresses(self) -> List[IPv6Address]: + """parse `br routers` output and return the list of IPv6 addresses""" + return [IPv6Address(line.split()[0]) for line in self.get_br_routers()] + def get_netdata_omr_prefixes(self): omr_prefixes = [] for prefix in self.get_prefixes():