Skip to content

Commit

Permalink
Modified test steps
Browse files Browse the repository at this point in the history
  • Loading branch information
DejinChen committed Jul 15, 2024
1 parent 78affce commit 63fc763
Showing 1 changed file with 26 additions and 25 deletions.
51 changes: 26 additions & 25 deletions src/python_testing/TC_CNET_1_4.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
# test-runner-run/run1/script-args: --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:${TRACE_TEST_JSON}.json --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto



class TC_CNET_1_4(MatterBaseTest):
def steps_TC_CNET_1_4(self):
return [TestStep("precondition", "TH is commissioned", is_commissioning=True),
TestStep(1, 'TH performs a wildcard read of Network Commissioning clusters across all endpoints, and save the number of Network Commissioning clusters as `NetworkNum` for future use. If `NetworkNum` is 0, skip the remaining steps in this test case'),
TestStep(2, 'TH reads from the DUT the Descriptor Cluster DeviceTypeList attribute on each endpoint that hosts a Network Commissioning cluster, verify that the device types include the value 0x0016 (Root Node) or 0x0019 (Secondary Network Interface)'),
TestStep(3, 'TH reads from the DUT the General Commissioning Cluster SupportsConcurrentConnection attribute if NetworkNum is greater than 1, verify that it is true')]
return [TestStep(1, "TH is commissioned", is_commissioning=True),
TestStep(2, 'TH performs a wildcard read of Network Commissioning clusters across all endpoints, and save the number of Network Commissioning clusters as `NumNetworkCommissioning` for future use. If `NumNetworkCommissioning` is 0, skip the remaining steps in this test case'),
TestStep(3, 'TH reads from the DUT the Descriptor Cluster DeviceTypeList attribute from Endpoint 0, verify that the Network Commissioning cluster id (0x0031) is listed in the ServerList'),
TestStep(4, 'TH reads from the DUT the Descriptor Cluster DeviceTypeList attribute on each endpoint (except for Endpoint 0) that hosts a Network Commissioning cluster, verify that the Secondary Network Interface device type id (0x0019) is listed in the DeviceTypeList'),
TestStep(5, 'TH reads from the DUT the General Commissioning Cluster SupportsConcurrentConnection attribute if NumNetworkCommissioning is greater than 1, verify that it is true')]

def def_TC_CNET_1_4(self):
return '[TC-CNET-1.4] Verification for Secondary Network Interface [DUT-Server]'
Expand All @@ -51,45 +51,46 @@ def default_timeout(self) -> int:
@async_test_body
async def test_TC_CNET_1_4(self):
# Commissioning is already done
self.step("precondition")
self.step(1)

cnet = Clusters.NetworkCommissioning
afeam = cnet.Attributes.FeatureMap

self.step(1)
self.step(2)
# Read FeatureMap attribute with wildcard endpoint
feature_map_results = await self.default_controller.ReadAttribute(self.dut_node_id, [(afeam)], fabricFiltered=True)

NetworkNum = len(feature_map_results)
if NetworkNum == 0:
logging.info('No endpoint has Network Commissioning Cluster, skipping remaining steps')
self.skip_all_remaining_steps(2)
self.skip_all_remaining_steps(3)
return

endpoints = []
for endpoint, data in feature_map_results.items():
endpoints.append(endpoint)
logging.info(f"Network Commissioning Cluster on endpoints: {endpoints}")

self.step(2)
self.step(3)
cdesc = Clusters.Descriptor
adevt = cdesc.Attributes.DeviceTypeList
aser = cdesc.Attributes.ServerList

server_list = await self.read_single_attribute_check_success(cluster=Clusters.Descriptor, attribute=aser, endpoint=0)
if 49 not in server_list:
asserts.assert_true(False, "There is no Network Commissioning Cluster on endpoint 0")

for endpoint in endpoints:
if NetworkNum == 1:
logging.info('Only endpoint 0 has Network Commissioning Cluster, skipping remaining steps')
self.skip_all_remaining_steps(4)
return

self.step(4)
adevt = cdesc.Attributes.DeviceTypeList
for endpoint, _ in feature_map_results.items():
if endpoint == 0:
continue
device_type_list = await self.read_single_attribute_check_success(cluster=Clusters.Descriptor, attribute=adevt, endpoint=endpoint)
logging.info(f"Device tyep list: {device_type_list}")
# Root Node device id: 0x16, Secondary Network Interface device id: 0x19
required_device_types = {22, 25}
required_device_types = {25}
found_device_types = {device.deviceType for device in device_type_list}
asserts.assert_true(required_device_types.intersection(found_device_types),
"Network Commissioning Cluster is not on Root Node or Secondary Network Interface")

if NetworkNum == 1:
logging.info('Only one endpoint has Network Commissioning Cluster, skipping remaining steps')
self.skip_all_remaining_steps(3)
return

self.step(3)
self.step(5)
cgen = Clusters.GeneralCommissioning
ascc = cgen.Attributes.SupportsConcurrentConnection
concurrent_connection = await self.read_single_attribute_check_success(cluster=cgen, attribute=ascc)
Expand Down

0 comments on commit 63fc763

Please sign in to comment.