mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 14:02:58 +08:00
Update sysfs path for setting standby mode
Related-To: LOCI-2734 Signed-off-by: Bellekallu Rajkiran <bellekallu.rajkiran@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
f00cae09d6
commit
ede0123561
@@ -7,12 +7,16 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shared/test/common/test_macros/mock_method_macros.h"
|
||||
|
||||
#include "level_zero/tools/source/sysman/standby/linux/os_standby_imp.h"
|
||||
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
|
||||
const std::string standbyModeFile("power/rc6_enable");
|
||||
const std::string standbyModeFile("gt/gt0/rc6_enable");
|
||||
const std::string standbyModeFile1("gt/gt1/rc6_enable");
|
||||
const std::string standbyModeFileLegacy("power/rc6_enable");
|
||||
|
||||
class StandbySysfsAccess : public SysfsAccess {};
|
||||
|
||||
@@ -24,6 +28,7 @@ struct Mock<StandbySysfsAccess> : public StandbySysfsAccess {
|
||||
MOCK_METHOD(ze_result_t, read, (const std::string file, int &val), (override));
|
||||
MOCK_METHOD(ze_result_t, write, (const std::string file, int val), (override));
|
||||
MOCK_METHOD(ze_result_t, canRead, (const std::string file), (override));
|
||||
ADDMETHOD_NOBASE(directoryExists, bool, true, (const std::string path));
|
||||
|
||||
ze_result_t getCanReadStatus(const std::string file) {
|
||||
if (isFileAccessible(file) == true) {
|
||||
@@ -80,7 +85,7 @@ struct Mock<StandbySysfsAccess> : public StandbySysfsAccess {
|
||||
|
||||
private:
|
||||
bool isFileAccessible(const std::string file) {
|
||||
if ((file.compare(standbyModeFile) == 0) && (isStandbyModeFileAvailable == true)) {
|
||||
if (((file.compare(standbyModeFile) == 0) || (file.compare(standbyModeFile1) == 0) || (file.compare(standbyModeFileLegacy) == 0)) && (isStandbyModeFileAvailable == true)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -27,6 +27,7 @@ class ZesStandbyFixture : public SysmanDeviceFixture {
|
||||
std::unique_ptr<Mock<StandbySysfsAccess>> ptestSysfsAccess;
|
||||
zes_standby_handle_t hSysmanStandby = {};
|
||||
SysfsAccess *pOriginalSysfsAccess = nullptr;
|
||||
std::vector<ze_device_handle_t> deviceHandles;
|
||||
|
||||
void SetUp() override {
|
||||
if (!sysmanUltsEnable) {
|
||||
@@ -48,7 +49,6 @@ class ZesStandbyFixture : public SysmanDeviceFixture {
|
||||
}
|
||||
pSysmanDeviceImp->pStandbyHandleContext->handleList.clear();
|
||||
uint32_t subDeviceCount = 0;
|
||||
std::vector<ze_device_handle_t> deviceHandles;
|
||||
// We received a device handle. Check for subdevices in this device
|
||||
Device::fromHandle(device->toHandle())->getSubDevices(&subDeviceCount, nullptr);
|
||||
if (subDeviceCount == 0) {
|
||||
@@ -259,6 +259,52 @@ TEST_F(ZesStandbyFixture, GivenOnSubdeviceNotSetWhenValidatingosStandbyGetProper
|
||||
delete pLinuxStandbyImp;
|
||||
}
|
||||
|
||||
TEST_F(ZesStandbyFixture, GivenValidStandbyHandleWhenCallingzesStandbySetModeDefaultWithLegacyPathThenVerifySysmanzesySetModeCallSucceeds) {
|
||||
for (auto handle : pSysmanDeviceImp->pStandbyHandleContext->handleList) {
|
||||
delete handle;
|
||||
}
|
||||
pSysmanDeviceImp->pStandbyHandleContext->handleList.clear();
|
||||
ptestSysfsAccess->directoryExistsResult = false;
|
||||
pSysmanDeviceImp->pStandbyHandleContext->init(deviceHandles);
|
||||
|
||||
auto handles = get_standby_handles(mockHandleCount);
|
||||
|
||||
for (auto hSysmanStandby : handles) {
|
||||
zes_standby_promo_mode_t mode;
|
||||
ptestSysfsAccess->setVal(standbyModeFile, standbyModeNever);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesStandbyGetMode(hSysmanStandby, &mode));
|
||||
EXPECT_EQ(ZES_STANDBY_PROMO_MODE_NEVER, mode);
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesStandbySetMode(hSysmanStandby, ZES_STANDBY_PROMO_MODE_DEFAULT));
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesStandbyGetMode(hSysmanStandby, &mode));
|
||||
EXPECT_EQ(ZES_STANDBY_PROMO_MODE_DEFAULT, mode);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(ZesStandbyFixture, GivenValidStandbyHandleWhenCallingzesStandbySetModeNeverWithLegacyPathThenVerifySysmanzesySetModeCallSucceeds) {
|
||||
for (auto handle : pSysmanDeviceImp->pStandbyHandleContext->handleList) {
|
||||
delete handle;
|
||||
}
|
||||
pSysmanDeviceImp->pStandbyHandleContext->handleList.clear();
|
||||
ptestSysfsAccess->directoryExistsResult = false;
|
||||
pSysmanDeviceImp->pStandbyHandleContext->init(deviceHandles);
|
||||
|
||||
auto handles = get_standby_handles(mockHandleCount);
|
||||
|
||||
for (auto hSysmanStandby : handles) {
|
||||
zes_standby_promo_mode_t mode;
|
||||
ptestSysfsAccess->setVal(standbyModeFile, standbyModeDefault);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesStandbyGetMode(hSysmanStandby, &mode));
|
||||
EXPECT_EQ(ZES_STANDBY_PROMO_MODE_DEFAULT, mode);
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesStandbySetMode(hSysmanStandby, ZES_STANDBY_PROMO_MODE_NEVER));
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zesStandbyGetMode(hSysmanStandby, &mode));
|
||||
EXPECT_EQ(ZES_STANDBY_PROMO_MODE_NEVER, mode);
|
||||
}
|
||||
}
|
||||
|
||||
class ZesStandbyMultiDeviceFixture : public SysmanMultiDeviceFixture {
|
||||
std::unique_ptr<Mock<StandbySysfsAccess>> ptestSysfsAccess;
|
||||
SysfsAccess *pOriginalSysfsAccess = nullptr;
|
||||
|
||||
Reference in New Issue
Block a user