diff --git a/conformance_tests/sysman/test_sysman_ras/src/test_sysman_ras.cpp b/conformance_tests/sysman/test_sysman_ras/src/test_sysman_ras.cpp index 7aee4613..5cc71feb 100644 --- a/conformance_tests/sysman/test_sysman_ras/src/test_sysman_ras.cpp +++ b/conformance_tests/sysman/test_sysman_ras/src/test_sysman_ras.cpp @@ -1,6 +1,6 @@ /* * - * Copyright (C) 2020-2023 Intel Corporation + * Copyright (C) 2020-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -41,6 +41,25 @@ void validate_ras_state(zes_ras_state_t detailedThresholds) { EXPECT_GE(detailedThresholds.category[ZES_RAS_ERROR_CAT_RESET], 0); } +void validate_ras_state_exp(zes_ras_state_exp_t ras_state) { + std::vector error_category = { + ZES_RAS_ERROR_CATEGORY_EXP_RESET, + ZES_RAS_ERROR_CATEGORY_EXP_PROGRAMMING_ERRORS, + ZES_RAS_ERROR_CATEGORY_EXP_DRIVER_ERRORS, + ZES_RAS_ERROR_CATEGORY_EXP_COMPUTE_ERRORS, + ZES_RAS_ERROR_CATEGORY_EXP_NON_COMPUTE_ERRORS, + ZES_RAS_ERROR_CATEGORY_EXP_CACHE_ERRORS, + ZES_RAS_ERROR_CATEGORY_EXP_DISPLAY_ERRORS, + ZES_RAS_ERROR_CATEGORY_EXP_MEMORY_ERRORS, + ZES_RAS_ERROR_CATEGORY_EXP_SCALE_ERRORS, + ZES_RAS_ERROR_CATEGORY_EXP_L3FABRIC_ERRORS}; + + EXPECT_NE(error_category.end(), + std::find(error_category.begin(), error_category.end(), + ras_state.category)); + EXPECT_GE(ras_state.errorCounter, 0); +} + void validate_ras_config(zes_ras_config_t rasConfig) { EXPECT_LT(rasConfig.totalThreshold, UINT64_MAX); EXPECT_GE(rasConfig.totalThreshold, 0); @@ -240,4 +259,57 @@ TEST_F( } } } + +TEST_F(RAS_TEST, + GivenValidRASHandleWhenRetrievingStateExpThenValidStateExpIsReturned) { + for (auto device : devices) { + uint32_t count = 0; + auto ras_handles = lzt::get_ras_handles(device, count); + if (count == 0) { + FAIL() << "No handles found: " + << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); + } + + for (auto ras_handle : ras_handles) { + ASSERT_NE(nullptr, ras_handle); + auto ras_states = lzt::ras_get_state_exp(ras_handle); + for (auto state : ras_states) { + validate_ras_state_exp(state); + } + } + } +} + +TEST_F( + RAS_TEST, + GivenValidRASHandleWhenRetrievingStateExpAfterInvokingClearstateExpThenUpdatedStateExpIsReturned) { + for (auto device : devices) { + uint32_t count = 0; + auto ras_handles = lzt::get_ras_handles(device, count); + if (count == 0) { + FAIL() << "No handles found: " + << _ze_result_t(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); + } + + for (auto ras_handle : ras_handles) { + ASSERT_NE(nullptr, ras_handle); + uint32_t initial_errors = 0; + uint32_t errors_after_clear = 0; + auto ras_states = lzt::ras_get_state_exp(ras_handle); + + for (auto state : ras_states) { + validate_ras_state_exp(state); + initial_errors += state.errorCounter; + lzt::ras_clear_state_exp(ras_handle, state.category); + } + + ras_states = lzt::ras_get_state_exp(ras_handle); + for (auto state : ras_states) { + validate_ras_state_exp(state); + errors_after_clear += state.errorCounter; + } + EXPECT_LE(errors_after_clear, initial_errors); + } + } +} } // namespace diff --git a/utils/test_harness/sysman/include/test_harness_sysman_ras.hpp b/utils/test_harness/sysman/include/test_harness_sysman_ras.hpp index ff77f818..65cd7827 100644 --- a/utils/test_harness/sysman/include/test_harness_sysman_ras.hpp +++ b/utils/test_harness/sysman/include/test_harness_sysman_ras.hpp @@ -1,6 +1,6 @@ /* * - * Copyright (C) 2020 Intel Corporation + * Copyright (C) 2020-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -20,6 +20,9 @@ zes_ras_config_t get_ras_config(zes_ras_handle_t rasHandle); void set_ras_config(zes_ras_handle_t rasHandle, zes_ras_config_t rasConfig); zes_ras_state_t get_ras_state(zes_ras_handle_t rasHandle, ze_bool_t clear); uint64_t sum_of_ras_errors(zes_ras_state_t state); +std::vector ras_get_state_exp(zes_ras_handle_t ras_handle); +void ras_clear_state_exp(zes_ras_handle_t ras_handle, + zes_ras_error_category_exp_t category); } // namespace level_zero_tests #endif diff --git a/utils/test_harness/sysman/src/test_harness_sysman_ras.cpp b/utils/test_harness/sysman/src/test_harness_sysman_ras.cpp index 11f1a203..c3df11cb 100644 --- a/utils/test_harness/sysman/src/test_harness_sysman_ras.cpp +++ b/utils/test_harness/sysman/src/test_harness_sysman_ras.cpp @@ -1,6 +1,6 @@ /* * - * Copyright (C) 2020 Intel Corporation + * Copyright (C) 2020-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -65,4 +65,18 @@ zes_ras_state_t get_ras_state(zes_ras_handle_t rasHandle, ze_bool_t clear) { EXPECT_EQ(ZE_RESULT_SUCCESS, zesRasGetState(rasHandle, clear, &state)); return state; } +std::vector +ras_get_state_exp(zes_ras_handle_t ras_handle) { + uint32_t count = 0; + EXPECT_EQ(ZE_RESULT_SUCCESS, zesRasGetStateExp(ras_handle, &count, NULL)); + EXPECT_GT(count, 0); + std::vector states(count); + EXPECT_EQ(ZE_RESULT_SUCCESS, + zesRasGetStateExp(ras_handle, &count, states.data())); + return states; +} +void ras_clear_state_exp(zes_ras_handle_t ras_handle, + zes_ras_error_category_exp_t category) { + EXPECT_EQ(ZE_RESULT_SUCCESS, zesRasClearStateExp(ras_handle, category)); +} } // namespace level_zero_tests