Skip to content

Commit

Permalink
test: Add CTS for Sysman memory diagnostics
Browse files Browse the repository at this point in the history
Related-To: VLCLJ-2372

Signed-off-by: B, Vishnu Khanth <[email protected]>
  • Loading branch information
vishnu-khanth committed Jan 10, 2025
1 parent ba6864e commit d3a8b66
Showing 1 changed file with 53 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,16 @@ void validate_tests(std::vector<zes_diag_test_t> tests) {
}

#ifdef USE_ZESINIT
class DiagnosticsZesTest : public lzt::ZesSysmanCtsClass {};
class DiagnosticsZesTest : public lzt::ZesSysmanCtsClass {
public:
bool diag_handles_available = false;
};
#define DIAGNOSTICS_TEST DiagnosticsZesTest
#else // USE_ZESINIT
class DiagnosticsTest : public lzt::SysmanCtsClass {};
class DiagnosticsTest : public lzt::SysmanCtsClass {
public:
bool diag_handles_available = false;
};
#define DIAGNOSTICS_TEST DiagnosticsTest
#endif // USE_ZESINIT

Expand Down Expand Up @@ -238,4 +244,49 @@ TEST_F(
}
}
}

TEST_F(
DIAGNOSTICS_TEST,
GivenValidDeviceWhenMemoryDiagnosticsIsRunAndMemoryGetStateIsCalledThenExpectSuccessIsReturned) {
for (auto device : devices) {
uint32_t count = 0;
auto diag_handles = lzt::get_diag_handles(device, count);

if (count > 0) {
bool mem_diag_available = false;
for (auto diag_handle : diag_handles) {
ASSERT_NE(nullptr, diag_handle);
auto properties = lzt::get_diag_properties(diag_handle);

if (strcmp(properties.name, "MEMORY_PPR") == 0) {
bool mem_diag_available = true;
auto result = lzt::run_diag_tests(
diag_handle, ZES_DIAG_FIRST_TEST_INDEX, ZES_DIAG_LAST_TEST_INDEX);
EXPECT_EQ(result, ZES_DIAG_RESULT_NO_ERRORS);

// get memory state after memory diagnostics
uint32_t mem_handles_count = 0;
std::vector<zes_mem_handle_t> mem_handles =
lzt::get_mem_handles(device, mem_handles_count);
EXPECT_GT(mem_handles_count, 0);

for (auto mem_handle : mem_handles) {
ASSERT_NE(nullptr, mem_handle);
lzt::get_mem_state(mem_handle);
}
}
}

if (!mem_diag_available) {
FAIL() << "Memory Diagnostics is not available for this device!";
}
} else {
LOG_WARNING << "No handles found on this device!";
}
}

if (!diag_handles_available) {
FAIL() << "No handles found in any of the devices!";
}
}
} // namespace

0 comments on commit d3a8b66

Please sign in to comment.