@@ -185,5 +185,59 @@ LZT_TEST_F(
185185 }
186186 }
187187}
188-
188+ LZT_TEST_F (
189+ ECC_TEST,
190+ GivenValidDeviceHandleWhenEccDefaultStateIsQueriedAndSetThenDefaultValuesAreReturned) {
191+ for (const auto &device : devices) {
192+ // Step 1: Get the ECC state (with default state extension)
193+ zes_device_ecc_properties_t originalProps = {};
194+ zes_device_ecc_default_properties_ext_t extProps = {};
195+ originalProps.stype = ZES_STRUCTURE_TYPE_DEVICE_ECC_PROPERTIES;
196+ originalProps.pNext = &extProps;
197+ extProps.stype = ZES_STRUCTURE_TYPE_DEVICE_ECC_DEFAULT_PROPERTIES_EXT;
198+ extProps.pNext = nullptr ;
199+
200+ ze_result_t result = zesDeviceGetEccState (device, &originalProps);
201+ EXPECT_ZE_RESULT_SUCCESS (ZE_RESULT_SUCCESS, result);
202+
203+ // Step 2: Set ECC state to default
204+ zes_device_ecc_desc_t setDesc = {};
205+ setDesc.stype = ZES_STRUCTURE_TYPE_DEVICE_ECC_DESC;
206+ setDesc.pNext = nullptr ;
207+ setDesc.state = extProps.defaultState ;
208+
209+ zes_device_ecc_properties_t newProps = {};
210+ newProps.stype = ZES_STRUCTURE_TYPE_DEVICE_ECC_PROPERTIES;
211+ newProps.pNext = nullptr ;
212+
213+ result = zesDeviceSetEccState (device, &setDesc, &newProps);
214+ EXPECT_ZE_RESULT_SUCCESS (ZE_RESULT_SUCCESS, result);
215+
216+ // Step 3: Re-check ECC state
217+ zes_device_ecc_properties_t checkProps = {};
218+ checkProps.stype = ZES_STRUCTURE_TYPE_DEVICE_ECC_PROPERTIES;
219+ checkProps.pNext = nullptr ;
220+
221+ result = zesDeviceGetEccState (device, &checkProps);
222+ EXPECT_ZE_RESULT_SUCCESS (ZE_RESULT_SUCCESS, result);
223+ EXPECT_ZE_RESULT_SUCCESS (checkProps.pendingState , extProps.defaultState );
224+
225+ // Step 4: Restore original pending ECC state if it changed
226+ if (checkProps.pendingState != originalProps.pendingState ) {
227+ zes_device_ecc_desc_t restoreDesc = {};
228+ restoreDesc.stype = ZES_STRUCTURE_TYPE_DEVICE_ECC_DESC;
229+ restoreDesc.pNext = nullptr ;
230+ restoreDesc.state = originalProps.pendingState ;
231+
232+ zes_device_ecc_properties_t restoredProps = {};
233+ restoredProps.stype = ZES_STRUCTURE_TYPE_DEVICE_ECC_PROPERTIES;
234+ restoredProps.pNext = nullptr ;
235+
236+ result = zesDeviceSetEccState (device, &restoreDesc, &restoredProps);
237+ EXPECT_ZE_RESULT_SUCCESS (ZE_RESULT_SUCCESS, result);
238+ EXPECT_ZE_RESULT_SUCCESS (restoredProps.pendingState ,
239+ originalProps.pendingState );
240+ }
241+ }
242+ }
189243} // namespace
0 commit comments