Skip to content

Commit

Permalink
Fix CHIP REPL tests runner after changes in e407d40 (project-chip#34453)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
arkq authored Aug 22, 2024
1 parent 607a6da commit 58896ab
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
1 change: 1 addition & 0 deletions scripts/tests/chiptest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ def _GetChipReplUnsupportedTests() -> Set[str]:
"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
Expand Down
11 changes: 10 additions & 1 deletion scripts/tests/chiptest/yamltest_with_chip_repl_tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import asyncio
import atexit
import functools
import logging
import os
import tempfile
Expand Down Expand Up @@ -84,6 +85,13 @@ async def execute_test(yaml, runner):
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',
Expand All @@ -101,6 +109,7 @@ async def execute_test(yaml, runner):
'--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:
Expand Down Expand Up @@ -153,4 +162,4 @@ def _StackShutDown():


if __name__ == '__main__':
asyncio.run(main())
main()
7 changes: 4 additions & 3 deletions src/controller/python/chip/yaml/format_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,11 @@ def convert_to_data_model_type(field_value, field_type):
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)
Expand Down
3 changes: 2 additions & 1 deletion src/controller/python/chip/yaml/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,8 @@ def _commissioner_command_action_factory(self, test_step):
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]:
Expand Down

0 comments on commit 58896ab

Please sign in to comment.