Skip to content

Commit

Permalink
Add CTS for RasGetStateExp and ClearStateExp (#42)
Browse files Browse the repository at this point in the history
Related-to: VLCLJ-2135

Signed-off-by: Vishnu Khanth <vishnu.khanth.b@intel.com>
  • Loading branch information
vishnu-khanth authored Jun 26, 2024
1 parent 64d1461 commit 6fe343d
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 3 deletions.
74 changes: 73 additions & 1 deletion conformance_tests/sysman/test_sysman_ras/src/test_sysman_ras.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (C) 2020-2023 Intel Corporation
* Copyright (C) 2020-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
Expand Down Expand Up @@ -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<zes_ras_error_category_exp_t> 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);
Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (C) 2020 Intel Corporation
* Copyright (C) 2020-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
Expand All @@ -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<zes_ras_state_exp_t> 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
16 changes: 15 additions & 1 deletion utils/test_harness/sysman/src/test_harness_sysman_ras.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (C) 2020 Intel Corporation
* Copyright (C) 2020-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
Expand Down Expand Up @@ -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<zes_ras_state_exp_t>
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<zes_ras_state_exp_t> 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

0 comments on commit 6fe343d

Please sign in to comment.