Skip to content

Commit 4205955

Browse files
tehampsonpull[bot]
authored andcommitted
yamltest: chip-repl: Make commissioning DUT flag more correct (#29473)
1 parent 9ca0eb1 commit 4205955

File tree

2 files changed

+13
-11
lines changed
  • scripts/tests/yaml
  • src/controller/python/py_matter_yamltest_repl_adapter/matter_yamltest_repl_adapter

2 files changed

+13
-11
lines changed

scripts/tests/yaml/runner.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,10 @@ def chip_repl(parser_group: ParserGroup, adapter: str, stop_on_error: bool, stop
344344
runner_hooks = TestRunnerLogger(show_adapter_logs, show_adapter_logs_on_error, use_test_harness_log_format)
345345
runner_config = TestRunnerConfig(adapter, parser_group.pseudo_clusters, runner_options, runner_hooks)
346346

347-
runner = __import__(runner, fromlist=[None]).Runner(repl_storage_path, commission_on_network_dut)
347+
node_id_to_commission = None
348+
if commission_on_network_dut:
349+
node_id_to_commission = parser_group.builder_config.parser_config.config_override['nodeId']
350+
runner = __import__(runner, fromlist=[None]).Runner(repl_storage_path, node_id_to_commission=node_id_to_commission)
348351
loop = asyncio.get_event_loop()
349352
return loop.run_until_complete(runner.run(parser_group.builder_config, runner_config))
350353

src/controller/python/py_matter_yamltest_repl_adapter/matter_yamltest_repl_adapter/runner.py

+9-10
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@
2828

2929

3030
class Runner(TestRunner):
31-
def __init__(self, repl_storage_path: str, commission_on_network_dut: bool):
31+
def __init__(self, repl_storage_path: str, node_id_to_commission: int = None):
3232
self._repl_runner = None
3333
self._chip_stack = None
3434
self._certificate_authority_manager = None
3535
self._repl_storage_path = repl_storage_path
36-
self._commission_on_network_dut = commission_on_network_dut
36+
self._node_id_to_commission = node_id_to_commission
3737

3838
async def start(self):
3939
chip.native.Init()
@@ -43,13 +43,8 @@ async def start(self):
4343
chip_stack, chip_stack.GetStorageManager())
4444
certificate_authority_manager.LoadAuthoritiesFromStorage()
4545

46-
commission_device = False
4746
if len(certificate_authority_manager.activeCaList) == 0:
48-
if self._commission_on_network_dut is False:
49-
raise Exception(
50-
'Provided repl storage does not contain certificate. Without commission_on_network_dut, there is no reachable DUT')
5147
certificate_authority_manager.NewCertificateAuthority()
52-
commission_device = True
5348

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

6055
dev_ctrl = ca_list[0].adminList[0].NewController()
61-
if commission_device:
62-
# These magic values are the defaults expected for YAML tests
63-
dev_ctrl.CommissionWithCode('MT:-24J0AFN00KA0648G00', 0x12344321)
56+
57+
# Unfortunately there is no convenient way to confirm if the provided node_id has
58+
# already been commissioned. At this point we blindly trust that we should commission
59+
# device with the provided node id.
60+
if self._node_id_to_commission is not None:
61+
# Magic value is the defaults expected for YAML tests.
62+
dev_ctrl.CommissionWithCode('MT:-24J0AFN00KA0648G00', self._node_id_to_commission)
6463

6564
self._chip_stack = chip_stack
6665
self._certificate_authority_manager = certificate_authority_manager

0 commit comments

Comments
 (0)