mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-30 18:37:46 +08:00
SysMan: clean up ULT's for Temperature Module.
Resolves: LOCI-3198 Signed-off-by: Vilvaraj, T J Vivek <t.j.vivek.vilvaraj@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
113b0378ac
commit
067bc890da
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -72,7 +72,12 @@ class TemperatureFsAccess : public FsAccess {};
|
||||
|
||||
template <>
|
||||
struct Mock<TemperatureFsAccess> : public TemperatureFsAccess {
|
||||
ze_result_t listDirectorySuccess(const std::string directory, std::vector<std::string> &listOfTelemNodes) {
|
||||
ze_result_t mockErrorListDirectory = ZE_RESULT_SUCCESS;
|
||||
ze_result_t mockErrorGetRealPath = ZE_RESULT_SUCCESS;
|
||||
ze_result_t listDirectory(const std::string directory, std::vector<std::string> &listOfTelemNodes) override {
|
||||
if (mockErrorListDirectory != ZE_RESULT_SUCCESS) {
|
||||
return mockErrorListDirectory;
|
||||
}
|
||||
if (directory.compare(baseTelemSysFS) == 0) {
|
||||
listOfTelemNodes.push_back("telem1");
|
||||
listOfTelemNodes.push_back("telem2");
|
||||
@@ -84,10 +89,10 @@ struct Mock<TemperatureFsAccess> : public TemperatureFsAccess {
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
ze_result_t listDirectoryFailure(const std::string directory, std::vector<std::string> &events) {
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
ze_result_t getRealPathSuccess(const std::string path, std::string &buf) {
|
||||
ze_result_t getRealPath(const std::string path, std::string &buf) override {
|
||||
if (mockErrorGetRealPath != ZE_RESULT_SUCCESS) {
|
||||
return mockErrorGetRealPath;
|
||||
}
|
||||
if (path.compare(sysfsPahTelem1) == 0) {
|
||||
buf = realPathTelem1;
|
||||
} else if (path.compare(sysfsPahTelem2) == 0) {
|
||||
@@ -101,16 +106,9 @@ struct Mock<TemperatureFsAccess> : public TemperatureFsAccess {
|
||||
} else {
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t getRealPathFailure(const std::string path, std::string &buf) {
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
MOCK_METHOD(ze_result_t, listDirectory, (const std::string path, std::vector<std::string> &list), (override));
|
||||
MOCK_METHOD(ze_result_t, getRealPath, (const std::string path, std::string &buf), (override));
|
||||
Mock<TemperatureFsAccess>() = default;
|
||||
};
|
||||
|
||||
|
||||
@@ -94,10 +94,6 @@ class SysmanMultiDeviceTemperatureFixture : public SysmanMultiDeviceFixture {
|
||||
pFsAccess = std::make_unique<NiceMock<Mock<TemperatureFsAccess>>>();
|
||||
pFsAccessOriginal = pLinuxSysmanImp->pFsAccess;
|
||||
pLinuxSysmanImp->pFsAccess = pFsAccess.get();
|
||||
ON_CALL(*pFsAccess.get(), listDirectory(_, _))
|
||||
.WillByDefault(::testing::Invoke(pFsAccess.get(), &Mock<TemperatureFsAccess>::listDirectorySuccess));
|
||||
ON_CALL(*pFsAccess.get(), getRealPath(_, _))
|
||||
.WillByDefault(::testing::Invoke(pFsAccess.get(), &Mock<TemperatureFsAccess>::getRealPathSuccess));
|
||||
|
||||
uint32_t subDeviceCount = 0;
|
||||
Device::fromHandle(device->toHandle())->getSubDevices(&subDeviceCount, nullptr);
|
||||
@@ -214,10 +210,6 @@ class SysmanDeviceTemperatureFixture : public SysmanDeviceFixture {
|
||||
pFsAccess = std::make_unique<NiceMock<Mock<TemperatureFsAccess>>>();
|
||||
pFsAccessOriginal = pLinuxSysmanImp->pFsAccess;
|
||||
pLinuxSysmanImp->pFsAccess = pFsAccess.get();
|
||||
ON_CALL(*pFsAccess.get(), listDirectory(_, _))
|
||||
.WillByDefault(::testing::Invoke(pFsAccess.get(), &Mock<TemperatureFsAccess>::listDirectorySuccess));
|
||||
ON_CALL(*pFsAccess.get(), getRealPath(_, _))
|
||||
.WillByDefault(::testing::Invoke(pFsAccess.get(), &Mock<TemperatureFsAccess>::getRealPathSuccess));
|
||||
|
||||
uint32_t subDeviceCount = 0;
|
||||
Device::fromHandle(device->toHandle())->getSubDevices(&subDeviceCount, nullptr);
|
||||
@@ -328,13 +320,10 @@ TEST_F(SysmanDeviceTemperatureFixture, GivenValidTempHandleWhenGettingUnsupporte
|
||||
}
|
||||
|
||||
TEST_F(SysmanDeviceTemperatureFixture, GivenValidateEnumerateRootTelemIndexWhengetRealPathFailsThenFailureReturned) {
|
||||
ON_CALL(*pFsAccess.get(), getRealPath(_, _))
|
||||
.WillByDefault(::testing::Invoke(pFsAccess.get(), &Mock<TemperatureFsAccess>::getRealPathFailure));
|
||||
pFsAccess->mockErrorGetRealPath = ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE;
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE,
|
||||
PlatformMonitoringTech::enumerateRootTelemIndex(pFsAccess.get(), rootPciPathOfGpuDevice));
|
||||
|
||||
ON_CALL(*pFsAccess.get(), listDirectory(_, _))
|
||||
.WillByDefault(::testing::Invoke(pFsAccess.get(), &Mock<TemperatureFsAccess>::listDirectoryFailure));
|
||||
pFsAccess->mockErrorListDirectory = ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_NOT_AVAILABLE,
|
||||
PlatformMonitoringTech::enumerateRootTelemIndex(pFsAccess.get(), rootPciPathOfGpuDevice));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user