mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-04 15:53:45 +08:00
sysman: clean up code duplication for reset
warm and cold reset are common functionality, the code is being moved to the common sysman implementation from diagnostics specific files. Related-To: LOCI-1908 Signed-off-by: Vilvaraj, T J Vivek <t.j.vivek.vilvaraj@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
0c0603966b
commit
47f7b4f509
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -288,6 +288,7 @@ struct Mock<GlobalOperationsSysfsAccess> : public GlobalOperationsSysfsAccess {
|
||||
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));
|
||||
ADDMETHOD_NOBASE(isRootUser, bool, true, ());
|
||||
};
|
||||
|
||||
class GlobalOperationsProcfsAccess : public ProcfsAccess {};
|
||||
@@ -452,6 +453,7 @@ struct Mock<FirmwareInterface> : public FirmwareUtil {
|
||||
|
||||
class PublicLinuxGlobalOperationsImp : public L0::LinuxGlobalOperationsImp {
|
||||
public:
|
||||
using LinuxGlobalOperationsImp::pLinuxSysmanImp;
|
||||
using LinuxGlobalOperationsImp::resetTimeout;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -154,6 +154,24 @@ class SysmanGlobalOperationsFixture : public SysmanDeviceFixture {
|
||||
pLinuxSysmanImp->pFsAccess = pFsAccessOld;
|
||||
}
|
||||
};
|
||||
class SysmanGlobalOperationsIntegratedFixture : public SysmanGlobalOperationsFixture {
|
||||
void SetUp() override {
|
||||
if (!sysmanUltsEnable) {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
SysmanGlobalOperationsFixture::SetUp();
|
||||
auto mockHardwareInfo = neoDevice->getHardwareInfo();
|
||||
mockHardwareInfo.capabilityTable.isIntegratedDevice = true;
|
||||
neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[device->getRootDeviceIndex()]->setHwInfo(&mockHardwareInfo);
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
if (!sysmanUltsEnable) {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
SysmanGlobalOperationsFixture::TearDown();
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(SysmanGlobalOperationsFixture, GivenValidDeviceHandleWhenCallingzetGlobalOperationsGetPropertiesThenVerifyzetGlobalOperationsGetPropertiesCallSucceeds) {
|
||||
zes_device_properties_t properties;
|
||||
@@ -384,7 +402,8 @@ TEST_F(SysmanGlobalOperationsFixture, GivenDeviceIsNotWedgedWhenCallingGetDevice
|
||||
EXPECT_EQ(0u, deviceState.reset);
|
||||
}
|
||||
|
||||
TEST_F(SysmanGlobalOperationsFixture, GivenPermissionDeniedWhenCallingGetDeviceStateThenZeResultErrorInsufficientPermissionsIsReturned) {
|
||||
TEST_F(SysmanGlobalOperationsIntegratedFixture, GivenPermissionDeniedWhenCallingGetDeviceStateThenZeResultErrorInsufficientPermissionsIsReturned) {
|
||||
|
||||
ON_CALL(*pFsAccess.get(), canWrite(Matcher<std::string>(mockFunctionResetPath)))
|
||||
.WillByDefault(::testing::Return(ZE_RESULT_ERROR_INSUFFICIENT_PERMISSIONS));
|
||||
pGlobalOperationsImp->init();
|
||||
@@ -392,7 +411,8 @@ TEST_F(SysmanGlobalOperationsFixture, GivenPermissionDeniedWhenCallingGetDeviceS
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_INSUFFICIENT_PERMISSIONS, result);
|
||||
}
|
||||
|
||||
TEST_F(SysmanGlobalOperationsFixture, GivenDeviceInUseWhenCallingResetThenZeResultErrorHandleObjectInUseIsReturned) {
|
||||
TEST_F(SysmanGlobalOperationsIntegratedFixture, GivenDeviceInUseWhenCallingResetThenZeResultErrorHandleObjectInUseIsReturned) {
|
||||
|
||||
pProcfsAccess->ourDevicePid = pProcfsAccess->extraPid;
|
||||
pProcfsAccess->ourDeviceFd = pProcfsAccess->extraFd;
|
||||
ON_CALL(*pProcfsAccess.get(), listProcesses(Matcher<std::vector<::pid_t> &>(_)))
|
||||
@@ -402,7 +422,8 @@ TEST_F(SysmanGlobalOperationsFixture, GivenDeviceInUseWhenCallingResetThenZeResu
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_HANDLE_OBJECT_IN_USE, result);
|
||||
}
|
||||
|
||||
TEST_F(SysmanGlobalOperationsFixture, GivenDeviceNotInUseWhenCallingResetThenSuccessIsReturned) {
|
||||
TEST_F(SysmanGlobalOperationsIntegratedFixture, GivenDeviceNotInUseWhenCallingResetThenSuccessIsReturned) {
|
||||
|
||||
// Pretend we have the device open
|
||||
pProcfsAccess->ourDevicePid = getpid();
|
||||
pProcfsAccess->ourDeviceFd = ::open("/dev/null", 0);
|
||||
@@ -424,7 +445,8 @@ TEST_F(SysmanGlobalOperationsFixture, GivenDeviceNotInUseWhenCallingResetThenSuc
|
||||
EXPECT_EQ(errno, EBADF);
|
||||
}
|
||||
|
||||
TEST_F(SysmanGlobalOperationsFixture, GivenForceTrueAndDeviceInUseWhenCallingResetThenSuccessIsReturned) {
|
||||
TEST_F(SysmanGlobalOperationsIntegratedFixture, GivenForceTrueAndDeviceInUseWhenCallingResetThenSuccessIsReturned) {
|
||||
|
||||
// Pretend another process has the device open
|
||||
pProcfsAccess->ourDevicePid = getpid() + 1; // make sure it isn't our process id
|
||||
pProcfsAccess->ourDeviceFd = pProcfsAccess->extraFd;
|
||||
@@ -440,7 +462,8 @@ TEST_F(SysmanGlobalOperationsFixture, GivenForceTrueAndDeviceInUseWhenCallingRes
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
}
|
||||
|
||||
TEST_F(SysmanGlobalOperationsFixture, GivenProcessStartsMidResetWhenCallingResetThenSuccessIsReturned) {
|
||||
TEST_F(SysmanGlobalOperationsIntegratedFixture, GivenProcessStartsMidResetWhenCallingResetThenSuccessIsReturned) {
|
||||
|
||||
// Pretend another process has the device open
|
||||
pProcfsAccess->ourDevicePid = getpid() + 1; // make sure it isn't our process id
|
||||
pProcfsAccess->ourDeviceFd = pProcfsAccess->extraFd;
|
||||
@@ -458,7 +481,8 @@ TEST_F(SysmanGlobalOperationsFixture, GivenProcessStartsMidResetWhenCallingReset
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
}
|
||||
|
||||
TEST_F(SysmanGlobalOperationsFixture, GivenProcessStartsMidResetWhenCallingResetAndIfNeoDeviceCreateFailsThenErrorIsReturned) {
|
||||
TEST_F(SysmanGlobalOperationsIntegratedFixture, GivenProcessStartsMidResetWhenCallingResetAndIfNeoDeviceCreateFailsThenErrorIsReturned) {
|
||||
|
||||
// Pretend another process has the device open
|
||||
pProcfsAccess->ourDevicePid = getpid() + 1; // make sure it isn't our process id
|
||||
pProcfsAccess->ourDeviceFd = pProcfsAccess->extraFd;
|
||||
@@ -478,7 +502,8 @@ TEST_F(SysmanGlobalOperationsFixture, GivenProcessStartsMidResetWhenCallingReset
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_DEVICE_LOST, result);
|
||||
}
|
||||
|
||||
TEST_F(SysmanGlobalOperationsFixture, GivenProcessStartsMidResetWhenCallingResetAndBindFailsThenFailureIsReturned) {
|
||||
TEST_F(SysmanGlobalOperationsIntegratedFixture, GivenProcessStartsMidResetWhenCallingResetAndBindFailsThenFailureIsReturned) {
|
||||
|
||||
// Pretend another process has the device open
|
||||
pProcfsAccess->ourDevicePid = getpid() + 1; // make sure it isn't our process id
|
||||
pProcfsAccess->ourDeviceFd = pProcfsAccess->extraFd;
|
||||
@@ -496,7 +521,8 @@ TEST_F(SysmanGlobalOperationsFixture, GivenProcessStartsMidResetWhenCallingReset
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNKNOWN, result);
|
||||
}
|
||||
|
||||
TEST_F(SysmanGlobalOperationsFixture, GivenDeviceInUseWhenCallingResetAndListProcessesFailsThenZeResultErrorIsReturned) {
|
||||
TEST_F(SysmanGlobalOperationsIntegratedFixture, GivenDeviceInUseWhenCallingResetAndListProcessesFailsThenZeResultErrorIsReturned) {
|
||||
|
||||
pProcfsAccess->ourDevicePid = pProcfsAccess->extraPid;
|
||||
pProcfsAccess->ourDeviceFd = pProcfsAccess->extraFd;
|
||||
EXPECT_CALL(*pProcfsAccess.get(), listProcesses(Matcher<std::vector<::pid_t> &>(_)))
|
||||
@@ -506,7 +532,8 @@ TEST_F(SysmanGlobalOperationsFixture, GivenDeviceInUseWhenCallingResetAndListPro
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_NOT_AVAILABLE, result);
|
||||
}
|
||||
|
||||
TEST_F(SysmanGlobalOperationsFixture, GivenProcessStartsMidResetWhenListProcessesFailsAfterUnbindThenFailureIsReturned) {
|
||||
TEST_F(SysmanGlobalOperationsIntegratedFixture, GivenProcessStartsMidResetWhenListProcessesFailsAfterUnbindThenFailureIsReturned) {
|
||||
|
||||
// Pretend another process has the device open
|
||||
pProcfsAccess->ourDevicePid = getpid() + 1; // make sure it isn't our process id
|
||||
pProcfsAccess->ourDeviceFd = pProcfsAccess->extraFd;
|
||||
@@ -521,7 +548,8 @@ TEST_F(SysmanGlobalOperationsFixture, GivenProcessStartsMidResetWhenListProcesse
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_NOT_AVAILABLE, result);
|
||||
}
|
||||
|
||||
TEST_F(SysmanGlobalOperationsFixture, GivenProcessStartsMidResetWhenCallingResetAndWriteFailsAfterUnbindThenFailureIsReturned) {
|
||||
TEST_F(SysmanGlobalOperationsIntegratedFixture, GivenProcessStartsMidResetWhenCallingResetAndWriteFailsAfterUnbindThenFailureIsReturned) {
|
||||
|
||||
// Pretend another process has the device open
|
||||
pProcfsAccess->ourDevicePid = getpid() + 1; // make sure it isn't our process id
|
||||
pProcfsAccess->ourDeviceFd = pProcfsAccess->extraFd;
|
||||
@@ -539,7 +567,8 @@ TEST_F(SysmanGlobalOperationsFixture, GivenProcessStartsMidResetWhenCallingReset
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNKNOWN, result);
|
||||
}
|
||||
|
||||
TEST_F(SysmanGlobalOperationsFixture, GivenProcessStartsMidResetWhenCallingResetAndUnbindFailsThenFailureIsReturned) {
|
||||
TEST_F(SysmanGlobalOperationsIntegratedFixture, GivenProcessStartsMidResetWhenCallingResetAndUnbindFailsThenFailureIsReturned) {
|
||||
|
||||
// Pretend another process has the device open
|
||||
pProcfsAccess->ourDevicePid = getpid() + 1; // make sure it isn't our process id
|
||||
pProcfsAccess->ourDeviceFd = pProcfsAccess->extraFd;
|
||||
@@ -556,7 +585,8 @@ TEST_F(SysmanGlobalOperationsFixture, GivenProcessStartsMidResetWhenCallingReset
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNKNOWN, result);
|
||||
}
|
||||
|
||||
TEST_F(SysmanGlobalOperationsFixture, GivenProcessStartsMidResetWhenCallingResetAndGetFileNameFailsThenSuccessIsReturned) {
|
||||
TEST_F(SysmanGlobalOperationsIntegratedFixture, GivenProcessStartsMidResetWhenCallingResetAndGetFileNameFailsThenSuccessIsReturned) {
|
||||
|
||||
// Pretend another process has the device open
|
||||
pProcfsAccess->ourDevicePid = getpid() + 1; // make sure it isn't our process id
|
||||
pProcfsAccess->ourDeviceFd = pProcfsAccess->extraFd;
|
||||
@@ -576,7 +606,8 @@ TEST_F(SysmanGlobalOperationsFixture, GivenProcessStartsMidResetWhenCallingReset
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
}
|
||||
|
||||
TEST_F(SysmanGlobalOperationsFixture, GivenProcessWontDieWhenCallingResetThenZeResultErrorHandleObjectInUseErrorIsReturned) {
|
||||
TEST_F(SysmanGlobalOperationsIntegratedFixture, GivenProcessWontDieWhenCallingResetThenZeResultErrorHandleObjectInUseErrorIsReturned) {
|
||||
|
||||
// Pretend another process has the device open
|
||||
pProcfsAccess->ourDevicePid = getpid() + 1; // make sure it isn't our process id
|
||||
pProcfsAccess->ourDeviceFd = pProcfsAccess->extraFd;
|
||||
@@ -598,7 +629,8 @@ TEST_F(SysmanGlobalOperationsFixture, GivenProcessWontDieWhenCallingResetThenZeR
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_HANDLE_OBJECT_IN_USE, result);
|
||||
}
|
||||
|
||||
TEST_F(SysmanGlobalOperationsFixture, GivenProcessStartsMidResetWhenCallingResetAndGetFileDescriptorsFailsThenSuccessIsReturned) {
|
||||
TEST_F(SysmanGlobalOperationsIntegratedFixture, GivenProcessStartsMidResetWhenCallingResetAndGetFileDescriptorsFailsThenSuccessIsReturned) {
|
||||
|
||||
// Pretend another process has the device open
|
||||
pProcfsAccess->ourDevicePid = getpid() + 1; // make sure it isn't our process id
|
||||
pProcfsAccess->ourDeviceFd = pProcfsAccess->extraFd;
|
||||
|
||||
@@ -300,6 +300,18 @@ TEST_F(SysmanDeviceFixture, GivenValidPciPathWhileGettingRootPciPortThenReturned
|
||||
EXPECT_EQ(pciRootPort2, "device");
|
||||
}
|
||||
|
||||
TEST_F(SysmanDeviceFixture, GivenValidPciPathWhileGettingRootPciPortThenReturnedPathIs1LevelAfterPCIePath) {
|
||||
const std::string mockBdf = "0000:00:02.0";
|
||||
const std::string mockRealPath = "/sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/0000:02:01.0/" + mockBdf;
|
||||
const std::string mockRootPortPath = "/sys/devices/pci0000:00/0000:00:01.0";
|
||||
|
||||
std::string pciRootPort1 = pLinuxSysmanImp->getPciRootPortDirectoryPathForReset(mockRealPath);
|
||||
EXPECT_EQ(pciRootPort1, mockRootPortPath);
|
||||
|
||||
std::string pciRootPort2 = pLinuxSysmanImp->getPciRootPortDirectoryPathForReset("device");
|
||||
EXPECT_EQ(pciRootPort2, "device");
|
||||
}
|
||||
|
||||
TEST_F(SysmanDeviceFixture, GivenNullDrmHandleWhenGettingDrmHandleThenValidDrmHandleIsReturned) {
|
||||
pLinuxSysmanImp->releaseLocalDrmHandle();
|
||||
EXPECT_NO_THROW(pLinuxSysmanImp->getDrm());
|
||||
|
||||
Reference in New Issue
Block a user