From 45489682d47fb0b1e8cb0dd88a9173f450fefb99 Mon Sep 17 00:00:00 2001 From: Song Guo Date: Tue, 4 May 2021 08:49:05 +0800 Subject: [PATCH] [cirque] Fix thread network setup code (#6156) --- .../linux-cirque/helper/CHIPTestBase.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/test_driver/linux-cirque/helper/CHIPTestBase.py b/src/test_driver/linux-cirque/helper/CHIPTestBase.py index 912b0eeccba043..23544cd36088d7 100644 --- a/src/test_driver/linux-cirque/helper/CHIPTestBase.py +++ b/src/test_driver/linux-cirque/helper/CHIPTestBase.py @@ -129,9 +129,16 @@ def sequenceMatch(self, string, patterns): return True def connect_to_thread_network(self): - self.logger.info("Running commands to form Thread network") + ''' + The dataset in this function is used to replace the default dataset generated by openthread. + When the test writer is calling this function to setup a thread network, it means they just + want a working IPv6 network or a working thread network and don't care about the detail of + this network. + ''' + self.logger.info("Running commands to form default Thread network") for device in self.non_ap_devices: self.wait_for_device_output(device['id'], "Border router agent started.", 5) + otInitCommands = [ "ot-ctl thread stop", "ot-ctl ifconfig down", @@ -147,13 +154,13 @@ def connect_to_thread_network(self): self.logger.info("Waiting for Thread network to be formed...") threadNetworkFormed = False for i in range(30): - roles = set() + roles = list() for device in self.non_ap_devices: # We can only check the status of ot-agent by query its state. reply = self.execute_device_cmd(device['id'], 'ot-ctl state') - roles.add(reply['output'].split()[0]) - if ('leader' in roles) and ('router' in roles or 'child' in roles): - threadNetworkFormed = True + roles.append(reply['output'].split()[0]) + threadNetworkFormed = (roles.count('leader') == 1) and (roles.count('leader') + roles.count('router') + roles.count('child') == len(self.non_ap_devices)) + if threadNetworkFormed: break time.sleep(1) self.assertTrue(threadNetworkFormed)