Skip to content

Commit

Permalink
[cirque] Fix thread network setup code (#6156)
Browse files Browse the repository at this point in the history
  • Loading branch information
erjiaqing authored and pull[bot] committed Sep 16, 2021
1 parent 761f952 commit 1952204
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/test_driver/linux-cirque/helper/CHIPTestBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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)
Expand Down

0 comments on commit 1952204

Please sign in to comment.