mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-05 09:09:04 +08:00
sysman: add multi-Device Support for diagnostics
Signed-off-by: Vilvaraj, T J Vivek <t.j.vivek.vilvaraj@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
9df53109b9
commit
d1e8f859d4
@@ -15,6 +15,7 @@ namespace ult {
|
||||
|
||||
constexpr uint32_t mockDiagHandleCount = 2;
|
||||
const std::string mockQuiescentGpuFile("quiesce_gpu");
|
||||
const std::string mockinvalidateLmemFile("invalidate_lmem_mmaps");
|
||||
const std::vector<std::string> mockSupportedDiagTypes = {"MOCKSUITE1", "MOCKSUITE2"};
|
||||
class DiagnosticsInterface : public FirmwareUtil {};
|
||||
|
||||
@@ -35,7 +36,7 @@ struct Mock<DiagnosticsInterface> : public FirmwareUtil {
|
||||
supportedDiagTests.push_back(mockSupportedDiagTypes[1]);
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
ze_result_t mockFwRunDiagTestsReturnSuccess(std::string &osDiagType, zes_diag_result_t *pResult) {
|
||||
ze_result_t mockFwRunDiagTestsReturnSuccess(std::string &osDiagType, zes_diag_result_t *pResult, uint32_t subDeviceId) {
|
||||
*pResult = ZES_DIAG_RESULT_NO_ERRORS;
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
@@ -50,7 +51,7 @@ struct Mock<DiagnosticsInterface> : public FirmwareUtil {
|
||||
MOCK_METHOD(ze_result_t, fwFlashOprom, (void *pImage, uint32_t size), (override));
|
||||
MOCK_METHOD(ze_result_t, fwIfrApplied, (bool &ifrStatus), (override));
|
||||
MOCK_METHOD(ze_result_t, fwSupportedDiagTests, (std::vector<std::string> & supportedDiagTests), (override));
|
||||
MOCK_METHOD(ze_result_t, fwRunDiagTests, (std::string & osDiagType, zes_diag_result_t *pResult), (override));
|
||||
MOCK_METHOD(ze_result_t, fwRunDiagTests, (std::string & osDiagType, zes_diag_result_t *pResult, uint32_t subDeviceId), (override));
|
||||
};
|
||||
|
||||
class DiagSysfsAccess : public SysfsAccess {};
|
||||
@@ -60,6 +61,8 @@ struct Mock<DiagSysfsAccess> : public DiagSysfsAccess {
|
||||
ze_result_t mockwrite(const std::string file, const int val) {
|
||||
if (std::string::npos != file.find(mockQuiescentGpuFile)) {
|
||||
return ZE_RESULT_SUCCESS;
|
||||
} else if (std::string::npos != file.find(mockinvalidateLmemFile)) {
|
||||
return ZE_RESULT_SUCCESS;
|
||||
} else {
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,17 @@ class ZesDiagnosticsFixture : public SysmanDeviceFixture {
|
||||
delete handle;
|
||||
}
|
||||
pSysmanDeviceImp->pDiagnosticsHandleContext->handleList.clear();
|
||||
pSysmanDeviceImp->pDiagnosticsHandleContext->init();
|
||||
uint32_t subDeviceCount = 0;
|
||||
std::vector<ze_device_handle_t> deviceHandles;
|
||||
// We received a device handle. Check for subdevices in this device
|
||||
Device::fromHandle(device->toHandle())->getSubDevices(&subDeviceCount, nullptr);
|
||||
if (subDeviceCount == 0) {
|
||||
deviceHandles.resize(1, device->toHandle());
|
||||
} else {
|
||||
deviceHandles.resize(subDeviceCount, nullptr);
|
||||
Device::fromHandle(device->toHandle())->getSubDevices(&subDeviceCount, deviceHandles.data());
|
||||
}
|
||||
pSysmanDeviceImp->pDiagnosticsHandleContext->init(deviceHandles);
|
||||
}
|
||||
void TearDown() override {
|
||||
SysmanDeviceFixture::TearDown();
|
||||
@@ -46,6 +56,23 @@ class ZesDiagnosticsFixture : public SysmanDeviceFixture {
|
||||
EXPECT_EQ(zesDeviceEnumDiagnosticTestSuites(device->toHandle(), &count, handles.data()), ZE_RESULT_SUCCESS);
|
||||
return handles;
|
||||
}
|
||||
void clear_and_reinit_handles(std::vector<ze_device_handle_t> &deviceHandles) {
|
||||
for (const auto &handle : pSysmanDeviceImp->pDiagnosticsHandleContext->handleList) {
|
||||
delete handle;
|
||||
}
|
||||
pSysmanDeviceImp->pDiagnosticsHandleContext->handleList.clear();
|
||||
pSysmanDeviceImp->pDiagnosticsHandleContext->supportedDiagTests.clear();
|
||||
uint32_t subDeviceCount = 0;
|
||||
|
||||
// We received a device handle. Check for subdevices in this device
|
||||
Device::fromHandle(device->toHandle())->getSubDevices(&subDeviceCount, nullptr);
|
||||
if (subDeviceCount == 0) {
|
||||
deviceHandles.resize(1, device->toHandle());
|
||||
} else {
|
||||
deviceHandles.resize(subDeviceCount, nullptr);
|
||||
Device::fromHandle(device->toHandle())->getSubDevices(&subDeviceCount, deviceHandles.data());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(ZesDiagnosticsFixture, GivenComponentCountZeroWhenCallingzesDeviceEnumDiagnosticTestSuitesThenZeroCountIsReturnedAndVerifyzesDeviceEnumDiagnosticTestSuitesCallSucceeds) {
|
||||
@@ -70,7 +97,17 @@ TEST_F(ZesDiagnosticsFixture, GivenComponentCountZeroWhenCallingzesDeviceEnumDia
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
EXPECT_EQ(count, 0u);
|
||||
|
||||
DiagnosticsImp *ptestDiagnosticsImp = new DiagnosticsImp(pSysmanDeviceImp->pDiagnosticsHandleContext->pOsSysman, mockSupportedDiagTypes[0]);
|
||||
uint32_t subDeviceCount = 0;
|
||||
std::vector<ze_device_handle_t> deviceHandles;
|
||||
// We received a device handle. Check for subdevices in this device
|
||||
Device::fromHandle(device->toHandle())->getSubDevices(&subDeviceCount, nullptr);
|
||||
if (subDeviceCount == 0) {
|
||||
deviceHandles.resize(1, device->toHandle());
|
||||
} else {
|
||||
deviceHandles.resize(subDeviceCount, nullptr);
|
||||
Device::fromHandle(device->toHandle())->getSubDevices(&subDeviceCount, deviceHandles.data());
|
||||
}
|
||||
DiagnosticsImp *ptestDiagnosticsImp = new DiagnosticsImp(pSysmanDeviceImp->pDiagnosticsHandleContext->pOsSysman, mockSupportedDiagTypes[0], deviceHandles[0]);
|
||||
pSysmanDeviceImp->pDiagnosticsHandleContext->handleList.push_back(ptestDiagnosticsImp);
|
||||
result = zesDeviceEnumDiagnosticTestSuites(device->toHandle(), &count, nullptr);
|
||||
|
||||
@@ -91,49 +128,36 @@ TEST_F(ZesDiagnosticsFixture, GivenComponentCountZeroWhenCallingzesDeviceEnumDia
|
||||
}
|
||||
|
||||
TEST_F(ZesDiagnosticsFixture, GivenFailedFirmwareInitializationWhenInitializingDiagnosticsContextThenexpectNoHandles) {
|
||||
for (const auto &handle : pSysmanDeviceImp->pDiagnosticsHandleContext->handleList) {
|
||||
delete handle;
|
||||
}
|
||||
pSysmanDeviceImp->pDiagnosticsHandleContext->handleList.clear();
|
||||
std::vector<ze_device_handle_t> deviceHandles;
|
||||
clear_and_reinit_handles(deviceHandles);
|
||||
ON_CALL(*pMockDiagInterface.get(), fwDeviceInit())
|
||||
.WillByDefault(::testing::Invoke(pMockDiagInterface.get(), &Mock<DiagnosticsInterface>::mockFwDeviceInitFail));
|
||||
|
||||
pSysmanDeviceImp->pDiagnosticsHandleContext->init();
|
||||
pSysmanDeviceImp->pDiagnosticsHandleContext->init(deviceHandles);
|
||||
|
||||
EXPECT_EQ(0u, pSysmanDeviceImp->pDiagnosticsHandleContext->handleList.size());
|
||||
}
|
||||
|
||||
TEST_F(ZesDiagnosticsFixture, GivenSupportedTestsWhenInitializingDiagnosticsContextThenexpectHandles) {
|
||||
for (const auto &handle : pSysmanDeviceImp->pDiagnosticsHandleContext->handleList) {
|
||||
delete handle;
|
||||
}
|
||||
pSysmanDeviceImp->pDiagnosticsHandleContext->handleList.clear();
|
||||
TEST_F(ZesDiagnosticsFixture, GivenSupportedTestsWhenInitializingDiagnosticsContextThenExpectHandles) {
|
||||
std::vector<ze_device_handle_t> deviceHandles;
|
||||
clear_and_reinit_handles(deviceHandles);
|
||||
pSysmanDeviceImp->pDiagnosticsHandleContext->supportedDiagTests.push_back(mockSupportedDiagTypes[0]);
|
||||
ON_CALL(*pMockDiagInterface.get(), fwDeviceInit())
|
||||
.WillByDefault(::testing::Invoke(pMockDiagInterface.get(), &Mock<DiagnosticsInterface>::mockFwDeviceInitFail));
|
||||
|
||||
pSysmanDeviceImp->pDiagnosticsHandleContext->init();
|
||||
|
||||
pSysmanDeviceImp->pDiagnosticsHandleContext->init(deviceHandles);
|
||||
EXPECT_EQ(1u, pSysmanDeviceImp->pDiagnosticsHandleContext->handleList.size());
|
||||
}
|
||||
|
||||
TEST_F(ZesDiagnosticsFixture, GivenFirmwareInitializationFailureThenCreateHandleMustFail) {
|
||||
for (const auto &handle : pSysmanDeviceImp->pDiagnosticsHandleContext->handleList) {
|
||||
delete handle;
|
||||
}
|
||||
pSysmanDeviceImp->pDiagnosticsHandleContext->handleList.clear();
|
||||
std::vector<ze_device_handle_t> deviceHandles;
|
||||
clear_and_reinit_handles(deviceHandles);
|
||||
ON_CALL(*pMockDiagInterface.get(), fwDeviceInit())
|
||||
.WillByDefault(::testing::Invoke(pMockDiagInterface.get(), &Mock<DiagnosticsInterface>::mockFwDeviceInitFail));
|
||||
pSysmanDeviceImp->pDiagnosticsHandleContext->init();
|
||||
pSysmanDeviceImp->pDiagnosticsHandleContext->init(deviceHandles);
|
||||
EXPECT_EQ(0u, pSysmanDeviceImp->pDiagnosticsHandleContext->handleList.size());
|
||||
}
|
||||
|
||||
TEST_F(ZesDiagnosticsFixture, GivenValidDiagnosticsHandleWhenGettingDiagnosticsPropertiesThenCallSucceeds) {
|
||||
for (const auto &handle : pSysmanDeviceImp->pDiagnosticsHandleContext->handleList) {
|
||||
delete handle;
|
||||
}
|
||||
pSysmanDeviceImp->pDiagnosticsHandleContext->handleList.clear();
|
||||
DiagnosticsImp *ptestDiagnosticsImp = new DiagnosticsImp(pSysmanDeviceImp->pDiagnosticsHandleContext->pOsSysman, mockSupportedDiagTypes[0]);
|
||||
std::vector<ze_device_handle_t> deviceHandles;
|
||||
clear_and_reinit_handles(deviceHandles);
|
||||
DiagnosticsImp *ptestDiagnosticsImp = new DiagnosticsImp(pSysmanDeviceImp->pDiagnosticsHandleContext->pOsSysman, mockSupportedDiagTypes[0], deviceHandles[0]);
|
||||
pSysmanDeviceImp->pDiagnosticsHandleContext->handleList.push_back(ptestDiagnosticsImp);
|
||||
|
||||
auto handle = pSysmanDeviceImp->pDiagnosticsHandleContext->handleList[0]->toHandle();
|
||||
@@ -142,11 +166,9 @@ TEST_F(ZesDiagnosticsFixture, GivenValidDiagnosticsHandleWhenGettingDiagnosticsP
|
||||
}
|
||||
|
||||
TEST_F(ZesDiagnosticsFixture, GivenValidDiagnosticsHandleWhenGettingDiagnosticsTestThenCallSucceeds) {
|
||||
for (const auto &handle : pSysmanDeviceImp->pDiagnosticsHandleContext->handleList) {
|
||||
delete handle;
|
||||
}
|
||||
pSysmanDeviceImp->pDiagnosticsHandleContext->handleList.clear();
|
||||
DiagnosticsImp *ptestDiagnosticsImp = new DiagnosticsImp(pSysmanDeviceImp->pDiagnosticsHandleContext->pOsSysman, mockSupportedDiagTypes[0]);
|
||||
std::vector<ze_device_handle_t> deviceHandles;
|
||||
clear_and_reinit_handles(deviceHandles);
|
||||
DiagnosticsImp *ptestDiagnosticsImp = new DiagnosticsImp(pSysmanDeviceImp->pDiagnosticsHandleContext->pOsSysman, mockSupportedDiagTypes[0], deviceHandles[0]);
|
||||
pSysmanDeviceImp->pDiagnosticsHandleContext->handleList.push_back(ptestDiagnosticsImp);
|
||||
|
||||
auto handle = pSysmanDeviceImp->pDiagnosticsHandleContext->handleList[0]->toHandle();
|
||||
@@ -159,11 +181,9 @@ TEST_F(ZesDiagnosticsFixture, GivenValidDiagnosticsHandleWhenGettingDiagnosticsT
|
||||
}
|
||||
|
||||
TEST_F(ZesDiagnosticsFixture, GivenValidDiagnosticsHandleWhenRunningDiagnosticsTestThenCallSucceeds) {
|
||||
for (const auto &handle : pSysmanDeviceImp->pDiagnosticsHandleContext->handleList) {
|
||||
delete handle;
|
||||
}
|
||||
pSysmanDeviceImp->pDiagnosticsHandleContext->handleList.clear();
|
||||
DiagnosticsImp *ptestDiagnosticsImp = new DiagnosticsImp(pSysmanDeviceImp->pDiagnosticsHandleContext->pOsSysman, mockSupportedDiagTypes[0]);
|
||||
std::vector<ze_device_handle_t> deviceHandles;
|
||||
clear_and_reinit_handles(deviceHandles);
|
||||
DiagnosticsImp *ptestDiagnosticsImp = new DiagnosticsImp(pSysmanDeviceImp->pDiagnosticsHandleContext->pOsSysman, mockSupportedDiagTypes[0], deviceHandles[0]);
|
||||
pSysmanDeviceImp->pDiagnosticsHandleContext->handleList.push_back(ptestDiagnosticsImp);
|
||||
|
||||
auto handle = pSysmanDeviceImp->pDiagnosticsHandleContext->handleList[0]->toHandle();
|
||||
|
||||
@@ -72,7 +72,7 @@ struct Mock<FirmwareInterface> : public FirmwareUtil {
|
||||
MOCK_METHOD(ze_result_t, fwFlashOprom, (void *pImage, uint32_t size), (override));
|
||||
MOCK_METHOD(ze_result_t, fwIfrApplied, (bool &ifrStatus), (override));
|
||||
MOCK_METHOD(ze_result_t, fwSupportedDiagTests, (std::vector<std::string> & supportedDiagTests), (override));
|
||||
MOCK_METHOD(ze_result_t, fwRunDiagTests, (std::string & osDiagType, zes_diag_result_t *pResult), (override));
|
||||
MOCK_METHOD(ze_result_t, fwRunDiagTests, (std::string & osDiagType, zes_diag_result_t *pResult, uint32_t subdeviceId), (override));
|
||||
};
|
||||
|
||||
class PublicLinuxFirmwareImp : public L0::LinuxFirmwareImp {
|
||||
|
||||
@@ -427,7 +427,7 @@ struct Mock<FirmwareInterface> : public FirmwareUtil {
|
||||
MOCK_METHOD(ze_result_t, fwFlashOprom, (void *pImage, uint32_t size), (override));
|
||||
MOCK_METHOD(ze_result_t, fwIfrApplied, (bool &ifrStatus), (override));
|
||||
MOCK_METHOD(ze_result_t, fwSupportedDiagTests, (std::vector<std::string> & supportedDiagTests), (override));
|
||||
MOCK_METHOD(ze_result_t, fwRunDiagTests, (std::string & osDiagType, zes_diag_result_t *pResult), (override));
|
||||
MOCK_METHOD(ze_result_t, fwRunDiagTests, (std::string & osDiagType, zes_diag_result_t *pResult, uint32_t subdeviceId), (override));
|
||||
};
|
||||
|
||||
class PublicLinuxGlobalOperationsImp : public L0::LinuxGlobalOperationsImp {
|
||||
|
||||
Reference in New Issue
Block a user