mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-07 20:54:47 +08:00
Added Global Operation ULT
Related-To: LOCI-3715 Signed-off-by: Bari, Pratik <pratik.bari@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
876de37b92
commit
96743747a3
@@ -8,12 +8,11 @@ set(L0_TESTS_TOOLS_SYSMAN_GLOBAL_OPERATIONS_LINUX
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test_zes_global_operations.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_global_operations.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/test_zes_global_operations_helper.cpp
|
||||
)
|
||||
|
||||
if((NEO_ENABLE_i915_PRELIM_DETECTION) AND ("${BRANCH_TYPE}" STREQUAL ""))
|
||||
list(REMOVE_ITEM L0_TESTS_TOOLS_SYSMAN_GLOBAL_OPERATIONS_LINUX
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test_zes_global_operations_helper.cpp
|
||||
if(NEO_ENABLE_i915_PRELIM_DETECTION)
|
||||
list(APPEND L0_TESTS_TOOLS_SYSMAN_GLOBAL_OPERATIONS_LINUX
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test_zes_global_operations_prelim.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
@@ -51,50 +51,47 @@ const std::string mockFunctionResetPath("/MOCK_FUNCTION_LEVEL_RESET_PATH");
|
||||
const std::string mockDeviceDir("devices/pci0000:89/0000:89:02.0/0000:8a:00.0/0000:8b:01.0/0000:8c:00.0");
|
||||
const std::string mockDeviceName("/MOCK_DEVICE_NAME");
|
||||
|
||||
struct GlobalOperationsEngineHandleContext : public EngineHandleContext {
|
||||
GlobalOperationsEngineHandleContext(OsSysman *pOsSysman) : EngineHandleContext(pOsSysman) {}
|
||||
};
|
||||
template <>
|
||||
struct Mock<GlobalOperationsEngineHandleContext> : public GlobalOperationsEngineHandleContext {
|
||||
void initMock(std::vector<ze_device_handle_t> &deviceHandles) {}
|
||||
Mock<GlobalOperationsEngineHandleContext>(OsSysman *pOsSysman) : GlobalOperationsEngineHandleContext(pOsSysman) {}
|
||||
MOCK_METHOD(void, init, (std::vector<ze_device_handle_t> & deviceHandles), (override));
|
||||
enum mockEnumListProcessCall {
|
||||
DEVICE_IN_USE = 0,
|
||||
DEVICE_UNUSED = 1,
|
||||
RETURN_ERROR = 2
|
||||
};
|
||||
|
||||
struct GlobalOperationsRasHandleContext : public RasHandleContext {
|
||||
GlobalOperationsRasHandleContext(OsSysman *pOsSysman) : RasHandleContext(pOsSysman) {}
|
||||
};
|
||||
template <>
|
||||
struct Mock<GlobalOperationsRasHandleContext> : public GlobalOperationsRasHandleContext {
|
||||
void initMock(std::vector<ze_device_handle_t> &deviceHandles) {}
|
||||
Mock<GlobalOperationsRasHandleContext>(OsSysman *pOsSysman) : GlobalOperationsRasHandleContext(pOsSysman) {}
|
||||
MOCK_METHOD(void, init, (std::vector<ze_device_handle_t> & deviceHandles), (override));
|
||||
struct MockGlobalOperationsEngineHandleContext : public EngineHandleContext {
|
||||
MockGlobalOperationsEngineHandleContext(OsSysman *pOsSysman) : EngineHandleContext(pOsSysman) {}
|
||||
ADDMETHOD_NOBASE_VOIDRETURN(init, (std::vector<ze_device_handle_t> & deviceHandles));
|
||||
};
|
||||
|
||||
struct GlobalOperationsDiagnosticsHandleContext : public DiagnosticsHandleContext {
|
||||
GlobalOperationsDiagnosticsHandleContext(OsSysman *pOsSysman) : DiagnosticsHandleContext(pOsSysman) {}
|
||||
struct MockGlobalOperationsRasHandleContext : public RasHandleContext {
|
||||
MockGlobalOperationsRasHandleContext(OsSysman *pOsSysman) : RasHandleContext(pOsSysman) {}
|
||||
ADDMETHOD_NOBASE_VOIDRETURN(init, (std::vector<ze_device_handle_t> & deviceHandles));
|
||||
};
|
||||
template <>
|
||||
struct Mock<GlobalOperationsDiagnosticsHandleContext> : public GlobalOperationsDiagnosticsHandleContext {
|
||||
Mock<GlobalOperationsDiagnosticsHandleContext>(OsSysman *pOsSysman) : GlobalOperationsDiagnosticsHandleContext(pOsSysman) {}
|
||||
|
||||
struct MockGlobalOperationsDiagnosticsHandleContext : public DiagnosticsHandleContext {
|
||||
MockGlobalOperationsDiagnosticsHandleContext(OsSysman *pOsSysman) : DiagnosticsHandleContext(pOsSysman) {}
|
||||
ADDMETHOD_NOBASE_VOIDRETURN(init, ());
|
||||
};
|
||||
|
||||
struct GlobalOperationsFirmwareHandleContext : public FirmwareHandleContext {
|
||||
GlobalOperationsFirmwareHandleContext(OsSysman *pOsSysman) : FirmwareHandleContext(pOsSysman) {}
|
||||
};
|
||||
template <>
|
||||
struct Mock<GlobalOperationsFirmwareHandleContext> : public GlobalOperationsFirmwareHandleContext {
|
||||
Mock<GlobalOperationsFirmwareHandleContext>(OsSysman *pOsSysman) : GlobalOperationsFirmwareHandleContext(pOsSysman) {}
|
||||
struct MockGlobalOperationsFirmwareHandleContext : public FirmwareHandleContext {
|
||||
MockGlobalOperationsFirmwareHandleContext(OsSysman *pOsSysman) : FirmwareHandleContext(pOsSysman) {}
|
||||
ADDMETHOD_NOBASE_VOIDRETURN(init, ());
|
||||
};
|
||||
|
||||
class GlobalOperationsSysfsAccess : public SysfsAccess {};
|
||||
struct MockGlobalOperationsSysfsAccess : public SysfsAccess {
|
||||
|
||||
template <>
|
||||
struct Mock<GlobalOperationsSysfsAccess> : public GlobalOperationsSysfsAccess {
|
||||
ze_result_t mockScanDirEntriesError = ZE_RESULT_SUCCESS;
|
||||
ze_result_t mockReadError = ZE_RESULT_SUCCESS;
|
||||
ze_result_t mockBindDeviceError = ZE_RESULT_SUCCESS;
|
||||
ze_result_t mockUnbindDeviceError = ZE_RESULT_SUCCESS;
|
||||
uint32_t mockCount = 0;
|
||||
bool isRootSet = true;
|
||||
ze_result_t getRealPathVal(const std::string file, std::string &val) {
|
||||
bool mockGetScannedDir4EntriesStatus = false;
|
||||
bool mockGetScannedDirPidEntriesStatus = false;
|
||||
bool mockGetScannedDirPidEntriesForClientsStatus = false;
|
||||
bool mockReadStatus = false;
|
||||
bool mockGetValUnsignedLongStatus = false;
|
||||
|
||||
ze_result_t getRealPath(const std::string file, std::string &val) override {
|
||||
if (file.compare(functionLevelReset) == 0) {
|
||||
val = mockFunctionResetPath;
|
||||
} else if (file.compare(deviceDir) == 0) {
|
||||
@@ -105,26 +102,43 @@ struct Mock<GlobalOperationsSysfsAccess> : public GlobalOperationsSysfsAccess {
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t getValString(const std::string file, std::string &val) {
|
||||
ze_result_t readResult = ZE_RESULT_SUCCESS;
|
||||
std::string mockReadVal = "";
|
||||
ze_result_t read(const std::string file, std::string &val) override {
|
||||
if (mockReadError != ZE_RESULT_SUCCESS) {
|
||||
return mockReadError;
|
||||
}
|
||||
|
||||
if (file.compare(subsystemVendorFile) == 0) {
|
||||
val = "0x8086";
|
||||
val = mockReadVal;
|
||||
} else if (file.compare("clients/8/pid") == 0) {
|
||||
val = bPid4;
|
||||
} else {
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
return ZE_RESULT_SUCCESS;
|
||||
return readResult;
|
||||
}
|
||||
|
||||
ze_result_t getFalseValString(const std::string file, std::string &val) {
|
||||
if (file.compare(subsystemVendorFile) == 0) {
|
||||
val = "0xa086";
|
||||
} else {
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
ze_result_t read(const std::string file, uint64_t &val) override {
|
||||
if (mockReadStatus == true) {
|
||||
if (mockCount == 0) {
|
||||
mockCount++;
|
||||
return getValUnsignedLongCreatedBytesSuccess(file, val);
|
||||
}
|
||||
|
||||
else {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
ze_result_t getValUnsignedLong(const std::string file, uint64_t &val) {
|
||||
|
||||
if (mockReadError != ZE_RESULT_SUCCESS) {
|
||||
return mockReadError;
|
||||
}
|
||||
|
||||
if (mockGetValUnsignedLongStatus == true) {
|
||||
return getValUnsignedLongCreatedBytesSuccess(file, val);
|
||||
}
|
||||
|
||||
if ((file.compare("clients/4/pid") == 0) || (file.compare("clients/5/pid") == 0)) {
|
||||
val = pid1;
|
||||
} else if (file.compare("clients/6/pid") == 0) {
|
||||
@@ -231,7 +245,23 @@ struct Mock<GlobalOperationsSysfsAccess> : public GlobalOperationsSysfsAccess {
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t getScannedDirEntries(const std::string path, std::vector<std::string> &list) {
|
||||
ze_result_t scanDirEntries(const std::string path, std::vector<std::string> &list) override {
|
||||
if (mockScanDirEntriesError != ZE_RESULT_SUCCESS) {
|
||||
return mockScanDirEntriesError;
|
||||
}
|
||||
|
||||
if (mockGetScannedDir4EntriesStatus == true) {
|
||||
return getScannedDir4Entries(path, list);
|
||||
}
|
||||
|
||||
if (mockGetScannedDirPidEntriesStatus == true) {
|
||||
return getScannedDirPidEntries(path, list);
|
||||
}
|
||||
|
||||
if (mockGetScannedDirPidEntriesForClientsStatus == true) {
|
||||
return getScannedDirPidEntiresForClients(path, list);
|
||||
}
|
||||
|
||||
if (path.compare(clientsDir) == 0) {
|
||||
list.push_back(clientId1);
|
||||
list.push_back(clientId2);
|
||||
@@ -251,7 +281,7 @@ struct Mock<GlobalOperationsSysfsAccess> : public GlobalOperationsSysfsAccess {
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t getScannedDirPidEntires(const std::string path, std::vector<std::string> &list) {
|
||||
ze_result_t getScannedDirPidEntries(const std::string path, std::vector<std::string> &list) {
|
||||
if (path.compare(clientsDir) == 0) {
|
||||
list.push_back(clientId8);
|
||||
} else if (path.compare("clients/12/busy") == 0) {
|
||||
@@ -269,7 +299,7 @@ struct Mock<GlobalOperationsSysfsAccess> : public GlobalOperationsSysfsAccess {
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
bool mockIsMyDeviceFile(const std::string dev) {
|
||||
bool isMyDeviceFile(const std::string dev) override {
|
||||
if (dev.compare(mockDeviceName) == 0) {
|
||||
return true;
|
||||
}
|
||||
@@ -283,22 +313,29 @@ struct Mock<GlobalOperationsSysfsAccess> : public GlobalOperationsSysfsAccess {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Mock<GlobalOperationsSysfsAccess>() = default;
|
||||
|
||||
MOCK_METHOD(ze_result_t, read, (const std::string file, std::string &val), (override));
|
||||
MOCK_METHOD(ze_result_t, read, (const std::string file, uint64_t &val), (override));
|
||||
MOCK_METHOD(ze_result_t, scanDirEntries, (const std::string path, std::vector<std::string> &list), (override));
|
||||
MOCK_METHOD(ze_result_t, getRealPath, (const std::string path, std::string &val), (override));
|
||||
MOCK_METHOD(ze_result_t, bindDevice, (const std::string device), (override));
|
||||
MOCK_METHOD(ze_result_t, unbindDevice, (const std::string device), (override));
|
||||
MOCK_METHOD(bool, fileExists, (const std::string file), (override));
|
||||
MOCK_METHOD(bool, isMyDeviceFile, (const std::string dev), (override));
|
||||
ze_result_t unbindDevice(const std::string device) override {
|
||||
if (mockUnbindDeviceError != ZE_RESULT_SUCCESS) {
|
||||
return mockUnbindDeviceError;
|
||||
}
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t bindDevice(const std::string device) override {
|
||||
if (mockBindDeviceError != ZE_RESULT_SUCCESS) {
|
||||
return mockBindDeviceError;
|
||||
}
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
MockGlobalOperationsSysfsAccess() = default;
|
||||
|
||||
ADDMETHOD_NOBASE(fileExists, bool, true, (const std::string file));
|
||||
};
|
||||
|
||||
class GlobalOperationsProcfsAccess : public ProcfsAccess {};
|
||||
|
||||
template <>
|
||||
struct Mock<GlobalOperationsProcfsAccess> : public GlobalOperationsProcfsAccess {
|
||||
struct MockGlobalOperationsProcfsAccess : public ProcfsAccess {
|
||||
|
||||
const ::pid_t extraPid = 4;
|
||||
const int extraFd = 5;
|
||||
@@ -307,148 +344,165 @@ struct Mock<GlobalOperationsProcfsAccess> : public GlobalOperationsProcfsAccess
|
||||
::pid_t ourDevicePid = 0;
|
||||
int ourDeviceFd = 0;
|
||||
|
||||
ze_result_t mockProcessListDeviceUnused(std::vector<::pid_t> &list) {
|
||||
std::vector<mockEnumListProcessCall> mockListProcessCall{};
|
||||
std::vector<bool> isRepeated{};
|
||||
ze_result_t listProcessesResult = ZE_RESULT_SUCCESS;
|
||||
uint32_t listProcessCalled = 0u;
|
||||
ze_result_t listProcesses(std::vector<::pid_t> &list) override {
|
||||
listProcessCalled++;
|
||||
list = pidList;
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t mockProcessListDeviceInUse(std::vector<::pid_t> &list) {
|
||||
list = pidList;
|
||||
if (ourDevicePid) {
|
||||
list.push_back(ourDevicePid);
|
||||
if (!mockListProcessCall.empty()) {
|
||||
mockEnumListProcessCall mockListProcessCallValue = mockListProcessCall.front();
|
||||
if (mockListProcessCallValue == mockEnumListProcessCall::DEVICE_IN_USE) {
|
||||
if (ourDevicePid) {
|
||||
list.push_back(ourDevicePid);
|
||||
}
|
||||
}
|
||||
|
||||
else if (mockListProcessCallValue == mockEnumListProcessCall::DEVICE_UNUSED) {
|
||||
}
|
||||
|
||||
else if (mockListProcessCallValue == mockEnumListProcessCall::RETURN_ERROR) {
|
||||
listProcessesResult = ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
if (!isRepeated.empty()) {
|
||||
if (isRepeated.front() == false) {
|
||||
mockListProcessCall.erase(mockListProcessCall.begin());
|
||||
isRepeated.erase(isRepeated.begin());
|
||||
}
|
||||
}
|
||||
}
|
||||
return ZE_RESULT_SUCCESS;
|
||||
return listProcessesResult;
|
||||
}
|
||||
|
||||
::pid_t getMockMyProcessId() {
|
||||
::pid_t myProcessId() override {
|
||||
return ::getpid();
|
||||
}
|
||||
|
||||
ze_result_t getMockFileDescriptors(const ::pid_t pid, std::vector<int> &list) {
|
||||
// Give every process 3 file descriptors
|
||||
// Except the device that MOCK has the device open. Give it one extra.
|
||||
ze_result_t mockGetFileDescriptorsError = ZE_RESULT_SUCCESS;
|
||||
ze_result_t getFileDescriptorsResult = ZE_RESULT_SUCCESS;
|
||||
ze_result_t getFileDescriptors(const ::pid_t pid, std::vector<int> &list) override {
|
||||
list.clear();
|
||||
|
||||
if (mockGetFileDescriptorsError != ZE_RESULT_SUCCESS) {
|
||||
getFileDescriptorsResult = mockGetFileDescriptorsError;
|
||||
mockGetFileDescriptorsError = ZE_RESULT_SUCCESS;
|
||||
return getFileDescriptorsResult;
|
||||
}
|
||||
|
||||
list = fdList;
|
||||
if (ourDevicePid == pid) {
|
||||
list.push_back(ourDeviceFd);
|
||||
}
|
||||
return ZE_RESULT_SUCCESS;
|
||||
return getFileDescriptorsResult;
|
||||
}
|
||||
|
||||
ze_result_t getMockFileDescriptorsFailure(const ::pid_t pid, std::vector<int> &list) {
|
||||
//return failure to verify the error condition check
|
||||
list.clear();
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
ze_result_t mockGetFileNameError = ZE_RESULT_SUCCESS;
|
||||
ze_result_t getFileNameResult = ZE_RESULT_SUCCESS;
|
||||
ze_result_t getFileName(const ::pid_t pid, const int fd, std::string &val) override {
|
||||
if (mockGetFileNameError != ZE_RESULT_SUCCESS) {
|
||||
return mockGetFileNameError;
|
||||
}
|
||||
|
||||
ze_result_t getMockFileName(const ::pid_t pid, const int fd, std::string &val) {
|
||||
if (pid == ourDevicePid && fd == ourDeviceFd) {
|
||||
val = mockDeviceName;
|
||||
} else {
|
||||
// return fake filenames for other file descriptors
|
||||
val = std::string("/FILENAME") + std::to_string(fd);
|
||||
}
|
||||
return ZE_RESULT_SUCCESS;
|
||||
return getFileNameResult;
|
||||
}
|
||||
|
||||
bool mockIsAlive(const ::pid_t pid) {
|
||||
bool isAlive(const ::pid_t pid) override {
|
||||
if (pid == ourDevicePid) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void mockKill(const ::pid_t pid) {
|
||||
bool mockNoKill = false;
|
||||
void kill(const ::pid_t pid) override {
|
||||
if (mockNoKill == true) {
|
||||
return;
|
||||
}
|
||||
ourDevicePid = 0;
|
||||
}
|
||||
|
||||
Mock<GlobalOperationsProcfsAccess>() = default;
|
||||
|
||||
MOCK_METHOD(ze_result_t, listProcesses, (std::vector<::pid_t> & list), (override));
|
||||
MOCK_METHOD(::pid_t, myProcessId, (), (override));
|
||||
MOCK_METHOD(ze_result_t, getFileDescriptors, (const ::pid_t pid, std::vector<int> &list), (override));
|
||||
MOCK_METHOD(ze_result_t, getFileName, (const ::pid_t pid, const int fd, std::string &val), (override));
|
||||
MOCK_METHOD(bool, isAlive, (const ::pid_t pid), (override));
|
||||
MOCK_METHOD(void, kill, (const ::pid_t pid), (override));
|
||||
MockGlobalOperationsProcfsAccess() = default;
|
||||
};
|
||||
|
||||
class GlobalOperationsFsAccess : public FsAccess {};
|
||||
|
||||
template <>
|
||||
struct Mock<GlobalOperationsFsAccess> : public GlobalOperationsFsAccess {
|
||||
ze_result_t getValAgamaFile(const std::string file, std::string &val) {
|
||||
if (file.compare(agamaVersionFile) == 0) {
|
||||
val = driverVersion;
|
||||
} else {
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
struct MockGlobalOperationsFsAccess : public FsAccess {
|
||||
ze_result_t mockReadError = ZE_RESULT_SUCCESS;
|
||||
ze_result_t readResult = ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
std::string mockReadVal = "";
|
||||
ze_result_t read(const std::string file, std::string &val) override {
|
||||
if (mockReadError != ZE_RESULT_SUCCESS) {
|
||||
return mockReadError;
|
||||
}
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t getValSrcFile(const std::string file, std::string &val) {
|
||||
if (file.compare(srcVersionFile) == 0) {
|
||||
val = srcVersion;
|
||||
if (mockReadVal == srcVersion) {
|
||||
if (file.compare(srcVersionFile) == 0) {
|
||||
val = mockReadVal;
|
||||
readResult = ZE_RESULT_SUCCESS;
|
||||
return readResult;
|
||||
}
|
||||
} else if (mockReadVal == driverVersion) {
|
||||
if (file.compare(agamaVersionFile) == 0) {
|
||||
val = mockReadVal;
|
||||
readResult = ZE_RESULT_SUCCESS;
|
||||
return readResult;
|
||||
}
|
||||
} else {
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
readResult = ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
return ZE_RESULT_SUCCESS;
|
||||
return readResult;
|
||||
}
|
||||
|
||||
ze_result_t getValWedgedFileTrue(const std::string file, uint32_t &val) {
|
||||
uint32_t mockReadUIntVal = 0;
|
||||
ze_result_t read(const std::string file, uint32_t &val) override {
|
||||
if (file.compare(ueventWedgedFile) == 0) {
|
||||
val = 1;
|
||||
val = mockReadUIntVal;
|
||||
readResult = ZE_RESULT_SUCCESS;
|
||||
} else {
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
readResult = ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
return ZE_RESULT_SUCCESS;
|
||||
return readResult;
|
||||
}
|
||||
|
||||
ze_result_t getValWedgedFileFalse(const std::string file, uint32_t &val) {
|
||||
if (file.compare(ueventWedgedFile) == 0) {
|
||||
val = 0;
|
||||
} else {
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
ze_result_t mockWriteError = ZE_RESULT_SUCCESS;
|
||||
ze_result_t writeResult = ZE_RESULT_SUCCESS;
|
||||
ze_result_t write(const std::string file, const std::string val) override {
|
||||
if (mockWriteError != ZE_RESULT_SUCCESS) {
|
||||
return mockWriteError;
|
||||
}
|
||||
return ZE_RESULT_SUCCESS;
|
||||
|
||||
return writeResult;
|
||||
}
|
||||
|
||||
Mock<GlobalOperationsFsAccess>() = default;
|
||||
|
||||
MOCK_METHOD(ze_result_t, read, (const std::string file, std::string &val), (override));
|
||||
MOCK_METHOD(ze_result_t, read, (const std::string file, uint32_t &val), (override));
|
||||
MOCK_METHOD(ze_result_t, write, (const std::string file, const std::string val), (override));
|
||||
MOCK_METHOD(ze_result_t, canWrite, (const std::string file), (override));
|
||||
ADDMETHOD_NOBASE(canWrite, ze_result_t, ZE_RESULT_SUCCESS, (const std::string file));
|
||||
MockGlobalOperationsFsAccess() = default;
|
||||
};
|
||||
|
||||
class GlobalOpsFwInterface : public FirmwareUtil {};
|
||||
template <>
|
||||
struct Mock<GlobalOpsFwInterface> : public GlobalOpsFwInterface {
|
||||
struct MockGlobalOpsFwInterface : public FirmwareUtil {
|
||||
ze_result_t mockIfrError = ZE_RESULT_SUCCESS;
|
||||
ze_result_t mockIfrResult = ZE_RESULT_SUCCESS;
|
||||
bool mockIfrStatus = true;
|
||||
ze_result_t fwIfrApplied(bool &ifrStatus) override {
|
||||
if (mockIfrError != ZE_RESULT_SUCCESS) {
|
||||
return mockIfrError;
|
||||
}
|
||||
|
||||
ze_result_t mockFwDeviceInit(void) {
|
||||
return ZE_RESULT_SUCCESS;
|
||||
ifrStatus = mockIfrStatus;
|
||||
return mockIfrResult;
|
||||
}
|
||||
ze_result_t mockFwDeviceInitFail(void) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
ze_result_t mockIfrReturnTrue(bool &ifrStatus) {
|
||||
ifrStatus = true;
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
ze_result_t mockIfrReturnFail(bool &ifrStatus) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
ze_result_t mockIfrReturnFalse(bool &ifrStatus) {
|
||||
ifrStatus = false;
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
Mock<GlobalOpsFwInterface>() = default;
|
||||
MockGlobalOpsFwInterface() = default;
|
||||
|
||||
MOCK_METHOD(ze_result_t, fwDeviceInit, (), (override));
|
||||
MOCK_METHOD(ze_result_t, getFirstDevice, (igsc_device_info * info), (override));
|
||||
MOCK_METHOD(ze_result_t, getFwVersion, (std::string fwType, std::string &firmwareVersion), (override));
|
||||
MOCK_METHOD(ze_result_t, flashFirmware, (std::string fwType, void *pImage, uint32_t size), (override));
|
||||
MOCK_METHOD(ze_result_t, fwIfrApplied, (bool &ifrStatus), (override));
|
||||
ADDMETHOD_NOBASE(fwDeviceInit, ze_result_t, ZE_RESULT_SUCCESS, (void));
|
||||
ADDMETHOD_NOBASE(getFirstDevice, ze_result_t, ZE_RESULT_SUCCESS, (igsc_device_info * info));
|
||||
ADDMETHOD_NOBASE(getFwVersion, ze_result_t, ZE_RESULT_SUCCESS, (std::string fwType, std::string &firmwareVersion));
|
||||
ADDMETHOD_NOBASE(flashFirmware, ze_result_t, ZE_RESULT_SUCCESS, (std::string fwType, void *pImage, uint32_t size));
|
||||
ADDMETHOD_NOBASE(fwSupportedDiagTests, ze_result_t, ZE_RESULT_SUCCESS, (std::vector<std::string> & supportedDiagTests));
|
||||
ADDMETHOD_NOBASE(fwRunDiagTests, ze_result_t, ZE_RESULT_SUCCESS, (std::string & osDiagType, zes_diag_result_t *pResult));
|
||||
ADDMETHOD_NOBASE(fwGetMemoryErrorCount, ze_result_t, ZE_RESULT_SUCCESS, (zes_ras_error_type_t category, uint32_t subDeviceCount, uint32_t subDeviceId, uint64_t &count));
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
|
||||
#include "level_zero/tools/test/unit_tests/sources/sysman/linux/mock_sysman_fixture.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "mock_global_operations.h"
|
||||
|
||||
extern bool sysmanUltsEnable;
|
||||
@@ -47,13 +46,13 @@ constexpr uint32_t totalProcessStates = 5u; // Three process States for three pi
|
||||
constexpr uint32_t totalProcessStatesForFaultyClients = 3u;
|
||||
class SysmanGlobalOperationsFixture : public SysmanDeviceFixture {
|
||||
protected:
|
||||
std::unique_ptr<Mock<GlobalOperationsEngineHandleContext>> pEngineHandleContext;
|
||||
std::unique_ptr<Mock<GlobalOperationsDiagnosticsHandleContext>> pDiagnosticsHandleContext;
|
||||
std::unique_ptr<Mock<GlobalOperationsFirmwareHandleContext>> pFirmwareHandleContext;
|
||||
std::unique_ptr<Mock<GlobalOperationsRasHandleContext>> pRasHandleContext;
|
||||
std::unique_ptr<Mock<GlobalOperationsSysfsAccess>> pSysfsAccess;
|
||||
std::unique_ptr<Mock<GlobalOperationsProcfsAccess>> pProcfsAccess;
|
||||
std::unique_ptr<Mock<GlobalOperationsFsAccess>> pFsAccess;
|
||||
std::unique_ptr<MockGlobalOperationsEngineHandleContext> pEngineHandleContext;
|
||||
std::unique_ptr<MockGlobalOperationsDiagnosticsHandleContext> pDiagnosticsHandleContext;
|
||||
std::unique_ptr<MockGlobalOperationsFirmwareHandleContext> pFirmwareHandleContext;
|
||||
std::unique_ptr<MockGlobalOperationsRasHandleContext> pRasHandleContext;
|
||||
std::unique_ptr<MockGlobalOperationsSysfsAccess> pSysfsAccess;
|
||||
std::unique_ptr<MockGlobalOperationsProcfsAccess> pProcfsAccess;
|
||||
std::unique_ptr<MockGlobalOperationsFsAccess> pFsAccess;
|
||||
std::unique_ptr<MockGlobalOpsLinuxSysmanImp> pMockGlobalOpsLinuxSysmanImp;
|
||||
EngineHandleContext *pEngineHandleContextOld = nullptr;
|
||||
DiagnosticsHandleContext *pDiagnosticsHandleContextOld = nullptr;
|
||||
@@ -82,13 +81,13 @@ class SysmanGlobalOperationsFixture : public SysmanDeviceFixture {
|
||||
pFsAccessOld = pLinuxSysmanImp->pFsAccess;
|
||||
pLinuxSysmanImpOld = pLinuxSysmanImp;
|
||||
|
||||
pEngineHandleContext = std::make_unique<NiceMock<Mock<GlobalOperationsEngineHandleContext>>>(pOsSysman);
|
||||
pSysfsAccess = std::make_unique<NiceMock<Mock<GlobalOperationsSysfsAccess>>>();
|
||||
pProcfsAccess = std::make_unique<NiceMock<Mock<GlobalOperationsProcfsAccess>>>();
|
||||
pFsAccess = std::make_unique<NiceMock<Mock<GlobalOperationsFsAccess>>>();
|
||||
pDiagnosticsHandleContext = std::make_unique<NiceMock<Mock<GlobalOperationsDiagnosticsHandleContext>>>(pOsSysman);
|
||||
pFirmwareHandleContext = std::make_unique<NiceMock<Mock<GlobalOperationsFirmwareHandleContext>>>(pOsSysman);
|
||||
pRasHandleContext = std::make_unique<NiceMock<Mock<GlobalOperationsRasHandleContext>>>(pOsSysman);
|
||||
pEngineHandleContext = std::make_unique<MockGlobalOperationsEngineHandleContext>(pOsSysman);
|
||||
pSysfsAccess = std::make_unique<MockGlobalOperationsSysfsAccess>();
|
||||
pProcfsAccess = std::make_unique<MockGlobalOperationsProcfsAccess>();
|
||||
pFsAccess = std::make_unique<MockGlobalOperationsFsAccess>();
|
||||
pDiagnosticsHandleContext = std::make_unique<MockGlobalOperationsDiagnosticsHandleContext>(pOsSysman);
|
||||
pFirmwareHandleContext = std::make_unique<MockGlobalOperationsFirmwareHandleContext>(pOsSysman);
|
||||
pRasHandleContext = std::make_unique<MockGlobalOperationsRasHandleContext>(pOsSysman);
|
||||
pMockGlobalOpsLinuxSysmanImp = std::make_unique<MockGlobalOpsLinuxSysmanImp>(pLinuxSysmanImp->getSysmanDeviceImp());
|
||||
|
||||
pSysmanDeviceImp->pEngineHandleContext = pEngineHandleContext.get();
|
||||
@@ -98,39 +97,8 @@ class SysmanGlobalOperationsFixture : public SysmanDeviceFixture {
|
||||
pSysmanDeviceImp->pDiagnosticsHandleContext = pDiagnosticsHandleContext.get();
|
||||
pSysmanDeviceImp->pFirmwareHandleContext = pFirmwareHandleContext.get();
|
||||
pSysmanDeviceImp->pRasHandleContext = pRasHandleContext.get();
|
||||
|
||||
ON_CALL(*pRasHandleContext.get(), init(_))
|
||||
.WillByDefault(::testing::Invoke(pRasHandleContext.get(), &Mock<GlobalOperationsRasHandleContext>::initMock));
|
||||
ON_CALL(*pEngineHandleContext.get(), init(_))
|
||||
.WillByDefault(::testing::Invoke(pEngineHandleContext.get(), &Mock<GlobalOperationsEngineHandleContext>::initMock));
|
||||
ON_CALL(*pSysfsAccess.get(), read(_, Matcher<std::string &>(_)))
|
||||
.WillByDefault(::testing::Invoke(pSysfsAccess.get(), &Mock<GlobalOperationsSysfsAccess>::getValString));
|
||||
ON_CALL(*pSysfsAccess.get(), read(_, Matcher<uint64_t &>(_)))
|
||||
.WillByDefault(::testing::Invoke(pSysfsAccess.get(), &Mock<GlobalOperationsSysfsAccess>::getValUnsignedLong));
|
||||
ON_CALL(*pSysfsAccess.get(), scanDirEntries(_, _))
|
||||
.WillByDefault(::testing::Invoke(pSysfsAccess.get(), &Mock<GlobalOperationsSysfsAccess>::getScannedDirEntries));
|
||||
ON_CALL(*pFsAccess.get(), read(_, Matcher<std::string &>(_)))
|
||||
.WillByDefault(::testing::Invoke(pFsAccess.get(), &Mock<GlobalOperationsFsAccess>::getValAgamaFile));
|
||||
|
||||
ON_CALL(*pSysfsAccess.get(), getRealPath(_, Matcher<std::string &>(_)))
|
||||
.WillByDefault(::testing::Invoke(pSysfsAccess.get(), &Mock<GlobalOperationsSysfsAccess>::getRealPathVal));
|
||||
ON_CALL(*pFsAccess.get(), canWrite(Matcher<std::string>(mockFunctionResetPath)))
|
||||
.WillByDefault(::testing::Return(ZE_RESULT_SUCCESS));
|
||||
ON_CALL(*pProcfsAccess.get(), myProcessId())
|
||||
.WillByDefault(::testing::Invoke(pProcfsAccess.get(), &Mock<GlobalOperationsProcfsAccess>::getMockMyProcessId));
|
||||
ON_CALL(*pProcfsAccess.get(), isAlive(_))
|
||||
.WillByDefault(::testing::Invoke(pProcfsAccess.get(), &Mock<GlobalOperationsProcfsAccess>::mockIsAlive));
|
||||
ON_CALL(*pSysfsAccess.get(), isMyDeviceFile(_))
|
||||
.WillByDefault(::testing::Invoke(pSysfsAccess.get(), &Mock<GlobalOperationsSysfsAccess>::mockIsMyDeviceFile));
|
||||
ON_CALL(*pProcfsAccess.get(), getFileName(_, _, Matcher<std::string &>(_)))
|
||||
.WillByDefault(::testing::Invoke(pProcfsAccess.get(), &Mock<GlobalOperationsProcfsAccess>::getMockFileName));
|
||||
ON_CALL(*pProcfsAccess.get(), getFileDescriptors(_, Matcher<std::vector<int> &>(_)))
|
||||
.WillByDefault(::testing::Invoke(pProcfsAccess.get(), &Mock<GlobalOperationsProcfsAccess>::getMockFileDescriptors));
|
||||
ON_CALL(*pSysfsAccess.get(), unbindDevice(_))
|
||||
.WillByDefault(::testing::Return(ZE_RESULT_SUCCESS));
|
||||
ON_CALL(*pFsAccess.get(), write(mockFunctionResetPath, std::string("1")))
|
||||
.WillByDefault(::testing::Return(ZE_RESULT_SUCCESS));
|
||||
|
||||
pSysfsAccess->mockReadVal = "0x8086";
|
||||
pFsAccess->mockReadVal = driverVersion;
|
||||
pGlobalOperationsImp = static_cast<L0::GlobalOperationsImp *>(pSysmanDeviceImp->pGlobalOperations);
|
||||
pOsGlobalOperationsPrev = pGlobalOperationsImp->pOsGlobalOperations;
|
||||
pGlobalOperationsImp->pOsGlobalOperations = nullptr;
|
||||
@@ -592,9 +560,7 @@ TEST_F(SysmanGlobalOperationsFixture, GivenValidDeviceHandleWhenCallingzesDevice
|
||||
zes_device_properties_t properties;
|
||||
std::string test;
|
||||
test = srcVersion;
|
||||
ON_CALL(*pFsAccess.get(), read(_, Matcher<std::string &>(_)))
|
||||
.WillByDefault(::testing::Invoke(pFsAccess.get(), &Mock<GlobalOperationsFsAccess>::getValSrcFile));
|
||||
|
||||
pFsAccess->mockReadVal = srcVersion;
|
||||
ze_result_t result = zesDeviceGetProperties(device, &properties);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
EXPECT_TRUE(0 == test.compare(properties.driverVersion));
|
||||
@@ -602,10 +568,7 @@ TEST_F(SysmanGlobalOperationsFixture, GivenValidDeviceHandleWhenCallingzesDevice
|
||||
|
||||
TEST_F(SysmanGlobalOperationsFixture, GivenValidDeviceHandleWhenCallingzesDeviceGetPropertiesForCheckingDriverVersionWhenAgmaFileAndSrcFileIsAbsentThenVerifyzesDeviceGetPropertiesCallSucceeds) {
|
||||
zes_device_properties_t properties;
|
||||
|
||||
ON_CALL(*pFsAccess.get(), read(_, Matcher<std::string &>(_)))
|
||||
.WillByDefault(::testing::Return(ZE_RESULT_ERROR_NOT_AVAILABLE));
|
||||
|
||||
pFsAccess->mockReadError = ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
ze_result_t result = zesDeviceGetProperties(device, &properties);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
EXPECT_TRUE(0 == unknown.compare(properties.driverVersion));
|
||||
@@ -613,9 +576,7 @@ TEST_F(SysmanGlobalOperationsFixture, GivenValidDeviceHandleWhenCallingzesDevice
|
||||
|
||||
TEST_F(SysmanGlobalOperationsFixture, GivenValidDeviceHandleWhenCallingzesDeviceGetPropertiesForCheckingDriverVersionWhenDriverVersionFileIsNotAvaliableThenVerifyzesDeviceGetPropertiesCallSucceeds) {
|
||||
zes_device_properties_t properties;
|
||||
ON_CALL(*pFsAccess.get(), read(_, Matcher<std::string &>(_)))
|
||||
.WillByDefault(::testing::Return(ZE_RESULT_ERROR_NOT_AVAILABLE));
|
||||
|
||||
pFsAccess->mockReadError = ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
ze_result_t result = zesDeviceGetProperties(device, &properties);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
EXPECT_TRUE(0 == unknown.compare(properties.driverVersion));
|
||||
@@ -623,17 +584,14 @@ TEST_F(SysmanGlobalOperationsFixture, GivenValidDeviceHandleWhenCallingzesDevice
|
||||
|
||||
TEST_F(SysmanGlobalOperationsFixture, GivenValidDeviceHandleWhenCallingzesDeviceGetPropertiesForCheckingDriverVersionWhenDriverVersionFileReadFailsThenVerifyzesDeviceGetPropertiesCallSucceeds) {
|
||||
zes_device_properties_t properties;
|
||||
ON_CALL(*pFsAccess.get(), read(_, Matcher<std::string &>(_)))
|
||||
.WillByDefault(::testing::Return(ZE_RESULT_ERROR_UNKNOWN));
|
||||
|
||||
pFsAccess->mockReadError = ZE_RESULT_ERROR_UNKNOWN;
|
||||
ze_result_t result = zesDeviceGetProperties(device, &properties);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
EXPECT_TRUE(0 == unknown.compare(properties.driverVersion));
|
||||
}
|
||||
|
||||
TEST_F(SysmanGlobalOperationsFixture, GivenValidDeviceHandleWhenCallingzesDeviceGetPropertiesForCheckingDevicePropertiesWhenVendorIsUnKnownThenVerifyzesDeviceGetPropertiesCallSucceeds) {
|
||||
ON_CALL(*pSysfsAccess.get(), read(_, Matcher<std::string &>(_)))
|
||||
.WillByDefault(::testing::Invoke(pSysfsAccess.get(), &Mock<GlobalOperationsSysfsAccess>::getFalseValString));
|
||||
pSysfsAccess->mockReadVal = "0xa086";
|
||||
neoDevice->deviceInfo.vendorId = 1806; // Unknown Vendor id
|
||||
zes_device_properties_t properties;
|
||||
ze_result_t result = zesDeviceGetProperties(device, &properties);
|
||||
@@ -644,9 +602,7 @@ TEST_F(SysmanGlobalOperationsFixture, GivenValidDeviceHandleWhenCallingzesDevice
|
||||
|
||||
TEST_F(SysmanGlobalOperationsFixture, GivenValidDeviceHandleWhenCallingzesDeviceGetPropertiesForCheckingDriverVersionWhenAccessingAgamaFileOrSrcFileGotPermissionDeniedThenVerifyzesDeviceGetPropertiesCallSucceeds) {
|
||||
zes_device_properties_t properties;
|
||||
ON_CALL(*pFsAccess.get(), read(_, Matcher<std::string &>(_)))
|
||||
.WillByDefault(::testing::Return(ZE_RESULT_ERROR_INSUFFICIENT_PERMISSIONS));
|
||||
|
||||
pFsAccess->mockReadError = ZE_RESULT_ERROR_INSUFFICIENT_PERMISSIONS;
|
||||
ze_result_t result = zesDeviceGetProperties(device, &properties);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
EXPECT_TRUE(0 == unknown.compare(properties.driverVersion));
|
||||
@@ -682,11 +638,8 @@ TEST_F(SysmanGlobalOperationsFixture, GivenValidDeviceHandleWhileRetrievingInfor
|
||||
|
||||
TEST_F(SysmanGlobalOperationsFixture, GivenValidDeviceHandleWhileRetrievingInformationAboutHostProcessesUsingDeviceThenSuccessIsReturnedEvenwithFaultyClient) {
|
||||
uint32_t count = 0;
|
||||
ON_CALL(*pSysfsAccess.get(), scanDirEntries(_, _))
|
||||
.WillByDefault(::testing::Invoke(pSysfsAccess.get(), &Mock<GlobalOperationsSysfsAccess>::getScannedDir4Entries));
|
||||
ON_CALL(*pSysfsAccess.get(), read(_, Matcher<uint64_t &>(_)))
|
||||
.WillByDefault(::testing::Invoke(pSysfsAccess.get(), &Mock<GlobalOperationsSysfsAccess>::getValUnsignedLongCreatedBytesSuccess));
|
||||
|
||||
pSysfsAccess->mockGetScannedDir4EntriesStatus = true;
|
||||
pSysfsAccess->mockGetValUnsignedLongStatus = true;
|
||||
ASSERT_EQ(ZE_RESULT_SUCCESS, zesDeviceProcessesGetState(device, &count, nullptr));
|
||||
EXPECT_EQ(count, totalProcessStatesForFaultyClients);
|
||||
std::vector<zes_process_state_t> processes(count);
|
||||
@@ -713,53 +666,39 @@ TEST_F(SysmanGlobalOperationsFixture, GivenValidDeviceHandleWhileCountValueIsPro
|
||||
|
||||
TEST_F(SysmanGlobalOperationsFixture, GivenValidDeviceHandleWhileRetrievingInformationAboutHostProcessesUsingFaultyClientFileThenFailureIsReturned) {
|
||||
uint32_t count = 0;
|
||||
ON_CALL(*pSysfsAccess.get(), scanDirEntries(_, _))
|
||||
.WillByDefault(::testing::Invoke(pSysfsAccess.get(), &Mock<GlobalOperationsSysfsAccess>::getScannedDir4Entries));
|
||||
pSysfsAccess->mockGetScannedDir4EntriesStatus = true;
|
||||
ASSERT_EQ(ZE_RESULT_ERROR_UNKNOWN, zesDeviceProcessesGetState(device, &count, nullptr));
|
||||
}
|
||||
|
||||
TEST_F(SysmanGlobalOperationsFixture, GivenValidDeviceHandleWhileRetrievingInformationAboutHostProcessesUsingNullDirThenFailureIsReturned) {
|
||||
uint32_t count = 0;
|
||||
EXPECT_CALL(*pSysfsAccess.get(), scanDirEntries(_, _))
|
||||
.WillOnce(::testing::Return(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE));
|
||||
pSysfsAccess->mockScanDirEntriesError = ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zesDeviceProcessesGetState(device, &count, nullptr));
|
||||
}
|
||||
TEST_F(SysmanGlobalOperationsFixture, GivenValidDeviceHandleWhileRetrievingInformationAboutHostProcessesUsingDeviceThenFailureIsReturnedEvenwithFaultyClient) {
|
||||
initGlobalOps();
|
||||
uint32_t count = 0;
|
||||
ON_CALL(*pSysfsAccess.get(), scanDirEntries(_, _))
|
||||
.WillByDefault(::testing::Invoke(pSysfsAccess.get(), &Mock<GlobalOperationsSysfsAccess>::getScannedDirPidEntires));
|
||||
EXPECT_CALL(*pSysfsAccess.get(), read(_, Matcher<uint64_t &>(_)))
|
||||
.WillOnce(::testing::Return(ZE_RESULT_ERROR_UNKNOWN));
|
||||
EXPECT_CALL(*pSysfsAccess.get(), read(_, Matcher<std::string &>(_)))
|
||||
.WillOnce(::testing::Return(ZE_RESULT_ERROR_UNKNOWN));
|
||||
|
||||
pSysfsAccess->mockGetScannedDirPidEntriesStatus = true;
|
||||
pSysfsAccess->mockReadError = ZE_RESULT_ERROR_UNKNOWN;
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNKNOWN, zesDeviceProcessesGetState(device, &count, nullptr));
|
||||
}
|
||||
|
||||
TEST_F(SysmanGlobalOperationsFixture, GivenValidDeviceHandleWhileRetrievingInformationAboutHostProcessesUsingBusyDirForEnginesReadThenFailureIsReturnedEvenwithFaultyClient) {
|
||||
uint32_t count = 0;
|
||||
ON_CALL(*pSysfsAccess.get(), scanDirEntries(_, _))
|
||||
.WillByDefault(::testing::Invoke(pSysfsAccess.get(), &Mock<GlobalOperationsSysfsAccess>::getScannedDirPidEntires));
|
||||
|
||||
pSysfsAccess->mockGetScannedDirPidEntriesStatus = true;
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNKNOWN, zesDeviceProcessesGetState(device, &count, nullptr));
|
||||
}
|
||||
|
||||
TEST_F(SysmanGlobalOperationsFixture, GivenValidDeviceHandleWhileRetrievingInformationAboutHostProcessesUsingBusyDirForEnginesThenFailureIsReturnedEvenwithFaultyClient) {
|
||||
uint32_t count = 0;
|
||||
ON_CALL(*pSysfsAccess.get(), scanDirEntries(_, _))
|
||||
.WillByDefault(::testing::Invoke(pSysfsAccess.get(), &Mock<GlobalOperationsSysfsAccess>::getScannedDir4Entries));
|
||||
EXPECT_CALL(*pSysfsAccess.get(), read(_, Matcher<uint64_t &>(_)))
|
||||
.WillOnce(::testing::Invoke(pSysfsAccess.get(), &Mock<GlobalOperationsSysfsAccess>::getValUnsignedLongCreatedBytesSuccess))
|
||||
.WillOnce(::testing::Return(ZE_RESULT_ERROR_UNKNOWN));
|
||||
|
||||
pSysfsAccess->mockGetScannedDir4EntriesStatus = true;
|
||||
pSysfsAccess->mockReadStatus = true;
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNKNOWN, zesDeviceProcessesGetState(device, &count, nullptr));
|
||||
}
|
||||
|
||||
TEST_F(SysmanGlobalOperationsFixture, GivenValidDeviceHandleWhileReadingInvalidBufferObjectsThenErrorIsReturned) {
|
||||
uint32_t count = 0;
|
||||
ON_CALL(*pSysfsAccess.get(), scanDirEntries(_, _))
|
||||
.WillByDefault(::testing::Invoke(pSysfsAccess.get(), &Mock<GlobalOperationsSysfsAccess>::getScannedDirPidEntiresForClients));
|
||||
pSysfsAccess->mockGetScannedDirPidEntriesForClientsStatus = true;
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNKNOWN, zesDeviceProcessesGetState(device, &count, nullptr));
|
||||
}
|
||||
|
||||
@@ -771,8 +710,7 @@ TEST_F(SysmanGlobalOperationsFixture, GivenValidDeviceHandleWhileReadingExisting
|
||||
|
||||
TEST_F(SysmanGlobalOperationsFixture, GivenValidDeviceHandleWhileReadingInvalidMemoryFileThenErrorIsReturned) {
|
||||
uint64_t memSize = 0;
|
||||
ON_CALL(*pSysfsAccess.get(), scanDirEntries(_, _))
|
||||
.WillByDefault(::testing::Invoke(pSysfsAccess.get(), &Mock<GlobalOperationsSysfsAccess>::getScannedDir4Entries));
|
||||
pSysfsAccess->mockGetScannedDir4EntriesStatus = true;
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_NOT_AVAILABLE, pSysfsAccess->read("clients/7/total_device_memory_buffer_objects/imported_bytes", memSize));
|
||||
}
|
||||
|
||||
@@ -782,16 +720,14 @@ TEST_F(SysmanGlobalOperationsFixture, GivenValidDeviceHandleWhileReadingNonExist
|
||||
}
|
||||
|
||||
TEST_F(SysmanGlobalOperationsFixture, GivenDeviceIsWedgedWhenCallingGetDeviceStateThenZesResetReasonFlagWedgedIsReturned) {
|
||||
ON_CALL(*pFsAccess.get(), read(_, Matcher<uint32_t &>(_)))
|
||||
.WillByDefault(::testing::Invoke(pFsAccess.get(), &Mock<GlobalOperationsFsAccess>::getValWedgedFileTrue));
|
||||
pFsAccess->mockReadUIntVal = 1;
|
||||
zes_device_state_t deviceState;
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceGetState(device, &deviceState));
|
||||
EXPECT_EQ(ZES_RESET_REASON_FLAG_WEDGED, deviceState.reset);
|
||||
}
|
||||
|
||||
TEST_F(SysmanGlobalOperationsFixture, GivenDeviceIsNotWedgedWhenCallingGetDeviceStateThenZeroIsReturned) {
|
||||
ON_CALL(*pFsAccess.get(), read(_, Matcher<uint32_t &>(_)))
|
||||
.WillByDefault(::testing::Invoke(pFsAccess.get(), &Mock<GlobalOperationsFsAccess>::getValWedgedFileFalse));
|
||||
pFsAccess->mockReadUIntVal = 0;
|
||||
zes_device_state_t deviceState;
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceGetState(device, &deviceState));
|
||||
EXPECT_EQ(0u, deviceState.reset);
|
||||
@@ -806,7 +742,6 @@ TEST_F(SysmanGlobalOperationsFixture, GivenForceTrueWhenCallingResetThenSuccessI
|
||||
}
|
||||
|
||||
TEST_F(SysmanGlobalOperationsIntegratedFixture, GivenPermissionDeniedWhenCallingGetDeviceStateThenZeResultErrorInsufficientPermissionsIsReturned) {
|
||||
|
||||
pSysfsAccess->isRootSet = false;
|
||||
ze_result_t result = zesDeviceReset(device, true);
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_INSUFFICIENT_PERMISSIONS, result);
|
||||
@@ -816,8 +751,8 @@ TEST_F(SysmanGlobalOperationsIntegratedFixture, GivenDeviceInUseWhenCallingReset
|
||||
|
||||
pProcfsAccess->ourDevicePid = pProcfsAccess->extraPid;
|
||||
pProcfsAccess->ourDeviceFd = pProcfsAccess->extraFd;
|
||||
ON_CALL(*pProcfsAccess.get(), listProcesses(Matcher<std::vector<::pid_t> &>(_)))
|
||||
.WillByDefault(::testing::Invoke(pProcfsAccess.get(), &Mock<GlobalOperationsProcfsAccess>::mockProcessListDeviceInUse));
|
||||
pProcfsAccess->mockListProcessCall.push_back(DEVICE_IN_USE);
|
||||
pProcfsAccess->isRepeated.push_back(true);
|
||||
ze_result_t result = zesDeviceReset(device, false);
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_HANDLE_OBJECT_IN_USE, result);
|
||||
}
|
||||
@@ -831,11 +766,10 @@ TEST_F(SysmanGlobalOperationsIntegratedFixture, GivenDeviceNotInUseWhenCallingRe
|
||||
// The first time we get the process list, include our own process, that has the file open
|
||||
// Reset should close the file (we verify after reset). On subsequent calls, return
|
||||
// the process list without our process
|
||||
EXPECT_CALL(*pProcfsAccess.get(), listProcesses(Matcher<std::vector<::pid_t> &>(_)))
|
||||
.WillOnce(::testing::Invoke(pProcfsAccess.get(), &Mock<GlobalOperationsProcfsAccess>::mockProcessListDeviceInUse))
|
||||
.WillRepeatedly(::testing::Invoke(pProcfsAccess.get(), &Mock<GlobalOperationsProcfsAccess>::mockProcessListDeviceUnused));
|
||||
EXPECT_CALL(*pSysfsAccess.get(), bindDevice(_))
|
||||
.WillOnce(::testing::Return(ZE_RESULT_SUCCESS));
|
||||
pProcfsAccess->mockListProcessCall.push_back(DEVICE_IN_USE);
|
||||
pProcfsAccess->isRepeated.push_back(false);
|
||||
pProcfsAccess->mockListProcessCall.push_back(DEVICE_UNUSED);
|
||||
pProcfsAccess->isRepeated.push_back(true);
|
||||
ze_result_t result = zesDeviceReset(device, false);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
// Check that reset closed the device
|
||||
@@ -849,13 +783,8 @@ TEST_F(SysmanGlobalOperationsIntegratedFixture, GivenForceTrueAndDeviceInUseWhen
|
||||
// Pretend another process has the device open
|
||||
pProcfsAccess->ourDevicePid = getpid() + 1; // make sure it isn't our process id
|
||||
pProcfsAccess->ourDeviceFd = pProcfsAccess->extraFd;
|
||||
|
||||
ON_CALL(*pProcfsAccess.get(), listProcesses(Matcher<std::vector<::pid_t> &>(_)))
|
||||
.WillByDefault(::testing::Invoke(pProcfsAccess.get(), &Mock<GlobalOperationsProcfsAccess>::mockProcessListDeviceInUse));
|
||||
EXPECT_CALL(*pProcfsAccess.get(), kill(pProcfsAccess->ourDevicePid))
|
||||
.WillOnce(::testing::Invoke(pProcfsAccess.get(), &Mock<GlobalOperationsProcfsAccess>::mockKill));
|
||||
EXPECT_CALL(*pSysfsAccess.get(), bindDevice(_))
|
||||
.WillOnce(::testing::Return(ZE_RESULT_SUCCESS));
|
||||
pProcfsAccess->mockListProcessCall.push_back(DEVICE_IN_USE);
|
||||
pProcfsAccess->isRepeated.push_back(true);
|
||||
ze_result_t result = zesDeviceReset(device, true);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
}
|
||||
@@ -867,13 +796,10 @@ TEST_F(SysmanGlobalOperationsIntegratedFixture, GivenProcessStartsMidResetWhenCa
|
||||
pProcfsAccess->ourDeviceFd = pProcfsAccess->extraFd;
|
||||
|
||||
// Return process list without open fd on first call, but with open fd on subsequent calls
|
||||
EXPECT_CALL(*pProcfsAccess.get(), listProcesses(Matcher<std::vector<::pid_t> &>(_)))
|
||||
.WillOnce(::testing::Invoke(pProcfsAccess.get(), &Mock<GlobalOperationsProcfsAccess>::mockProcessListDeviceUnused))
|
||||
.WillRepeatedly(::testing::Invoke(pProcfsAccess.get(), &Mock<GlobalOperationsProcfsAccess>::mockProcessListDeviceInUse));
|
||||
EXPECT_CALL(*pProcfsAccess.get(), kill(pProcfsAccess->ourDevicePid))
|
||||
.WillOnce(::testing::Invoke(pProcfsAccess.get(), &Mock<GlobalOperationsProcfsAccess>::mockKill));
|
||||
EXPECT_CALL(*pSysfsAccess.get(), bindDevice(_))
|
||||
.WillOnce(::testing::Return(ZE_RESULT_SUCCESS));
|
||||
pProcfsAccess->mockListProcessCall.push_back(DEVICE_UNUSED);
|
||||
pProcfsAccess->isRepeated.push_back(false);
|
||||
pProcfsAccess->mockListProcessCall.push_back(DEVICE_IN_USE);
|
||||
pProcfsAccess->isRepeated.push_back(true);
|
||||
ze_result_t result = zesDeviceReset(device, false);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
}
|
||||
@@ -885,13 +811,10 @@ TEST_F(SysmanGlobalOperationsIntegratedFixture, GivenProcessStartsMidResetWhenCa
|
||||
pProcfsAccess->ourDeviceFd = pProcfsAccess->extraFd;
|
||||
|
||||
// Return process list without open fd on first call, but with open fd on subsequent calls
|
||||
EXPECT_CALL(*pProcfsAccess.get(), listProcesses(Matcher<std::vector<::pid_t> &>(_)))
|
||||
.WillOnce(::testing::Invoke(pProcfsAccess.get(), &Mock<GlobalOperationsProcfsAccess>::mockProcessListDeviceUnused))
|
||||
.WillRepeatedly(::testing::Invoke(pProcfsAccess.get(), &Mock<GlobalOperationsProcfsAccess>::mockProcessListDeviceInUse));
|
||||
EXPECT_CALL(*pProcfsAccess.get(), kill(pProcfsAccess->ourDevicePid))
|
||||
.WillOnce(::testing::Invoke(pProcfsAccess.get(), &Mock<GlobalOperationsProcfsAccess>::mockKill));
|
||||
EXPECT_CALL(*pSysfsAccess.get(), bindDevice(_))
|
||||
.WillOnce(::testing::Return(ZE_RESULT_SUCCESS));
|
||||
pProcfsAccess->mockListProcessCall.push_back(DEVICE_UNUSED);
|
||||
pProcfsAccess->isRepeated.push_back(false);
|
||||
pProcfsAccess->mockListProcessCall.push_back(DEVICE_IN_USE);
|
||||
pProcfsAccess->isRepeated.push_back(true);
|
||||
VariableBackup<UltHwConfig> backup{&ultHwConfig};
|
||||
ultHwConfig.mockedPrepareDeviceEnvironmentsFuncResult = false;
|
||||
ze_result_t result = zesDeviceReset(device, false);
|
||||
@@ -905,13 +828,11 @@ TEST_F(SysmanGlobalOperationsIntegratedFixture, GivenProcessStartsMidResetWhenCa
|
||||
pProcfsAccess->ourDeviceFd = pProcfsAccess->extraFd;
|
||||
|
||||
// Return process list without open fd on first call, but with open fd on subsequent calls
|
||||
EXPECT_CALL(*pProcfsAccess.get(), listProcesses(Matcher<std::vector<::pid_t> &>(_)))
|
||||
.WillOnce(::testing::Invoke(pProcfsAccess.get(), &Mock<GlobalOperationsProcfsAccess>::mockProcessListDeviceUnused))
|
||||
.WillRepeatedly(::testing::Invoke(pProcfsAccess.get(), &Mock<GlobalOperationsProcfsAccess>::mockProcessListDeviceInUse));
|
||||
EXPECT_CALL(*pProcfsAccess.get(), kill(pProcfsAccess->ourDevicePid))
|
||||
.WillOnce(::testing::Invoke(pProcfsAccess.get(), &Mock<GlobalOperationsProcfsAccess>::mockKill));
|
||||
EXPECT_CALL(*pSysfsAccess.get(), bindDevice(_))
|
||||
.WillOnce(::testing::Return(ZE_RESULT_ERROR_UNKNOWN));
|
||||
pProcfsAccess->mockListProcessCall.push_back(DEVICE_UNUSED);
|
||||
pProcfsAccess->isRepeated.push_back(false);
|
||||
pProcfsAccess->mockListProcessCall.push_back(DEVICE_IN_USE);
|
||||
pProcfsAccess->isRepeated.push_back(true);
|
||||
pSysfsAccess->mockBindDeviceError = ZE_RESULT_ERROR_UNKNOWN;
|
||||
ze_result_t result = zesDeviceReset(device, false);
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNKNOWN, result);
|
||||
}
|
||||
@@ -920,8 +841,8 @@ TEST_F(SysmanGlobalOperationsIntegratedFixture, GivenDeviceInUseWhenCallingReset
|
||||
|
||||
pProcfsAccess->ourDevicePid = pProcfsAccess->extraPid;
|
||||
pProcfsAccess->ourDeviceFd = pProcfsAccess->extraFd;
|
||||
EXPECT_CALL(*pProcfsAccess.get(), listProcesses(Matcher<std::vector<::pid_t> &>(_)))
|
||||
.WillOnce(::testing::Return(ZE_RESULT_ERROR_NOT_AVAILABLE));
|
||||
pProcfsAccess->mockListProcessCall.push_back(RETURN_ERROR);
|
||||
pProcfsAccess->isRepeated.push_back(false);
|
||||
ze_result_t result = zesDeviceReset(device, false);
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_NOT_AVAILABLE, result);
|
||||
}
|
||||
@@ -931,12 +852,12 @@ TEST_F(SysmanGlobalOperationsIntegratedFixture, GivenProcessStartsMidResetWhenLi
|
||||
// Pretend another process has the device open
|
||||
pProcfsAccess->ourDevicePid = getpid() + 1; // make sure it isn't our process id
|
||||
pProcfsAccess->ourDeviceFd = pProcfsAccess->extraFd;
|
||||
|
||||
// Return process list without open fd on first call
|
||||
EXPECT_CALL(*pProcfsAccess.get(), listProcesses(Matcher<std::vector<::pid_t> &>(_)))
|
||||
.WillOnce(::testing::Invoke(pProcfsAccess.get(), &Mock<GlobalOperationsProcfsAccess>::mockProcessListDeviceUnused))
|
||||
.WillOnce(::testing::Return(ZE_RESULT_ERROR_NOT_AVAILABLE));
|
||||
ON_CALL(*pProcfsAccess.get(), kill(pProcfsAccess->ourDevicePid))
|
||||
.WillByDefault(::testing::Invoke(pProcfsAccess.get(), &Mock<GlobalOperationsProcfsAccess>::mockKill));
|
||||
pProcfsAccess->mockListProcessCall.push_back(DEVICE_UNUSED);
|
||||
pProcfsAccess->isRepeated.push_back(false);
|
||||
pProcfsAccess->mockListProcessCall.push_back(RETURN_ERROR);
|
||||
pProcfsAccess->isRepeated.push_back(false);
|
||||
ze_result_t result = zesDeviceReset(device, false);
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_NOT_AVAILABLE, result);
|
||||
}
|
||||
@@ -948,13 +869,11 @@ TEST_F(SysmanGlobalOperationsIntegratedFixture, GivenProcessStartsMidResetWhenCa
|
||||
pProcfsAccess->ourDeviceFd = pProcfsAccess->extraFd;
|
||||
|
||||
// Return process list without open fd on first call, but with open fd on subsequent calls
|
||||
EXPECT_CALL(*pProcfsAccess.get(), listProcesses(Matcher<std::vector<::pid_t> &>(_)))
|
||||
.WillOnce(::testing::Invoke(pProcfsAccess.get(), &Mock<GlobalOperationsProcfsAccess>::mockProcessListDeviceUnused))
|
||||
.WillRepeatedly(::testing::Invoke(pProcfsAccess.get(), &Mock<GlobalOperationsProcfsAccess>::mockProcessListDeviceInUse));
|
||||
EXPECT_CALL(*pProcfsAccess.get(), kill(pProcfsAccess->ourDevicePid))
|
||||
.WillOnce(::testing::Invoke(pProcfsAccess.get(), &Mock<GlobalOperationsProcfsAccess>::mockKill));
|
||||
EXPECT_CALL(*pFsAccess.get(), write(mockFunctionResetPath, std::string("1")))
|
||||
.WillOnce(::testing::Return(ZE_RESULT_ERROR_UNKNOWN));
|
||||
pProcfsAccess->mockListProcessCall.push_back(DEVICE_UNUSED);
|
||||
pProcfsAccess->isRepeated.push_back(false);
|
||||
pProcfsAccess->mockListProcessCall.push_back(DEVICE_IN_USE);
|
||||
pProcfsAccess->isRepeated.push_back(true);
|
||||
pFsAccess->mockWriteError = ZE_RESULT_ERROR_UNKNOWN;
|
||||
ze_result_t result = zesDeviceReset(device, false);
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNKNOWN, result);
|
||||
}
|
||||
@@ -966,12 +885,9 @@ TEST_F(SysmanGlobalOperationsIntegratedFixture, GivenProcessStartsMidResetWhenCa
|
||||
pProcfsAccess->ourDeviceFd = pProcfsAccess->extraFd;
|
||||
|
||||
// Return process list without open fd on first call, but with open fd on subsequent calls
|
||||
ON_CALL(*pProcfsAccess.get(), listProcesses(Matcher<std::vector<::pid_t> &>(_)))
|
||||
.WillByDefault(::testing::Invoke(pProcfsAccess.get(), &Mock<GlobalOperationsProcfsAccess>::mockProcessListDeviceUnused));
|
||||
ON_CALL(*pProcfsAccess.get(), kill(pProcfsAccess->ourDevicePid))
|
||||
.WillByDefault(::testing::Invoke(pProcfsAccess.get(), &Mock<GlobalOperationsProcfsAccess>::mockKill));
|
||||
EXPECT_CALL(*pSysfsAccess.get(), unbindDevice(_))
|
||||
.WillOnce(::testing::Return(ZE_RESULT_ERROR_UNKNOWN));
|
||||
pProcfsAccess->mockListProcessCall.push_back(DEVICE_UNUSED);
|
||||
pProcfsAccess->isRepeated.push_back(true);
|
||||
pSysfsAccess->mockUnbindDeviceError = ZE_RESULT_ERROR_UNKNOWN;
|
||||
ze_result_t result = zesDeviceReset(device, false);
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNKNOWN, result);
|
||||
}
|
||||
@@ -983,15 +899,11 @@ TEST_F(SysmanGlobalOperationsIntegratedFixture, GivenProcessStartsMidResetWhenCa
|
||||
pProcfsAccess->ourDeviceFd = pProcfsAccess->extraFd;
|
||||
|
||||
// Return process list without open fd on first call, but with open fd on subsequent calls
|
||||
EXPECT_CALL(*pProcfsAccess.get(), listProcesses(Matcher<std::vector<::pid_t> &>(_)))
|
||||
.WillOnce(::testing::Invoke(pProcfsAccess.get(), &Mock<GlobalOperationsProcfsAccess>::mockProcessListDeviceUnused))
|
||||
.WillRepeatedly(::testing::Invoke(pProcfsAccess.get(), &Mock<GlobalOperationsProcfsAccess>::mockProcessListDeviceInUse));
|
||||
ON_CALL(*pProcfsAccess.get(), getFileName(_, _, Matcher<std::string &>(_)))
|
||||
.WillByDefault(::testing::Return(ZE_RESULT_ERROR_UNKNOWN));
|
||||
ON_CALL(*pProcfsAccess.get(), kill(pProcfsAccess->ourDevicePid))
|
||||
.WillByDefault(::testing::Invoke(pProcfsAccess.get(), &Mock<GlobalOperationsProcfsAccess>::mockKill));
|
||||
EXPECT_CALL(*pSysfsAccess.get(), bindDevice(_))
|
||||
.WillOnce(::testing::Return(ZE_RESULT_SUCCESS));
|
||||
pProcfsAccess->mockListProcessCall.push_back(DEVICE_UNUSED);
|
||||
pProcfsAccess->isRepeated.push_back(false);
|
||||
pProcfsAccess->mockListProcessCall.push_back(DEVICE_IN_USE);
|
||||
pProcfsAccess->isRepeated.push_back(true);
|
||||
pProcfsAccess->mockGetFileNameError = ZE_RESULT_ERROR_UNKNOWN;
|
||||
ze_result_t result = zesDeviceReset(device, false);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
}
|
||||
@@ -1004,15 +916,11 @@ TEST_F(SysmanGlobalOperationsIntegratedFixture, GivenProcessWontDieWhenCallingRe
|
||||
static_cast<PublicLinuxGlobalOperationsImp *>(pGlobalOperationsImp->pOsGlobalOperations)->resetTimeout = 0; // timeout immediate
|
||||
|
||||
// Return process list without open fd on first call, but with open fd on subsequent calls
|
||||
EXPECT_CALL(*pProcfsAccess.get(), listProcesses(Matcher<std::vector<::pid_t> &>(_)))
|
||||
.WillOnce(::testing::Invoke(pProcfsAccess.get(), &Mock<GlobalOperationsProcfsAccess>::mockProcessListDeviceUnused))
|
||||
.WillRepeatedly(::testing::Invoke(pProcfsAccess.get(), &Mock<GlobalOperationsProcfsAccess>::mockProcessListDeviceInUse));
|
||||
EXPECT_CALL(*pProcfsAccess.get(), kill(pProcfsAccess->ourDevicePid))
|
||||
.Times(1);
|
||||
EXPECT_CALL(*pFsAccess.get(), write(mockFunctionResetPath, std::string("1")))
|
||||
.Times(0);
|
||||
EXPECT_CALL(*pSysfsAccess.get(), bindDevice(_))
|
||||
.Times(0);
|
||||
pProcfsAccess->mockListProcessCall.push_back(DEVICE_UNUSED);
|
||||
pProcfsAccess->isRepeated.push_back(false);
|
||||
pProcfsAccess->mockListProcessCall.push_back(DEVICE_IN_USE);
|
||||
pProcfsAccess->isRepeated.push_back(true);
|
||||
pProcfsAccess->mockNoKill = true;
|
||||
ze_result_t result = zesDeviceReset(device, false);
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_HANDLE_OBJECT_IN_USE, result);
|
||||
}
|
||||
@@ -1024,17 +932,10 @@ TEST_F(SysmanGlobalOperationsIntegratedFixture, GivenProcessStartsMidResetWhenCa
|
||||
pProcfsAccess->ourDeviceFd = pProcfsAccess->extraFd;
|
||||
|
||||
// Return process list without open fd on first call, but with open fd on subsequent calls
|
||||
ON_CALL(*pProcfsAccess.get(), listProcesses(Matcher<std::vector<::pid_t> &>(_)))
|
||||
.WillByDefault(::testing::Invoke(pProcfsAccess.get(), &Mock<GlobalOperationsProcfsAccess>::mockProcessListDeviceInUse));
|
||||
EXPECT_CALL(*pProcfsAccess.get(), getFileDescriptors(_, Matcher<std::vector<int> &>(_)))
|
||||
.WillOnce(::testing::Invoke(pProcfsAccess.get(), &Mock<GlobalOperationsProcfsAccess>::getMockFileDescriptorsFailure))
|
||||
.WillRepeatedly(::testing::Invoke(pProcfsAccess.get(), &Mock<GlobalOperationsProcfsAccess>::getMockFileDescriptors));
|
||||
ON_CALL(*pProcfsAccess.get(), getFileName(_, _, Matcher<std::string &>(_)))
|
||||
.WillByDefault(::testing::Return(ZE_RESULT_ERROR_UNKNOWN));
|
||||
ON_CALL(*pProcfsAccess.get(), kill(pProcfsAccess->ourDevicePid))
|
||||
.WillByDefault(::testing::Invoke(pProcfsAccess.get(), &Mock<GlobalOperationsProcfsAccess>::mockKill));
|
||||
EXPECT_CALL(*pSysfsAccess.get(), bindDevice(_))
|
||||
.WillOnce(::testing::Return(ZE_RESULT_SUCCESS));
|
||||
pProcfsAccess->mockListProcessCall.push_back(DEVICE_IN_USE);
|
||||
pProcfsAccess->isRepeated.push_back(true);
|
||||
pProcfsAccess->mockGetFileDescriptorsError = ZE_RESULT_ERROR_UNKNOWN;
|
||||
pProcfsAccess->mockGetFileNameError = ZE_RESULT_ERROR_UNKNOWN;
|
||||
ze_result_t result = zesDeviceReset(device, false);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
}
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/tools/test/unit_tests/sources/sysman/linux/mock_sysman_fixture.h"
|
||||
|
||||
#include "mock_global_operations.h"
|
||||
|
||||
extern bool sysmanUltsEnable;
|
||||
|
||||
using ::testing::Matcher;
|
||||
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
|
||||
class SysmanGlobalOperationsHelperFixture : public SysmanDeviceFixture {
|
||||
protected:
|
||||
std::unique_ptr<MockGlobalOperationsSysfsAccess> pSysfsAccess;
|
||||
std::unique_ptr<MockGlobalOperationsProcfsAccess> pProcfsAccess;
|
||||
std::unique_ptr<MockGlobalOperationsFsAccess> pFsAccess;
|
||||
std::unique_ptr<MockGlobalOpsFwInterface> pMockFwInterface;
|
||||
FirmwareUtil *pFwUtilInterfaceOld = nullptr;
|
||||
SysfsAccess *pSysfsAccessOld = nullptr;
|
||||
ProcfsAccess *pProcfsAccessOld = nullptr;
|
||||
FsAccess *pFsAccessOld = nullptr;
|
||||
OsGlobalOperations *pOsGlobalOperationsPrev = nullptr;
|
||||
L0::GlobalOperations *pGlobalOperationsPrev = nullptr;
|
||||
L0::GlobalOperationsImp *pGlobalOperationsImp;
|
||||
PRODUCT_FAMILY productFamily;
|
||||
|
||||
void SetUp() override {
|
||||
if (!sysmanUltsEnable) {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
SysmanDeviceFixture::SetUp();
|
||||
pSysfsAccessOld = pLinuxSysmanImp->pSysfsAccess;
|
||||
pProcfsAccessOld = pLinuxSysmanImp->pProcfsAccess;
|
||||
pFsAccessOld = pLinuxSysmanImp->pFsAccess;
|
||||
pFwUtilInterfaceOld = pLinuxSysmanImp->pFwUtilInterface;
|
||||
pSysfsAccess = std::make_unique<MockGlobalOperationsSysfsAccess>();
|
||||
pProcfsAccess = std::make_unique<MockGlobalOperationsProcfsAccess>();
|
||||
pFsAccess = std::make_unique<MockGlobalOperationsFsAccess>();
|
||||
pMockFwInterface = std::make_unique<MockGlobalOpsFwInterface>();
|
||||
pLinuxSysmanImp->pFwUtilInterface = pMockFwInterface.get();
|
||||
pLinuxSysmanImp->pSysfsAccess = pSysfsAccess.get();
|
||||
pLinuxSysmanImp->pProcfsAccess = pProcfsAccess.get();
|
||||
pLinuxSysmanImp->pFsAccess = pFsAccess.get();
|
||||
pSysfsAccess->mockReadVal = "0x8086";
|
||||
pFsAccess->mockReadVal = driverVersion;
|
||||
pGlobalOperationsImp = static_cast<L0::GlobalOperationsImp *>(pSysmanDeviceImp->pGlobalOperations);
|
||||
pOsGlobalOperationsPrev = pGlobalOperationsImp->pOsGlobalOperations;
|
||||
pGlobalOperationsImp->pOsGlobalOperations = nullptr;
|
||||
productFamily = pLinuxSysmanImp->getDeviceHandle()->getNEODevice()->getHardwareInfo().platform.eProductFamily;
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
if (!sysmanUltsEnable) {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
if (nullptr != pGlobalOperationsImp->pOsGlobalOperations) {
|
||||
delete pGlobalOperationsImp->pOsGlobalOperations;
|
||||
}
|
||||
pGlobalOperationsImp->pOsGlobalOperations = pOsGlobalOperationsPrev;
|
||||
pGlobalOperationsImp = nullptr;
|
||||
pLinuxSysmanImp->pSysfsAccess = pSysfsAccessOld;
|
||||
pLinuxSysmanImp->pProcfsAccess = pProcfsAccessOld;
|
||||
pLinuxSysmanImp->pFsAccess = pFsAccessOld;
|
||||
pLinuxSysmanImp->pFwUtilInterface = pFwUtilInterfaceOld;
|
||||
SysmanDeviceFixture::TearDown();
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(SysmanGlobalOperationsHelperFixture, GivenDeviceIsRepairedWhenCallingGetDeviceStateThenZesResetReasonFlagRepairedIsReturned) {
|
||||
pMockFwInterface->mockIfrStatus = true;
|
||||
zes_device_state_t deviceState;
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceGetState(device, &deviceState));
|
||||
if (productFamily == IGFX_PVC) {
|
||||
EXPECT_EQ(ZES_RESET_REASON_FLAG_REPAIR, deviceState.reset);
|
||||
EXPECT_EQ(ZES_REPAIR_STATUS_PERFORMED, deviceState.repaired);
|
||||
} else {
|
||||
EXPECT_EQ(ZES_REPAIR_STATUS_UNSUPPORTED, deviceState.repaired);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(SysmanGlobalOperationsHelperFixture, GivenDeviceIsRepairedWhenCallingGetDeviceStateAndFirmwareRepairStatusIsFalseThenZesResetReasonFlagRepairedIsNotReturned) {
|
||||
pMockFwInterface->mockIfrStatus = false;
|
||||
zes_device_state_t deviceState;
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceGetState(device, &deviceState));
|
||||
EXPECT_EQ(0u, deviceState.reset);
|
||||
if (productFamily == IGFX_PVC) {
|
||||
EXPECT_EQ(ZES_REPAIR_STATUS_NOT_PERFORMED, deviceState.repaired);
|
||||
} else {
|
||||
EXPECT_EQ(ZES_REPAIR_STATUS_UNSUPPORTED, deviceState.repaired);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(SysmanGlobalOperationsHelperFixture, GivenDeviceIsRepairedWhenCallingGetDeviceStateAndFirmwareRepairStatusFailsThenZesResetReasonFlagRepairedIsNotReturned) {
|
||||
pMockFwInterface->mockIfrError = ZE_RESULT_ERROR_UNKNOWN;
|
||||
zes_device_state_t deviceState;
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceGetState(device, &deviceState));
|
||||
EXPECT_EQ(0u, deviceState.reset);
|
||||
EXPECT_EQ(ZES_REPAIR_STATUS_UNSUPPORTED, deviceState.repaired);
|
||||
}
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
Reference in New Issue
Block a user