Skip to content

Commit

Permalink
Apply Cecille's suggestion to use GlobalAttributeIds checks
Browse files Browse the repository at this point in the history
  • Loading branch information
soares-sergio committed Oct 9, 2024
1 parent 3244b40 commit e3362ac
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/python_testing/TC_DeviceBasicComposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit e3362ac

Please sign in to comment.