Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cirque] Cleanup thread network setup code #6156

Merged
merged 1 commit into from
May 4, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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