Skip to content

Commit

Permalink
Add test requirments
Browse files Browse the repository at this point in the history
  • Loading branch information
yufengwangca committed Jan 24, 2025
1 parent f6a43ec commit 94cc34b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/python_testing/TC_DGETH_2_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from chip.clusters.Types import NullValue
from chip.testing import matter_asserts
from chip.testing.matter_testing import MatterBaseTest, TestStep, async_test_body, default_matter_test_main
from mobly import asserts


class TC_DGETH_2_1(MatterBaseTest):
Expand All @@ -47,6 +48,10 @@ class TC_DGETH_2_1(MatterBaseTest):
This test case verifies the behavior of the attributes of the Ethernet Diagnostics cluster server.
See the test plan steps for details on each attribute read and expected outcome.
Requirements:
- The Test Harness and DUT must be running on different physical devices.
- Communication between the Test Harness and DUT should occur via Ethernet.
"""

async def read_dgeth_attribute_expect_success(self, endpoint, attribute):
Expand Down Expand Up @@ -104,12 +109,16 @@ async def test_TC_DGETH_2_1(self):
packet_rx_count_attr = await self.read_dgeth_attribute_expect_success(endpoint=endpoint, attribute=attributes.PacketRxCount)
if packet_rx_count_attr is not None:
matter_asserts.assert_valid_uint64(packet_rx_count_attr, "PacketRxCount")
if not self.is_pics_sdk_ci_only:
asserts.assert_true(packet_rx_count_attr > 0, f"PacketRxCount ({packet_rx_count_attr}) should be > 0)")

# STEP 5: TH reads from the DUT the PacketTxCount attribute
self.step(5)
packet_tx_count_attr = await self.read_dgeth_attribute_expect_success(endpoint=endpoint, attribute=attributes.PacketTxCount)
if packet_tx_count_attr is not None:
matter_asserts.assert_valid_uint64(packet_tx_count_attr, "PacketTxCount")
if not self.is_pics_sdk_ci_only:
asserts.assert_true(packet_tx_count_attr > 0, f"PacketTxCount ({packet_tx_count_attr}) should be > 0)")

# STEP 6: TH reads from the DUT the TxErrCount attribute
self.step(6)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,14 @@ def assert_valid_int8(value: Any, description: str) -> None:
f"{description} must be a valid int8 integer")


def assert_valid_bool(value: Any, description: str) -> None:
"""
Asserts that the value is a valid bool (True/False).
"""
asserts.assert_true(is_valid_bool_value(value),
f"{description} must be a valid bool (True/False)")


def assert_int_in_range(value: Any, min_value: int, max_value: int, description: str) -> None:
"""
Asserts that the value is an integer within the specified range (inclusive).
Expand Down

0 comments on commit 94cc34b

Please sign in to comment.