Skip to content

Commit

Permalink
Consolidate global attribute IDs between tests (#30179)
Browse files Browse the repository at this point in the history
* Consolidate global attribute IDs between tests

* one more

* Restyled by isort

---------

Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Nov 6, 2023
1 parent 595308b commit 4350132
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions src/python_testing/TC_DeviceBasicComposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@
from mobly import asserts
from spec_parsing_support import CommandType, build_xml_clusters

ATTRIBUTE_LIST_ID = 0xFFFB
ACCEPTED_COMMAND_LIST_ID = 0xFFF9
GENERATED_COMMAND_LIST_ID = 0xFFF8
FEATURE_MAP_ID = 0xFFFC
CLUSTER_REVISION_ID = 0xFFFD


def MatterTlvToJson(tlv_data: dict[int, Any]) -> dict[str, Any]:
"""Given TLV data for a specific cluster instance, convert to the Matter JSON format."""
Expand Down Expand Up @@ -475,12 +481,6 @@ class RequiredMandatoryAttribute:
name: str
validators: list[Callable]

ATTRIBUTE_LIST_ID = 0xFFFB
ACCEPTED_COMMAND_LIST_ID = 0xFFF9
GENERATED_COMMAND_LIST_ID = 0xFFF8
FEATURE_MAP_ID = 0xFFFC
CLUSTER_REVISION_ID = 0xFFFD

ATTRIBUTES_TO_CHECK = [
RequiredMandatoryAttribute(id=CLUSTER_REVISION_ID, name="ClusterRevision", validators=[check_int_in_range(1, 0xFFFF)]),
RequiredMandatoryAttribute(id=FEATURE_MAP_ID, name="FeatureMap", validators=[check_int_in_range(0, 0xFFFF_FFFF)]),
Expand Down Expand Up @@ -1032,15 +1032,9 @@ def conformance_str(conformance: Callable, feature_map: uint, feature_dict: dict
problem='Standard cluster found on device, but is not present in spec data')
continue

# TODO: switch to use global FEATURE_MAP_ID etc. once the IDM-10.1 change is merged.
FEATURE_MAP_ID = 0xFFFC
ATTRIBUTE_LIST_ID = 0xFFFB
ACCEPTED_COMMAND_ID = 0xFFF9
GENERATED_COMMAND_ID = 0xFFF8

feature_map = cluster[FEATURE_MAP_ID]
attribute_list = cluster[ATTRIBUTE_LIST_ID]
all_command_list = cluster[ACCEPTED_COMMAND_ID] + cluster[GENERATED_COMMAND_ID]
all_command_list = cluster[ACCEPTED_COMMAND_LIST_ID] + cluster[GENERATED_COMMAND_LIST_ID]

# Feature conformance checking
feature_masks = [1 << i for i in range(32) if feature_map & (1 << i)]
Expand Down Expand Up @@ -1091,8 +1085,7 @@ def conformance_str(conformance: Callable, feature_map: uint, feature_dict: dict

def check_spec_conformance_for_commands(command_type: CommandType) -> bool:
success = True
# TODO: once IDM-10.1 lands, use the globals
global_attribute_id = 0xFFF9 if command_type == CommandType.ACCEPTED else 0xFFF8
global_attribute_id = ACCEPTED_COMMAND_LIST_ID if command_type == CommandType.ACCEPTED else GENERATED_COMMAND_LIST_ID
xml_commands_dict = clusters[cluster_id].accepted_commands if command_type == CommandType.ACCEPTED else clusters[cluster_id].generated_commands
command_list = cluster[global_attribute_id]
for command_id in command_list:
Expand Down

0 comments on commit 4350132

Please sign in to comment.