Skip to content

Commit a276a70

Browse files
Add ICDM 3.4 Python Tests
1 parent b9c192b commit a276a70

File tree

1 file changed

+120
-0
lines changed

1 file changed

+120
-0
lines changed

src/python_testing/TC_ICDM_3_4.py

+120
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
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+
33+
import chip.clusters as Clusters
34+
from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main
35+
from mobly import asserts
36+
import time
37+
38+
39+
logger = logging.getLogger(__name__)
40+
41+
kRootEndpointId = 0
42+
cluster = Clusters.Objects.IcdManagement
43+
attributes = cluster.Attributes
44+
45+
46+
class TC_ICDM_3_4(MatterBaseTest):
47+
48+
#
49+
# Class Helper functions
50+
#
51+
async def _read_icdm_attribute_expect_success(self, attribute):
52+
return await self.read_single_attribute_check_success(endpoint=kRootEndpointId, cluster=cluster, attribute=attribute)
53+
54+
#
55+
# Test Harness Helpers
56+
#
57+
58+
def desc_TC_ICDM_3_4(self) -> str:
59+
"""Returns a description of this test"""
60+
return "[TC-ICDM-3.4] ICDCounter Persistence with DUT as Server"
61+
62+
def steps_TC_ICDM_3_4(self) -> list[TestStep]:
63+
steps = [
64+
TestStep(0, "Commissioning, already done", is_commissioning=True),
65+
TestStep(1, "TH reads from the DUT the ICDCounter attribute."),
66+
TestStep("2a", "Reboot DUT."),
67+
TestStep("2b", "TH waits for {PIXIT.WAITTIME.REBOOT}"),
68+
TestStep(3, "Verify that the DUT response contains value of ICDCounter and stores in IcdCounter2. \
69+
IcdCounter2 is greater or equal to IcdCounter1. \
70+
ICDCounter attribute can roll over. If the attribute rolls over, it will be greater or equal to 0.")
71+
]
72+
return steps
73+
74+
def pics_TC_ICDM_3_4(self) -> list[str]:
75+
""" This function returns a list of PICS for this test case that must be True for the test to be run"""
76+
pics = [
77+
"ICDM.S",
78+
"ICDM.S.F00"
79+
]
80+
return pics
81+
82+
#
83+
# ICDM 3.4 Test Body
84+
#
85+
86+
@async_test_body
87+
async def test_TC_ICDM_3_4(self):
88+
is_ci = self.check_pics("PICS_SDK_CI_ONLY")
89+
90+
if not is_ci:
91+
asserts.assert_true('PIXIT.WAITTIME.REBOOT' in self.matter_test_config.global_test_params,
92+
"PIXIT.WAITTIME.REBOOT must be included on the command line in "
93+
"the --int-arg flag as PIXIT.WAITTIME.REBOOT:<wait time>")
94+
95+
wait_time_reboot = self.matter_test_config.global_test_params['PIXIT.WAITTIME.REBOOT']
96+
if wait_time_reboot == 0:
97+
asserts.fail("PIXIT.WAITTIME.REBOOT shall be higher than 0.")
98+
99+
# Pre-Condition: Commissioning
100+
self.step(0)
101+
102+
self.step(1)
103+
icdCounter1 = await self._read_icdm_attribute_expect_success(attribute=attributes.ICDCounter)
104+
105+
self.step("2a")
106+
if not is_ci:
107+
self.wait_for_user_input(prompt_msg="Restart DUT. Press Enter when restart has been initiated.")
108+
109+
self.step("2b")
110+
if not is_ci:
111+
time.sleep(wait_time_reboot)
112+
113+
self.step(3)
114+
icdCounter2 = await self._read_icdm_attribute_expect_success(attribute=attributes.ICDCounter)
115+
asserts.assert_greater_equal(icdCounter2, icdCounter1,
116+
"ICDCounter have reboot is not greater or equal to the ICDCounter read before the reboot.")
117+
118+
119+
if __name__ == "__main__":
120+
default_matter_test_main()

0 commit comments

Comments
 (0)