Skip to content

Commit 6683b32

Browse files
mkardous-silabsrestyled-commits
authored andcommitted
[ICD] Add ICDM 3.4 Python Tests (project-chip#34784)
* Add ICDM 3.4 Python Tests * Restyled by isort * Delete yaml since it was replaced with python --------- Co-authored-by: Restyled.io <commits@restyled.io>
1 parent d8049ae commit 6683b32

File tree

3 files changed

+119
-202
lines changed

3 files changed

+119
-202
lines changed

src/app/tests/suites/certification/Test_TC_ICDM_3_4.yaml

-201
This file was deleted.

src/app/tests/suites/ciTests.json

-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@
7171
"IcdManagement": [
7272
"TestIcdManagementCluster",
7373
"Test_TC_ICDM_1_1",
74-
"Test_TC_ICDM_3_4",
7574
"Test_TC_ICDM_4_1"
7675
],
7776
"Identify": ["Test_TC_I_2_1", "Test_TC_I_2_2", "Test_TC_I_2_3"],

src/python_testing/TC_ICDM_3_4.py

+119
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
2+
#
3+
# Copyright (c) 2023 Project CHIP Authors
4+
# All rights reserved.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
19+
# See https://github.com/project-chip/connectedhomeip/blob/master/docs/testing/python.md#defining-the-ci-test-arguments
20+
# for details about the block below.
21+
#
22+
# === BEGIN CI TEST ARGUMENTS ===
23+
# test-runner-runs: run1
24+
# test-runner-run/run1/app: ${LIT_ICD_APP}
25+
# test-runner-run/run1/factoryreset: True
26+
# test-runner-run/run1/quiet: True
27+
# test-runner-run/run1/app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json
28+
# 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
29+
# === END CI TEST ARGUMENTS ===
30+
31+
import logging
32+
import time
33+
34+
import chip.clusters as Clusters
35+
from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main
36+
from mobly import asserts
37+
38+
logger = logging.getLogger(__name__)
39+
40+
kRootEndpointId = 0
41+
cluster = Clusters.Objects.IcdManagement
42+
attributes = cluster.Attributes
43+
44+
45+
class TC_ICDM_3_4(MatterBaseTest):
46+
47+
#
48+
# Class Helper functions
49+
#
50+
async def _read_icdm_attribute_expect_success(self, attribute):
51+
return await self.read_single_attribute_check_success(endpoint=kRootEndpointId, cluster=cluster, attribute=attribute)
52+
53+
#
54+
# Test Harness Helpers
55+
#
56+
57+
def desc_TC_ICDM_3_4(self) -> str:
58+
"""Returns a description of this test"""
59+
return "[TC-ICDM-3.4] ICDCounter Persistence with DUT as Server"
60+
61+
def steps_TC_ICDM_3_4(self) -> list[TestStep]:
62+
steps = [
63+
TestStep(0, "Commissioning, already done", is_commissioning=True),
64+
TestStep(1, "TH reads from the DUT the ICDCounter attribute."),
65+
TestStep("2a", "Reboot DUT."),
66+
TestStep("2b", "TH waits for {PIXIT.WAITTIME.REBOOT}"),
67+
TestStep(3, "Verify that the DUT response contains value of ICDCounter and stores in IcdCounter2. \
68+
IcdCounter2 is greater or equal to IcdCounter1. \
69+
ICDCounter attribute can roll over. If the attribute rolls over, it will be greater or equal to 0.")
70+
]
71+
return steps
72+
73+
def pics_TC_ICDM_3_4(self) -> list[str]:
74+
""" This function returns a list of PICS for this test case that must be True for the test to be run"""
75+
pics = [
76+
"ICDM.S",
77+
"ICDM.S.F00"
78+
]
79+
return pics
80+
81+
#
82+
# ICDM 3.4 Test Body
83+
#
84+
85+
@async_test_body
86+
async def test_TC_ICDM_3_4(self):
87+
is_ci = self.check_pics("PICS_SDK_CI_ONLY")
88+
89+
if not is_ci:
90+
asserts.assert_true('PIXIT.WAITTIME.REBOOT' in self.matter_test_config.global_test_params,
91+
"PIXIT.WAITTIME.REBOOT must be included on the command line in "
92+
"the --int-arg flag as PIXIT.WAITTIME.REBOOT:<wait time>")
93+
94+
wait_time_reboot = self.matter_test_config.global_test_params['PIXIT.WAITTIME.REBOOT']
95+
if wait_time_reboot == 0:
96+
asserts.fail("PIXIT.WAITTIME.REBOOT shall be higher than 0.")
97+
98+
# Pre-Condition: Commissioning
99+
self.step(0)
100+
101+
self.step(1)
102+
icdCounter1 = await self._read_icdm_attribute_expect_success(attribute=attributes.ICDCounter)
103+
104+
self.step("2a")
105+
if not is_ci:
106+
self.wait_for_user_input(prompt_msg="Restart DUT. Press Enter when restart has been initiated.")
107+
108+
self.step("2b")
109+
if not is_ci:
110+
time.sleep(wait_time_reboot)
111+
112+
self.step(3)
113+
icdCounter2 = await self._read_icdm_attribute_expect_success(attribute=attributes.ICDCounter)
114+
asserts.assert_greater_equal(icdCounter2, icdCounter1,
115+
"ICDCounter have reboot is not greater or equal to the ICDCounter read before the reboot.")
116+
117+
118+
if __name__ == "__main__":
119+
default_matter_test_main()

0 commit comments

Comments
 (0)