Skip to content

Commit

Permalink
yamltest: chip-repl: Make commissioning DUT flag more correct
Browse files Browse the repository at this point in the history
  • Loading branch information
tehampson committed Sep 27, 2023
1 parent 24b1d03 commit b4333fb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
5 changes: 4 additions & 1 deletion scripts/tests/yaml/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,10 @@ def chip_repl(parser_group: ParserGroup, adapter: str, stop_on_error: bool, stop
runner_hooks = TestRunnerLogger(show_adapter_logs, show_adapter_logs_on_error, use_test_harness_log_format)
runner_config = TestRunnerConfig(adapter, parser_group.pseudo_clusters, runner_options, runner_hooks)

runner = __import__(runner, fromlist=[None]).Runner(repl_storage_path, commission_on_network_dut)
node_id_to_commission = None
if commission_on_network_dut:
node_id_to_commission = parser_group.builder_config.parser_config.config_override['nodeId']
runner = __import__(runner, fromlist=[None]).Runner(repl_storage_path, node_id_to_commission=node_id_to_commission)
loop = asyncio.get_event_loop()
return loop.run_until_complete(runner.run(parser_group.builder_config, runner_config))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@


class Runner(TestRunner):
def __init__(self, repl_storage_path: str, commission_on_network_dut: bool):
def __init__(self, repl_storage_path: str, node_id_to_commission: int = None):
self._repl_runner = None
self._chip_stack = None
self._certificate_authority_manager = None
self._repl_storage_path = repl_storage_path
self._commission_on_network_dut = commission_on_network_dut
self._node_id_to_commission = node_id_to_commission

async def start(self):
chip.native.Init()
Expand All @@ -43,13 +43,8 @@ async def start(self):
chip_stack, chip_stack.GetStorageManager())
certificate_authority_manager.LoadAuthoritiesFromStorage()

commission_device = False
if len(certificate_authority_manager.activeCaList) == 0:
if self._commission_on_network_dut is False:
raise Exception(
'Provided repl storage does not contain certificate. Without commission_on_network_dut, there is no reachable DUT')
certificate_authority_manager.NewCertificateAuthority()
commission_device = True

if len(certificate_authority_manager.activeCaList[0].adminList) == 0:
certificate_authority_manager.activeCaList[0].NewFabricAdmin(
Expand All @@ -58,9 +53,13 @@ async def start(self):
ca_list = certificate_authority_manager.activeCaList

dev_ctrl = ca_list[0].adminList[0].NewController()
if commission_device:
# These magic values are the defaults expected for YAML tests
dev_ctrl.CommissionWithCode('MT:-24J0AFN00KA0648G00', 0x12344321)

# Unfortunately there is no convenient way to confirm if the provided node_id has
# already been commissioned. At this point we blindly trust that we should commission
# device with the provided node id.
if self._node_id_to_commission is not None:
# Magic value is the defaults expected for YAML tests.
dev_ctrl.CommissionWithCode('MT:-24J0AFN00KA0648G00', self._node_id_to_commission)

self._chip_stack = chip_stack
self._certificate_authority_manager = certificate_authority_manager
Expand Down

0 comments on commit b4333fb

Please sign in to comment.