mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-19 06:24:51 +08:00
test(sysman): Restore ULTs to original zes* API calls
Related-To: NEO-9698 Signed-off-by: shubham kumar <shubham.kumar@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
c7c7ba7159
commit
7cd08edd57
@@ -21,6 +21,7 @@
|
||||
#include "level_zero/sysman/source/driver/sysman_driver.h"
|
||||
#include "level_zero/sysman/source/driver/sysman_driver_handle_imp.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access_interface.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_kmd_interface.h"
|
||||
#include "level_zero/sysman/source/shared/linux/zes_os_sysman_driver_imp.h"
|
||||
#include "level_zero/sysman/source/shared/linux/zes_os_sysman_imp.h"
|
||||
#include "level_zero/sysman/test/unit_tests/sources/firmware_util/mock_fw_util_fixture.h"
|
||||
@@ -159,6 +160,13 @@ class PublicLinuxSysmanDriverImp : public L0::Sysman::LinuxSysmanDriverImp {
|
||||
using LinuxSysmanDriverImp::pUdevLib;
|
||||
};
|
||||
|
||||
class PublicSysmanKmdInterfaceI915 : public L0::Sysman::SysmanKmdInterfaceI915Upstream {
|
||||
public:
|
||||
PublicSysmanKmdInterfaceI915(const PRODUCT_FAMILY productFamily) : L0::Sysman::SysmanKmdInterfaceI915Upstream(productFamily) {}
|
||||
~PublicSysmanKmdInterfaceI915() override = default;
|
||||
using L0::Sysman::SysmanKmdInterface::pSysfsAccess;
|
||||
};
|
||||
|
||||
} // namespace ult
|
||||
} // namespace Sysman
|
||||
} // namespace L0
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
#include "level_zero/sysman/source/device/sysman_device_imp.h"
|
||||
#include "level_zero/sysman/source/shared/linux/pmt/sysman_pmt.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_fs_access_interface.h"
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_kmd_interface.h"
|
||||
#include "level_zero/sysman/source/sysman_const.h"
|
||||
#include "level_zero/sysman/test/unit_tests/sources/linux/mock_sysman_fixture.h"
|
||||
|
||||
@@ -50,241 +49,6 @@ const std::map<std::string, uint64_t> deviceKeyOffsetMapPower = {
|
||||
{"SOC_TEMPERATURES", 0x60},
|
||||
{"CORE_TEMPERATURES", 0x6c}};
|
||||
|
||||
struct MockPowerSysfsAccess : public L0::Sysman::SysFsAccessInterface {
|
||||
|
||||
std::vector<ze_result_t> mockReadReturnStatus{};
|
||||
std::vector<ze_result_t> mockWriteReturnStatus{};
|
||||
std::vector<ze_result_t> mockScanDirEntriesReturnStatus{};
|
||||
std::vector<uint64_t> mockReadUnsignedLongValue{};
|
||||
std::vector<uint32_t> mockReadUnsignedIntValue{};
|
||||
bool isRepeated = false;
|
||||
|
||||
ze_result_t read(const std::string file, std::string &val) override {
|
||||
|
||||
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 getValUnsignedLongReturnErrorForBurstPowerLimit(const std::string file, uint64_t &val) {
|
||||
if (file.compare(i915HwmonDir + "/" + burstPowerLimitEnabled) == 0) {
|
||||
val = burstPowerLimitEnabledVal;
|
||||
}
|
||||
if (file.compare(i915HwmonDir + "/" + burstPowerLimit) == 0) {
|
||||
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
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 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 setValUnsignedLongReturnErrorForSustainedPowerLimitEnabled(const std::string file, const int val) {
|
||||
if (file.compare(i915HwmonDir + "/" + sustainedPowerLimitEnabled) == 0) {
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t setValUnsignedLongReturnInsufficientForSustainedPowerLimitEnabled(const std::string file, const int val) {
|
||||
if (file.compare(i915HwmonDir + "/" + sustainedPowerLimitEnabled) == 0) {
|
||||
return ZE_RESULT_ERROR_INSUFFICIENT_PERMISSIONS;
|
||||
}
|
||||
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 read(const std::string file, uint64_t &val) override {
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
if (!mockReadReturnStatus.empty()) {
|
||||
result = mockReadReturnStatus.front();
|
||||
if (!mockReadUnsignedLongValue.empty()) {
|
||||
val = mockReadUnsignedLongValue.front();
|
||||
}
|
||||
if (isRepeated != true) {
|
||||
if (mockReadUnsignedLongValue.size() != 0) {
|
||||
mockReadUnsignedLongValue.erase(mockReadUnsignedLongValue.begin());
|
||||
}
|
||||
mockReadReturnStatus.erase(mockReadReturnStatus.begin());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
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 read(const std::string file, uint32_t &val) override {
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
if (!mockReadReturnStatus.empty()) {
|
||||
result = mockReadReturnStatus.front();
|
||||
if (!mockReadUnsignedIntValue.empty()) {
|
||||
val = mockReadUnsignedIntValue.front();
|
||||
}
|
||||
if (isRepeated != true) {
|
||||
if (mockReadUnsignedIntValue.size() != 0) {
|
||||
mockReadUnsignedIntValue.erase(mockReadUnsignedIntValue.begin());
|
||||
}
|
||||
mockReadReturnStatus.erase(mockReadReturnStatus.begin());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
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 write(const std::string file, const int val) override {
|
||||
ze_result_t result = ZE_RESULT_SUCCESS;
|
||||
if (!mockWriteReturnStatus.empty()) {
|
||||
ze_result_t result = mockWriteReturnStatus.front();
|
||||
if (isRepeated != true) {
|
||||
mockWriteReturnStatus.erase(mockWriteReturnStatus.begin());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
if (file.compare(i915HwmonDir + "/" + sustainedPowerLimitEnabled) == 0) {
|
||||
sustainedPowerLimitEnabledVal = static_cast<uint64_t>(val);
|
||||
} else 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 scanDirEntries(const std::string file, std::vector<std::string> &listOfEntries) override {
|
||||
ze_result_t result = ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
if (!mockScanDirEntriesReturnStatus.empty()) {
|
||||
ze_result_t result = mockScanDirEntriesReturnStatus.front();
|
||||
if (isRepeated != true) {
|
||||
mockScanDirEntriesReturnStatus.erase(mockScanDirEntriesReturnStatus.begin());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
if (file.compare(hwmonDir) == 0) {
|
||||
listOfEntries = listOfMockedHwmonDirs;
|
||||
result = ZE_RESULT_SUCCESS;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
MockPowerSysfsAccess() = default;
|
||||
};
|
||||
|
||||
struct MockPowerSysfsAccessInterface : public L0::Sysman::SysFsAccessInterface {
|
||||
|
||||
std::vector<ze_result_t> mockReadReturnStatus{};
|
||||
@@ -591,24 +355,20 @@ class PublicLinuxPowerImp : public L0::Sysman::LinuxPowerImp {
|
||||
class SysmanDevicePowerFixtureI915 : public SysmanDeviceFixture {
|
||||
protected:
|
||||
L0::Sysman::SysmanDevice *device = nullptr;
|
||||
std::unique_ptr<PublicLinuxPowerImp> pPublicLinuxPowerImp;
|
||||
std::unique_ptr<MockPowerPmt> pPmt;
|
||||
std::unique_ptr<MockPowerFsAccess> pFsAccess;
|
||||
std::unique_ptr<MockPowerSysfsAccess> pSysfsAccess;
|
||||
L0::Sysman::SysFsAccessInterface *pSysfsAccessOld = nullptr;
|
||||
L0::Sysman::FsAccessInterface *pFsAccessOriginal = nullptr;
|
||||
L0::Sysman::OsPower *pOsPowerOriginal = nullptr;
|
||||
std::map<uint32_t, L0::Sysman::PlatformMonitoringTech *> pmtMapOriginal;
|
||||
PublicSysmanKmdInterfaceI915 *pSysmanKmdInterface = nullptr;
|
||||
MockPowerSysfsAccessInterface *pSysfsAccess = nullptr;
|
||||
|
||||
void SetUp() override {
|
||||
SysmanDeviceFixture::SetUp();
|
||||
device = pSysmanDevice;
|
||||
pFsAccess = std::make_unique<MockPowerFsAccess>();
|
||||
pFsAccessOriginal = pLinuxSysmanImp->pFsAccess;
|
||||
pLinuxSysmanImp->pFsAccess = pFsAccess.get();
|
||||
pSysfsAccessOld = pLinuxSysmanImp->pSysfsAccess;
|
||||
pSysfsAccess = std::make_unique<MockPowerSysfsAccess>();
|
||||
pLinuxSysmanImp->pSysfsAccess = pSysfsAccess.get();
|
||||
pSysmanKmdInterface = new PublicSysmanKmdInterfaceI915(pLinuxSysmanImp->getProductFamily());
|
||||
pSysfsAccess = new MockPowerSysfsAccessInterface();
|
||||
pSysmanKmdInterface->pSysfsAccess.reset(pSysfsAccess);
|
||||
pLinuxSysmanImp->pSysmanKmdInterface.reset(pSysmanKmdInterface);
|
||||
|
||||
pmtMapOriginal = pLinuxSysmanImp->mapOfSubDeviceIdToPmtObject;
|
||||
pLinuxSysmanImp->mapOfSubDeviceIdToPmtObject.clear();
|
||||
@@ -628,8 +388,6 @@ class SysmanDevicePowerFixtureI915 : public SysmanDeviceFixture {
|
||||
void TearDown() override {
|
||||
pLinuxSysmanImp->releasePmtObject();
|
||||
pLinuxSysmanImp->mapOfSubDeviceIdToPmtObject = pmtMapOriginal;
|
||||
pLinuxSysmanImp->pFsAccess = pFsAccessOriginal;
|
||||
pLinuxSysmanImp->pSysfsAccess = pSysfsAccessOld;
|
||||
SysmanDeviceFixture::TearDown();
|
||||
}
|
||||
|
||||
@@ -659,20 +417,19 @@ class SysmanDevicePowerMultiDeviceFixture : public SysmanMultiDeviceFixture {
|
||||
std::unique_ptr<PublicLinuxPowerImp> pPublicLinuxPowerImp;
|
||||
std::unique_ptr<MockPowerPmt> pPmt;
|
||||
std::unique_ptr<MockPowerFsAccess> pFsAccess;
|
||||
std::unique_ptr<MockPowerSysfsAccess> pSysfsAccess;
|
||||
L0::Sysman::SysFsAccessInterface *pSysfsAccessOld = nullptr;
|
||||
L0::Sysman::FsAccessInterface *pFsAccessOriginal = nullptr;
|
||||
L0::Sysman::OsPower *pOsPowerOriginal = nullptr;
|
||||
std::map<uint32_t, L0::Sysman::PlatformMonitoringTech *> mapOriginal;
|
||||
PublicSysmanKmdInterfaceI915 *pSysmanKmdInterface = nullptr;
|
||||
MockPowerSysfsAccessInterface *pSysfsAccess = nullptr;
|
||||
|
||||
void SetUp() override {
|
||||
SysmanMultiDeviceFixture::SetUp();
|
||||
device = pSysmanDevice;
|
||||
pFsAccess = std::make_unique<MockPowerFsAccess>();
|
||||
pFsAccessOriginal = pLinuxSysmanImp->pFsAccess;
|
||||
pLinuxSysmanImp->pFsAccess = pFsAccess.get();
|
||||
pSysfsAccessOld = pLinuxSysmanImp->pSysfsAccess;
|
||||
pSysfsAccess = std::make_unique<MockPowerSysfsAccess>();
|
||||
pLinuxSysmanImp->pSysfsAccess = pSysfsAccess.get();
|
||||
|
||||
pSysmanKmdInterface = new PublicSysmanKmdInterfaceI915(pLinuxSysmanImp->getProductFamily());
|
||||
pSysfsAccess = new MockPowerSysfsAccessInterface();
|
||||
pSysmanKmdInterface->pSysfsAccess.reset(pSysfsAccess);
|
||||
pLinuxSysmanImp->pSysmanKmdInterface.reset(pSysmanKmdInterface);
|
||||
|
||||
mapOriginal = pLinuxSysmanImp->mapOfSubDeviceIdToPmtObject;
|
||||
pLinuxSysmanImp->mapOfSubDeviceIdToPmtObject.clear();
|
||||
@@ -691,8 +448,6 @@ class SysmanDevicePowerMultiDeviceFixture : public SysmanMultiDeviceFixture {
|
||||
for (const auto &pmtMapElement : pLinuxSysmanImp->mapOfSubDeviceIdToPmtObject) {
|
||||
delete pmtMapElement.second;
|
||||
}
|
||||
pLinuxSysmanImp->pFsAccess = pFsAccessOriginal;
|
||||
pLinuxSysmanImp->pSysfsAccess = pSysfsAccessOld;
|
||||
pLinuxSysmanImp->mapOfSubDeviceIdToPmtObject = mapOriginal;
|
||||
SysmanMultiDeviceFixture::TearDown();
|
||||
}
|
||||
|
||||
@@ -69,39 +69,41 @@ TEST_F(SysmanDevicePowerFixtureI915, GivenUninitializedPowerHandlesAndWhenGettin
|
||||
|
||||
TEST_F(SysmanDevicePowerFixtureI915, GivenValidPowerHandleWhenGettingPowerPropertiesWhenhwmonInterfaceExistsThenCallSucceeds) {
|
||||
|
||||
auto pSysFsAccess = std::make_unique<MockPowerSysfsAccessInterface>();
|
||||
std::unique_ptr<PublicLinuxPowerImp> pLinuxPowerImp(new PublicLinuxPowerImp(pOsSysman, false, 0));
|
||||
pLinuxPowerImp->pSysfsAccess = pSysFsAccess.get();
|
||||
pLinuxPowerImp->pPmt = static_cast<MockPowerPmt *>(pLinuxSysmanImp->getPlatformMonitoringTechAccess(0));
|
||||
pLinuxPowerImp->isPowerModuleSupported();
|
||||
auto handles = getPowerHandles(powerHandleComponentCount);
|
||||
|
||||
zes_power_properties_t properties{};
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, pLinuxPowerImp->getProperties(&properties));
|
||||
EXPECT_FALSE(properties.onSubdevice);
|
||||
EXPECT_EQ(properties.subdeviceId, 0u);
|
||||
EXPECT_EQ(properties.canControl, true);
|
||||
EXPECT_EQ(properties.isEnergyThresholdSupported, false);
|
||||
EXPECT_EQ(properties.defaultLimit, static_cast<int32_t>(mockDefaultPowerLimitVal / milliFactor));
|
||||
EXPECT_EQ(properties.maxLimit, static_cast<int32_t>(mockMaxPowerLimitVal / milliFactor));
|
||||
EXPECT_EQ(properties.minLimit, static_cast<int32_t>(mockMinPowerLimitVal / milliFactor));
|
||||
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, static_cast<int32_t>(mockDefaultPowerLimitVal / milliFactor));
|
||||
EXPECT_EQ(properties.maxLimit, static_cast<int32_t>(mockMaxPowerLimitVal / milliFactor));
|
||||
EXPECT_EQ(properties.minLimit, static_cast<int32_t>(mockMinPowerLimitVal / milliFactor));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixtureI915, GivenValidPowerHandleWhenGettingPowerPropertiesWhenHwmonInterfaceExistThenLimitsReturnsUnknown) {
|
||||
|
||||
auto pSysFsAccess = std::make_unique<MockPowerSysfsAccessInterface>();
|
||||
pSysFsAccess->mockReadReturnStatus.push_back(ZE_RESULT_ERROR_NOT_AVAILABLE);
|
||||
pSysFsAccess->isRepeated = true;
|
||||
std::unique_ptr<PublicLinuxPowerImp> pLinuxPowerImp(new PublicLinuxPowerImp(pOsSysman, false, 0));
|
||||
pLinuxPowerImp->pSysfsAccess = pSysFsAccess.get();
|
||||
pLinuxPowerImp->isPowerModuleSupported();
|
||||
pSysfsAccess->mockReadReturnStatus.push_back(ZE_RESULT_ERROR_NOT_AVAILABLE);
|
||||
pSysfsAccess->isRepeated = true;
|
||||
|
||||
zes_power_properties_t properties{};
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, pLinuxPowerImp->getProperties(&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);
|
||||
for (const auto &handle : pSysmanDeviceImp->pPowerHandleContext->handleList) {
|
||||
delete handle;
|
||||
}
|
||||
pSysmanDeviceImp->pPowerHandleContext->handleList.clear();
|
||||
pSysmanDeviceImp->pPowerHandleContext->init(pLinuxSysmanImp->getSubDeviceCount());
|
||||
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(SysmanDevicePowerFixtureI915, GivenValidPowerHandleWhenGettingPowerPropertiesWhenHwmonInterfaceExistThenMaxLimitIsUnsupported) {
|
||||
@@ -134,259 +136,238 @@ TEST_F(SysmanDevicePowerFixtureI915, GivenValidPowerHandleWhenGettingPowerProper
|
||||
|
||||
TEST_F(SysmanDevicePowerFixtureI915, GivenValidPowerHandleWhenGettingPowerPropertiesThenHwmonInterfaceExistAndMinLimitIsUnknown) {
|
||||
|
||||
auto pSysFsAccess = std::make_unique<MockPowerSysfsAccessInterface>();
|
||||
pSysfsAccess->mockReadReturnStatus.push_back(ZE_RESULT_ERROR_NOT_AVAILABLE);
|
||||
pSysfsAccess->mockReadUnsignedIntValue.push_back(0);
|
||||
|
||||
pSysFsAccess->mockReadReturnStatus.push_back(ZE_RESULT_ERROR_NOT_AVAILABLE);
|
||||
pSysFsAccess->mockReadUnsignedIntValue.push_back(0);
|
||||
pSysFsAccess->mockReadReturnStatus.push_back(ZE_RESULT_SUCCESS);
|
||||
pSysFsAccess->mockReadUnsignedIntValue.push_back(0);
|
||||
pSysfsAccess->mockReadReturnStatus.push_back(ZE_RESULT_SUCCESS);
|
||||
pSysfsAccess->mockReadUnsignedIntValue.push_back(0);
|
||||
|
||||
std::unique_ptr<PublicLinuxPowerImp> pLinuxPowerImp(new PublicLinuxPowerImp(pOsSysman, false, 0));
|
||||
pLinuxPowerImp->pSysfsAccess = pSysFsAccess.get();
|
||||
pLinuxPowerImp->pPmt = static_cast<MockPowerPmt *>(pLinuxSysmanImp->getPlatformMonitoringTechAccess(0));
|
||||
pLinuxPowerImp->isPowerModuleSupported();
|
||||
for (const auto &handle : pSysmanDeviceImp->pPowerHandleContext->handleList) {
|
||||
delete handle;
|
||||
}
|
||||
|
||||
zes_power_properties_t properties{};
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, pLinuxPowerImp->getProperties(&properties));
|
||||
EXPECT_FALSE(properties.onSubdevice);
|
||||
EXPECT_EQ(properties.subdeviceId, 0u);
|
||||
EXPECT_EQ(properties.defaultLimit, -1);
|
||||
EXPECT_EQ(properties.maxLimit, static_cast<int32_t>(mockMaxPowerLimitVal / milliFactor));
|
||||
EXPECT_EQ(properties.minLimit, -1);
|
||||
pSysmanDeviceImp->pPowerHandleContext->handleList.clear();
|
||||
pSysmanDeviceImp->pPowerHandleContext->init(pLinuxSysmanImp->getSubDeviceCount());
|
||||
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, static_cast<int32_t>(mockMaxPowerLimitVal / milliFactor));
|
||||
EXPECT_EQ(properties.minLimit, -1);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixtureI915, GivenValidPowerHandleWhenGettingPowerEnergyCounterFailedWhenHwmonInterfaceExistThenValidErrorCodeReturned) {
|
||||
|
||||
auto pSysFsAccess = std::make_unique<MockPowerSysfsAccessInterface>();
|
||||
pSysFsAccess->mockReadReturnStatus.push_back(ZE_RESULT_ERROR_INSUFFICIENT_PERMISSIONS);
|
||||
pSysFsAccess->isRepeated = true;
|
||||
auto handles = getPowerHandles(powerHandleComponentCount);
|
||||
auto subDeviceCount = pLinuxSysmanImp->getSubDeviceCount();
|
||||
uint32_t subdeviceId = 0;
|
||||
do {
|
||||
auto pPmt = static_cast<MockPowerPmt *>(pLinuxSysmanImp->getPlatformMonitoringTechAccess(subdeviceId));
|
||||
pPmt->preadFunction = preadMockPower;
|
||||
} while (++subdeviceId < subDeviceCount);
|
||||
|
||||
auto pPmt = static_cast<MockPowerPmt *>(pLinuxSysmanImp->getPlatformMonitoringTechAccess(0));
|
||||
pSysfsAccess->mockReadReturnStatus.push_back(ZE_RESULT_ERROR_INSUFFICIENT_PERMISSIONS);
|
||||
pSysfsAccess->isRepeated = true;
|
||||
|
||||
pPmt->preadFunction = preadMockPower;
|
||||
|
||||
std::unique_ptr<PublicLinuxPowerImp> pLinuxPowerImp(new PublicLinuxPowerImp(pOsSysman, false, 0));
|
||||
pLinuxPowerImp->pSysfsAccess = pSysFsAccess.get();
|
||||
pLinuxPowerImp->pPmt = pPmt;
|
||||
pLinuxPowerImp->isPowerModuleSupported();
|
||||
|
||||
zes_power_energy_counter_t energyCounter = {};
|
||||
uint64_t expectedEnergyCounter = convertJouleToMicroJoule * (setEnergyCounter / 1048576);
|
||||
ASSERT_EQ(ZE_RESULT_SUCCESS, pLinuxPowerImp->getEnergyCounter(&energyCounter));
|
||||
EXPECT_EQ(energyCounter.energy, expectedEnergyCounter);
|
||||
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(SysmanDevicePowerFixtureI915, GivenSetPowerLimitsWhenGettingPowerLimitsWhenHwmonInterfaceExistThenLimitsSetEarlierAreRetrieved) {
|
||||
|
||||
auto pSysFsAccess = std::make_unique<MockPowerSysfsAccessInterface>();
|
||||
std::unique_ptr<PublicLinuxPowerImp> pLinuxPowerImp(new PublicLinuxPowerImp(pOsSysman, false, 0));
|
||||
pLinuxPowerImp->pSysfsAccess = pSysFsAccess.get();
|
||||
pLinuxPowerImp->pPmt = static_cast<MockPowerPmt *>(pLinuxSysmanImp->getPlatformMonitoringTechAccess(0));
|
||||
pLinuxPowerImp->isPowerModuleSupported();
|
||||
zes_power_sustained_limit_t sustainedSet = {};
|
||||
zes_power_sustained_limit_t sustainedGet = {};
|
||||
sustainedSet.enabled = 1;
|
||||
sustainedSet.interval = 10;
|
||||
sustainedSet.power = 300000;
|
||||
auto handles = getPowerHandles(powerHandleComponentCount);
|
||||
for (auto handle : handles) {
|
||||
zes_power_sustained_limit_t sustainedSet = {};
|
||||
zes_power_sustained_limit_t sustainedGet = {};
|
||||
sustainedSet.enabled = 1;
|
||||
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);
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, pLinuxPowerImp->setLimits(&sustainedSet, nullptr, nullptr));
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, pLinuxPowerImp->getLimits(&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);
|
||||
|
||||
zes_power_burst_limit_t burstSet = {};
|
||||
zes_power_burst_limit_t burstGet = {};
|
||||
burstSet.enabled = 1;
|
||||
burstSet.power = 375000;
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, pLinuxPowerImp->setLimits(nullptr, &burstSet, nullptr));
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, pLinuxPowerImp->getLimits(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);
|
||||
|
||||
burstSet.enabled = 0;
|
||||
burstGet.enabled = 0;
|
||||
burstGet.power = 0;
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, pLinuxPowerImp->setLimits(nullptr, &burstSet, nullptr));
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, pLinuxPowerImp->getLimits(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, pLinuxPowerImp->getLimits(nullptr, nullptr, &peakGet));
|
||||
EXPECT_EQ(peakGet.powerAC, -1);
|
||||
EXPECT_EQ(peakGet.powerDC, -1);
|
||||
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(SysmanDevicePowerFixtureI915, GivenGetPowerLimitsReturnErrorWhenGettingPowerLimitsWhenHwmonInterfaceExistForBurstPowerLimitThenProperErrorCodesReturned) {
|
||||
auto pSysFsAccess = std::make_unique<MockPowerSysfsAccessInterface>();
|
||||
pSysFsAccess->mockReadReturnStatus.push_back(ZE_RESULT_ERROR_NOT_AVAILABLE);
|
||||
std::unique_ptr<PublicLinuxPowerImp> pLinuxPowerImp(new PublicLinuxPowerImp(pOsSysman, false, 0));
|
||||
pLinuxPowerImp->pSysfsAccess = pSysFsAccess.get();
|
||||
pLinuxPowerImp->pPmt = static_cast<MockPowerPmt *>(pLinuxSysmanImp->getPlatformMonitoringTechAccess(0));
|
||||
pLinuxPowerImp->isPowerModuleSupported();
|
||||
auto handles = getPowerHandles(powerHandleComponentCount);
|
||||
|
||||
zes_power_burst_limit_t burstSet = {};
|
||||
zes_power_burst_limit_t burstGet = {};
|
||||
burstSet.enabled = 1;
|
||||
burstSet.power = 375000;
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, pLinuxPowerImp->setLimits(nullptr, &burstSet, nullptr));
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, pLinuxPowerImp->getLimits(nullptr, &burstGet, nullptr));
|
||||
pSysfsAccess->mockReadReturnStatus.push_back(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(SysmanDevicePowerFixtureI915, GivenGetPowerLimitsReturnErrorWhenGettingPowerLimitsWhenHwmonInterfaceExistForBurstPowerLimitThenProperErrorCodesIsReturned) {
|
||||
|
||||
auto pSysFsAccess = std::make_unique<MockPowerSysfsAccessInterface>();
|
||||
pSysFsAccess->mockReadReturnStatus.push_back(ZE_RESULT_ERROR_UNKNOWN);
|
||||
pSysFsAccess->isRepeated = true;
|
||||
std::unique_ptr<PublicLinuxPowerImp> pLinuxPowerImp(new PublicLinuxPowerImp(pOsSysman, false, 0));
|
||||
pLinuxPowerImp->pSysfsAccess = pSysFsAccess.get();
|
||||
pLinuxPowerImp->pPmt = static_cast<MockPowerPmt *>(pLinuxSysmanImp->getPlatformMonitoringTechAccess(0));
|
||||
pLinuxPowerImp->isPowerModuleSupported();
|
||||
auto handles = getPowerHandles(powerHandleComponentCount);
|
||||
|
||||
zes_power_burst_limit_t burstSet = {};
|
||||
zes_power_burst_limit_t burstGet = {};
|
||||
burstSet.enabled = 1;
|
||||
burstSet.power = 375000;
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, pLinuxPowerImp->setLimits(nullptr, &burstSet, nullptr));
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNKNOWN, pLinuxPowerImp->getLimits(nullptr, &burstGet, nullptr));
|
||||
pSysfsAccess->mockReadReturnStatus.push_back(ZE_RESULT_ERROR_UNKNOWN);
|
||||
pSysfsAccess->isRepeated = true;
|
||||
|
||||
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(SysmanDevicePowerFixtureI915, GivenSetPowerLimitsReturnErrorWhenSettingPowerLimitsWhenHwmonInterfaceExistForBurstPowerLimitThenProperErrorCodesReturned) {
|
||||
|
||||
auto pSysFsAccess = std::make_unique<MockPowerSysfsAccessInterface>();
|
||||
pSysFsAccess->mockWriteReturnStatus.push_back(ZE_RESULT_ERROR_NOT_AVAILABLE);
|
||||
std::unique_ptr<PublicLinuxPowerImp> pLinuxPowerImp(new PublicLinuxPowerImp(pOsSysman, false, 0));
|
||||
pLinuxPowerImp->pSysfsAccess = pSysFsAccess.get();
|
||||
pLinuxPowerImp->pPmt = static_cast<MockPowerPmt *>(pLinuxSysmanImp->getPlatformMonitoringTechAccess(0));
|
||||
pLinuxPowerImp->isPowerModuleSupported();
|
||||
auto handles = getPowerHandles(powerHandleComponentCount);
|
||||
|
||||
zes_power_burst_limit_t burstSet = {};
|
||||
burstSet.enabled = 1;
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, pLinuxPowerImp->setLimits(nullptr, &burstSet, nullptr));
|
||||
pSysfsAccess->mockWriteReturnStatus.push_back(ZE_RESULT_ERROR_NOT_AVAILABLE);
|
||||
|
||||
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(SysmanDevicePowerFixtureI915, GivenSetPowerLimitsReturnErrorWhenSettingPowerLimitsWhenHwmonInterfaceExistForBurstPowerLimitEnabledThenProperErrorCodesReturned) {
|
||||
|
||||
auto pSysFsAccess = std::make_unique<MockPowerSysfsAccessInterface>();
|
||||
pSysFsAccess->mockWriteReturnStatus.push_back(ZE_RESULT_ERROR_NOT_AVAILABLE);
|
||||
pSysFsAccess->mockReadReturnStatus.push_back(ZE_RESULT_ERROR_NOT_AVAILABLE);
|
||||
std::unique_ptr<PublicLinuxPowerImp> pLinuxPowerImp(new PublicLinuxPowerImp(pOsSysman, false, 0));
|
||||
pLinuxPowerImp->pSysfsAccess = pSysFsAccess.get();
|
||||
pLinuxPowerImp->pPmt = static_cast<MockPowerPmt *>(pLinuxSysmanImp->getPlatformMonitoringTechAccess(0));
|
||||
pLinuxPowerImp->isPowerModuleSupported();
|
||||
auto handles = getPowerHandles(powerHandleComponentCount);
|
||||
|
||||
zes_power_burst_limit_t burstSet = {};
|
||||
zes_power_burst_limit_t burstGet = {};
|
||||
burstSet.enabled = 1;
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, pLinuxPowerImp->setLimits(nullptr, &burstSet, nullptr));
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, pLinuxPowerImp->getLimits(nullptr, &burstGet, nullptr));
|
||||
pSysfsAccess->mockWriteReturnStatus.push_back(ZE_RESULT_ERROR_NOT_AVAILABLE);
|
||||
pSysfsAccess->mockReadReturnStatus.push_back(ZE_RESULT_ERROR_NOT_AVAILABLE);
|
||||
|
||||
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(SysmanDevicePowerFixtureI915, GivenReadingSustainedPowerLimitNodeReturnErrorWhenSetOrGetPowerLimitsWhenHwmonInterfaceExistForSustainedPowerLimitEnabledThenProperErrorCodesReturned) {
|
||||
|
||||
auto pSysFsAccess = std::make_unique<MockPowerSysfsAccessInterface>();
|
||||
pSysFsAccess->mockReadReturnStatus.push_back(ZE_RESULT_ERROR_NOT_AVAILABLE);
|
||||
pSysFsAccess->isRepeated = true;
|
||||
std::unique_ptr<PublicLinuxPowerImp> pLinuxPowerImp(new PublicLinuxPowerImp(pOsSysman, false, 0));
|
||||
pLinuxPowerImp->pSysfsAccess = pSysFsAccess.get();
|
||||
pLinuxPowerImp->pPmt = static_cast<MockPowerPmt *>(pLinuxSysmanImp->getPlatformMonitoringTechAccess(0));
|
||||
pLinuxPowerImp->isPowerModuleSupported();
|
||||
auto handles = getPowerHandles(powerHandleComponentCount);
|
||||
|
||||
zes_power_sustained_limit_t sustainedSet = {};
|
||||
zes_power_sustained_limit_t sustainedGet = {};
|
||||
pSysfsAccess->mockReadReturnStatus.push_back(ZE_RESULT_ERROR_NOT_AVAILABLE);
|
||||
pSysfsAccess->isRepeated = true;
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, pLinuxPowerImp->setLimits(&sustainedSet, nullptr, nullptr));
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, pLinuxPowerImp->getLimits(&sustainedGet, nullptr, nullptr));
|
||||
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(SysmanDevicePowerFixtureI915, GivenReadingSustainedPowerNodeReturnErrorWhenGetPowerLimitsForSustainedPowerWhenHwmonInterfaceExistThenProperErrorCodesReturned) {
|
||||
|
||||
auto pSysFsAccess = std::make_unique<MockPowerSysfsAccessInterface>();
|
||||
pSysFsAccess->mockReadReturnStatus.push_back(ZE_RESULT_ERROR_NOT_AVAILABLE);
|
||||
std::unique_ptr<PublicLinuxPowerImp> pLinuxPowerImp(new PublicLinuxPowerImp(pOsSysman, false, 0));
|
||||
pLinuxPowerImp->pSysfsAccess = pSysFsAccess.get();
|
||||
pLinuxPowerImp->pPmt = static_cast<MockPowerPmt *>(pLinuxSysmanImp->getPlatformMonitoringTechAccess(0));
|
||||
pLinuxPowerImp->isPowerModuleSupported();
|
||||
auto handles = getPowerHandles(powerHandleComponentCount);
|
||||
|
||||
zes_power_sustained_limit_t sustainedGet = {};
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, pLinuxPowerImp->getLimits(&sustainedGet, nullptr, nullptr));
|
||||
pSysfsAccess->mockReadReturnStatus.push_back(ZE_RESULT_ERROR_NOT_AVAILABLE);
|
||||
|
||||
for (auto handle : handles) {
|
||||
zes_power_sustained_limit_t sustainedGet = {};
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zesPowerGetLimits(handle, &sustainedGet, nullptr, nullptr));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixtureI915, GivenReadingSustainedPowerIntervalNodeReturnErrorWhenGetPowerLimitsForSustainedPowerWhenHwmonInterfaceExistThenProperErrorCodesReturned) {
|
||||
|
||||
auto pSysFsAccess = std::make_unique<MockPowerSysfsAccessInterface>();
|
||||
pSysFsAccess->mockReadReturnStatus.push_back(ZE_RESULT_ERROR_NOT_AVAILABLE);
|
||||
std::unique_ptr<PublicLinuxPowerImp> pLinuxPowerImp(new PublicLinuxPowerImp(pOsSysman, false, 0));
|
||||
pLinuxPowerImp->pSysfsAccess = pSysFsAccess.get();
|
||||
pLinuxPowerImp->pPmt = static_cast<MockPowerPmt *>(pLinuxSysmanImp->getPlatformMonitoringTechAccess(0));
|
||||
pLinuxPowerImp->isPowerModuleSupported();
|
||||
auto handles = getPowerHandles(powerHandleComponentCount);
|
||||
|
||||
zes_power_sustained_limit_t sustainedGet = {};
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, pLinuxPowerImp->getLimits(&sustainedGet, nullptr, nullptr));
|
||||
pSysfsAccess->mockReadReturnStatus.push_back(ZE_RESULT_ERROR_NOT_AVAILABLE);
|
||||
|
||||
for (auto handle : handles) {
|
||||
zes_power_sustained_limit_t sustainedGet = {};
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zesPowerGetLimits(handle, &sustainedGet, nullptr, nullptr));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixtureI915, GivenwritingSustainedPowerNodeReturnErrorWhenSetPowerLimitsForSustainedPowerWhenHwmonInterfaceExistThenProperErrorCodesReturned) {
|
||||
|
||||
auto pSysFsAccess = std::make_unique<MockPowerSysfsAccessInterface>();
|
||||
pSysFsAccess->mockWriteReturnStatus.push_back(ZE_RESULT_ERROR_NOT_AVAILABLE);
|
||||
std::unique_ptr<PublicLinuxPowerImp> pLinuxPowerImp(new PublicLinuxPowerImp(pOsSysman, false, 0));
|
||||
pLinuxPowerImp->pSysfsAccess = pSysFsAccess.get();
|
||||
pLinuxPowerImp->pPmt = static_cast<MockPowerPmt *>(pLinuxSysmanImp->getPlatformMonitoringTechAccess(0));
|
||||
pLinuxPowerImp->isPowerModuleSupported();
|
||||
auto handles = getPowerHandles(powerHandleComponentCount);
|
||||
|
||||
pSysfsAccess->mockWriteReturnStatus.push_back(ZE_RESULT_ERROR_NOT_AVAILABLE);
|
||||
|
||||
zes_power_sustained_limit_t sustainedSet = {};
|
||||
sustainedSet.enabled = 1;
|
||||
sustainedSet.interval = 10;
|
||||
sustainedSet.power = 300000;
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, pLinuxPowerImp->setLimits(&sustainedSet, nullptr, nullptr));
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zesPowerSetLimits(handles[0], &sustainedSet, nullptr, nullptr));
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixtureI915, GivenwritingSustainedPowerIntervalNodeReturnErrorWhenSetPowerLimitsForSustainedPowerIntervalWhenHwmonInterfaceExistThenProperErrorCodesReturned) {
|
||||
auto pSysFsAccess = std::make_unique<MockPowerSysfsAccessInterface>();
|
||||
pSysFsAccess->mockWriteReturnStatus.push_back(ZE_RESULT_ERROR_NOT_AVAILABLE);
|
||||
std::unique_ptr<PublicLinuxPowerImp> pLinuxPowerImp(new PublicLinuxPowerImp(pOsSysman, false, 0));
|
||||
pLinuxPowerImp->pSysfsAccess = pSysFsAccess.get();
|
||||
pLinuxPowerImp->pPmt = static_cast<MockPowerPmt *>(pLinuxSysmanImp->getPlatformMonitoringTechAccess(0));
|
||||
pLinuxPowerImp->isPowerModuleSupported();
|
||||
auto handles = getPowerHandles(powerHandleComponentCount);
|
||||
|
||||
pSysfsAccess->mockWriteReturnStatus.push_back(ZE_RESULT_ERROR_NOT_AVAILABLE);
|
||||
|
||||
zes_power_sustained_limit_t sustainedSet = {};
|
||||
sustainedSet.enabled = 1;
|
||||
sustainedSet.interval = 10;
|
||||
sustainedSet.power = 300000;
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, pLinuxPowerImp->setLimits(&sustainedSet, nullptr, nullptr));
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zesPowerSetLimits(handles[0], &sustainedSet, nullptr, nullptr));
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixtureI915, GivenValidPowerHandleWhenWritingToSustainedPowerEnableNodeWithoutPermissionsThenValidErrorIsReturned) {
|
||||
|
||||
auto pSysFsAccess = std::make_unique<MockPowerSysfsAccessInterface>();
|
||||
pSysFsAccess->mockWriteReturnStatus.push_back(ZE_RESULT_ERROR_INSUFFICIENT_PERMISSIONS);
|
||||
std::unique_ptr<PublicLinuxPowerImp> pLinuxPowerImp(new PublicLinuxPowerImp(pOsSysman, false, 0));
|
||||
pLinuxPowerImp->pSysfsAccess = pSysFsAccess.get();
|
||||
pLinuxPowerImp->pPmt = static_cast<MockPowerPmt *>(pLinuxSysmanImp->getPlatformMonitoringTechAccess(0));
|
||||
pLinuxPowerImp->isPowerModuleSupported();
|
||||
auto handles = getPowerHandles(powerHandleComponentCount);
|
||||
|
||||
pSysfsAccess->mockWriteReturnStatus.push_back(ZE_RESULT_ERROR_INSUFFICIENT_PERMISSIONS);
|
||||
|
||||
zes_power_sustained_limit_t sustainedSet = {};
|
||||
sustainedSet.enabled = 0;
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_INSUFFICIENT_PERMISSIONS, pLinuxPowerImp->setLimits(&sustainedSet, nullptr, nullptr));
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_INSUFFICIENT_PERMISSIONS, zesPowerSetLimits(handles[0], &sustainedSet, nullptr, nullptr));
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixtureI915, GivenValidPowerHandleAndPermissionsThenFirstDisableSustainedPowerLimitAndThenEnableItAndCheckSuccesIsReturned) {
|
||||
|
||||
auto pSysFsAccess = std::make_unique<MockPowerSysfsAccessInterface>();
|
||||
std::unique_ptr<PublicLinuxPowerImp> pLinuxPowerImp(new PublicLinuxPowerImp(pOsSysman, false, 0));
|
||||
pLinuxPowerImp->pSysfsAccess = pSysFsAccess.get();
|
||||
pLinuxPowerImp->pPmt = static_cast<MockPowerPmt *>(pLinuxSysmanImp->getPlatformMonitoringTechAccess(0));
|
||||
pLinuxPowerImp->isPowerModuleSupported();
|
||||
|
||||
auto handles = getPowerHandles(powerHandleComponentCount);
|
||||
zes_power_sustained_limit_t sustainedSet = {};
|
||||
zes_power_sustained_limit_t sustainedGet = {};
|
||||
sustainedSet.enabled = 0;
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, pLinuxPowerImp->setLimits(&sustainedSet, nullptr, nullptr));
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesPowerSetLimits(handles[0], &sustainedSet, nullptr, nullptr));
|
||||
sustainedSet.enabled = 1;
|
||||
sustainedSet.interval = 10;
|
||||
sustainedSet.power = 300000;
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, pLinuxPowerImp->setLimits(&sustainedSet, nullptr, nullptr));
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, pLinuxPowerImp->getLimits(&sustainedGet, nullptr, nullptr));
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesPowerSetLimits(handles[0], &sustainedSet, nullptr, nullptr));
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesPowerGetLimits(handles[0], &sustainedGet, nullptr, nullptr));
|
||||
EXPECT_EQ(sustainedGet.enabled, sustainedSet.enabled);
|
||||
EXPECT_EQ(sustainedGet.power, sustainedSet.power);
|
||||
EXPECT_EQ(sustainedGet.interval, sustainedSet.interval);
|
||||
@@ -394,27 +375,24 @@ TEST_F(SysmanDevicePowerFixtureI915, GivenValidPowerHandleAndPermissionsThenFirs
|
||||
|
||||
TEST_F(SysmanDevicePowerFixtureI915, GivenGetPowerLimitsWhenPowerLimitsAreDisabledWhenHwmonInterfaceExistThenAllPowerValuesAreIgnored) {
|
||||
|
||||
auto pSysFsAccess = std::make_unique<MockPowerSysfsAccessInterface>();
|
||||
pSysFsAccess->mockReadReturnStatus.push_back(ZE_RESULT_SUCCESS);
|
||||
pSysFsAccess->mockReadUnsignedLongValue.push_back(0);
|
||||
std::unique_ptr<PublicLinuxPowerImp> pLinuxPowerImp(new PublicLinuxPowerImp(pOsSysman, false, 0));
|
||||
pLinuxPowerImp->pSysfsAccess = pSysFsAccess.get();
|
||||
pLinuxPowerImp->pPmt = static_cast<MockPowerPmt *>(pLinuxSysmanImp->getPlatformMonitoringTechAccess(0));
|
||||
pLinuxPowerImp->isPowerModuleSupported();
|
||||
auto handles = getPowerHandles(powerHandleComponentCount);
|
||||
|
||||
pSysfsAccess->mockReadReturnStatus.push_back(ZE_RESULT_SUCCESS);
|
||||
pSysfsAccess->mockReadUnsignedLongValue.push_back(0);
|
||||
|
||||
zes_power_sustained_limit_t sustainedGet = {};
|
||||
zes_power_burst_limit_t burstGet = {};
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, pLinuxPowerImp->getLimits(&sustainedGet, nullptr, nullptr));
|
||||
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, pLinuxPowerImp->getLimits(nullptr, &burstGet, nullptr));
|
||||
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, pLinuxPowerImp->setLimits(&sustainedGet, nullptr, nullptr));
|
||||
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, pLinuxPowerImp->setLimits(nullptr, &burstSet, nullptr));
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesPowerSetLimits(handles[0], nullptr, &burstSet, nullptr));
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixtureI915, GivenScanDirectoriesFailAndPmtIsNotNullPointerThenPowerModuleIsSupported) {
|
||||
@@ -487,52 +465,77 @@ TEST_F(SysmanDevicePowerFixtureI915, GivenComponentCountZeroWhenEnumeratingPower
|
||||
|
||||
TEST_F(SysmanDevicePowerFixtureI915, GivenValidPowerHandleWhenGettingPowerPropertiesThenCallSucceeds) {
|
||||
|
||||
auto pSysFsAccess = std::make_unique<MockPowerSysfsAccessInterface>();
|
||||
pSysFsAccess->mockScanDirEntriesReturnStatus.push_back(ZE_RESULT_ERROR_NOT_AVAILABLE);
|
||||
pSysFsAccess->isRepeated = true;
|
||||
pSysfsAccess->mockScanDirEntriesReturnStatus.push_back(ZE_RESULT_ERROR_NOT_AVAILABLE);
|
||||
pSysfsAccess->isRepeated = true;
|
||||
|
||||
std::unique_ptr<PublicLinuxPowerImp> pLinuxPowerImp(new PublicLinuxPowerImp(pOsSysman, false, 0));
|
||||
pLinuxPowerImp->pSysfsAccess = pSysFsAccess.get();
|
||||
pLinuxPowerImp->isPowerModuleSupported();
|
||||
for (const auto &handle : pSysmanDeviceImp->pPowerHandleContext->handleList) {
|
||||
delete handle;
|
||||
}
|
||||
pSysmanDeviceImp->pPowerHandleContext->handleList.clear();
|
||||
pSysmanDeviceImp->pPowerHandleContext->init(pLinuxSysmanImp->getSubDeviceCount());
|
||||
auto handles = getPowerHandles(powerHandleComponentCount);
|
||||
|
||||
zes_power_properties_t properties{};
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, pLinuxPowerImp->getProperties(&properties));
|
||||
EXPECT_FALSE(properties.onSubdevice);
|
||||
EXPECT_EQ(properties.subdeviceId, 0u);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixtureI915, GivenValidPowerHandleWhenGettingPowerEnergyCounterThenValidPowerReadingsRetrieved) {
|
||||
|
||||
auto pSysFsAccess = std::make_unique<MockPowerSysfsAccessInterface>();
|
||||
pSysFsAccess->mockScanDirEntriesReturnStatus.push_back(ZE_RESULT_ERROR_NOT_AVAILABLE);
|
||||
pSysFsAccess->isRepeated = true;
|
||||
pSysfsAccess->mockScanDirEntriesReturnStatus.push_back(ZE_RESULT_ERROR_NOT_AVAILABLE);
|
||||
pSysfsAccess->isRepeated = true;
|
||||
|
||||
auto pPmt = static_cast<MockPowerPmt *>(pLinuxSysmanImp->getPlatformMonitoringTechAccess(0));
|
||||
pPmt->preadFunction = preadMockPower;
|
||||
for (const auto &handle : pSysmanDeviceImp->pPowerHandleContext->handleList) {
|
||||
delete handle;
|
||||
}
|
||||
pSysmanDeviceImp->pPowerHandleContext->handleList.clear();
|
||||
auto subDeviceCount = pLinuxSysmanImp->getSubDeviceCount();
|
||||
pSysmanDeviceImp->pPowerHandleContext->init(pLinuxSysmanImp->getSubDeviceCount());
|
||||
auto handles = getPowerHandles(powerHandleComponentCount);
|
||||
|
||||
std::unique_ptr<PublicLinuxPowerImp> pLinuxPowerImp(new PublicLinuxPowerImp(pOsSysman, false, 0));
|
||||
pLinuxPowerImp->pSysfsAccess = pSysFsAccess.get();
|
||||
pLinuxPowerImp->pPmt = pPmt;
|
||||
pLinuxPowerImp->isPowerModuleSupported();
|
||||
uint32_t subdeviceId = 0;
|
||||
do {
|
||||
auto pPmt = static_cast<MockPowerPmt *>(pLinuxSysmanImp->getPlatformMonitoringTechAccess(subdeviceId));
|
||||
pPmt->preadFunction = preadMockPower;
|
||||
} while (++subdeviceId < subDeviceCount);
|
||||
|
||||
zes_power_energy_counter_t energyCounter;
|
||||
uint64_t expectedEnergyCounter = convertJouleToMicroJoule * (setEnergyCounter / 1048576);
|
||||
ASSERT_EQ(ZE_RESULT_SUCCESS, pLinuxPowerImp->getEnergyCounter(&energyCounter));
|
||||
EXPECT_EQ(energyCounter.energy, expectedEnergyCounter);
|
||||
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(SysmanDevicePowerFixtureI915, GivenValidPowerHandleWhenGettingPowerEnergyCounterWhenEnergyHwmonFileReturnsErrorAndPmtFailsThenFailureIsReturned) {
|
||||
|
||||
auto pSysFsAccess = std::make_unique<MockPowerSysfsAccessInterface>();
|
||||
pSysFsAccess->mockReadReturnStatus.push_back(ZE_RESULT_ERROR_NOT_AVAILABLE);
|
||||
pSysFsAccess->isRepeated = true;
|
||||
std::unique_ptr<PublicLinuxPowerImp> pLinuxPowerImp(new PublicLinuxPowerImp(pOsSysman, false, 0));
|
||||
pLinuxPowerImp->pSysfsAccess = pSysFsAccess.get();
|
||||
pLinuxPowerImp->pPmt = nullptr;
|
||||
pLinuxPowerImp->isPowerModuleSupported();
|
||||
pSysfsAccess->mockReadReturnStatus.push_back(ZE_RESULT_ERROR_NOT_AVAILABLE);
|
||||
pSysfsAccess->isRepeated = true;
|
||||
|
||||
zes_power_energy_counter_t energyCounter = {};
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, pLinuxPowerImp->getEnergyCounter(&energyCounter));
|
||||
for (const auto &handle : pSysmanDeviceImp->pPowerHandleContext->handleList) {
|
||||
delete handle;
|
||||
}
|
||||
for (auto &subDeviceIdToPmtEntry : pLinuxSysmanImp->mapOfSubDeviceIdToPmtObject) {
|
||||
delete subDeviceIdToPmtEntry.second;
|
||||
}
|
||||
auto subDeviceCount = pLinuxSysmanImp->getSubDeviceCount();
|
||||
uint32_t subdeviceId = 0;
|
||||
pLinuxSysmanImp->mapOfSubDeviceIdToPmtObject.clear();
|
||||
do {
|
||||
pLinuxSysmanImp->mapOfSubDeviceIdToPmtObject.emplace(subdeviceId, nullptr);
|
||||
} while (++subdeviceId < subDeviceCount);
|
||||
|
||||
pSysmanDeviceImp->pPowerHandleContext->handleList.clear();
|
||||
pSysmanDeviceImp->pPowerHandleContext->init(subDeviceCount);
|
||||
auto handles = getPowerHandles(powerHandleComponentCount);
|
||||
|
||||
for (auto handle : handles) {
|
||||
zes_power_energy_counter_t energyCounter = {};
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zesPowerGetEnergyCounter(handle, &energyCounter));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixtureI915, GivenValidPowerHandleWhenGettingPowerEnergyThresholdThenUnsupportedFeatureErrorIsReturned) {
|
||||
@@ -593,71 +596,78 @@ TEST_F(SysmanDevicePowerFixtureI915, GivenValidPowerHandleWhenSettingPowerEnergy
|
||||
|
||||
TEST_F(SysmanDevicePowerFixtureI915, GivenValidPowerHandleWhenGettingPowerLimitsThenUnsupportedFeatureErrorIsReturned) {
|
||||
|
||||
auto pSysFsAccess = std::make_unique<MockPowerSysfsAccessInterface>();
|
||||
pSysFsAccess->mockScanDirEntriesReturnStatus.push_back(ZE_RESULT_ERROR_NOT_AVAILABLE);
|
||||
pSysFsAccess->isRepeated = true;
|
||||
auto pPmt = static_cast<MockPowerPmt *>(pLinuxSysmanImp->getPlatformMonitoringTechAccess(0));
|
||||
std::unique_ptr<PublicLinuxPowerImp> pLinuxPowerImp(new PublicLinuxPowerImp(pOsSysman, false, 0));
|
||||
pLinuxPowerImp->pSysfsAccess = pSysFsAccess.get();
|
||||
pLinuxPowerImp->pPmt = pPmt;
|
||||
pLinuxPowerImp->isPowerModuleSupported();
|
||||
pSysfsAccess->mockScanDirEntriesReturnStatus.push_back(ZE_RESULT_ERROR_NOT_AVAILABLE);
|
||||
pSysfsAccess->isRepeated = true;
|
||||
|
||||
zes_power_sustained_limit_t sustained;
|
||||
zes_power_burst_limit_t burst;
|
||||
zes_power_peak_limit_t peak;
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, pLinuxPowerImp->getLimits(&sustained, &burst, &peak));
|
||||
for (const auto &handle : pSysmanDeviceImp->pPowerHandleContext->handleList) {
|
||||
delete handle;
|
||||
}
|
||||
pSysmanDeviceImp->pPowerHandleContext->handleList.clear();
|
||||
pSysmanDeviceImp->pPowerHandleContext->init(pLinuxSysmanImp->getSubDeviceCount());
|
||||
auto handles = getPowerHandles(powerHandleComponentCount);
|
||||
for (auto handle : handles) {
|
||||
zes_power_sustained_limit_t sustained;
|
||||
zes_power_burst_limit_t burst;
|
||||
zes_power_peak_limit_t peak;
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zesPowerGetLimits(handle, &sustained, &burst, &peak));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixtureI915, GivenValidPowerHandleWhenSettingPowerLimitsThenUnsupportedFeatureErrorIsReturned) {
|
||||
|
||||
auto pSysFsAccess = std::make_unique<MockPowerSysfsAccessInterface>();
|
||||
pSysFsAccess->mockScanDirEntriesReturnStatus.push_back(ZE_RESULT_ERROR_NOT_AVAILABLE);
|
||||
pSysFsAccess->isRepeated = true;
|
||||
auto pPmt = static_cast<MockPowerPmt *>(pLinuxSysmanImp->getPlatformMonitoringTechAccess(0));
|
||||
std::unique_ptr<PublicLinuxPowerImp> pLinuxPowerImp(new PublicLinuxPowerImp(pOsSysman, false, 0));
|
||||
pLinuxPowerImp->pSysfsAccess = pSysFsAccess.get();
|
||||
pLinuxPowerImp->pPmt = pPmt;
|
||||
pLinuxPowerImp->isPowerModuleSupported();
|
||||
pSysfsAccess->mockScanDirEntriesReturnStatus.push_back(ZE_RESULT_ERROR_NOT_AVAILABLE);
|
||||
pSysfsAccess->isRepeated = true;
|
||||
|
||||
zes_power_sustained_limit_t sustained;
|
||||
zes_power_burst_limit_t burst;
|
||||
zes_power_peak_limit_t peak;
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, pLinuxPowerImp->setLimits(&sustained, &burst, &peak));
|
||||
for (const auto &handle : pSysmanDeviceImp->pPowerHandleContext->handleList) {
|
||||
delete handle;
|
||||
}
|
||||
pSysmanDeviceImp->pPowerHandleContext->handleList.clear();
|
||||
pSysmanDeviceImp->pPowerHandleContext->init(pLinuxSysmanImp->getSubDeviceCount());
|
||||
auto handles = getPowerHandles(powerHandleComponentCount);
|
||||
for (auto handle : handles) {
|
||||
zes_power_sustained_limit_t sustained;
|
||||
zes_power_burst_limit_t burst;
|
||||
zes_power_peak_limit_t peak;
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zesPowerSetLimits(handle, &sustained, &burst, &peak));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerMultiDeviceFixture, GivenValidPowerHandleWhenGettingPowerEnergyCounterWhenEnergyHwmonFailsThenValidPowerReadingsRetrievedFromPmt) {
|
||||
|
||||
auto pSysFsAccess = std::make_unique<MockPowerSysfsAccessInterface>();
|
||||
pSysFsAccess->mockScanDirEntriesReturnStatus.push_back(ZE_RESULT_ERROR_NOT_AVAILABLE);
|
||||
pSysFsAccess->isRepeated = true;
|
||||
pSysfsAccess->mockScanDirEntriesReturnStatus.push_back(ZE_RESULT_ERROR_NOT_AVAILABLE);
|
||||
pSysfsAccess->isRepeated = true;
|
||||
|
||||
auto pPmt = static_cast<MockPowerPmt *>(pLinuxSysmanImp->getPlatformMonitoringTechAccess(0));
|
||||
pPmt->preadFunction = preadMockPower;
|
||||
for (const auto &handle : pSysmanDeviceImp->pPowerHandleContext->handleList) {
|
||||
delete handle;
|
||||
}
|
||||
pSysmanDeviceImp->pPowerHandleContext->handleList.clear();
|
||||
auto subDeviceCount = pLinuxSysmanImp->getSubDeviceCount();
|
||||
pSysmanDeviceImp->pPowerHandleContext->init(pLinuxSysmanImp->getSubDeviceCount());
|
||||
auto handles = getPowerHandles(powerHandleComponentCount);
|
||||
|
||||
std::unique_ptr<PublicLinuxPowerImp> pLinuxPowerImp(new PublicLinuxPowerImp(pOsSysman, false, 0));
|
||||
pLinuxPowerImp->pSysfsAccess = pSysFsAccess.get();
|
||||
pLinuxPowerImp->pPmt = pPmt;
|
||||
pLinuxPowerImp->isPowerModuleSupported();
|
||||
uint32_t subdeviceId = 0;
|
||||
do {
|
||||
auto pPmt = static_cast<MockPowerPmt *>(pLinuxSysmanImp->getPlatformMonitoringTechAccess(subdeviceId));
|
||||
pPmt->preadFunction = preadMockPower;
|
||||
} while (++subdeviceId < subDeviceCount);
|
||||
|
||||
zes_power_energy_counter_t energyCounter;
|
||||
uint64_t expectedEnergyCounter = convertJouleToMicroJoule * (setEnergyCounter / 1048576);
|
||||
ASSERT_EQ(ZE_RESULT_SUCCESS, pLinuxPowerImp->getEnergyCounter(&energyCounter));
|
||||
EXPECT_EQ(energyCounter.energy, expectedEnergyCounter);
|
||||
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(SysmanDevicePowerFixtureI915, GivenValidPowerHandlesWhenCallingSetAndGetPowerLimitExtWhenHwmonInterfaceExistThenUnsupportedFeatureIsReturned) {
|
||||
|
||||
auto pSysFsAccess = std::make_unique<MockPowerSysfsAccessInterface>();
|
||||
auto pPmt = static_cast<MockPowerPmt *>(pLinuxSysmanImp->getPlatformMonitoringTechAccess(0));
|
||||
std::unique_ptr<PublicLinuxPowerImp> pLinuxPowerImp(new PublicLinuxPowerImp(pOsSysman, false, 0));
|
||||
pLinuxPowerImp->pSysfsAccess = pSysFsAccess.get();
|
||||
pLinuxPowerImp->pPmt = pPmt;
|
||||
pLinuxPowerImp->isPowerModuleSupported();
|
||||
auto handles = getPowerHandles(powerHandleComponentCount);
|
||||
for (auto handle : handles) {
|
||||
uint32_t limitCount = 0;
|
||||
|
||||
uint32_t limitCount = 0;
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, pLinuxPowerImp->getLimitsExt(&limitCount, nullptr));
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, pLinuxPowerImp->setLimitsExt(&limitCount, nullptr));
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zesPowerGetLimitsExt(handle, &limitCount, nullptr));
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zesPowerSetLimitsExt(handle, &limitCount, nullptr));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixtureI915, GivenValidPowerHandleWhenGettingPowerPropertiesExtThenApiReturnsFailure) {
|
||||
@@ -674,25 +684,21 @@ TEST_F(SysmanDevicePowerFixtureI915, GivenValidPowerHandleWhenGettingPowerProper
|
||||
|
||||
TEST_F(SysmanDevicePowerFixtureI915, GivenValidPowerHandleWhenGettingPowerPropertiesExtWithoutStypeThenExtPropertiesAreNotReturned) {
|
||||
|
||||
auto pSysFsAccess = std::make_unique<MockPowerSysfsAccessInterface>();
|
||||
auto pPmt = static_cast<MockPowerPmt *>(pLinuxSysmanImp->getPlatformMonitoringTechAccess(0));
|
||||
std::unique_ptr<PublicLinuxPowerImp> pLinuxPowerImp(new PublicLinuxPowerImp(pOsSysman, false, 0));
|
||||
pLinuxPowerImp->pSysfsAccess = pSysFsAccess.get();
|
||||
pLinuxPowerImp->pPmt = pPmt;
|
||||
pLinuxPowerImp->isPowerModuleSupported();
|
||||
auto handles = getPowerHandles(powerHandleComponentCount);
|
||||
for (auto handle : handles) {
|
||||
zes_power_properties_t properties = {};
|
||||
zes_power_ext_properties_t extProperties = {};
|
||||
|
||||
zes_power_properties_t properties = {};
|
||||
zes_power_ext_properties_t extProperties = {};
|
||||
|
||||
properties.pNext = &extProperties;
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, pLinuxPowerImp->getProperties(&properties));
|
||||
EXPECT_FALSE(properties.onSubdevice);
|
||||
EXPECT_EQ(properties.subdeviceId, 0u);
|
||||
EXPECT_EQ(properties.canControl, true);
|
||||
EXPECT_EQ(properties.isEnergyThresholdSupported, false);
|
||||
EXPECT_EQ(properties.defaultLimit, static_cast<int32_t>(mockDefaultPowerLimitVal / milliFactor));
|
||||
EXPECT_EQ(properties.maxLimit, static_cast<int32_t>(mockMaxPowerLimitVal / milliFactor));
|
||||
EXPECT_EQ(properties.minLimit, static_cast<int32_t>(mockMinPowerLimitVal / milliFactor));
|
||||
properties.pNext = &extProperties;
|
||||
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, static_cast<int32_t>(mockDefaultPowerLimitVal / milliFactor));
|
||||
EXPECT_EQ(properties.maxLimit, static_cast<int32_t>(mockMaxPowerLimitVal / milliFactor));
|
||||
EXPECT_EQ(properties.minLimit, static_cast<int32_t>(mockMinPowerLimitVal / milliFactor));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(SysmanDevicePowerFixtureXe, GivenKmdInterfaceWhenGettingSysFsFilenamesForPowerForXeVersionThenProperPathsAreReturned) {
|
||||
|
||||
@@ -11,20 +11,17 @@ namespace L0 {
|
||||
namespace Sysman {
|
||||
namespace ult {
|
||||
|
||||
constexpr uint32_t powerHandleComponentCount = 1u;
|
||||
using SysmanDevicePowerFixtureHelper = SysmanDevicePowerFixtureI915;
|
||||
|
||||
TEST_F(SysmanDevicePowerFixtureHelper, GivenValidPowerHandleWhenGettingPowerEnergyCounterThenValidPowerReadingsRetrieved) {
|
||||
|
||||
auto pSysFsAccess = std::make_unique<MockPowerSysfsAccessInterface>();
|
||||
auto pPmt = static_cast<MockPowerPmt *>(pLinuxSysmanImp->getPlatformMonitoringTechAccess(0));
|
||||
std::unique_ptr<PublicLinuxPowerImp> pLinuxPowerImp(new PublicLinuxPowerImp(pOsSysman, false, 0));
|
||||
pLinuxPowerImp->pSysfsAccess = pSysFsAccess.get();
|
||||
pLinuxPowerImp->pPmt = pPmt;
|
||||
pLinuxPowerImp->isPowerModuleSupported();
|
||||
|
||||
zes_power_energy_counter_t energyCounter = {};
|
||||
ASSERT_EQ(ZE_RESULT_SUCCESS, pLinuxPowerImp->getEnergyCounter(&energyCounter));
|
||||
EXPECT_EQ(energyCounter.energy, expectedEnergyCounter);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
using SysmanDevicePowerMultiDeviceFixtureHelper = SysmanDevicePowerMultiDeviceFixture;
|
||||
|
||||
@@ -107,13 +107,6 @@ class PublicLinuxStandbyImp : public L0::Sysman::LinuxStandbyImp {
|
||||
using L0::Sysman::LinuxStandbyImp::pSysmanKmdInterface;
|
||||
};
|
||||
|
||||
class PublicSysmanKmdInterfaceI915 : public L0::Sysman::SysmanKmdInterfaceI915Upstream {
|
||||
public:
|
||||
PublicSysmanKmdInterfaceI915(const PRODUCT_FAMILY productFamily) : L0::Sysman::SysmanKmdInterfaceI915Upstream(productFamily) {}
|
||||
~PublicSysmanKmdInterfaceI915() override = default;
|
||||
using L0::Sysman::SysmanKmdInterface::pSysfsAccess;
|
||||
};
|
||||
|
||||
} // namespace ult
|
||||
} // namespace Sysman
|
||||
} // namespace L0
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/sysman/source/shared/linux/sysman_kmd_interface.h"
|
||||
#include "level_zero/sysman/test/unit_tests/sources/linux/mock_sysman_fixture.h"
|
||||
#include "level_zero/sysman/test/unit_tests/sources/standby/linux/mock_sysfs_standby.h"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user