Skip to content

Commit 513ee90

Browse files
cecillepull[bot]
authored andcommitted
Basic comp tests: Update to Test plan style (#28145)
* Basic comp tests: Update to Test plan style Also add in the missing bits. NOTE: Still missing the topology test - it's getting close to the deadline and I don't want to rush here and make errors. * Device composition: duplicate device types * Appease the python overlords * Change back default * Revert "Device composition: duplicate device types" This reverts commit 333d9d5. * Apply suggestions from code review
1 parent 1ea7768 commit 513ee90

File tree

1 file changed

+71
-8
lines changed

1 file changed

+71
-8
lines changed

src/python_testing/TC_DeviceBasicComposition.py

+71-8
Original file line numberDiff line numberDiff line change
@@ -251,16 +251,52 @@ def fail_current_test(self, msg: Optional[str] = None):
251251
asserts.fail(msg)
252252

253253
# ======= START OF ACTUAL TESTS =======
254-
def test_endpoint_zero_present(self):
255-
logging.info("Validating that the Root Node endpoint is present (EP0)")
254+
def test_TC_SM_1_1(self):
255+
ROOT_NODE_DEVICE_TYPE = 0x16
256+
self.print_step(1, "Perform a wildcard read of attributes on all endpoints - already done")
257+
self.print_step(2, "Verify that endpoint 0 exists")
256258
if 0 not in self.endpoints:
257259
self.record_error(self.get_test_name(), location=AttributePathLocation(endpoint_id=0),
258260
problem="Did not find Endpoint 0.", spec_location="Endpoint Composition")
259261
self.fail_current_test()
260262

261-
def test_descriptor_present_on_each_endpoint(self):
262-
logging.info("Validating each endpoint has a descriptor cluster")
263+
self.print_step(3, "Verify that endpoint 0 descriptor cluster includes the root node device type")
264+
if Clusters.Descriptor not in self.endpoints[0]:
265+
self.record_error(self.get_test_name(), location=AttributePathLocation(endpoint_id=0),
266+
problem="No descriptor cluster on Endpoint 0", spec_location="Root node device type")
267+
self.fail_current_test()
268+
269+
listed_device_types = [i.deviceType for i in self.endpoints[0]
270+
[Clusters.Descriptor][Clusters.Descriptor.Attributes.DeviceTypeList]]
271+
if ROOT_NODE_DEVICE_TYPE not in listed_device_types:
272+
self.record_error(self.get_test_name(), location=AttributePathLocation(endpoint_id=0),
273+
problem="Root node device type not listed on endpoint 0", spec_location="Root node device type")
274+
self.fail_current_test()
263275

276+
self.print_step(4, "Verify that the root node device type does not appear in any of the non-zero endpoints")
277+
for endpoint_id, endpoint in self.endpoints.items():
278+
if endpoint_id == 0:
279+
continue
280+
listed_device_types = [i.deviceType for i in endpoint[Clusters.Descriptor]
281+
[Clusters.Descriptor.Attributes.DeviceTypeList]]
282+
if ROOT_NODE_DEVICE_TYPE in listed_device_types:
283+
self.record_error(self.get_test_name(), location=AttributePathLocation(endpoint_id=endpoint_id),
284+
problem=f'Root node device type listed on endpoint {endpoint_id}', spec_location="Root node device type")
285+
self.fail_current_test()
286+
287+
self.print_step(5, "Verify the existence of all the root node clusters on EP0")
288+
root = self.endpoints[0]
289+
required_clusters = [Clusters.BasicInformation, Clusters.AccessControl, Clusters.GroupKeyManagement,
290+
Clusters.GeneralCommissioning, Clusters.AdministratorCommissioning, Clusters.OperationalCredentials, Clusters.GeneralDiagnostics]
291+
for c in required_clusters:
292+
if c not in root:
293+
self.record_error(self.get_test_name(), location=AttributePathLocation(endpoint_id=0),
294+
problem=f'Root node does not contain required cluster {c}', spec_location="Root node device type")
295+
self.fail_current_test()
296+
297+
def test_DT_1_1(self):
298+
self.print_step(1, "Perform a wildcard read of attributes on all endpoints - already done")
299+
self.print_step(2, "Verify that each endpoint includes a descriptor cluster")
264300
success = True
265301
for endpoint_id, endpoint in self.endpoints.items():
266302
has_descriptor = (Clusters.Descriptor in endpoint)
@@ -273,8 +309,10 @@ def test_descriptor_present_on_each_endpoint(self):
273309
if not success:
274310
self.fail_current_test("At least one endpoint was missing the descriptor cluster.")
275311

276-
def test_global_attributes_present_on_each_cluster(self):
277-
logging.info("Validating each cluster has the mandatory global attributes")
312+
def test_IDM_10_1(self):
313+
self.print_step(1, "Perform a wildcard read of attributes on all endpoints - already done")
314+
315+
self.print_step(2, "Validate all global attributes are present")
278316

279317
@dataclass
280318
class RequiredMandatoryAttribute:
@@ -297,6 +335,7 @@ class RequiredMandatoryAttribute:
297335
validator=check_list_of_ints_in_range(0, 0xFFFF_FFFF)),
298336
]
299337

338+
self.print_step(3, "Validate all reported attributes match AttributeList")
300339
success = True
301340
for endpoint_id, endpoint in self.endpoints_tlv.items():
302341
for cluster_id, cluster in endpoint.items():
@@ -359,13 +398,37 @@ class RequiredMandatoryAttribute:
359398
# Warn only for now
360399
# TODO: Fail in the future
361400
continue
401+
for attribute_id in cluster:
402+
if attribute_id not in attribute_list:
403+
attribute_string = self.cluster_mapper.get_attribute_string(cluster_id, attribute_id)
404+
location = AttributePathLocation(endpoint_id, cluster_id, attribute_id)
405+
self.record_error(self.get_test_name(), location=location,
406+
problem=f'Found attribute {attribute_string} on {location.as_cluster_string(self.cluster_mapper)} not listed in attribute list', spec_location="AttributeList Attribute")
407+
success = False
362408

363409
if not success:
364410
self.fail_current_test(
365411
"At least one cluster was missing a mandatory global attribute or had differences between claimed attributes supported and actual.")
366412

367-
def test_all_attribute_strings_valid(self):
368-
asserts.skip("TODO: Validate every string in the attribute tree is valid UTF-8 and has no nulls")
413+
def test_IDM_11_1(self):
414+
success = True
415+
for endpoint_id, endpoint in self.endpoints_tlv.items():
416+
for cluster_id, cluster in endpoint.items():
417+
for attribute_id, attribute in cluster.items():
418+
if cluster_id not in Clusters.ClusterObjects.ALL_ATTRIBUTES or attribute_id not in Clusters.ClusterObjects.ALL_ATTRIBUTES[cluster_id]:
419+
continue
420+
if Clusters.ClusterObjects.ALL_ATTRIBUTES[cluster_id][attribute_id].attribute_type.Type is not str:
421+
continue
422+
try:
423+
cluster[attribute_id].encode('utf-8', errors='strict')
424+
except UnicodeError:
425+
location = AttributePathLocation(endpoint_id, cluster_id, attribute_id)
426+
attribute_string = self.cluster_mapper.get_attribute_string(cluster_id, attribute_id)
427+
self.record_error(self.get_test_name(
428+
), location=location, problem=f'Attribute {attribute_string} on {location.as_cluster_string(self.cluster_mapper)} is invalid UTF-8', spec_location="Data types - Character String")
429+
success = False
430+
if not success:
431+
self.fail_current_test("At least one attribute string was not valid UTF-8")
369432

370433
def test_all_event_strings_valid(self):
371434
asserts.skip("TODO: Validate every string in the read events is valid UTF-8 and has no nulls")

0 commit comments

Comments
 (0)