|
| 1 | +# |
| 2 | +# Copyright (c) 2024 Project CHIP Authors |
| 3 | +# All rights reserved. |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | +# |
| 17 | + |
| 18 | +# See https://github.com/project-chip/connectedhomeip/blob/master/docs/testing/python.md#defining-the-ci-test-arguments |
| 19 | +# for details about the block below. |
| 20 | +# |
| 21 | +# === BEGIN CI TEST ARGUMENTS === |
| 22 | +# test-runner-runs: run1 |
| 23 | +# test-runner-run/run1/app: ${ALL_CLUSTERS_APP} |
| 24 | +# test-runner-run/run1/factoryreset: True |
| 25 | +# test-runner-run/run1/quiet: True |
| 26 | +# test-runner-run/run1/app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json |
| 27 | +# 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 |
| 28 | +# === END CI TEST ARGUMENTS === |
| 29 | + |
| 30 | +import logging |
| 31 | + |
| 32 | +import chip.clusters as Clusters |
| 33 | +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main |
| 34 | +from mobly import asserts |
| 35 | + |
| 36 | +kRootEndpointId = 0 |
| 37 | +kSecondaryNetworkInterfaceDeviceTypeId = 0x0019 |
| 38 | + |
| 39 | + |
| 40 | +class TC_CNET_1_4(MatterBaseTest): |
| 41 | + def steps_TC_CNET_1_4(self): |
| 42 | + return [TestStep(1, "TH is commissioned", is_commissioning=True), |
| 43 | + TestStep(2, 'TH performs a wildcard read of the FeatureMap attribute on Network Commissioning clusters across all endpoints, and saves the response as `NetworkCommissioningResponse`'), |
| 44 | + TestStep(3, 'If `NetworkCommissioningResponse` does not contain any entries for Network Commissioning cluster, skip remaining steps and end test case'), |
| 45 | + 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'), |
| 46 | + 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'), |
| 47 | + TestStep(6, 'TH reads from the DUT the General Commissioning Cluster SupportsConcurrentConnection attribute, verify that it is true')] |
| 48 | + |
| 49 | + def def_TC_CNET_1_4(self): |
| 50 | + return '[TC-CNET-1.4] Verification for Secondary Network Interface [DUT-Server]' |
| 51 | + |
| 52 | + def pics_TC_CNET_1_4(self): |
| 53 | + return ['CNET.S'] |
| 54 | + |
| 55 | + # Override default timeout. |
| 56 | + @property |
| 57 | + def default_timeout(self) -> int: |
| 58 | + return 200 |
| 59 | + |
| 60 | + @async_test_body |
| 61 | + async def test_TC_CNET_1_4(self): |
| 62 | + # Commissioning is already done |
| 63 | + self.step(1) |
| 64 | + |
| 65 | + self.step(2) |
| 66 | + # Read FeatureMap attribute with wildcard endpoint |
| 67 | + NetworkCommissioningResponse = await self.default_controller.ReadAttribute(self.dut_node_id, [(Clusters.NetworkCommissioning.Attributes.FeatureMap)], fabricFiltered=True) |
| 68 | + |
| 69 | + self.step(3) |
| 70 | + NumNetworkCommissioning = len(NetworkCommissioningResponse) |
| 71 | + if NumNetworkCommissioning == 0: |
| 72 | + logging.info('No endpoint has Network Commissioning Cluster, skipping remaining steps') |
| 73 | + self.skip_all_remaining_steps(4) |
| 74 | + return |
| 75 | + |
| 76 | + self.step(4) |
| 77 | + endpoints = [] |
| 78 | + for endpoint, _ in NetworkCommissioningResponse.items(): |
| 79 | + endpoints.append(endpoint) |
| 80 | + if kRootEndpointId not in endpoints: |
| 81 | + asserts.assert_true(False, "There is no Network Commissioning Cluster on endpoint 0") |
| 82 | + |
| 83 | + if NumNetworkCommissioning == 1: |
| 84 | + logging.info('Only endpoint 0 has Network Commissioning Cluster, skipping remaining steps') |
| 85 | + self.skip_all_remaining_steps(5) |
| 86 | + return |
| 87 | + |
| 88 | + self.step(5) |
| 89 | + for endpoint in endpoints: |
| 90 | + if endpoint == kRootEndpointId: |
| 91 | + continue |
| 92 | + device_type_list = await self.read_single_attribute_check_success(cluster=Clusters.Descriptor, |
| 93 | + attribute=Clusters.Descriptor.Attributes.DeviceTypeList, endpoint=endpoint) |
| 94 | + required_device_types = {kSecondaryNetworkInterfaceDeviceTypeId} |
| 95 | + found_device_types = {device.deviceType for device in device_type_list} |
| 96 | + asserts.assert_true(required_device_types.intersection(found_device_types), |
| 97 | + "Network Commissioning Cluster is not on Root Node or Secondary Network Interface") |
| 98 | + |
| 99 | + self.step(6) |
| 100 | + concurrent_connection = await self.read_single_attribute_check_success(cluster=Clusters.GeneralCommissioning, |
| 101 | + attribute=Clusters.GeneralCommissioning.Attributes.SupportsConcurrentConnection) |
| 102 | + asserts.assert_true(concurrent_connection, "The device does not support concurrent connection commissioning") |
| 103 | + |
| 104 | + |
| 105 | +if __name__ == "__main__": |
| 106 | + default_matter_test_main() |
0 commit comments