mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-11 00:10:58 +08:00
Add support for hwmon interface for sysman power
Signed-off-by: Mayank Raghuwanshi <mayank.raghuwanshi@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
229ab9e30c
commit
0f2754e943
@@ -6,8 +6,8 @@
|
||||
|
||||
set(L0_TESTS_TOOLS_SYSMAN_POWER_LINUX
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/test_zes_power.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/mock_sysfs_power.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test_zes_power.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_sysfs_power.h
|
||||
)
|
||||
|
||||
if(UNIX)
|
||||
|
||||
@@ -17,11 +17,223 @@
|
||||
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
constexpr uint64_t setEnergyCounter = 83456;
|
||||
constexpr uint64_t setEnergyCounter = (83456u * 1048576u);
|
||||
constexpr uint64_t offset = 0x400;
|
||||
constexpr uint64_t mappedLength = 2048;
|
||||
const std::string deviceName("device");
|
||||
const std::string baseTelemSysFS("/sys/class/intel_pmt");
|
||||
const std::string hwmonDir("device/hwmon");
|
||||
const std::string i915HwmonDir("device/hwmon/hwmon4");
|
||||
const std::string nonI915HwmonDir("device/hwmon/hwmon1");
|
||||
const std::vector<std::string> listOfMockedHwmonDirs = {"hwmon1", "hwmon2", "hwmon3", "hwmon4"};
|
||||
const std::string sustainedPowerLimitEnabled("power1_max_enable");
|
||||
const std::string sustainedPowerLimit("power1_max");
|
||||
const std::string sustainedPowerLimitInterval("power1_max_interval");
|
||||
const std::string burstPowerLimitEnabled("power1_cap_enable");
|
||||
const std::string burstPowerLimit("power1_cap");
|
||||
const std::string energyCounterNode("energy1_input");
|
||||
const std::string defaultPowerLimit("power_default_limit");
|
||||
const std::string minPowerLimit("power_min_limit");
|
||||
const std::string maxPowerLimit("power_max_limit");
|
||||
constexpr uint64_t expectedEnergyCounter = 123456785u;
|
||||
constexpr uint32_t mockDefaultPowerLimitVal = 300000000;
|
||||
constexpr uint32_t mockMaxPowerLimitVal = 490000000;
|
||||
constexpr uint32_t mockMinPowerLimitVal = 0;
|
||||
class PowerSysfsAccess : public SysfsAccess {};
|
||||
|
||||
template <>
|
||||
struct Mock<PowerSysfsAccess> : public PowerSysfsAccess {
|
||||
|
||||
ze_result_t getValString(const std::string file, std::string &val) {
|
||||
ze_result_t result = ZE_RESULT_ERROR_UNKNOWN;
|
||||
if (file.compare(i915HwmonDir + "/" + "name") == 0) {
|
||||
val = "i915";
|
||||
result = ZE_RESULT_SUCCESS;
|
||||
} else if (file.compare(nonI915HwmonDir + "/" + "name") == 0) {
|
||||
result = ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
} else {
|
||||
val = "garbageI915";
|
||||
result = ZE_RESULT_SUCCESS;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
uint64_t sustainedPowerLimitEnabledVal = 1u;
|
||||
uint64_t sustainedPowerLimitVal = 0;
|
||||
uint64_t sustainedPowerLimitIntervalVal = 0;
|
||||
uint64_t burstPowerLimitEnabledVal = 0;
|
||||
uint64_t burstPowerLimitVal = 0;
|
||||
uint64_t energyCounterNodeVal = expectedEnergyCounter;
|
||||
|
||||
ze_result_t getValUnsignedLongReturnErrorForEnergyCounter(const std::string file, uint64_t &val) {
|
||||
if (file.compare(i915HwmonDir + "/" + energyCounterNode) == 0) {
|
||||
return ZE_RESULT_ERROR_INSUFFICIENT_PERMISSIONS;
|
||||
}
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t getValUnsignedLongReturnErrorForBurstPowerLimit(const std::string file, uint64_t &val) {
|
||||
if (file.compare(i915HwmonDir + "/" + burstPowerLimitEnabled) == 0) {
|
||||
val = burstPowerLimitEnabledVal;
|
||||
}
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t getValUnsignedLongReturnErrorForBurstPowerLimitEnabled(const std::string file, uint64_t &val) {
|
||||
if (file.compare(i915HwmonDir + "/" + burstPowerLimitEnabled) == 0) {
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE; // mocking the condition when user passes nullptr for sustained and peak power in zesPowerGetLimit and burst power file is absent
|
||||
}
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t getValUnsignedLongReturnErrorForSustainedPowerLimitEnabled(const std::string file, uint64_t &val) {
|
||||
if (file.compare(i915HwmonDir + "/" + sustainedPowerLimitEnabled) == 0) {
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE; // mocking the condition when user passes nullptr for burst and peak power in zesPowerGetLimit and sustained power file is absent
|
||||
}
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t getValUnsignedLongReturnsPowerLimitEnabledAsDisabled(const std::string file, uint64_t &val) {
|
||||
if (file.compare(i915HwmonDir + "/" + sustainedPowerLimitEnabled) == 0) {
|
||||
val = 0;
|
||||
return ZE_RESULT_SUCCESS;
|
||||
} else if (file.compare(i915HwmonDir + "/" + burstPowerLimitEnabled) == 0) {
|
||||
val = 0;
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t getValUnsignedLongReturnErrorForSustainedPower(const std::string file, uint64_t &val) {
|
||||
if (file.compare(i915HwmonDir + "/" + sustainedPowerLimitEnabled) == 0) {
|
||||
val = 1;
|
||||
} else if (file.compare(i915HwmonDir + "/" + sustainedPowerLimit) == 0) {
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t getValUnsignedLongReturnErrorForSustainedPowerInterval(const std::string file, uint64_t &val) {
|
||||
if (file.compare(i915HwmonDir + "/" + sustainedPowerLimitEnabled) == 0) {
|
||||
val = 1;
|
||||
} else if (file.compare(i915HwmonDir + "/" + sustainedPowerLimitInterval) == 0) {
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t getValUnsignedLongReturnErrorUnknown(const std::string file, uint64_t &val) {
|
||||
return ZE_RESULT_ERROR_UNKNOWN;
|
||||
}
|
||||
|
||||
ze_result_t setValUnsignedLongReturnErrorForBurstPowerLimit(const std::string file, const int val) {
|
||||
if (file.compare(i915HwmonDir + "/" + burstPowerLimit) == 0) {
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t setValUnsignedLongReturnErrorForBurstPowerLimitEnabled(const std::string file, const int val) {
|
||||
if (file.compare(i915HwmonDir + "/" + burstPowerLimitEnabled) == 0) {
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t setValReturnErrorForSustainedPower(const std::string file, const int val) {
|
||||
if (file.compare(i915HwmonDir + "/" + sustainedPowerLimit) == 0) {
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t setValReturnErrorForSustainedPowerInterval(const std::string file, const int val) {
|
||||
if (file.compare(i915HwmonDir + "/" + sustainedPowerLimitInterval) == 0) {
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t getValUnsignedLong(const std::string file, uint64_t &val) {
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
if (file.compare(i915HwmonDir + "/" + sustainedPowerLimitEnabled) == 0) {
|
||||
val = sustainedPowerLimitEnabledVal;
|
||||
} else if (file.compare(i915HwmonDir + "/" + sustainedPowerLimit) == 0) {
|
||||
val = sustainedPowerLimitVal;
|
||||
} else if (file.compare(i915HwmonDir + "/" + sustainedPowerLimitInterval) == 0) {
|
||||
val = sustainedPowerLimitIntervalVal;
|
||||
} else if (file.compare(i915HwmonDir + "/" + burstPowerLimitEnabled) == 0) {
|
||||
val = burstPowerLimitEnabledVal;
|
||||
} else if (file.compare(i915HwmonDir + "/" + burstPowerLimit) == 0) {
|
||||
val = burstPowerLimitVal;
|
||||
} else if (file.compare(i915HwmonDir + "/" + energyCounterNode) == 0) {
|
||||
val = energyCounterNodeVal;
|
||||
} else {
|
||||
result = ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
ze_result_t getValUnsignedInt(const std::string file, uint32_t &val) {
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
if (file.compare(i915HwmonDir + "/" + defaultPowerLimit) == 0) {
|
||||
val = mockDefaultPowerLimitVal;
|
||||
} else if (file.compare(i915HwmonDir + "/" + maxPowerLimit) == 0) {
|
||||
val = mockMaxPowerLimitVal;
|
||||
} else if (file.compare(i915HwmonDir + "/" + minPowerLimit) == 0) {
|
||||
val = mockMinPowerLimitVal;
|
||||
} else {
|
||||
result = ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
ze_result_t getValUnsignedIntMax(const std::string file, uint32_t &val) {
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
if (file.compare(i915HwmonDir + "/" + maxPowerLimit) == 0) {
|
||||
val = std::numeric_limits<uint32_t>::max();
|
||||
} else {
|
||||
result = ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
ze_result_t setVal(const std::string file, const int val) {
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
if (file.compare(i915HwmonDir + "/" + sustainedPowerLimit) == 0) {
|
||||
sustainedPowerLimitVal = static_cast<uint64_t>(val);
|
||||
} else if (file.compare(i915HwmonDir + "/" + sustainedPowerLimitInterval) == 0) {
|
||||
sustainedPowerLimitIntervalVal = static_cast<uint64_t>(val);
|
||||
} else if (file.compare(i915HwmonDir + "/" + burstPowerLimitEnabled) == 0) {
|
||||
burstPowerLimitEnabledVal = static_cast<uint64_t>(val);
|
||||
} else if (file.compare(i915HwmonDir + "/" + burstPowerLimit) == 0) {
|
||||
burstPowerLimitVal = static_cast<uint64_t>(val);
|
||||
} else {
|
||||
result = ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
ze_result_t getscanDirEntries(const std::string file, std::vector<std::string> &listOfEntries) {
|
||||
if (file.compare(hwmonDir) == 0) {
|
||||
listOfEntries = listOfMockedHwmonDirs;
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
ze_result_t getscanDirEntriesStatusReturnError(const std::string file, std::vector<std::string> &listOfEntries) {
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
Mock<PowerSysfsAccess>() = default;
|
||||
|
||||
MOCK_METHOD(ze_result_t, read, (const std::string file, uint64_t &val), (override));
|
||||
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 int val), (override));
|
||||
MOCK_METHOD(ze_result_t, scanDirEntries, (const std::string file, std::vector<std::string> &listOfEntries), (override));
|
||||
};
|
||||
|
||||
class PowerPmt : public PlatformMonitoringTech {
|
||||
public:
|
||||
|
||||
@@ -13,6 +13,10 @@
|
||||
#include "mock_sysfs_power.h"
|
||||
#include "sysman/power/power_imp.h"
|
||||
|
||||
using ::testing::DoDefault;
|
||||
using ::testing::Matcher;
|
||||
using ::testing::Return;
|
||||
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
|
||||
@@ -29,6 +33,8 @@ class SysmanDevicePowerFixture : public SysmanDeviceFixture {
|
||||
std::unique_ptr<PublicLinuxPowerImp> pPublicLinuxPowerImp;
|
||||
std::unique_ptr<Mock<PowerPmt>> pPmt;
|
||||
std::unique_ptr<Mock<PowerFsAccess>> pFsAccess;
|
||||
std::unique_ptr<Mock<PowerSysfsAccess>> pSysfsAccess;
|
||||
SysfsAccess *pSysfsAccessOld = nullptr;
|
||||
FsAccess *pFsAccessOriginal = nullptr;
|
||||
OsPower *pOsPowerOriginal = nullptr;
|
||||
std::vector<ze_device_handle_t> deviceHandles;
|
||||
@@ -37,10 +43,23 @@ class SysmanDevicePowerFixture : public SysmanDeviceFixture {
|
||||
pFsAccess = std::make_unique<NiceMock<Mock<PowerFsAccess>>>();
|
||||
pFsAccessOriginal = pLinuxSysmanImp->pFsAccess;
|
||||
pLinuxSysmanImp->pFsAccess = pFsAccess.get();
|
||||
pSysfsAccessOld = pLinuxSysmanImp->pSysfsAccess;
|
||||
pSysfsAccess = std::make_unique<NiceMock<Mock<PowerSysfsAccess>>>();
|
||||
pLinuxSysmanImp->pSysfsAccess = pSysfsAccess.get();
|
||||
ON_CALL(*pFsAccess.get(), listDirectory(_, _))
|
||||
.WillByDefault(::testing::Invoke(pFsAccess.get(), &Mock<PowerFsAccess>::listDirectorySuccess));
|
||||
ON_CALL(*pFsAccess.get(), getRealPath(_, _))
|
||||
.WillByDefault(::testing::Invoke(pFsAccess.get(), &Mock<PowerFsAccess>::getRealPathSuccess));
|
||||
ON_CALL(*pSysfsAccess.get(), read(_, Matcher<std::string &>(_)))
|
||||
.WillByDefault(::testing::Invoke(pSysfsAccess.get(), &Mock<PowerSysfsAccess>::getValString));
|
||||
ON_CALL(*pSysfsAccess.get(), read(_, Matcher<uint64_t &>(_)))
|
||||
.WillByDefault(::testing::Invoke(pSysfsAccess.get(), &Mock<PowerSysfsAccess>::getValUnsignedLong));
|
||||
ON_CALL(*pSysfsAccess.get(), read(_, Matcher<uint32_t &>(_)))
|
||||
.WillByDefault(::testing::Invoke(pSysfsAccess.get(), &Mock<PowerSysfsAccess>::getValUnsignedInt));
|
||||
ON_CALL(*pSysfsAccess.get(), write(_, _))
|
||||
.WillByDefault(::testing::Invoke(pSysfsAccess.get(), &Mock<PowerSysfsAccess>::setVal));
|
||||
ON_CALL(*pSysfsAccess.get(), scanDirEntries(_, _))
|
||||
.WillByDefault(::testing::Invoke(pSysfsAccess.get(), &Mock<PowerSysfsAccess>::getscanDirEntries));
|
||||
|
||||
uint32_t subDeviceCount = 0;
|
||||
Device::fromHandle(device->toHandle())->getSubDevices(&subDeviceCount, nullptr);
|
||||
@@ -66,22 +85,340 @@ class SysmanDevicePowerFixture : public SysmanDeviceFixture {
|
||||
void TearDown() override {
|
||||
SysmanDeviceFixture::TearDown();
|
||||
pLinuxSysmanImp->pFsAccess = pFsAccessOriginal;
|
||||
pLinuxSysmanImp->pSysfsAccess = pSysfsAccessOld;
|
||||
}
|
||||
|
||||
std::vector<zes_pwr_handle_t> get_power_handles(uint32_t count) {
|
||||
std::vector<zes_pwr_handle_t> getPowerHandles(uint32_t count) {
|
||||
std::vector<zes_pwr_handle_t> handles(count, nullptr);
|
||||
EXPECT_EQ(zesDeviceEnumPowerDomains(device->toHandle(), &count, handles.data()), ZE_RESULT_SUCCESS);
|
||||
return handles;
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(SysmanDevicePowerFixture, GivenComponentCountZeroWhenEnumeratingPowerDomainsWhenhwmonInterfaceExistsThenValidCountIsReturnedAndVerifySysmanPowerGetCallSucceeds) {
|
||||
uint32_t count = 0;
|
||||
EXPECT_EQ(zesDeviceEnumPowerDomains(device->toHandle(), &count, nullptr), ZE_RESULT_SUCCESS);
|
||||
EXPECT_EQ(count, powerHandleComponentCount);
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixture, GivenInvalidComponentCountWhenEnumeratingPowerDomainsWhenhwmonInterfaceExistsThenValidCountIsReturnedAndVerifySysmanPowerGetCallSucceeds) {
|
||||
uint32_t count = 0;
|
||||
EXPECT_EQ(zesDeviceEnumPowerDomains(device->toHandle(), &count, nullptr), ZE_RESULT_SUCCESS);
|
||||
EXPECT_EQ(count, powerHandleComponentCount);
|
||||
|
||||
count = count + 1;
|
||||
EXPECT_EQ(zesDeviceEnumPowerDomains(device->toHandle(), &count, nullptr), ZE_RESULT_SUCCESS);
|
||||
EXPECT_EQ(count, powerHandleComponentCount);
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixture, GivenComponentCountZeroWhenEnumeratingPowerDomainsWhenhwmonInterfaceExistsThenValidPowerHandlesIsReturned) {
|
||||
uint32_t count = 0;
|
||||
EXPECT_EQ(zesDeviceEnumPowerDomains(device->toHandle(), &count, nullptr), ZE_RESULT_SUCCESS);
|
||||
EXPECT_EQ(count, powerHandleComponentCount);
|
||||
|
||||
std::vector<zes_pwr_handle_t> handles(count, nullptr);
|
||||
EXPECT_EQ(zesDeviceEnumPowerDomains(device->toHandle(), &count, handles.data()), ZE_RESULT_SUCCESS);
|
||||
for (auto handle : handles) {
|
||||
EXPECT_NE(handle, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixture, GivenValidPowerHandleWhenGettingPowerPropertiesWhenhwmonInterfaceExistsThenCallSucceeds) {
|
||||
auto handles = getPowerHandles(powerHandleComponentCount);
|
||||
|
||||
for (auto handle : handles) {
|
||||
zes_power_properties_t properties;
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesPowerGetProperties(handle, &properties));
|
||||
EXPECT_FALSE(properties.onSubdevice);
|
||||
EXPECT_EQ(properties.subdeviceId, 0u);
|
||||
EXPECT_EQ(properties.canControl, true);
|
||||
EXPECT_EQ(properties.isEnergyThresholdSupported, false);
|
||||
EXPECT_EQ(properties.defaultLimit, (int32_t)(mockDefaultPowerLimitVal / milliFactor));
|
||||
EXPECT_EQ(properties.maxLimit, (int32_t)(mockMaxPowerLimitVal / milliFactor));
|
||||
EXPECT_EQ(properties.minLimit, (int32_t)(mockMinPowerLimitVal / milliFactor));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixture, GivenValidPowerHandleWhenGettingPowerPropertiesWhenHwmonInterfaceExistThenLimitsReturnsUnkown) {
|
||||
|
||||
EXPECT_CALL(*pSysfsAccess.get(), read(_, Matcher<uint32_t &>(_)))
|
||||
.WillRepeatedly(Return(ZE_RESULT_ERROR_NOT_AVAILABLE));
|
||||
for (const auto &handle : pSysmanDeviceImp->pPowerHandleContext->handleList) {
|
||||
delete handle;
|
||||
}
|
||||
pSysmanDeviceImp->pPowerHandleContext->handleList.clear();
|
||||
pSysmanDeviceImp->pPowerHandleContext->init();
|
||||
auto handles = getPowerHandles(powerHandleComponentCount);
|
||||
for (auto handle : handles) {
|
||||
zes_power_properties_t properties;
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesPowerGetProperties(handle, &properties));
|
||||
EXPECT_FALSE(properties.onSubdevice);
|
||||
EXPECT_EQ(properties.subdeviceId, 0u);
|
||||
EXPECT_EQ(properties.defaultLimit, -1);
|
||||
EXPECT_EQ(properties.maxLimit, -1);
|
||||
EXPECT_EQ(properties.minLimit, -1);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixture, GivenValidPowerHandleWhenGettingPowerPropertiesWhenHwmonInterfaceExistThenMaxLimitIsUnsupported) {
|
||||
|
||||
EXPECT_CALL(*pSysfsAccess.get(), read(_, Matcher<uint32_t &>(_)))
|
||||
.WillOnce(Return(ZE_RESULT_ERROR_NOT_AVAILABLE))
|
||||
.WillOnce(Return(ZE_RESULT_ERROR_NOT_AVAILABLE))
|
||||
.WillOnce(::testing::Invoke(pSysfsAccess.get(), &Mock<PowerSysfsAccess>::getValUnsignedIntMax))
|
||||
.WillRepeatedly(DoDefault());
|
||||
for (const auto &handle : pSysmanDeviceImp->pPowerHandleContext->handleList) {
|
||||
delete handle;
|
||||
}
|
||||
pSysmanDeviceImp->pPowerHandleContext->handleList.clear();
|
||||
pSysmanDeviceImp->pPowerHandleContext->init();
|
||||
auto handles = getPowerHandles(powerHandleComponentCount);
|
||||
for (auto handle : handles) {
|
||||
zes_power_properties_t properties;
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesPowerGetProperties(handle, &properties));
|
||||
EXPECT_FALSE(properties.onSubdevice);
|
||||
EXPECT_EQ(properties.subdeviceId, 0u);
|
||||
EXPECT_EQ(properties.defaultLimit, -1);
|
||||
EXPECT_EQ(properties.maxLimit, -1);
|
||||
EXPECT_EQ(properties.minLimit, -1);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixture, GivenValidPowerHandleWhenGettingPowerEnergyCounterWhenHwmonInterfaceExistThenValidPowerReadingsRetrieved) {
|
||||
auto handles = getPowerHandles(powerHandleComponentCount);
|
||||
|
||||
for (auto handle : handles) {
|
||||
zes_power_energy_counter_t energyCounter = {};
|
||||
ASSERT_EQ(ZE_RESULT_SUCCESS, zesPowerGetEnergyCounter(handle, &energyCounter));
|
||||
EXPECT_EQ(energyCounter.energy, expectedEnergyCounter);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixture, GivenValidPowerHandleWhenGettingPowerEnergyCounterFailedWhenHwmonInterfaceExistThenValidErrorCodeReturned) {
|
||||
auto handles = getPowerHandles(powerHandleComponentCount);
|
||||
|
||||
ON_CALL(*pSysfsAccess.get(), read(_, Matcher<uint64_t &>(_)))
|
||||
.WillByDefault(::testing::Invoke(pSysfsAccess.get(), &Mock<PowerSysfsAccess>::getValUnsignedLongReturnErrorForEnergyCounter));
|
||||
for (auto handle : handles) {
|
||||
zes_power_energy_counter_t energyCounter = {};
|
||||
uint64_t expectedEnergyCounter = convertJouleToMicroJoule * (setEnergyCounter / 1048576);
|
||||
ASSERT_EQ(ZE_RESULT_SUCCESS, zesPowerGetEnergyCounter(handle, &energyCounter));
|
||||
EXPECT_EQ(energyCounter.energy, expectedEnergyCounter);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixture, GivenSetPowerLimitsWhenGettingPowerLimitsWhenHwmonInterfaceExistThenLimitsSetEarlierAreRetrieved) {
|
||||
auto handles = getPowerHandles(powerHandleComponentCount);
|
||||
for (auto handle : handles) {
|
||||
zes_power_sustained_limit_t sustainedSet = {};
|
||||
zes_power_sustained_limit_t sustainedGet = {};
|
||||
sustainedSet.interval = 10;
|
||||
sustainedSet.power = 300000;
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesPowerSetLimits(handle, &sustainedSet, nullptr, nullptr));
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesPowerGetLimits(handle, &sustainedGet, nullptr, nullptr));
|
||||
EXPECT_EQ(sustainedGet.power, sustainedSet.power);
|
||||
EXPECT_EQ(sustainedGet.interval, sustainedSet.interval);
|
||||
|
||||
zes_power_burst_limit_t burstSet = {};
|
||||
zes_power_burst_limit_t burstGet = {};
|
||||
burstSet.enabled = 1;
|
||||
burstSet.power = 375000;
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesPowerSetLimits(handle, nullptr, &burstSet, nullptr));
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesPowerGetLimits(handle, nullptr, &burstGet, nullptr));
|
||||
EXPECT_EQ(burstSet.enabled, burstGet.enabled);
|
||||
EXPECT_EQ(burstSet.power, burstGet.power);
|
||||
|
||||
burstSet.enabled = 0;
|
||||
burstGet.enabled = 0;
|
||||
burstGet.power = 0;
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesPowerSetLimits(handle, nullptr, &burstSet, nullptr));
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesPowerGetLimits(handle, nullptr, &burstGet, nullptr));
|
||||
EXPECT_EQ(burstSet.enabled, burstGet.enabled);
|
||||
EXPECT_EQ(burstGet.power, 0);
|
||||
|
||||
zes_power_peak_limit_t peakGet = {};
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesPowerGetLimits(handle, nullptr, nullptr, &peakGet));
|
||||
EXPECT_EQ(peakGet.powerAC, -1);
|
||||
EXPECT_EQ(peakGet.powerDC, -1);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixture, GivenGetPowerLimitsReturnErrorWhenGettingPowerLimitsWhenHwmonInterfaceExistForBurstPowerLimitThenProperErrorCodesReturned) {
|
||||
auto handles = getPowerHandles(powerHandleComponentCount);
|
||||
|
||||
EXPECT_CALL(*pSysfsAccess.get(), read(_, Matcher<uint64_t &>(_)))
|
||||
.WillOnce(::testing::Invoke(pSysfsAccess.get(), &Mock<PowerSysfsAccess>::getValUnsignedLongReturnErrorForBurstPowerLimit))
|
||||
.WillOnce(Return(ZE_RESULT_ERROR_NOT_AVAILABLE));
|
||||
for (auto handle : handles) {
|
||||
zes_power_burst_limit_t burstSet = {};
|
||||
zes_power_burst_limit_t burstGet = {};
|
||||
burstSet.enabled = 1;
|
||||
burstSet.power = 375000;
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesPowerSetLimits(handle, nullptr, &burstSet, nullptr));
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zesPowerGetLimits(handle, nullptr, &burstGet, nullptr));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixture, GivenGetPowerLimitsReturnErrorWhenGettingPowerLimitsWhenHwmonInterfaceExistForBurstPowerLimitThenProperErrorCodesIsReturned) {
|
||||
auto handles = getPowerHandles(powerHandleComponentCount);
|
||||
|
||||
ON_CALL(*pSysfsAccess.get(), read(_, Matcher<uint64_t &>(_)))
|
||||
.WillByDefault(::testing::Invoke(pSysfsAccess.get(), &Mock<PowerSysfsAccess>::getValUnsignedLongReturnErrorUnknown));
|
||||
|
||||
for (auto handle : handles) {
|
||||
zes_power_burst_limit_t burstSet = {};
|
||||
zes_power_burst_limit_t burstGet = {};
|
||||
burstSet.enabled = 1;
|
||||
burstSet.power = 375000;
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesPowerSetLimits(handle, nullptr, &burstSet, nullptr));
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNKNOWN, zesPowerGetLimits(handle, nullptr, &burstGet, nullptr));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixture, GivenSetPowerLimitsReturnErrorWhenSettingPowerLimitsWhenHwmonInterfaceExistForBurstPowerLimitThenProperErrorCodesReturned) {
|
||||
auto handles = getPowerHandles(powerHandleComponentCount);
|
||||
|
||||
ON_CALL(*pSysfsAccess.get(), write(_, _))
|
||||
.WillByDefault(::testing::Invoke(pSysfsAccess.get(), &Mock<PowerSysfsAccess>::setValUnsignedLongReturnErrorForBurstPowerLimit));
|
||||
|
||||
for (auto handle : handles) {
|
||||
zes_power_burst_limit_t burstSet = {};
|
||||
burstSet.enabled = 1;
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zesPowerSetLimits(handle, nullptr, &burstSet, nullptr));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixture, GivenSetPowerLimitsReturnErrorWhenSettingPowerLimitsWhenHwmonInterfaceExistForBurstPowerLimitEnabledThenProperErrorCodesReturned) {
|
||||
auto handles = getPowerHandles(powerHandleComponentCount);
|
||||
|
||||
ON_CALL(*pSysfsAccess.get(), write(_, _))
|
||||
.WillByDefault(::testing::Invoke(pSysfsAccess.get(), &Mock<PowerSysfsAccess>::setValUnsignedLongReturnErrorForBurstPowerLimitEnabled));
|
||||
ON_CALL(*pSysfsAccess.get(), read(_, Matcher<uint64_t &>(_)))
|
||||
.WillByDefault(::testing::Invoke(pSysfsAccess.get(), &Mock<PowerSysfsAccess>::getValUnsignedLongReturnErrorForBurstPowerLimitEnabled));
|
||||
|
||||
for (auto handle : handles) {
|
||||
zes_power_burst_limit_t burstSet = {};
|
||||
zes_power_burst_limit_t burstGet = {};
|
||||
burstSet.enabled = 1;
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zesPowerSetLimits(handle, nullptr, &burstSet, nullptr));
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zesPowerGetLimits(handle, nullptr, &burstGet, nullptr));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixture, GivenReadingSustainedPowerLimitNodeReturnErrorWhenSetOrGetPowerLimitsWhenHwmonInterfaceExistForSustainedPowerLimitEnabledThenProperErrorCodesReturned) {
|
||||
auto handles = getPowerHandles(powerHandleComponentCount);
|
||||
|
||||
ON_CALL(*pSysfsAccess.get(), read(_, Matcher<uint64_t &>(_)))
|
||||
.WillByDefault(::testing::Invoke(pSysfsAccess.get(), &Mock<PowerSysfsAccess>::getValUnsignedLongReturnErrorForSustainedPowerLimitEnabled));
|
||||
|
||||
for (auto handle : handles) {
|
||||
zes_power_sustained_limit_t sustainedSet = {};
|
||||
zes_power_sustained_limit_t sustainedGet = {};
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zesPowerSetLimits(handle, &sustainedSet, nullptr, nullptr));
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zesPowerGetLimits(handle, &sustainedGet, nullptr, nullptr));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixture, GivenReadingSustainedPowerNodeReturnErrorWhenGetPowerLimitsForSustainedPowerWhenHwmonInterfaceExistThenProperErrorCodesReturned) {
|
||||
auto handles = getPowerHandles(powerHandleComponentCount);
|
||||
|
||||
ON_CALL(*pSysfsAccess.get(), read(_, Matcher<uint64_t &>(_)))
|
||||
.WillByDefault(::testing::Invoke(pSysfsAccess.get(), &Mock<PowerSysfsAccess>::getValUnsignedLongReturnErrorForSustainedPower));
|
||||
|
||||
for (auto handle : handles) {
|
||||
zes_power_sustained_limit_t sustainedGet = {};
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zesPowerGetLimits(handle, &sustainedGet, nullptr, nullptr));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixture, GivenReadingSustainedPowerIntervalNodeReturnErrorWhenGetPowerLimitsForSustainedPowerWhenHwmonInterfaceExistThenProperErrorCodesReturned) {
|
||||
auto handles = getPowerHandles(powerHandleComponentCount);
|
||||
|
||||
ON_CALL(*pSysfsAccess.get(), read(_, Matcher<uint64_t &>(_)))
|
||||
.WillByDefault(::testing::Invoke(pSysfsAccess.get(), &Mock<PowerSysfsAccess>::getValUnsignedLongReturnErrorForSustainedPowerInterval));
|
||||
|
||||
for (auto handle : handles) {
|
||||
zes_power_sustained_limit_t sustainedGet = {};
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zesPowerGetLimits(handle, &sustainedGet, nullptr, nullptr));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixture, GivenwritingSustainedPowerNodeReturnErrorWhenSetPowerLimitsForSustainedPowerWhenHwmonInterfaceExistThenProperErrorCodesReturned) {
|
||||
auto handles = getPowerHandles(powerHandleComponentCount);
|
||||
|
||||
ON_CALL(*pSysfsAccess.get(), write(_, _))
|
||||
.WillByDefault(::testing::Invoke(pSysfsAccess.get(), &Mock<PowerSysfsAccess>::setValReturnErrorForSustainedPower));
|
||||
|
||||
zes_power_sustained_limit_t sustainedSet = {};
|
||||
sustainedSet.interval = 10;
|
||||
sustainedSet.power = 300000;
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zesPowerSetLimits(handles[0], &sustainedSet, nullptr, nullptr));
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixture, GivenwritingSustainedPowerIntervalNodeReturnErrorWhenSetPowerLimitsForSustainedPowerIntervalWhenHwmonInterfaceExistThenProperErrorCodesReturned) {
|
||||
auto handles = getPowerHandles(powerHandleComponentCount);
|
||||
|
||||
ON_CALL(*pSysfsAccess.get(), write(_, _))
|
||||
.WillByDefault(::testing::Invoke(pSysfsAccess.get(), &Mock<PowerSysfsAccess>::setValReturnErrorForSustainedPowerInterval));
|
||||
|
||||
zes_power_sustained_limit_t sustainedSet = {};
|
||||
sustainedSet.interval = 10;
|
||||
sustainedSet.power = 300000;
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zesPowerSetLimits(handles[0], &sustainedSet, nullptr, nullptr));
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixture, GivenGetPowerLimitsWhenPowerLimitsAreDisabledWhenHwmonInterfaceExistThenAllPowerValuesAreIgnored) {
|
||||
auto handles = getPowerHandles(powerHandleComponentCount);
|
||||
|
||||
ON_CALL(*pSysfsAccess.get(), read(_, Matcher<uint64_t &>(_)))
|
||||
.WillByDefault(::testing::Invoke(pSysfsAccess.get(), &Mock<PowerSysfsAccess>::getValUnsignedLongReturnsPowerLimitEnabledAsDisabled));
|
||||
|
||||
zes_power_sustained_limit_t sustainedGet = {};
|
||||
zes_power_burst_limit_t burstGet = {};
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesPowerGetLimits(handles[0], &sustainedGet, nullptr, nullptr));
|
||||
EXPECT_EQ(sustainedGet.interval, 0);
|
||||
EXPECT_EQ(sustainedGet.power, 0);
|
||||
EXPECT_EQ(sustainedGet.enabled, 0);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesPowerGetLimits(handles[0], nullptr, &burstGet, nullptr));
|
||||
EXPECT_EQ(burstGet.enabled, 0);
|
||||
EXPECT_EQ(burstGet.power, 0);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesPowerSetLimits(handles[0], &sustainedGet, nullptr, nullptr));
|
||||
zes_power_burst_limit_t burstSet = {};
|
||||
burstSet.enabled = 0;
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesPowerSetLimits(handles[0], nullptr, &burstSet, nullptr));
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixture, GivenScanDiectoriesFailAndPmtIsNotNullPointerThenPowerModuleIsSupported) {
|
||||
ON_CALL(*pSysfsAccess.get(), scanDirEntries(_, _))
|
||||
.WillByDefault(::testing::Invoke(pSysfsAccess.get(), &Mock<PowerSysfsAccess>::getscanDirEntriesStatusReturnError));
|
||||
pSysmanDeviceImp->pPowerHandleContext->init();
|
||||
PublicLinuxPowerImp *pPowerImp = new PublicLinuxPowerImp(pOsSysman);
|
||||
EXPECT_TRUE(pPowerImp->isPowerModuleSupported());
|
||||
delete pPowerImp;
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixture, GivenComponentCountZeroWhenEnumeratingPowerDomainsThenValidCountIsReturnedAndVerifySysmanPowerGetCallSucceeds) {
|
||||
ON_CALL(*pSysfsAccess.get(), scanDirEntries(_, _))
|
||||
.WillByDefault(::testing::Invoke(pSysfsAccess.get(), &Mock<PowerSysfsAccess>::getscanDirEntriesStatusReturnError));
|
||||
for (const auto &handle : pSysmanDeviceImp->pPowerHandleContext->handleList) {
|
||||
delete handle;
|
||||
}
|
||||
pSysmanDeviceImp->pPowerHandleContext->handleList.clear();
|
||||
pSysmanDeviceImp->pPowerHandleContext->init();
|
||||
uint32_t count = 0;
|
||||
EXPECT_EQ(zesDeviceEnumPowerDomains(device->toHandle(), &count, nullptr), ZE_RESULT_SUCCESS);
|
||||
EXPECT_EQ(count, powerHandleComponentCount);
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixture, GivenInvalidComponentCountWhenEnumeratingPowerDomainsThenValidCountIsReturnedAndVerifySysmanPowerGetCallSucceeds) {
|
||||
ON_CALL(*pSysfsAccess.get(), scanDirEntries(_, _))
|
||||
.WillByDefault(::testing::Invoke(pSysfsAccess.get(), &Mock<PowerSysfsAccess>::getscanDirEntriesStatusReturnError));
|
||||
for (const auto &handle : pSysmanDeviceImp->pPowerHandleContext->handleList) {
|
||||
delete handle;
|
||||
}
|
||||
pSysmanDeviceImp->pPowerHandleContext->handleList.clear();
|
||||
pSysmanDeviceImp->pPowerHandleContext->init();
|
||||
uint32_t count = 0;
|
||||
EXPECT_EQ(zesDeviceEnumPowerDomains(device->toHandle(), &count, nullptr), ZE_RESULT_SUCCESS);
|
||||
EXPECT_EQ(count, powerHandleComponentCount);
|
||||
@@ -92,6 +429,13 @@ TEST_F(SysmanDevicePowerFixture, GivenInvalidComponentCountWhenEnumeratingPowerD
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixture, GivenComponentCountZeroWhenEnumeratingPowerDomainsThenValidPowerHandlesIsReturned) {
|
||||
ON_CALL(*pSysfsAccess.get(), scanDirEntries(_, _))
|
||||
.WillByDefault(::testing::Invoke(pSysfsAccess.get(), &Mock<PowerSysfsAccess>::getscanDirEntriesStatusReturnError));
|
||||
for (const auto &handle : pSysmanDeviceImp->pPowerHandleContext->handleList) {
|
||||
delete handle;
|
||||
}
|
||||
pSysmanDeviceImp->pPowerHandleContext->handleList.clear();
|
||||
pSysmanDeviceImp->pPowerHandleContext->init();
|
||||
uint32_t count = 0;
|
||||
EXPECT_EQ(zesDeviceEnumPowerDomains(device->toHandle(), &count, nullptr), ZE_RESULT_SUCCESS);
|
||||
EXPECT_EQ(count, powerHandleComponentCount);
|
||||
@@ -104,7 +448,14 @@ TEST_F(SysmanDevicePowerFixture, GivenComponentCountZeroWhenEnumeratingPowerDoma
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixture, GivenValidPowerHandleWhenGettingPowerPropertiesThenCallSucceeds) {
|
||||
auto handles = get_power_handles(powerHandleComponentCount);
|
||||
ON_CALL(*pSysfsAccess.get(), scanDirEntries(_, _))
|
||||
.WillByDefault(::testing::Invoke(pSysfsAccess.get(), &Mock<PowerSysfsAccess>::getscanDirEntriesStatusReturnError));
|
||||
for (const auto &handle : pSysmanDeviceImp->pPowerHandleContext->handleList) {
|
||||
delete handle;
|
||||
}
|
||||
pSysmanDeviceImp->pPowerHandleContext->handleList.clear();
|
||||
pSysmanDeviceImp->pPowerHandleContext->init();
|
||||
auto handles = getPowerHandles(powerHandleComponentCount);
|
||||
|
||||
for (auto handle : handles) {
|
||||
zes_power_properties_t properties;
|
||||
@@ -115,34 +466,62 @@ TEST_F(SysmanDevicePowerFixture, GivenValidPowerHandleWhenGettingPowerProperties
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixture, GivenValidPowerHandleWhenGettingPowerEnergyCounterThenValidPowerReadingsRetrieved) {
|
||||
auto handles = get_power_handles(powerHandleComponentCount);
|
||||
ON_CALL(*pSysfsAccess.get(), scanDirEntries(_, _))
|
||||
.WillByDefault(::testing::Invoke(pSysfsAccess.get(), &Mock<PowerSysfsAccess>::getscanDirEntriesStatusReturnError));
|
||||
for (const auto &handle : pSysmanDeviceImp->pPowerHandleContext->handleList) {
|
||||
delete handle;
|
||||
}
|
||||
pSysmanDeviceImp->pPowerHandleContext->handleList.clear();
|
||||
pSysmanDeviceImp->pPowerHandleContext->init();
|
||||
auto handles = getPowerHandles(powerHandleComponentCount);
|
||||
|
||||
for (auto handle : handles) {
|
||||
zes_power_energy_counter_t energyCounter;
|
||||
uint64_t expectedEnergyCounter = convertJouleToMicroJoule * setEnergyCounter;
|
||||
uint64_t expectedEnergyCounter = convertJouleToMicroJoule * (setEnergyCounter / 1048576);
|
||||
ASSERT_EQ(ZE_RESULT_SUCCESS, zesPowerGetEnergyCounter(handle, &energyCounter));
|
||||
EXPECT_EQ(energyCounter.energy, expectedEnergyCounter);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixture, GivenValidPowerHandleWhenGettingPowerEnergyThresholdThenUnsupportedFeatureErrorIsReturned) {
|
||||
ON_CALL(*pSysfsAccess.get(), scanDirEntries(_, _))
|
||||
.WillByDefault(::testing::Invoke(pSysfsAccess.get(), &Mock<PowerSysfsAccess>::getscanDirEntriesStatusReturnError));
|
||||
for (const auto &handle : pSysmanDeviceImp->pPowerHandleContext->handleList) {
|
||||
delete handle;
|
||||
}
|
||||
pSysmanDeviceImp->pPowerHandleContext->handleList.clear();
|
||||
pSysmanDeviceImp->pPowerHandleContext->init();
|
||||
zes_energy_threshold_t threshold;
|
||||
auto handles = get_power_handles(powerHandleComponentCount);
|
||||
auto handles = getPowerHandles(powerHandleComponentCount);
|
||||
for (auto handle : handles) {
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zesPowerGetEnergyThreshold(handle, &threshold));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixture, GivenValidPowerHandleWhenSettingPowerEnergyThresholdThenUnsupportedFeatureErrorIsReturned) {
|
||||
ON_CALL(*pSysfsAccess.get(), scanDirEntries(_, _))
|
||||
.WillByDefault(::testing::Invoke(pSysfsAccess.get(), &Mock<PowerSysfsAccess>::getscanDirEntriesStatusReturnError));
|
||||
for (const auto &handle : pSysmanDeviceImp->pPowerHandleContext->handleList) {
|
||||
delete handle;
|
||||
}
|
||||
pSysmanDeviceImp->pPowerHandleContext->handleList.clear();
|
||||
pSysmanDeviceImp->pPowerHandleContext->init();
|
||||
double threshold = 0;
|
||||
auto handles = get_power_handles(powerHandleComponentCount);
|
||||
auto handles = getPowerHandles(powerHandleComponentCount);
|
||||
for (auto handle : handles) {
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zesPowerSetEnergyThreshold(handle, threshold));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixture, GivenValidPowerHandleWhenGettingPowerLimitsThenUnsupportedFeatureErrorIsReturned) {
|
||||
auto handles = get_power_handles(powerHandleComponentCount);
|
||||
ON_CALL(*pSysfsAccess.get(), scanDirEntries(_, _))
|
||||
.WillByDefault(::testing::Invoke(pSysfsAccess.get(), &Mock<PowerSysfsAccess>::getscanDirEntriesStatusReturnError));
|
||||
for (const auto &handle : pSysmanDeviceImp->pPowerHandleContext->handleList) {
|
||||
delete handle;
|
||||
}
|
||||
pSysmanDeviceImp->pPowerHandleContext->handleList.clear();
|
||||
pSysmanDeviceImp->pPowerHandleContext->init();
|
||||
auto handles = getPowerHandles(powerHandleComponentCount);
|
||||
for (auto handle : handles) {
|
||||
zes_power_sustained_limit_t sustained;
|
||||
zes_power_burst_limit_t burst;
|
||||
@@ -152,7 +531,14 @@ TEST_F(SysmanDevicePowerFixture, GivenValidPowerHandleWhenGettingPowerLimitsThen
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixture, GivenValidPowerHandleWhenSettingPowerLimitsThenUnsupportedFeatureErrorIsReturned) {
|
||||
auto handles = get_power_handles(powerHandleComponentCount);
|
||||
ON_CALL(*pSysfsAccess.get(), scanDirEntries(_, _))
|
||||
.WillByDefault(::testing::Invoke(pSysfsAccess.get(), &Mock<PowerSysfsAccess>::getscanDirEntriesStatusReturnError));
|
||||
for (const auto &handle : pSysmanDeviceImp->pPowerHandleContext->handleList) {
|
||||
delete handle;
|
||||
}
|
||||
pSysmanDeviceImp->pPowerHandleContext->handleList.clear();
|
||||
pSysmanDeviceImp->pPowerHandleContext->init();
|
||||
auto handles = getPowerHandles(powerHandleComponentCount);
|
||||
for (auto handle : handles) {
|
||||
zes_power_sustained_limit_t sustained;
|
||||
zes_power_burst_limit_t burst;
|
||||
|
||||
Reference in New Issue
Block a user