diff --git a/src/python_testing/TC_DeviceBasicComposition.py b/src/python_testing/TC_DeviceBasicComposition.py index 9ff05d4ab0d68f..ba10ba97675d43 100644 --- a/src/python_testing/TC_DeviceBasicComposition.py +++ b/src/python_testing/TC_DeviceBasicComposition.py @@ -109,7 +109,7 @@ from chip.clusters.ClusterObjects import ClusterAttributeDescriptor, ClusterObjectFieldDescriptor from chip.interaction_model import InteractionModelError, Status from chip.tlv import uint -from global_attribute_ids import GlobalAttributeIds +from global_attribute_ids import AttributeIdType, ClusterIdType, GlobalAttributeIds, attribute_id_type, cluster_id_type from matter_testing_support import (AttributePathLocation, ClusterPathLocation, CommandPathLocation, MatterBaseTest, TestStep, async_test_body, default_matter_test_main) from mobly import asserts @@ -118,6 +118,11 @@ separate_endpoint_types) +def get_vendor_id(mei: int) -> int: + """Get the vendor ID portion (MEI prefix) of an overall MEI.""" + return (mei >> 16) & 0xffff + + def check_int_in_range(min_value: int, max_value: int, allow_null: bool = False) -> Callable: """Returns a checker for whether `obj` is an int that fits in a range.""" def int_in_range_checker(obj: Any): @@ -488,15 +493,17 @@ class RequiredMandatoryAttribute: cmd_prefixes = [a & 0xFFFF_0000 for a in cmd_values] bad_attrs = [a for a in attr_prefixes if a >= bad_prefix_min] bad_cmds = [a for a in cmd_prefixes if a >= bad_prefix_min] - for bad in bad_attrs: - location = AttributePathLocation(endpoint_id=endpoint_id, cluster_id=cluster_id, attribute_id=bad) + for bad_attrib_id in bad_attrs: + location = AttributePathLocation(endpoint_id=endpoint_id, cluster_id=cluster_id, attribute_id=bad_attrib_id) + vendor_id = get_vendor_id(bad_attrib_id) self.record_error(self.get_test_name( - ), location=location, problem=f'Attribute with bad prefix {attribute_id} in cluster {cluster_id}', spec_location='Manufacturer Extensible Identifier (MEI)') + ), location=location, problem=f'Attribute 0x{bad_attrib_id:08x} with bad prefix 0x{vendor_id:04x} in cluster 0x{cluster_id:08x}' + (' (Test Vendor)' if attribute_id_type(bad_attrib_id) == AttributeIdType.kTest else ''), spec_location='Manufacturer Extensible Identifier (MEI)') success = False - for bad in bad_cmds: - location = CommandPathLocation(endpoint_id=endpoint_id, cluster_id=cluster_id, command_id=bad) + for bad_cmd_id in bad_cmds: + location = CommandPathLocation(endpoint_id=endpoint_id, cluster_id=cluster_id, command_id=bad_cmd_id) + vendor_id = get_vendor_id(bad_cmd_id) self.record_error(self.get_test_name( - ), location=location, problem=f'Command with bad prefix {attribute_id} in cluster {cluster_id}', spec_location='Manufacturer Extensible Identifier (MEI)') + ), location=location, problem=f'Command 0x{bad_cmd_id:08x} with bad prefix 0x{vendor_id:04x} in cluster 0x{cluster_id:08x}', spec_location='Manufacturer Extensible Identifier (MEI)') success = False self.print_step(7, "Validate that none of the MEI global attribute IDs contain values outside of the allowed suffix range") @@ -539,10 +546,11 @@ class RequiredMandatoryAttribute: for endpoint_id, endpoint in self.endpoints_tlv.items(): cluster_prefixes = [a & 0xFFFF_0000 for a in endpoint.keys()] bad_clusters_ids = [a for a in cluster_prefixes if a >= bad_prefix_min] - for bad in bad_clusters_ids: - location = ClusterPathLocation(endpoint_id=endpoint_id, cluster_id=bad) + for bad_cluster_id in bad_clusters_ids: + location = ClusterPathLocation(endpoint_id=endpoint_id, cluster_id=bad_cluster_id) + vendor_id = get_vendor_id(bad_cluster_id) self.record_error(self.get_test_name(), location=location, - problem=f'Bad cluster id prefix {bad}', spec_location='Manufacturer Extensible Identifier (MEI)') + problem=f'Cluster 0x{bad_cluster_id:08x} with bad prefix 0x{vendor_id:04x}' + (' (Test Vendor)' if cluster_id_type(bad_cluster_id) == ClusterIdType.kTest else ''), spec_location='Manufacturer Extensible Identifier (MEI)') success = False self.print_step(9, "Validate that all clusters in the standard range have a known cluster ID")