Fix CHIP REPL tests runner after changes in e407d40 (#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
diff --git a/scripts/tests/chiptest/__init__.py b/scripts/tests/chiptest/__init__.py
index aef22e0..03ac663 100644
--- a/scripts/tests/chiptest/__init__.py
+++ b/scripts/tests/chiptest/__init__.py
@@ -234,6 +234,7 @@
"TestEventsById.yaml", # chip-repl does not support AnyCommands (06/06/2023)
"TestReadNoneSubscribeNone.yaml", # chip-repl does not support AnyCommands (07/27/2023)
"Test_TC_IDM_1_2.yaml", # chip-repl does not support AnyCommands (19/07/2023)
+ "Test_TC_BRBINFO_2_1.yaml", # chip-repl does not support AnyCommands (24/07/2024)
"TestIcdManagementCluster.yaml", # TODO(#30430): add ICD registration support in chip-repl
"Test_TC_ICDM_3_4.yaml", # chip-repl does not support ICD registration
# chip-repl and chip-tool disagree on what the YAML here should look like: https://github.com/project-chip/connectedhomeip/issues/29110
diff --git a/scripts/tests/chiptest/yamltest_with_chip_repl_tester.py b/scripts/tests/chiptest/yamltest_with_chip_repl_tester.py
index 1b301c5..70f9215 100644
--- a/scripts/tests/chiptest/yamltest_with_chip_repl_tester.py
+++ b/scripts/tests/chiptest/yamltest_with_chip_repl_tester.py
@@ -16,6 +16,7 @@
import asyncio
import atexit
+import functools
import logging
import os
import tempfile
@@ -84,6 +85,13 @@
raise Exception(f'Test step failed {test_step.label}')
+def asyncio_executor(f):
+ @functools.wraps(f)
+ def wrapper(*args, **kwargs):
+ return asyncio.run(f(*args, **kwargs))
+ return wrapper
+
+
@click.command()
@click.option(
'--setup-code',
@@ -101,6 +109,7 @@
'--pics-file',
default=None,
help='Optional PICS file')
+@asyncio_executor
async def main(setup_code, yaml_path, node_id, pics_file):
# Setting up python environment for running YAML CI tests using python parser.
with tempfile.NamedTemporaryFile() as chip_stack_storage:
@@ -153,4 +162,4 @@
if __name__ == '__main__':
- asyncio.run(main())
+ main()
diff --git a/src/controller/python/chip/yaml/format_converter.py b/src/controller/python/chip/yaml/format_converter.py
index eefe61f..1be0511 100644
--- a/src/controller/python/chip/yaml/format_converter.py
+++ b/src/controller/python/chip/yaml/format_converter.py
@@ -198,10 +198,11 @@
return field_value
# YAML conversion treats all numbers as ints. Convert to a uint type if the schema
# type indicates so.
- elif (field_type == uint):
+ elif (type(field_value) is str and field_type == uint):
# Longer number are stored as strings. Need to make this conversion first.
- value = int(field_value)
- return field_type(value)
+ # The value can be represented in binary, octal, decimal or hexadecimal
+ # format.
+ return field_type(int(field_value, 0))
# YAML treats enums as ints. Convert to the typed enum class.
elif (issubclass(field_type, MatterIntEnum)):
return field_type.extend_enum_if_value_doesnt_exist(field_value)
diff --git a/src/controller/python/chip/yaml/runner.py b/src/controller/python/chip/yaml/runner.py
index 00e0de2..8a19109 100644
--- a/src/controller/python/chip/yaml/runner.py
+++ b/src/controller/python/chip/yaml/runner.py
@@ -832,7 +832,8 @@
def _default_pseudo_cluster(self, test_step):
try:
return DefaultPseudoCluster(test_step)
- except ActionCreationError:
+ except ActionCreationError as e:
+ logger.warn(f"Failed create default pseudo cluster: {e}")
return None
def encode(self, request) -> Optional[BaseAction]: