@@ -56,6 +56,18 @@ def is_valid_uint32_value(value):
56
56
def is_valid_str_value (value ):
57
57
return isinstance (value , str ) and len (value ) > 0
58
58
59
+ def assert_valid_uint64 (self , value , field_name ):
60
+ """Asserts that the value is a valid uint64."""
61
+ asserts .assert_true (self .is_valid_uint64_value (value ), f"{ field_name } field should be a uint64 type" )
62
+
63
+ def assert_valid_uint32 (self , value , field_name ):
64
+ """Asserts that the value is a valid uint32."""
65
+ asserts .assert_true (self .is_valid_uint32_value (value ), f"{ field_name } field should be a uint32 type" )
66
+
67
+ def assert_valid_str (self , value , field_name ):
68
+ """Asserts that the value is a non-empty string."""
69
+ asserts .assert_true (self .is_valid_str_value (value ), f"{ field_name } field should be a non-empty string" )
70
+
59
71
async def read_dgsw_attribute_expect_success (self , endpoint , attribute ):
60
72
cluster = Clusters .Objects .SoftwareDiagnostics
61
73
return await self .read_single_attribute_check_success (endpoint = endpoint , cluster = cluster , attribute = attribute )
@@ -67,7 +79,7 @@ async def send_reset_watermarks_command(self):
67
79
68
80
def desc_TC_DGSW_2_3 (self ) -> str :
69
81
"""Returns a description of this test"""
70
- return "[TC-DGSW-2.1 ] Attributes with Server as DUT"
82
+ return "[TC-DGSW-2.3 ] Attributes with Server as DUT"
71
83
72
84
def pics_TC_DGSW_2_3 (self ) -> list [str ]:
73
85
return ["DGSW.S" ]
@@ -106,35 +118,32 @@ async def test_TC_DGSW_2_3(self):
106
118
# Iterate over all items in the list and validate each one
107
119
for metric in thread_metrics_original :
108
120
# The Id field is mandatory
109
- asserts . assert_true ( self .is_valid_uint64_value (metric .id ) , "Id field should be a uint64 type " )
121
+ self .assert_valid_uint64 (metric .id , "Id" )
110
122
111
123
if metric .name is not None :
112
- asserts . assert_true ( self .is_valid_str_value (metric .name ) , "Name field should be a string type " )
124
+ self .assert_valid_str (metric .name , "Name" )
113
125
114
126
if metric .stackFreeCurrent is not None :
115
- asserts .assert_true (self .is_valid_uint32_value (metric .stackFreeCurrent ),
116
- "StackFreeCurrent field should be a uint32 type" )
127
+ self .assert_valid_uint32 (metric .stackFreeCurrent , "StackFreeCurrent" )
117
128
118
129
if metric .stackFreeMinimum is not None :
119
- asserts .assert_true (self .is_valid_uint32_value (metric .stackFreeMinimum ),
120
- "StackFreeMinimum field should be a uint32 type" )
130
+ self .assert_valid_uint32 (metric .stackFreeMinimum , "StackFreeMinimum" )
121
131
122
132
if metric .stackSize is not None :
123
- asserts . assert_true ( self .is_valid_uint32_value (metric .stackSize ) , "StackSize field should be a uint32 type " )
133
+ self .assert_valid_uint32 (metric .stackSize , "StackSize" )
124
134
125
135
# STEP 4: TH reads from the DUT the CurrentHeapHighWatermark attribute
126
136
self .step (4 )
127
137
if self .pics_guard (attributes .CurrentHeapHighWatermark .attribute_id in attribute_list ):
128
138
high_watermark_original = await self .read_dgsw_attribute_expect_success (endpoint = endpoint , attribute = attributes .CurrentHeapHighWatermark )
129
- asserts .assert_true (self .is_valid_uint64_value (high_watermark_original ),
130
- "CurrentHeapHighWatermark field should be a uint64 type" )
139
+ self .assert_valid_uint64 (high_watermark_original , "CurrentHeapHighWatermark" )
131
140
132
141
# STEP 5: TH reads from the DUT the CurrentHeapUsed attribute
133
142
self .step (5 )
134
143
if self .pics_guard (attributes .CurrentHeapUsed .attribute_id in attribute_list ):
135
144
current_heap_used_original = await self .read_dgsw_attribute_expect_success (endpoint = endpoint , attribute = attributes .CurrentHeapUsed )
136
- asserts . assert_true ( self .is_valid_uint64_value (current_heap_used_original ),
137
- "CurrentHeapUsed field should be a uint64 type" )
145
+ self .assert_valid_uint64 (current_heap_used_original , "CurrentHeapUsed" )
146
+
138
147
if high_watermark_original is not None :
139
148
asserts .assert_true (current_heap_used_original <= high_watermark_original ,
140
149
"CurrentHeapUsed should be less than or equal to CurrentHeapHighWatermark" )
@@ -148,8 +157,7 @@ async def test_TC_DGSW_2_3(self):
148
157
self .step (7 )
149
158
if self .pics_guard (attributes .CurrentHeapHighWatermark .attribute_id in attribute_list ):
150
159
current_heap_high_watermark = await self .read_dgsw_attribute_expect_success (endpoint = endpoint , attribute = attributes .CurrentHeapHighWatermark )
151
- asserts .assert_true (self .is_valid_uint64_value (current_heap_high_watermark ),
152
- "CurrentHeapHighWatermark field should be a uint64 type" )
160
+ self .assert_valid_uint64 (current_heap_high_watermark , "CurrentHeapHighWatermark" )
153
161
154
162
# Verify that the returned value is <= high_watermark_original
155
163
asserts .assert_true (current_heap_high_watermark <= high_watermark_original ,
@@ -168,22 +176,19 @@ async def test_TC_DGSW_2_3(self):
168
176
169
177
# Validate all elements in the list
170
178
for metric in thread_metrics_reset :
171
- # The Id field is mandatory
172
- asserts .assert_true (self .is_valid_uint64_value (metric .id ), "Id field should be a uint64 type" )
179
+ self .assert_valid_uint64 (metric .id , "Id" )
173
180
174
181
if metric .name is not None :
175
- asserts . assert_true ( self .is_valid_str_value (metric .name ) , "Name field should be a string type " )
182
+ self .assert_valid_str (metric .name , "Name" )
176
183
177
184
if metric .stackFreeCurrent is not None :
178
- asserts .assert_true (self .is_valid_uint32_value (metric .stackFreeCurrent ),
179
- "StackFreeCurrent field should be a uint32 type" )
185
+ self .assert_valid_uint32 (metric .stackFreeCurrent , "StackFreeCurrent" )
180
186
181
187
if metric .stackFreeMinimum is not None :
182
- asserts .assert_true (self .is_valid_uint32_value (metric .stackFreeMinimum ),
183
- "StackFreeMinimum field should be a uint32 type" )
188
+ self .assert_valid_uint32 (metric .stackFreeMinimum , "StackFreeMinimum" )
184
189
185
190
if metric .stackSize is not None :
186
- asserts . assert_true ( self .is_valid_uint32_value (metric .stackSize ) , "StackSize field should be a uint32 type " )
191
+ self .assert_valid_uint32 (metric .stackSize , "StackSize" )
187
192
188
193
# Ensure the list length matches thread_metrics_original to simplify matching
189
194
asserts .assert_equal (len (thread_metrics_reset ), len (thread_metrics_original ),
0 commit comments