From e3362ac11185b7b6a66c7250ee286b74519b0b13 Mon Sep 17 00:00:00 2001 From: Sergio Soares Date: Wed, 9 Oct 2024 16:41:45 -0400 Subject: [PATCH] Apply Cecille's suggestion to use GlobalAttributeIds checks --- src/python_testing/TC_DeviceBasicComposition.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/python_testing/TC_DeviceBasicComposition.py b/src/python_testing/TC_DeviceBasicComposition.py index 940358599e608e..ac20795d76ffca 100644 --- a/src/python_testing/TC_DeviceBasicComposition.py +++ b/src/python_testing/TC_DeviceBasicComposition.py @@ -90,7 +90,9 @@ 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 (GlobalAttributeIds, AttributeIdType, ClusterIdType, 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 @@ -166,11 +168,6 @@ def check_no_duplicates(obj: Any) -> None: raise ValueError(f"Value {str(obj)} contains duplicate values") -def is_test_vendor(id: int) -> bool: - vendor_id = (id >> 16) & 0xFFFF - return 0xFFF1 <= vendor_id <= 0xFFF4 - - class TC_DeviceBasicComposition(MatterBaseTest, BasicCompositionTests): @async_test_body async def setup_class(self): @@ -477,12 +474,12 @@ class RequiredMandatoryAttribute: for bad in bad_attrs: location = AttributePathLocation(endpoint_id=endpoint_id, cluster_id=cluster_id, attribute_id=bad) self.record_error(self.get_test_name( - ), location=location, problem=f'Attribute with bad prefix 0x{bad:04x} in cluster 0x{cluster_id:08x}' + (' (Test Vendor)' if is_test_vendor(bad) else ''), spec_location='Manufacturer Extensible Identifier (MEI)') + ), location=location, problem=f'Attribute with bad prefix 0x{bad:04x} in cluster 0x{cluster_id:08x}' + (' (Test Vendor)' if attribute_id_type(bad) == 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) self.record_error(self.get_test_name( - ), location=location, problem=f'Command with bad prefix 0x{bad:04x} in cluster 0x{cluster_id:08x}' + (' (Test Vendor)' if is_test_vendor(bad) else ''), spec_location='Manufacturer Extensible Identifier(MEI)') + ), location=location, problem=f'Command with bad prefix 0x{bad: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") @@ -528,7 +525,7 @@ class RequiredMandatoryAttribute: for bad in bad_clusters_ids: location = ClusterPathLocation(endpoint_id=endpoint_id, cluster_id=bad) self.record_error(self.get_test_name(), location=location, - problem=f'Bad cluster id prefix 0x{bad:04x}' + (' (Test Vendor)' if is_test_vendor(bad) else ''), spec_location='Manufacturer Extensible Identifier (MEI)') + problem=f'Bad cluster id prefix 0x{bad:04x}' + (' (Test Vendor)' if cluster_id_type(bad) == 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")