Skip to content

Commit

Permalink
Basic comp tests: add fix for pre-commissioned devices
Browse files Browse the repository at this point in the history
  • Loading branch information
cecille committed Sep 4, 2024
1 parent 44f8837 commit ff6cdaa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/python_testing/basic_composition_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ def get_code(self, dev_ctrl):
created_codes.append(dev_ctrl.CreateManualCode(discriminator, self.matter_test_config.setup_passcodes[idx]))

setup_codes = self.matter_test_config.qr_code_content + self.matter_test_config.manual_code + created_codes
if not setup_codes:
return None
asserts.assert_equal(len(setup_codes), 1,
"Require exactly one of either --qr-code, --manual-code or (--discriminator and --passcode).")
return setup_codes[0]
Expand Down Expand Up @@ -132,7 +134,7 @@ async def setup_class_helper(self, allow_pase: bool = True):
node_id = self.dut_node_id

task_list = []
if allow_pase:
if allow_pase and self.get_code(dev_ctrl):
setup_code = self.get_code(dev_ctrl)
pase_future = dev_ctrl.EstablishPASESession(setup_code, self.dut_node_id)
task_list.append(asyncio.create_task(pase_future))
Expand Down
11 changes: 6 additions & 5 deletions src/python_testing/matter_testing_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -1744,15 +1744,19 @@ def populate_commissioning_args(args: argparse.Namespace, config: MatterTestConf

device_descriptors = config.qr_code_content + config.manual_code + config.discriminators

if not config.dut_node_ids:
config.dut_node_ids = [_DEFAULT_DUT_NODE_ID]

if args.commissioning_method is None:
return True

if len(config.dut_node_ids) > len(device_descriptors):
print("error: More node IDs provided than discriminators")
return False

if len(config.dut_node_ids) < len(device_descriptors):
# We generate new node IDs sequentially from the last one seen for all
# missing NodeIDs when commissioning many nodes at once.
if not config.dut_node_ids:
config.dut_node_ids = [_DEFAULT_DUT_NODE_ID]
missing = len(device_descriptors) - len(config.dut_node_ids)
for i in range(missing):
config.dut_node_ids.append(config.dut_node_ids[-1] + 1)
Expand All @@ -1765,9 +1769,6 @@ def populate_commissioning_args(args: argparse.Namespace, config: MatterTestConf
print("error: Duplicate value in discriminator list")
return False

if args.commissioning_method is None:
return True

if args.discriminators == [] and (args.qr_code == [] and args.manual_code == []):
print("error: Missing --discriminator when no --qr-code/--manual-code present!")
return False
Expand Down

0 comments on commit ff6cdaa

Please sign in to comment.