Skip to content

Commit 58896ab

Browse files
authored
Fix CHIP REPL tests runner after changes in e407d40 (project-chip#34453)
* Fix CHIP REPL tests runner after changes in e407d40 The click framework does not have a support for async functions. The async needs to be synchronized before applying click wrappers. * Accept 0x, 0b or 0o prefix for int values * Fix for non-string numbers * Exclude Test_TC_BRBINFO_2_1 from chip-repl engine * Log what happened in case of pseudo cluster creation failure * Fix typo * Fix typo when accessing TestGlobalStruct * Fix new line
1 parent 607a6da commit 58896ab

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

scripts/tests/chiptest/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ def _GetChipReplUnsupportedTests() -> Set[str]:
234234
"TestEventsById.yaml", # chip-repl does not support AnyCommands (06/06/2023)
235235
"TestReadNoneSubscribeNone.yaml", # chip-repl does not support AnyCommands (07/27/2023)
236236
"Test_TC_IDM_1_2.yaml", # chip-repl does not support AnyCommands (19/07/2023)
237+
"Test_TC_BRBINFO_2_1.yaml", # chip-repl does not support AnyCommands (24/07/2024)
237238
"TestIcdManagementCluster.yaml", # TODO(#30430): add ICD registration support in chip-repl
238239
"Test_TC_ICDM_3_4.yaml", # chip-repl does not support ICD registration
239240
# chip-repl and chip-tool disagree on what the YAML here should look like: https://github.com/project-chip/connectedhomeip/issues/29110

scripts/tests/chiptest/yamltest_with_chip_repl_tester.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import asyncio
1818
import atexit
19+
import functools
1920
import logging
2021
import os
2122
import tempfile
@@ -84,6 +85,13 @@ async def execute_test(yaml, runner):
8485
raise Exception(f'Test step failed {test_step.label}')
8586

8687

88+
def asyncio_executor(f):
89+
@functools.wraps(f)
90+
def wrapper(*args, **kwargs):
91+
return asyncio.run(f(*args, **kwargs))
92+
return wrapper
93+
94+
8795
@click.command()
8896
@click.option(
8997
'--setup-code',
@@ -101,6 +109,7 @@ async def execute_test(yaml, runner):
101109
'--pics-file',
102110
default=None,
103111
help='Optional PICS file')
112+
@asyncio_executor
104113
async def main(setup_code, yaml_path, node_id, pics_file):
105114
# Setting up python environment for running YAML CI tests using python parser.
106115
with tempfile.NamedTemporaryFile() as chip_stack_storage:
@@ -153,4 +162,4 @@ def _StackShutDown():
153162

154163

155164
if __name__ == '__main__':
156-
asyncio.run(main())
165+
main()

src/controller/python/chip/yaml/format_converter.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,11 @@ def convert_to_data_model_type(field_value, field_type):
198198
return field_value
199199
# YAML conversion treats all numbers as ints. Convert to a uint type if the schema
200200
# type indicates so.
201-
elif (field_type == uint):
201+
elif (type(field_value) is str and field_type == uint):
202202
# Longer number are stored as strings. Need to make this conversion first.
203-
value = int(field_value)
204-
return field_type(value)
203+
# The value can be represented in binary, octal, decimal or hexadecimal
204+
# format.
205+
return field_type(int(field_value, 0))
205206
# YAML treats enums as ints. Convert to the typed enum class.
206207
elif (issubclass(field_type, MatterIntEnum)):
207208
return field_type.extend_enum_if_value_doesnt_exist(field_value)

src/controller/python/chip/yaml/runner.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,8 @@ def _commissioner_command_action_factory(self, test_step):
832832
def _default_pseudo_cluster(self, test_step):
833833
try:
834834
return DefaultPseudoCluster(test_step)
835-
except ActionCreationError:
835+
except ActionCreationError as e:
836+
logger.warn(f"Failed create default pseudo cluster: {e}")
836837
return None
837838

838839
def encode(self, request) -> Optional[BaseAction]:

0 commit comments

Comments
 (0)