diff --git a/src/app/tests/suites/certification/Test_TC_ICDM_3_4.yaml b/src/app/tests/suites/certification/Test_TC_ICDM_3_4.yaml deleted file mode 100644 index a4eb232b98e157..00000000000000 --- a/src/app/tests/suites/certification/Test_TC_ICDM_3_4.yaml +++ /dev/null @@ -1,201 +0,0 @@ -# Copyright (c) 2024 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: 217.1.6. [TC-ICDM-3.4] ICDCounter persistence with DUT as Server - -PICS: - - ICDM.S - -config: - nodeId: 0x12344321 - cluster: "ICD Management" - endpoint: 0 - - CheckInNodeID1: - type: node_id - defaultValue: 1 - MonitorSubID1: - type: subject-id - defaultValue: 2 - Key1: - type: octstr - defaultValue: "hex:1234567890abcdef1234567890abcdef" - IdleModedurationValue: - type: int16u - defaultValue: 5 - -tests: - - label: - "Precondition: Commission DUT to TH (can be skipped if done in a - preceding test)" - cluster: "DelayCommands" - command: "WaitForCommissionee" - arguments: - values: - - name: "nodeId" - value: nodeId - - - label: - "Precondition: TH reads the RegisteredClients attribute from the DUT" - PICS: ICDM.S.A0003 - command: "readAttribute" - attribute: "RegisteredClients" - response: - saveAs: RegisteredClientsIDs - constraints: - type: list - - - label: - "Precondition: If list of registered clients is not empty, unregister - existing client(s)" - verification: | - Please send the 'unregister client' command using the check-in nodeID received from the previous read - ./chip-tool icdmanagement unregister-client 112233 1 0 - - [1704888949.629057][71657:71659] CHIP:DMG: - [1704888949.629066][71657:71659] CHIP:DMG: InteractionModelRevision = 11 - [1704888949.629074][71657:71659] CHIP:DMG: }, - [1704888949.629125][71657:71659] CHIP:DMG: Received Command Response Status for Endpoint=0 Cluster=0x0000_0046 Command=0x0000_0002 Status=0x0 - [1704888949.629153][71657:71659] CHIP:DMG: ICR moving to [AwaitingDe] - cluster: "LogCommands" - command: "UserPrompt" - PICS: PICS_USER_PROMPT && ICDM.S.C02.Rsp - arguments: - values: - - name: "message" - value: "Please enter 'y' for success" - - name: "expectedValue" - value: "y" - - - label: - "Precondition: TH reads from the DUT the RegisteredClients attribute. - Verify that the DUT response contains empty list of registered - clients." - PICS: ICDM.S.A0003 && PICS_USER_PROMPT - command: "readAttribute" - attribute: "RegisteredClients" - response: - value: [] - constraints: - type: list - - - label: "Step 1: TH reads from the DUT the IdleModeDuration attribute" - PICS: ICDM.S.A0000 - command: "readAttribute" - attribute: "IdleModeDuration" - response: - saveAs: IdleModeDuration1 - constraints: - type: int32u - minValue: 1 - maxValue: 64800 - - - label: "Step 2: TH reads from the DUT the ICDCounter attribute." - PICS: ICDM.S.A0004 - command: "readAttribute" - attribute: "ICDCounter" - response: - saveAs: ICDCounter1 - constraints: - type: int32u - minValue: 0 - maxValue: 4294967295 - - - label: - "Step 3a & 3b: TH sends RegisterClient command. - CheckInNodeID: - registering clients node ID (CheckInNodeID1) - MonitoredSubject: - monitored subject ID (MonitorSubID1) - Key: shared secret between the - client and the ICD (Key1). Verify DUT responds w/ status - SUCCESS(0x00); Verify that the DUT response contains IcdCounter1" - PICS: ICDM.S.C00.Rsp && ICDM.S.C01.Tx - command: "RegisterClient" - arguments: - values: - - name: "CheckInNodeID" - value: CheckInNodeID1 - - name: "MonitoredSubject" - value: MonitorSubID1 - - name: "Key" - value: Key1 - # Adding input for the test to pass for now - Full test script needs to be updated - - name: "ClientType" - value: ClientTypeEnum.Permanent - response: - values: - - name: "ICDCounter" - value: ICDCounter1 - constraints: - type: int32u - - - label: "Step 4: Wait for 1 or more Idle Mode duration." - cluster: "DelayCommands" - command: "WaitForMs" - arguments: - values: - - name: "ms" - value: ( IdleModedurationValue * 1000 ) - - #Issue https://github.com/project-chip/connectedhomeip/issues/31297 - - label: "Step 5: TH reads from the DUT the ICDCounter attribute." - verification: | - ./chip-tool icdmanagement read icdcounter 1 0 - - [1702421000.635860][1431:1433] CHIP:TOO: Endpoint: 0 Cluster: 0x0000_0046 Attribute 0x0000_0004 DataVersion: 2255930497 - [1702421000.635970][1431:1433] CHIP:TOO: ICDCounter: 1706188496 - cluster: "LogCommands" - command: "UserPrompt" - PICS: PICS_USER_PROMPT && ICDM.S.A0004 - arguments: - values: - - name: "message" - value: "Please enter 'y' for success" - - name: "expectedValue" - value: "y" - - - label: "Step 6: Reboot DUT" - PICS: PICS_SDK_CI_ONLY - cluster: "SystemCommands" - endpoint: 0 - command: "Reboot" - - - label: "Step Reboot target device(DUT)" - verification: | - Did the DUT successfully reboot? - cluster: "LogCommands" - command: "UserPrompt" - PICS: PICS_SKIP_SAMPLE_APP - arguments: - values: - - name: "message" - value: "Please reboot the DUT and enter 'y' after DUT starts" - - name: "expectedValue" - value: "y" - - - label: "Wait for the commissioned device to be retrieved" - cluster: "DelayCommands" - command: "WaitForCommissionee" - arguments: - values: - - name: "nodeId" - value: nodeId - - - label: "Step 7: TH reads from the DUT the ICDCounter attribute." - PICS: ICDM.S.A0004 && PICS_USER_PROMPT - command: "readAttribute" - attribute: "ICDCounter" - response: - constraints: - type: int32u - minValue: ICDCounter2 - maxValue: 4294967295 diff --git a/src/app/tests/suites/ciTests.json b/src/app/tests/suites/ciTests.json index 1e2410650bf1bc..d976d7623244fd 100644 --- a/src/app/tests/suites/ciTests.json +++ b/src/app/tests/suites/ciTests.json @@ -71,7 +71,6 @@ "IcdManagement": [ "TestIcdManagementCluster", "Test_TC_ICDM_1_1", - "Test_TC_ICDM_3_4", "Test_TC_ICDM_4_1" ], "Identify": ["Test_TC_I_2_1", "Test_TC_I_2_2", "Test_TC_I_2_3"], diff --git a/src/python_testing/TC_ICDM_3_4.py b/src/python_testing/TC_ICDM_3_4.py new file mode 100644 index 00000000000000..61230532178a08 --- /dev/null +++ b/src/python_testing/TC_ICDM_3_4.py @@ -0,0 +1,119 @@ + +# +# 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. +# + +# 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: ${LIT_ICD_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 time + +import chip.clusters as Clusters +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main +from mobly import asserts + +logger = logging.getLogger(__name__) + +kRootEndpointId = 0 +cluster = Clusters.Objects.IcdManagement +attributes = cluster.Attributes + + +class TC_ICDM_3_4(MatterBaseTest): + + # + # Class Helper functions + # + async def _read_icdm_attribute_expect_success(self, attribute): + return await self.read_single_attribute_check_success(endpoint=kRootEndpointId, cluster=cluster, attribute=attribute) + + # + # Test Harness Helpers + # + + def desc_TC_ICDM_3_4(self) -> str: + """Returns a description of this test""" + return "[TC-ICDM-3.4] ICDCounter Persistence with DUT as Server" + + def steps_TC_ICDM_3_4(self) -> list[TestStep]: + steps = [ + TestStep(0, "Commissioning, already done", is_commissioning=True), + TestStep(1, "TH reads from the DUT the ICDCounter attribute."), + TestStep("2a", "Reboot DUT."), + TestStep("2b", "TH waits for {PIXIT.WAITTIME.REBOOT}"), + TestStep(3, "Verify that the DUT response contains value of ICDCounter and stores in IcdCounter2. \ + IcdCounter2 is greater or equal to IcdCounter1. \ + ICDCounter attribute can roll over. If the attribute rolls over, it will be greater or equal to 0.") + ] + return steps + + def pics_TC_ICDM_3_4(self) -> list[str]: + """ This function returns a list of PICS for this test case that must be True for the test to be run""" + pics = [ + "ICDM.S", + "ICDM.S.F00" + ] + return pics + + # + # ICDM 3.4 Test Body + # + + @async_test_body + async def test_TC_ICDM_3_4(self): + is_ci = self.check_pics("PICS_SDK_CI_ONLY") + + if not is_ci: + asserts.assert_true('PIXIT.WAITTIME.REBOOT' in self.matter_test_config.global_test_params, + "PIXIT.WAITTIME.REBOOT must be included on the command line in " + "the --int-arg flag as PIXIT.WAITTIME.REBOOT:") + + wait_time_reboot = self.matter_test_config.global_test_params['PIXIT.WAITTIME.REBOOT'] + if wait_time_reboot == 0: + asserts.fail("PIXIT.WAITTIME.REBOOT shall be higher than 0.") + + # Pre-Condition: Commissioning + self.step(0) + + self.step(1) + icdCounter1 = await self._read_icdm_attribute_expect_success(attribute=attributes.ICDCounter) + + self.step("2a") + if not is_ci: + self.wait_for_user_input(prompt_msg="Restart DUT. Press Enter when restart has been initiated.") + + self.step("2b") + if not is_ci: + time.sleep(wait_time_reboot) + + self.step(3) + icdCounter2 = await self._read_icdm_attribute_expect_success(attribute=attributes.ICDCounter) + asserts.assert_greater_equal(icdCounter2, icdCounter1, + "ICDCounter have reboot is not greater or equal to the ICDCounter read before the reboot.") + + +if __name__ == "__main__": + default_matter_test_main()