|
1 | 1 | /*
|
2 | 2 | *
|
3 |
| - * Copyright (C) 2020-2023 Intel Corporation |
| 3 | + * Copyright (C) 2020-2024 Intel Corporation |
4 | 4 | *
|
5 | 5 | * SPDX-License-Identifier: MIT
|
6 | 6 | *
|
@@ -41,6 +41,25 @@ void validate_ras_state(zes_ras_state_t detailedThresholds) {
|
41 | 41 | EXPECT_GE(detailedThresholds.category[ZES_RAS_ERROR_CAT_RESET], 0);
|
42 | 42 | }
|
43 | 43 |
|
| 44 | +void validate_ras_state_exp(zes_ras_state_exp_t ras_state) { |
| 45 | + std::vector<zes_ras_error_category_exp_t> error_category = { |
| 46 | + ZES_RAS_ERROR_CATEGORY_EXP_RESET, |
| 47 | + ZES_RAS_ERROR_CATEGORY_EXP_PROGRAMMING_ERRORS, |
| 48 | + ZES_RAS_ERROR_CATEGORY_EXP_DRIVER_ERRORS, |
| 49 | + ZES_RAS_ERROR_CATEGORY_EXP_COMPUTE_ERRORS, |
| 50 | + ZES_RAS_ERROR_CATEGORY_EXP_NON_COMPUTE_ERRORS, |
| 51 | + ZES_RAS_ERROR_CATEGORY_EXP_CACHE_ERRORS, |
| 52 | + ZES_RAS_ERROR_CATEGORY_EXP_DISPLAY_ERRORS, |
| 53 | + ZES_RAS_ERROR_CATEGORY_EXP_MEMORY_ERRORS, |
| 54 | + ZES_RAS_ERROR_CATEGORY_EXP_SCALE_ERRORS, |
| 55 | + ZES_RAS_ERROR_CATEGORY_EXP_L3FABRIC_ERRORS}; |
| 56 | + |
| 57 | + EXPECT_NE(error_category.end(), |
| 58 | + std::find(error_category.begin(), error_category.end(), |
| 59 | + ras_state.category)); |
| 60 | + EXPECT_GE(ras_state.errorCounter, 0); |
| 61 | +} |
| 62 | + |
44 | 63 | void validate_ras_config(zes_ras_config_t rasConfig) {
|
45 | 64 | EXPECT_LT(rasConfig.totalThreshold, UINT64_MAX);
|
46 | 65 | EXPECT_GE(rasConfig.totalThreshold, 0);
|
@@ -240,4 +259,57 @@ TEST_F(
|
240 | 259 | }
|
241 | 260 | }
|
242 | 261 | }
|
| 262 | + |
| 263 | +TEST_F(RAS_TEST, |
| 264 | + GivenValidRASHandleWhenRetrievingStateExpThenValidStateExpIsReturned) { |
| 265 | + for (auto device : devices) { |
| 266 | + uint32_t count = 0; |
| 267 | + auto ras_handles = lzt::get_ras_handles(device, count); |
| 268 | + if (count == 0) { |
| 269 | + FAIL() << "No handles found: " |
| 270 | + << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); |
| 271 | + } |
| 272 | + |
| 273 | + for (auto ras_handle : ras_handles) { |
| 274 | + ASSERT_NE(nullptr, ras_handle); |
| 275 | + auto ras_states = lzt::ras_get_state_exp(ras_handle); |
| 276 | + for (auto state : ras_states) { |
| 277 | + validate_ras_state_exp(state); |
| 278 | + } |
| 279 | + } |
| 280 | + } |
| 281 | +} |
| 282 | + |
| 283 | +TEST_F( |
| 284 | + RAS_TEST, |
| 285 | + GivenValidRASHandleWhenRetrievingStateExpAfterInvokingClearstateExpThenUpdatedStateExpIsReturned) { |
| 286 | + for (auto device : devices) { |
| 287 | + uint32_t count = 0; |
| 288 | + auto ras_handles = lzt::get_ras_handles(device, count); |
| 289 | + if (count == 0) { |
| 290 | + FAIL() << "No handles found: " |
| 291 | + << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); |
| 292 | + } |
| 293 | + |
| 294 | + for (auto ras_handle : ras_handles) { |
| 295 | + ASSERT_NE(nullptr, ras_handle); |
| 296 | + uint32_t initial_errors = 0; |
| 297 | + uint32_t errors_after_clear = 0; |
| 298 | + auto ras_states = lzt::ras_get_state_exp(ras_handle); |
| 299 | + |
| 300 | + for (auto state : ras_states) { |
| 301 | + validate_ras_state_exp(state); |
| 302 | + initial_errors += state.errorCounter; |
| 303 | + lzt::ras_clear_state_exp(ras_handle, state.category); |
| 304 | + } |
| 305 | + |
| 306 | + ras_states = lzt::ras_get_state_exp(ras_handle); |
| 307 | + for (auto state : ras_states) { |
| 308 | + validate_ras_state_exp(state); |
| 309 | + errors_after_clear += state.errorCounter; |
| 310 | + } |
| 311 | + EXPECT_LE(errors_after_clear, initial_errors); |
| 312 | + } |
| 313 | + } |
| 314 | +} |
243 | 315 | } // namespace
|
0 commit comments