Skip to content

Commit ddf6e2f

Browse files
authored
Implement python test for TC_DGETH_2_1 (project-chip#37153)
* Implement python test for TC_DGETH_2_1 * Add test requirments * Add PICs parameter
1 parent a576366 commit ddf6e2f

File tree

1 file changed

+157
-0
lines changed

1 file changed

+157
-0
lines changed

src/python_testing/TC_DGETH_2_1.py

+157
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
#
2+
# Copyright (c) 2025 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:
23+
# run1:
24+
# app: ${ALL_CLUSTERS_APP}
25+
# app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json
26+
# script-args: >
27+
# --PICS src/app/tests/suites/certification/ci-pics-values
28+
# --storage-path admin_storage.json
29+
# --commissioning-method on-network
30+
# --discriminator 1234
31+
# --passcode 20202021
32+
# --trace-to json:${TRACE_TEST_JSON}.json
33+
# --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto
34+
# factory-reset: true
35+
# quiet: true
36+
# === END CI TEST ARGUMENTS ===
37+
#
38+
39+
import chip.clusters as Clusters
40+
from chip.clusters.Types import NullValue
41+
from chip.testing import matter_asserts
42+
from chip.testing.matter_testing import MatterBaseTest, TestStep, async_test_body, default_matter_test_main
43+
from mobly import asserts
44+
45+
46+
class TC_DGETH_2_1(MatterBaseTest):
47+
"""
48+
[TC-DGETH-2.1] Ethernet Diagnostics Cluster - Attribute Read Verification
49+
50+
This test case verifies the behavior of the attributes of the Ethernet Diagnostics cluster server.
51+
See the test plan steps for details on each attribute read and expected outcome.
52+
53+
Requirements:
54+
- The Test Harness and DUT must be running on different physical devices.
55+
- Communication between the Test Harness and DUT should occur via Ethernet.
56+
"""
57+
58+
async def read_dgeth_attribute_expect_success(self, endpoint, attribute):
59+
cluster = Clusters.Objects.EthernetNetworkDiagnostics
60+
return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute)
61+
62+
def desc_TC_DGETH_2_1(self) -> str:
63+
"""Returns a description of this test"""
64+
return "[TC-DGETH-2.1] Attributes with Server as DUT"
65+
66+
def pics_TC_DGETH_2_1(self) -> list[str]:
67+
return ["DGETH.S"]
68+
69+
def steps_TC_DGETH_2_1(self) -> list[TestStep]:
70+
steps = [
71+
TestStep(1, "Commissioning, already done", is_commissioning=True),
72+
TestStep(2, "Read PHYRate attribute"),
73+
TestStep(3, "Read FullDuplex attribute"),
74+
TestStep(4, "Read PacketRxCount attribute"),
75+
TestStep(5, "Read PacketTxCount attribute"),
76+
TestStep(6, "Read TxErrCount attribute"),
77+
TestStep(7, "Read CollisionCount attribute"),
78+
TestStep(8, "Read OverrunCount attribute"),
79+
TestStep(9, "Read CarrierDetect attribute"),
80+
TestStep(10, "Read TimeSinceReset attribute"),
81+
]
82+
return steps
83+
84+
@async_test_body
85+
async def test_TC_DGETH_2_1(self):
86+
87+
endpoint = self.get_endpoint(0)
88+
89+
# STEP 1: Commission DUT (already done)
90+
self.step(1)
91+
92+
attributes = Clusters.EthernetNetworkDiagnostics.Attributes
93+
94+
# STEP 2: TH reads from the DUT the PHYRate attribute
95+
self.step(2)
96+
phy_rate_attr = await self.read_dgeth_attribute_expect_success(endpoint=endpoint, attribute=attributes.PHYRate)
97+
if phy_rate_attr is not None:
98+
if phy_rate_attr is not NullValue:
99+
matter_asserts.assert_valid_enum(phy_rate_attr, "PHYRate", Clusters.EthernetNetworkDiagnostics.Enums.PHYRateEnum)
100+
101+
# STEP 3: TH reads from the DUT the FullDuplex attribute
102+
self.step(3)
103+
full_duplex_attr = await self.read_dgeth_attribute_expect_success(endpoint=endpoint, attribute=attributes.FullDuplex)
104+
if full_duplex_attr is not None:
105+
if full_duplex_attr is not NullValue:
106+
matter_asserts.assert_valid_bool(full_duplex_attr, "FullDuplex")
107+
108+
# STEP 4: TH reads from the DUT the PacketRxCount attribute
109+
self.step(4)
110+
packet_rx_count_attr = await self.read_dgeth_attribute_expect_success(endpoint=endpoint, attribute=attributes.PacketRxCount)
111+
if packet_rx_count_attr is not None:
112+
matter_asserts.assert_valid_uint64(packet_rx_count_attr, "PacketRxCount")
113+
if not self.is_pics_sdk_ci_only:
114+
asserts.assert_true(packet_rx_count_attr > 0, f"PacketRxCount ({packet_rx_count_attr}) should be > 0)")
115+
116+
# STEP 5: TH reads from the DUT the PacketTxCount attribute
117+
self.step(5)
118+
packet_tx_count_attr = await self.read_dgeth_attribute_expect_success(endpoint=endpoint, attribute=attributes.PacketTxCount)
119+
if packet_tx_count_attr is not None:
120+
matter_asserts.assert_valid_uint64(packet_tx_count_attr, "PacketTxCount")
121+
if not self.is_pics_sdk_ci_only:
122+
asserts.assert_true(packet_tx_count_attr > 0, f"PacketTxCount ({packet_tx_count_attr}) should be > 0)")
123+
124+
# STEP 6: TH reads from the DUT the TxErrCount attribute
125+
self.step(6)
126+
tx_err_count_attr = await self.read_dgeth_attribute_expect_success(endpoint=endpoint, attribute=attributes.TxErrCount)
127+
if tx_err_count_attr is not None:
128+
matter_asserts.assert_valid_uint64(tx_err_count_attr, "TxErrCount")
129+
130+
# STEP 7: TH reads from the DUT the CollisionCount attribute
131+
self.step(7)
132+
collision_count_attr = await self.read_dgeth_attribute_expect_success(endpoint=endpoint, attribute=attributes.CollisionCount)
133+
if collision_count_attr is not None:
134+
matter_asserts.assert_valid_uint64(collision_count_attr, "CollisionCount")
135+
136+
# STEP 8: TH reads from the DUT the OverrunCount attribute
137+
self.step(8)
138+
overrun_count_attr = await self.read_dgeth_attribute_expect_success(endpoint=endpoint, attribute=attributes.OverrunCount)
139+
if overrun_count_attr is not None:
140+
matter_asserts.assert_valid_uint64(overrun_count_attr, "OverrunCount")
141+
142+
# STEP 9: TH reads from the DUT the CarrierDetect attribute
143+
self.step(9)
144+
carrier_detect_attr = await self.read_dgeth_attribute_expect_success(endpoint=endpoint, attribute=attributes.CarrierDetect)
145+
if carrier_detect_attr is not None:
146+
if carrier_detect_attr is not NullValue:
147+
matter_asserts.assert_valid_bool(carrier_detect_attr, "CarrierDetect")
148+
149+
# STEP 10: TH reads from the DUT the TimeSinceReset attribute
150+
self.step(10)
151+
time_since_reset_attr = await self.read_dgeth_attribute_expect_success(endpoint=endpoint, attribute=attributes.TimeSinceReset)
152+
if time_since_reset_attr is not None:
153+
matter_asserts.assert_valid_uint32(time_since_reset_attr, "TimeSinceReset")
154+
155+
156+
if __name__ == "__main__":
157+
default_matter_test_main()

0 commit comments

Comments
 (0)