From 9fdabb352504f259d179c0ccf2394073c1dd390c Mon Sep 17 00:00:00 2001 From: chendejin Date: Thu, 4 Jul 2024 10:48:51 +0800 Subject: [PATCH 01/13] Added python testing for secondary network interface --- .github/workflows/tests.yaml | 1 + src/python_testing/TC_CNET_1_4.py | 98 +++++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+) create mode 100644 src/python_testing/TC_CNET_1_4.py diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index a8bdfdcdc2c1ec..2084ceb3febff0 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -500,6 +500,7 @@ jobs: scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_ACE_1_5.py' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_AccessChecker.py' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_CGEN_2_4.py' + scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_CNET_1_4.py' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_DA_1_2.py' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_DA_1_5.py' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_DA_1_7.py' diff --git a/src/python_testing/TC_CNET_1_4.py b/src/python_testing/TC_CNET_1_4.py new file mode 100644 index 00000000000000..791f19ea405079 --- /dev/null +++ b/src/python_testing/TC_CNET_1_4.py @@ -0,0 +1,98 @@ +# +# Copyright (c) 2024 Project CHIP Authors +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import logging + +# test-runner-runs: run1 +# test-runner-run/run1/app: ${ALL_CLUSTERS_APP} +# test-runner-run/run1/factoryreset: True +# test-runner-run/run1/quiet: True +# test-runner-run/run1/app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json +# 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 + +import chip.clusters as Clusters +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main +from mobly import asserts + + +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')] + + def def_TC_CNET_1_4(self): + return '[TC-CNET-1.4] Verification for Secondary Network Interface [DUT-Server]' + + def pics_TC_CNET_1_4(self): + return ['CNET.S'] + + # Override default timeout. + @property + def default_timeout(self) -> int: + return 200 + + @async_test_body + async def test_TC_CNET_1_4(self): + # Commissioning is already done + self.step("precondition") + + cnet = Clusters.NetworkCommissioning + afeam = cnet.Attributes.FeatureMap + + self.step(1) + # 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) + 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) + cdesc = Clusters.Descriptor + adevt = cdesc.Attributes.DeviceTypeList + + for endpoint in endpoints: + 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} + 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) + cgen = Clusters.GeneralCommissioning + ascc = cgen.Attributes.SupportsConcurrentConnection + concurrent_connection = await self.read_single_attribute_check_success(cluster=cgen, attribute=ascc) + asserts.assert_true(concurrent_connection, "The device does not support concurrent connection commissioning") + +if __name__ == "__main__": + default_matter_test_main() From 281833b819ada5a5566c811bc51ad83b32906077 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Fri, 12 Jul 2024 04:28:57 +0000 Subject: [PATCH 02/13] Restyled by autopep8 --- src/python_testing/TC_CNET_1_4.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/python_testing/TC_CNET_1_4.py b/src/python_testing/TC_CNET_1_4.py index 791f19ea405079..1234ad01740ba2 100644 --- a/src/python_testing/TC_CNET_1_4.py +++ b/src/python_testing/TC_CNET_1_4.py @@ -94,5 +94,6 @@ async def test_TC_CNET_1_4(self): concurrent_connection = await self.read_single_attribute_check_success(cluster=cgen, attribute=ascc) asserts.assert_true(concurrent_connection, "The device does not support concurrent connection commissioning") + if __name__ == "__main__": default_matter_test_main() From 78affce484a488cd36956b773ad486e8a6ffb24c Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Fri, 12 Jul 2024 04:29:01 +0000 Subject: [PATCH 03/13] Restyled by isort --- src/python_testing/TC_CNET_1_4.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/python_testing/TC_CNET_1_4.py b/src/python_testing/TC_CNET_1_4.py index 1234ad01740ba2..1b85e2ea60b109 100644 --- a/src/python_testing/TC_CNET_1_4.py +++ b/src/python_testing/TC_CNET_1_4.py @@ -17,6 +17,10 @@ import logging +import chip.clusters as Clusters +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main +from mobly import asserts + # test-runner-runs: run1 # test-runner-run/run1/app: ${ALL_CLUSTERS_APP} # test-runner-run/run1/factoryreset: True @@ -24,9 +28,6 @@ # test-runner-run/run1/app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json # 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 -import chip.clusters as Clusters -from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main -from mobly import asserts class TC_CNET_1_4(MatterBaseTest): From 63fc763ba37faf723d041702ce0dd6561920560d Mon Sep 17 00:00:00 2001 From: chendejin Date: Mon, 15 Jul 2024 20:53:31 +0800 Subject: [PATCH 04/13] Modified test steps --- src/python_testing/TC_CNET_1_4.py | 51 ++++++++++++++++--------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/src/python_testing/TC_CNET_1_4.py b/src/python_testing/TC_CNET_1_4.py index 1b85e2ea60b109..6c87f0d1fca4de 100644 --- a/src/python_testing/TC_CNET_1_4.py +++ b/src/python_testing/TC_CNET_1_4.py @@ -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]' @@ -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) From d165d07823fea6f568c5c1181562ac9e8118b2c6 Mon Sep 17 00:00:00 2001 From: cdj <45139296+DejinChen@users.noreply.github.com> Date: Wed, 17 Jul 2024 12:19:33 +0800 Subject: [PATCH 05/13] Use NumNetworkCommissioning in test --- src/python_testing/TC_CNET_1_4.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/python_testing/TC_CNET_1_4.py b/src/python_testing/TC_CNET_1_4.py index 6c87f0d1fca4de..64d821cfbdae7c 100644 --- a/src/python_testing/TC_CNET_1_4.py +++ b/src/python_testing/TC_CNET_1_4.py @@ -60,8 +60,8 @@ async def test_TC_CNET_1_4(self): # 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: + NumNetworkCommissioning = len(feature_map_results) + if NumNetworkCommissioning == 0: logging.info('No endpoint has Network Commissioning Cluster, skipping remaining steps') self.skip_all_remaining_steps(3) return @@ -74,7 +74,7 @@ async def test_TC_CNET_1_4(self): if 49 not in server_list: asserts.assert_true(False, "There is no Network Commissioning Cluster on endpoint 0") - if NetworkNum == 1: + if NumNetworkCommissioning == 1: logging.info('Only endpoint 0 has Network Commissioning Cluster, skipping remaining steps') self.skip_all_remaining_steps(4) return From 00be27b0a2a4b885995951cb51da1292dc207676 Mon Sep 17 00:00:00 2001 From: cdj <45139296+DejinChen@users.noreply.github.com> Date: Wed, 17 Jul 2024 13:26:25 +0800 Subject: [PATCH 06/13] Fix CI error. --- src/python_testing/TC_CNET_1_4.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/python_testing/TC_CNET_1_4.py b/src/python_testing/TC_CNET_1_4.py index 64d821cfbdae7c..bd7d024a420e83 100644 --- a/src/python_testing/TC_CNET_1_4.py +++ b/src/python_testing/TC_CNET_1_4.py @@ -15,18 +15,23 @@ # limitations under the License. # -import logging - -import chip.clusters as Clusters -from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main -from mobly import asserts - +# See https://github.com/project-chip/connectedhomeip/blob/master/docs/testing/python.md#defining-the-ci-test-arguments +# for details about the block below. +# +# === BEGIN CI TEST ARGUMENTS === # test-runner-runs: run1 # test-runner-run/run1/app: ${ALL_CLUSTERS_APP} # test-runner-run/run1/factoryreset: True # test-runner-run/run1/quiet: True # test-runner-run/run1/app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json # 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 +# === END CI TEST ARGUMENTS === + +import logging + +import chip.clusters as Clusters +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main +from mobly import asserts class TC_CNET_1_4(MatterBaseTest): From 54a8f1982be9120b24283f22ed69904e1ac2692d Mon Sep 17 00:00:00 2001 From: cdj <45139296+DejinChen@users.noreply.github.com> Date: Thu, 18 Jul 2024 09:46:49 +0800 Subject: [PATCH 07/13] Update src/python_testing/TC_CNET_1_4.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: René Josefsen <69624991+ReneJosefsen@users.noreply.github.com> --- src/python_testing/TC_CNET_1_4.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/python_testing/TC_CNET_1_4.py b/src/python_testing/TC_CNET_1_4.py index bd7d024a420e83..0122f7c90c5e2a 100644 --- a/src/python_testing/TC_CNET_1_4.py +++ b/src/python_testing/TC_CNET_1_4.py @@ -73,9 +73,7 @@ async def test_TC_CNET_1_4(self): self.step(3) cdesc = Clusters.Descriptor - aser = cdesc.Attributes.ServerList - - server_list = await self.read_single_attribute_check_success(cluster=Clusters.Descriptor, attribute=aser, endpoint=0) + server_list = await self.read_single_attribute_check_success(cluster=cdesc, attribute=cdesc.Attributes.ServerList, endpoint=0) if 49 not in server_list: asserts.assert_true(False, "There is no Network Commissioning Cluster on endpoint 0") From fa3ed3a9f8ab72813c2e5802da5f770841c327e8 Mon Sep 17 00:00:00 2001 From: cdj <45139296+DejinChen@users.noreply.github.com> Date: Thu, 18 Jul 2024 09:49:56 +0800 Subject: [PATCH 08/13] Update src/python_testing/TC_CNET_1_4.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: René Josefsen <69624991+ReneJosefsen@users.noreply.github.com> --- src/python_testing/TC_CNET_1_4.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/python_testing/TC_CNET_1_4.py b/src/python_testing/TC_CNET_1_4.py index 0122f7c90c5e2a..2065587bd4a02d 100644 --- a/src/python_testing/TC_CNET_1_4.py +++ b/src/python_testing/TC_CNET_1_4.py @@ -58,12 +58,9 @@ async def test_TC_CNET_1_4(self): # Commissioning is already done self.step(1) - cnet = Clusters.NetworkCommissioning - afeam = cnet.Attributes.FeatureMap - self.step(2) # Read FeatureMap attribute with wildcard endpoint - feature_map_results = await self.default_controller.ReadAttribute(self.dut_node_id, [(afeam)], fabricFiltered=True) + feature_map_results = await self.default_controller.ReadAttribute(self.dut_node_id, [(Clusters.NetworkCommissioning.Attributes.FeatureMap)], fabricFiltered=True) NumNetworkCommissioning = len(feature_map_results) if NumNetworkCommissioning == 0: From e41e3b80e1a41d7346027c50916eab360bbb841e Mon Sep 17 00:00:00 2001 From: chendejin Date: Thu, 18 Jul 2024 10:58:40 +0800 Subject: [PATCH 09/13] check response instead of reading on endpoint 0 --- src/python_testing/TC_CNET_1_4.py | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/python_testing/TC_CNET_1_4.py b/src/python_testing/TC_CNET_1_4.py index 2065587bd4a02d..9806b91cc02478 100644 --- a/src/python_testing/TC_CNET_1_4.py +++ b/src/python_testing/TC_CNET_1_4.py @@ -33,12 +33,15 @@ from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main from mobly import asserts +kRootEndpointId = 0 +kSecondaryNetworkInterfaceDeviceTypeId = 0x0019 + class TC_CNET_1_4(MatterBaseTest): def steps_TC_CNET_1_4(self): 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(3, 'TH checks whether endpoint 0 is contained in the response of the previous response to determine whether there is a Network Commissioning cluster on endpoint 0'), 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')] @@ -61,7 +64,6 @@ async def test_TC_CNET_1_4(self): self.step(2) # Read FeatureMap attribute with wildcard endpoint feature_map_results = await self.default_controller.ReadAttribute(self.dut_node_id, [(Clusters.NetworkCommissioning.Attributes.FeatureMap)], fabricFiltered=True) - NumNetworkCommissioning = len(feature_map_results) if NumNetworkCommissioning == 0: logging.info('No endpoint has Network Commissioning Cluster, skipping remaining steps') @@ -69,9 +71,10 @@ async def test_TC_CNET_1_4(self): return self.step(3) - cdesc = Clusters.Descriptor - server_list = await self.read_single_attribute_check_success(cluster=cdesc, attribute=cdesc.Attributes.ServerList, endpoint=0) - if 49 not in server_list: + endpoints = [] + for endpoint, _ in feature_map_results.items(): + endpoints.append(endpoint) + if kRootEndpointId not in endpoints: asserts.assert_true(False, "There is no Network Commissioning Cluster on endpoint 0") if NumNetworkCommissioning == 1: @@ -80,20 +83,19 @@ async def test_TC_CNET_1_4(self): return self.step(4) - adevt = cdesc.Attributes.DeviceTypeList - for endpoint, _ in feature_map_results.items(): - if endpoint == 0: + for endpoint in endpoints: + if endpoint == kRootEndpointId: continue - device_type_list = await self.read_single_attribute_check_success(cluster=Clusters.Descriptor, attribute=adevt, endpoint=endpoint) - required_device_types = {25} + device_type_list = await self.read_single_attribute_check_success(cluster=Clusters.Descriptor, + attribute=Clusters.Descriptor.Attributes.DeviceTypeList, endpoint=endpoint) + required_device_types = { kSecondaryNetworkInterfaceDeviceTypeId } 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") self.step(5) - cgen = Clusters.GeneralCommissioning - ascc = cgen.Attributes.SupportsConcurrentConnection - concurrent_connection = await self.read_single_attribute_check_success(cluster=cgen, attribute=ascc) + concurrent_connection = await self.read_single_attribute_check_success(cluster=Clusters.GeneralCommissioning, + attribute=Clusters.GeneralCommissioning.Attributes.SupportsConcurrentConnection) asserts.assert_true(concurrent_connection, "The device does not support concurrent connection commissioning") From 55a5c02e9d83d2454c3b6f764136c992af1086f0 Mon Sep 17 00:00:00 2001 From: chendejin Date: Thu, 18 Jul 2024 11:03:20 +0800 Subject: [PATCH 10/13] modified step description --- src/python_testing/TC_CNET_1_4.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/python_testing/TC_CNET_1_4.py b/src/python_testing/TC_CNET_1_4.py index 9806b91cc02478..0667dc3ef3c88c 100644 --- a/src/python_testing/TC_CNET_1_4.py +++ b/src/python_testing/TC_CNET_1_4.py @@ -41,7 +41,7 @@ class TC_CNET_1_4(MatterBaseTest): def steps_TC_CNET_1_4(self): 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 checks whether endpoint 0 is contained in the response of the previous response to determine whether there is a Network Commissioning cluster on endpoint 0'), + TestStep(3, 'TH checks whether endpoint 0 is contained in the previous response to determine whether there is a Network Commissioning cluster on endpoint 0'), 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')] @@ -88,7 +88,7 @@ async def test_TC_CNET_1_4(self): continue device_type_list = await self.read_single_attribute_check_success(cluster=Clusters.Descriptor, attribute=Clusters.Descriptor.Attributes.DeviceTypeList, endpoint=endpoint) - required_device_types = { kSecondaryNetworkInterfaceDeviceTypeId } + required_device_types = {kSecondaryNetworkInterfaceDeviceTypeId} 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") From 3a2096c308c9be67eb7203e1b48cb8ccb40db038 Mon Sep 17 00:00:00 2001 From: cdj <45139296+DejinChen@users.noreply.github.com> Date: Fri, 19 Jul 2024 09:42:41 +0800 Subject: [PATCH 11/13] Modified step description. --- src/python_testing/TC_CNET_1_4.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/python_testing/TC_CNET_1_4.py b/src/python_testing/TC_CNET_1_4.py index 0667dc3ef3c88c..1574b0fca51260 100644 --- a/src/python_testing/TC_CNET_1_4.py +++ b/src/python_testing/TC_CNET_1_4.py @@ -41,9 +41,9 @@ class TC_CNET_1_4(MatterBaseTest): def steps_TC_CNET_1_4(self): 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 checks whether endpoint 0 is contained in the previous response to determine whether there is a Network Commissioning cluster on endpoint 0'), + TestStep(3, 'TH verifies that Endpoint 0 exists in the returned data. If `NumNetworkCommissioning` is 1, skip the remaining steps'), 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')] + TestStep(5, 'TH reads from the DUT the General Commissioning Cluster SupportsConcurrentConnection attribute, verify that it is true')] def def_TC_CNET_1_4(self): return '[TC-CNET-1.4] Verification for Secondary Network Interface [DUT-Server]' From 0e32d253f2ea7138669c3273b3b0350ab32343b6 Mon Sep 17 00:00:00 2001 From: cdj <45139296+DejinChen@users.noreply.github.com> Date: Tue, 23 Jul 2024 09:50:44 +0800 Subject: [PATCH 12/13] Update steps. --- src/python_testing/TC_CNET_1_4.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/python_testing/TC_CNET_1_4.py b/src/python_testing/TC_CNET_1_4.py index 1574b0fca51260..03afff1ce58fc5 100644 --- a/src/python_testing/TC_CNET_1_4.py +++ b/src/python_testing/TC_CNET_1_4.py @@ -40,10 +40,11 @@ class TC_CNET_1_4(MatterBaseTest): def steps_TC_CNET_1_4(self): 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 verifies that Endpoint 0 exists in the returned data. If `NumNetworkCommissioning` is 1, skip the remaining steps'), - 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, verify that it is true')] + TestStep(2, 'TH performs a wildcard read of the FeatureMap attribute on Network Commissioning clusters across all endpoints, and save the response as `NetworkCommissioningResponse`'), + TestStep(3, 'If `NetworkCommissioningResponse` does not contain any entries for Network Commissioning cluster, skip remaining steps and end test case'), + TestStep(4, 'If `NetworkCommissioningResponse` contains only a single entry for Network Commissioning cluster on Endpoint 0, skip remaining steps and end test case. Verify `NetworkCommissioningResponse` contains an entry for Network Commissioning cluster on Endpoint 0'), + TestStep(5, 'TH reads from the DUT the Descriptor Cluster DeviceTypeList attribute on each endpoint from the `NetworkCommissioningResponse` (except for Endpoint 0), verify that the Secondary Network Interface device type id (0x0019) is listed in the DeviceTypeList'), + TestStep(6, 'TH reads from the DUT the General Commissioning Cluster SupportsConcurrentConnection attribute, verify that it is true')] def def_TC_CNET_1_4(self): return '[TC-CNET-1.4] Verification for Secondary Network Interface [DUT-Server]' @@ -63,26 +64,28 @@ async def test_TC_CNET_1_4(self): self.step(2) # Read FeatureMap attribute with wildcard endpoint - feature_map_results = await self.default_controller.ReadAttribute(self.dut_node_id, [(Clusters.NetworkCommissioning.Attributes.FeatureMap)], fabricFiltered=True) - NumNetworkCommissioning = len(feature_map_results) + NetworkCommissioningResponse = await self.default_controller.ReadAttribute(self.dut_node_id, [(Clusters.NetworkCommissioning.Attributes.FeatureMap)], fabricFiltered=True) + + self.step(3) + NumNetworkCommissioning = len(NetworkCommissioningResponse) if NumNetworkCommissioning == 0: logging.info('No endpoint has Network Commissioning Cluster, skipping remaining steps') - self.skip_all_remaining_steps(3) + self.skip_all_remaining_steps(4) return - self.step(3) + self.step(4) endpoints = [] - for endpoint, _ in feature_map_results.items(): + for endpoint, _ in NetworkCommissioningResponse.items(): endpoints.append(endpoint) if kRootEndpointId not in endpoints: asserts.assert_true(False, "There is no Network Commissioning Cluster on endpoint 0") if NumNetworkCommissioning == 1: logging.info('Only endpoint 0 has Network Commissioning Cluster, skipping remaining steps') - self.skip_all_remaining_steps(4) + self.skip_all_remaining_steps(5) return - self.step(4) + self.step(5) for endpoint in endpoints: if endpoint == kRootEndpointId: continue @@ -93,7 +96,7 @@ async def test_TC_CNET_1_4(self): asserts.assert_true(required_device_types.intersection(found_device_types), "Network Commissioning Cluster is not on Root Node or Secondary Network Interface") - self.step(5) + self.step(6) concurrent_connection = await self.read_single_attribute_check_success(cluster=Clusters.GeneralCommissioning, attribute=Clusters.GeneralCommissioning.Attributes.SupportsConcurrentConnection) asserts.assert_true(concurrent_connection, "The device does not support concurrent connection commissioning") From 3cbca240415c7c7e5668d0665f9069b6825935e0 Mon Sep 17 00:00:00 2001 From: cdj <45139296+DejinChen@users.noreply.github.com> Date: Fri, 26 Jul 2024 10:22:17 +0800 Subject: [PATCH 13/13] Update steps. --- src/python_testing/TC_CNET_1_4.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python_testing/TC_CNET_1_4.py b/src/python_testing/TC_CNET_1_4.py index 03afff1ce58fc5..d7560c4fd03942 100644 --- a/src/python_testing/TC_CNET_1_4.py +++ b/src/python_testing/TC_CNET_1_4.py @@ -40,7 +40,7 @@ class TC_CNET_1_4(MatterBaseTest): def steps_TC_CNET_1_4(self): return [TestStep(1, "TH is commissioned", is_commissioning=True), - TestStep(2, 'TH performs a wildcard read of the FeatureMap attribute on Network Commissioning clusters across all endpoints, and save the response as `NetworkCommissioningResponse`'), + TestStep(2, 'TH performs a wildcard read of the FeatureMap attribute on Network Commissioning clusters across all endpoints, and saves the response as `NetworkCommissioningResponse`'), TestStep(3, 'If `NetworkCommissioningResponse` does not contain any entries for Network Commissioning cluster, skip remaining steps and end test case'), TestStep(4, 'If `NetworkCommissioningResponse` contains only a single entry for Network Commissioning cluster on Endpoint 0, skip remaining steps and end test case. Verify `NetworkCommissioningResponse` contains an entry for Network Commissioning cluster on Endpoint 0'), TestStep(5, 'TH reads from the DUT the Descriptor Cluster DeviceTypeList attribute on each endpoint from the `NetworkCommissioningResponse` (except for Endpoint 0), verify that the Secondary Network Interface device type id (0x0019) is listed in the DeviceTypeList'),