Skip to content

Commit a76cc9b

Browse files
soares-sergiotcarmelveilleuxarkqandy31415restyled-commits
authored
python_testing: Improve TC_IDM_10_1 error msgs (project-chip#35999)
* python_testing: Improve TC_IDM_10_1 error msgs * Fix the prefix ID displayed in TC_IDM_10_1 error messages * Add "(Test Vendor)" to the error message when the ID is in the test vendor range * Apply suggestions from code review Co-authored-by: Tennessee Carmel-Veilleux <tennessee.carmelveilleux@gmail.com> * Apply Cecille's suggestion to use GlobalAttributeIds checks * Add space before (MEI) Co-authored-by: Arkadiusz Bokowy <arkadiusz.bokowy@gmail.com> * Apply Tennessee's review suggestions * Restyled by isort --------- Co-authored-by: Tennessee Carmel-Veilleux <tennessee.carmelveilleux@gmail.com> Co-authored-by: Arkadiusz Bokowy <arkadiusz.bokowy@gmail.com> Co-authored-by: Andrei Litvin <andy314@gmail.com> Co-authored-by: Restyled.io <commits@restyled.io>
1 parent 14e75a4 commit a76cc9b

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

src/python_testing/TC_DeviceBasicComposition.py

+18-10
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
from chip.clusters.ClusterObjects import ClusterAttributeDescriptor, ClusterObjectFieldDescriptor
110110
from chip.interaction_model import InteractionModelError, Status
111111
from chip.tlv import uint
112-
from global_attribute_ids import GlobalAttributeIds
112+
from global_attribute_ids import AttributeIdType, ClusterIdType, GlobalAttributeIds, attribute_id_type, cluster_id_type
113113
from matter_testing_support import (AttributePathLocation, ClusterPathLocation, CommandPathLocation, MatterBaseTest, TestStep,
114114
async_test_body, default_matter_test_main)
115115
from mobly import asserts
@@ -118,6 +118,11 @@
118118
separate_endpoint_types)
119119

120120

121+
def get_vendor_id(mei: int) -> int:
122+
"""Get the vendor ID portion (MEI prefix) of an overall MEI."""
123+
return (mei >> 16) & 0xffff
124+
125+
121126
def check_int_in_range(min_value: int, max_value: int, allow_null: bool = False) -> Callable:
122127
"""Returns a checker for whether `obj` is an int that fits in a range."""
123128
def int_in_range_checker(obj: Any):
@@ -488,15 +493,17 @@ class RequiredMandatoryAttribute:
488493
cmd_prefixes = [a & 0xFFFF_0000 for a in cmd_values]
489494
bad_attrs = [a for a in attr_prefixes if a >= bad_prefix_min]
490495
bad_cmds = [a for a in cmd_prefixes if a >= bad_prefix_min]
491-
for bad in bad_attrs:
492-
location = AttributePathLocation(endpoint_id=endpoint_id, cluster_id=cluster_id, attribute_id=bad)
496+
for bad_attrib_id in bad_attrs:
497+
location = AttributePathLocation(endpoint_id=endpoint_id, cluster_id=cluster_id, attribute_id=bad_attrib_id)
498+
vendor_id = get_vendor_id(bad_attrib_id)
493499
self.record_error(self.get_test_name(
494-
), location=location, problem=f'Attribute with bad prefix {attribute_id} in cluster {cluster_id}', spec_location='Manufacturer Extensible Identifier (MEI)')
500+
), 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)')
495501
success = False
496-
for bad in bad_cmds:
497-
location = CommandPathLocation(endpoint_id=endpoint_id, cluster_id=cluster_id, command_id=bad)
502+
for bad_cmd_id in bad_cmds:
503+
location = CommandPathLocation(endpoint_id=endpoint_id, cluster_id=cluster_id, command_id=bad_cmd_id)
504+
vendor_id = get_vendor_id(bad_cmd_id)
498505
self.record_error(self.get_test_name(
499-
), location=location, problem=f'Command with bad prefix {attribute_id} in cluster {cluster_id}', spec_location='Manufacturer Extensible Identifier (MEI)')
506+
), 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)')
500507
success = False
501508

502509
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:
539546
for endpoint_id, endpoint in self.endpoints_tlv.items():
540547
cluster_prefixes = [a & 0xFFFF_0000 for a in endpoint.keys()]
541548
bad_clusters_ids = [a for a in cluster_prefixes if a >= bad_prefix_min]
542-
for bad in bad_clusters_ids:
543-
location = ClusterPathLocation(endpoint_id=endpoint_id, cluster_id=bad)
549+
for bad_cluster_id in bad_clusters_ids:
550+
location = ClusterPathLocation(endpoint_id=endpoint_id, cluster_id=bad_cluster_id)
551+
vendor_id = get_vendor_id(bad_cluster_id)
544552
self.record_error(self.get_test_name(), location=location,
545-
problem=f'Bad cluster id prefix {bad}', spec_location='Manufacturer Extensible Identifier (MEI)')
553+
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)')
546554
success = False
547555

548556
self.print_step(9, "Validate that all clusters in the standard range have a known cluster ID")

0 commit comments

Comments
 (0)