@@ -40,26 +40,49 @@ def generated_cmd_pics(pics_base: str, id: int) -> str:
40
40
def feature_pics (pics_base : str , bit : int ) -> str :
41
41
return f'{ pics_base } .S.F{ bit :02x} '
42
42
43
+ # Use bool-arg check_base_pics_files=True to check the base PICS xml against all known elements
44
+
43
45
44
46
class TC_PICS_Checker (MatterBaseTest , BasicCompositionTests ):
45
47
@async_test_body
46
48
async def setup_class (self ):
47
49
super ().setup_class ()
48
- await self .setup_class_helper (False )
50
+ if not self .user_params .get ("check_base_pics_files" , False ):
51
+ await self .setup_class_helper (False )
49
52
# build_xml_cluster returns a list of issues found when paring the XML
50
53
# Problems in the XML shouldn't cause test failure, but we want them recorded
51
54
# so they are added to the list of problems that get output when the test set completes.
52
55
self .xml_clusters , self .problems = build_xml_clusters ()
53
56
54
57
def _check_and_record_errors (self , location , required , pics ):
55
- if required and not self .check_pics (pics ):
58
+ if self .user_params .get ("check_base_pics_files" , False ):
59
+ # We just want to know that the pics appears in the xml file (aka in the dictionary), don't care about the value
60
+ have_pics = pics in self .matter_test_config .pics
61
+ else :
62
+ have_pics = self .check_pics (pics )
63
+
64
+ if required and not have_pics :
56
65
self .record_error ("PICS check" , location = location ,
57
66
problem = f"An element found on the device, but the corresponding PICS { pics } was not found in pics list" )
58
67
self .success = False
59
68
elif not required and self .check_pics (pics ):
60
69
self .record_error ("PICS check" , location = location , problem = f"PICS { pics } found in PICS list, but not on device" )
61
70
self .success = False
62
71
72
+ def _check_pics_required (self , attribute_id_of_element_list : int , cluster_id : int , element_id : int ):
73
+ if self .user_params .get ("check_base_pics_files" , False ):
74
+ return True
75
+
76
+ if cluster_id not in self .endpoint .keys ():
77
+ # This cluster is not on this endpoint
78
+ required = False
79
+ elif element_id in self .endpoint [cluster_id ][attribute_id_of_element_list ]:
80
+ # Cluster and element are on the endpoint
81
+ required = True
82
+ else :
83
+ # Cluster is on the endpoint but the element is not in the list
84
+ required = False
85
+
63
86
def _add_pics_for_lists (self , cluster_id : int , attribute_id_of_element_list : GlobalAttributeIds ) -> None :
64
87
try :
65
88
if attribute_id_of_element_list == GlobalAttributeIds .ATTRIBUTE_LIST_ID :
@@ -84,15 +107,7 @@ def _add_pics_for_lists(self, cluster_id: int, attribute_id_of_element_list: Glo
84
107
continue
85
108
pics = pics_mapper (self .xml_clusters [cluster_id ].pics , element_id )
86
109
87
- if cluster_id not in self .endpoint .keys ():
88
- # This cluster is not on this endpoint
89
- required = False
90
- elif element_id in self .endpoint [cluster_id ][attribute_id_of_element_list ]:
91
- # Cluster and element are on the endpoint
92
- required = True
93
- else :
94
- # Cluster is on the endpoint but the element is not in the list
95
- required = False
110
+ required = self ._check_pics_required (attribute_id_of_element_list , cluster_id , element_id )
96
111
97
112
if attribute_id_of_element_list == GlobalAttributeIds .ATTRIBUTE_LIST_ID :
98
113
location = AttributePathLocation (endpoint_id = self .endpoint_id , cluster_id = cluster_id , attribute_id = element_id )
@@ -113,7 +128,8 @@ def test_TC_IDM_10_4(self):
113
128
# wildcard read is done in setup_class
114
129
self .step (1 )
115
130
self .endpoint_id = self .matter_test_config .endpoint
116
- self .endpoint = self .endpoints_tlv [self .endpoint_id ]
131
+ if not self .user_params .get ("check_base_pics_files" , False ):
132
+ self .endpoint = self .endpoints_tlv [self .endpoint_id ]
117
133
self .success = True
118
134
119
135
# Data model XML is used to get the PICS code for this cluster. If we don't know the PICS
@@ -127,7 +143,12 @@ def test_TC_IDM_10_4(self):
127
143
# Ensure the PICS.S code is correctly marked
128
144
pics_cluster = f'{ self .xml_clusters [cluster_id ].pics } .S'
129
145
location = ClusterPathLocation (endpoint_id = self .endpoint_id , cluster_id = cluster_id )
130
- self ._check_and_record_errors (location , cluster_id in self .endpoint , pics_cluster )
146
+ if not self .user_params .get ("check_base_pics_files" , False ):
147
+ cluster_pics_required = cluster_id in self .endpoint
148
+ else :
149
+ cluster_pics_required = True
150
+
151
+ self ._check_and_record_errors (location , cluster_pics_required , pics_cluster )
131
152
132
153
self .step (3 )
133
154
for cluster_id , cluster in checkable_clusters .items ():
@@ -150,10 +171,18 @@ def test_TC_IDM_10_4(self):
150
171
continue
151
172
152
173
pics_base = self .xml_clusters [cluster_id ].pics
153
- try :
154
- feature_map = self .endpoint [cluster_id ][GlobalAttributeIds .FEATURE_MAP_ID ]
155
- except KeyError :
156
- feature_map = 0
174
+ if self .user_params .get ("check_base_pics_files" , False ):
175
+ try :
176
+ feature_map = 0
177
+ for f in Clusters .ClusterObjects .ALL_CLUSTERS [cluster_id ].Bitmaps .Feature :
178
+ feature_map &= f
179
+ except KeyError :
180
+ feature_map = 0
181
+ else :
182
+ try :
183
+ feature_map = self .endpoint [cluster_id ][GlobalAttributeIds .FEATURE_MAP_ID ]
184
+ except KeyError :
185
+ feature_map = 0
157
186
158
187
for feature_mask in cluster_features :
159
188
# Codegen in python uses feature masks (0x01, 0x02, 0x04 etc.)
0 commit comments