From 3773614e41eec78e95b5acadc04c9a7737783c6a Mon Sep 17 00:00:00 2001 From: Mathieu Kardous Date: Tue, 22 Aug 2023 19:10:40 -0400 Subject: [PATCH] replace yaml test by python test --- .github/workflows/tests.yaml | 1 + .../certification/Test_TC_ICDM_2_1.yaml | 88 --------------- src/app/tests/suites/ciTests.json | 2 +- src/python_testing/TC_ICDM_2_1.py | 102 ++++++++++++++++++ 4 files changed, 104 insertions(+), 89 deletions(-) delete mode 100644 src/app/tests/suites/certification/Test_TC_ICDM_2_1.yaml create mode 100644 src/python_testing/TC_ICDM_2_1.py diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 3acc9e4cdf4fe2..e5e8f9d2eb78d3 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -417,6 +417,7 @@ jobs: scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_ACE_1_3.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_CGEN_2_4.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_DA_1_2.py" --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:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' + scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_ICDM_2_1.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_TIMESYNC_3_1.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_DA_1_5.py" --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:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_IDM_1_2.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' diff --git a/src/app/tests/suites/certification/Test_TC_ICDM_2_1.yaml b/src/app/tests/suites/certification/Test_TC_ICDM_2_1.yaml deleted file mode 100644 index 62ac283afcc8e8..00000000000000 --- a/src/app/tests/suites/certification/Test_TC_ICDM_2_1.yaml +++ /dev/null @@ -1,88 +0,0 @@ -# Copyright (c) 2023 Project CHIP Authors -# -# 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. - -name: 312.2.1. [TC-ICDM-2.1] Attributes with DUT as Server - -PICS: - - ICDM.S - -config: - nodeId: 0x12344321 - cluster: "ICD Management" - endpoint: 0 - -tests: - - label: "Step 1: Wait for the commissioned device to be retrieved" - cluster: "DelayCommands" - command: "WaitForCommissionee" - arguments: - values: - - name: "nodeId" - value: nodeId - - - label: "Step 2: TH reads from the DUT the IdleModeInterval attribute" - PICS: ICDM.S.A0000 - command: "readAttribute" - attribute: "IdleModeInterval" - response: - saveAs: IdleModeIntervalValue - constraints: - type: int32u - minValue: 1 - maxValue: 64800 - - - label: "Step 3: TH reads from the DUT the ActiveModeInterval attribute" - PICS: ICDM.S.A0001 - command: "readAttribute" - attribute: "ActiveModeInterval" - response: - constraints: - type: int32u - minValue: 300 - maxValue: (IdleModeIntervalValue * 1000) - - - label: "Step 4: TH reads from the DUT the ActiveModeThreshold attribute" - PICS: ICDM.S.A0002 - command: "readAttribute" - attribute: "ActiveModeThreshold" - response: - constraints: - type: int16u - minValue: 300 - - - label: "Step 5: TH reads from the DUT the RegisteredClients attribute" - PICS: ICDM.S.A0003 - command: "readAttribute" - attribute: "RegisteredClients" - response: - constraints: - type: list - - - label: "Step 6: TH reads from the DUT the IcdCounter attribute" - PICS: ICDM.S.A0004 - command: "readAttribute" - attribute: "ICDCounter" - response: - constraints: - type: int32u - - - label: - "Step 7: TH reads from the DUT the ClientsSupportedPerFabric attribute" - PICS: ICDM.S.A0005 - command: "readAttribute" - attribute: "ClientsSupportedPerFabric" - response: - constraints: - type: int16u - minValue: 1 diff --git a/src/app/tests/suites/ciTests.json b/src/app/tests/suites/ciTests.json index 93746a43470d09..8fd0ac79b9c1ea 100644 --- a/src/app/tests/suites/ciTests.json +++ b/src/app/tests/suites/ciTests.json @@ -74,7 +74,7 @@ "GeneralCommissioning": ["Test_TC_CGEN_1_1", "Test_TC_CGEN_2_1"], "GeneralDiagnostics": ["Test_TC_DGGEN_1_1", "Test_TC_DGGEN_2_1"], "GroupKeyManagement": ["Test_TC_GRPKEY_1_1"], - "IcdManagement": ["Test_TC_ICDM_1_1", "Test_TC_ICDM_2_1"], + "IcdManagement": ["Test_TC_ICDM_1_1"], "Identify": [ "Test_TC_I_1_1", "Test_TC_I_2_1", diff --git a/src/python_testing/TC_ICDM_2_1.py b/src/python_testing/TC_ICDM_2_1.py new file mode 100644 index 00000000000000..897c13acfba792 --- /dev/null +++ b/src/python_testing/TC_ICDM_2_1.py @@ -0,0 +1,102 @@ +# +# Copyright (c) 2023 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 ipaddress +from datetime import timedelta + +import chip.clusters as Clusters +from chip.clusters.Types import NullValue +from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main +from mobly import asserts + + +class TC_ICDM_2_1(MatterBaseTest): + async def read_icdm_attribute_expect_success(self, endpoint, attribute): + cluster = Clusters.Objects.ICDManagement + return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute) + + @async_test_body + async def test_TC_ICDM_2_1(self): + + endpoint = self.user_params.get("endpoint", 0) + + self.print_step(1, "Commissioning, already done") + attributes = Clusters.ICDManagement.Attributes + idleModeInterval = 0 + + # Idle Mode Interval attribute test + if (self.check_pics("ICDM.S.A0000")): + self.print_step(2, "Read IdleModeInterval Attribute") + + idleModeInterval = await self.read_icdm_attribute_expect_success(endpoint=endpoint, + attribute=attributes.IdleModeInterval) + asserts.assert_greater_equal(idleModeInterval, 1, "IdleModeInterval attribute is smaller than minimum value (1).") + asserts.assert_less_equal(idleModeInterval, 64800, "IdleModeInterval attribute is greater than maximum value (64800).") + else: + asserts.assert_true(False, "IdleModeInterval is a mandatory attribute and must be present in the PICS file") + + # Active Mode Interval attribute test + if (self.check_pics("ICDM.S.A0001")): + self.print_step(2, "Read ActiveModeInterval Attribute") + + idleModeInterval *= 1000 # Convert seconds to milliseconds + activeModeInterval = await self.read_icdm_attribute_expect_success(endpoint=endpoint, + attribute=attributes.ActiveModeInterval) + asserts.assert_greater_equal(activeModeInterval, 300, + "ActiveModeInterval attribute is smaller than minimum value (300).") + asserts.assert_less_equal(activeModeInterval, idleModeInterval, + "ActiveModeInterval attribute is greater than the IdleModeInterval attrbiute.") + else: + asserts.assert_true(False, "ActiveModeInterval is a mandatory attribute and must be present in the PICS file") + + # Active Mode Threshold attribute test + if (self.check_pics("ICDM.S.A0002")): + self.print_step(2, "Read ActiveModeThreshold Attribute") + + activeModeThreshold = await self.read_icdm_attribute_expect_success(endpoint=endpoint, + attribute=attributes.ActiveModeThreshold) + asserts.assert_greater_equal(activeModeThreshold, 300, + "ActiveModeThreshold attribute is smaller than minimum value (300).") + else: + asserts.assert_true(False, "ActiveModeThreshold is a mandatory attribute and must be present in the PICS file") + + # RegisteredClients attribute test + if (self.check_pics("ICDM.S.A0003")): + self.print_step(2, "Read RegisteredClients Attribute") + + registeredClients = await self.read_icdm_attribute_expect_success(endpoint=endpoint, + attribute=attributes.RegisteredClients) + + # ICDCounter attribute test + if (self.check_pics("ICDM.S.A0003")): + self.print_step(2, "Read ICDCounter Attribute") + + icdCounter = await self.read_icdm_attribute_expect_success(endpoint=endpoint, + attribute=attributes.ICDCounter) + + # ClientsSupportedPerFabric attribute test + if (self.check_pics("ICDM.S.A0003")): + self.print_step(2, "Read ClientsSupportedPerFabric Attribute") + + clientsSupportedPerFabric = await self.read_icdm_attribute_expect_success(endpoint=endpoint, + attribute=attributes.ClientsSupportedPerFabric) + asserts.assert_greater_equal(clientsSupportedPerFabric, 1, + "ActiveModeThreshold attribute is smaller than minimum value (300).") + + +if __name__ == "__main__": + default_matter_test_main()