@@ -100,34 +100,9 @@ TEST_F(SysmanDevicePowerFixtureI915, GivenValidPowerHandleWhenGettingPowerProper
100100 EXPECT_EQ (properties.canControl , true );
101101 EXPECT_EQ (properties.isEnergyThresholdSupported , false );
102102 EXPECT_EQ (properties.defaultLimit , static_cast <int32_t >(mockDefaultPowerLimitVal / milliFactor));
103- EXPECT_EQ (properties.maxLimit , static_cast <int32_t >(mockMaxPowerLimitVal / milliFactor));
104- EXPECT_EQ (properties.minLimit , static_cast <int32_t >(mockMinPowerLimitVal / milliFactor));
105- }
106- }
107-
108- TEST_F (SysmanDevicePowerFixtureI915, GivenValidMockMutexPowerImpWhenGettingPowerPropertiesThenMutexLockCounterMatchesNumberOfGetCalls) {
109- class MockMutexPowerImp : public L0 ::Sysman::LinuxPowerImp {
110- public:
111- using L0::Sysman::LinuxPowerImp::pSysfsAccess;
112- MockMutexPowerImp (L0::Sysman::OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId) : L0::Sysman::LinuxPowerImp(pOsSysman, onSubdevice, subdeviceId) {}
113- uint32_t mutexLockCounter = 0 ;
114- std::unique_lock<std::mutex> obtainMutex () override {
115- mutexLockCounter++;
116- std::unique_lock<std::mutex> mutexLock = L0::Sysman::LinuxPowerImp::obtainMutex ();
117- EXPECT_TRUE (mutexLock.owns_lock ());
118- return mutexLock;
119- }
120- };
121-
122- std::unique_ptr<MockMutexPowerImp> pLinuxPowerImp (new MockMutexPowerImp (pOsSysman, false , 0 ));
123- pLinuxPowerImp->pSysfsAccess = pSysfsAccess;
124-
125- zes_power_properties_t properties{};
126- uint32_t testReadCount = 0 ;
127- for (uint32_t i = 0 ; i < testReadCount; i++) {
128- EXPECT_EQ (ZE_RESULT_SUCCESS, pLinuxPowerImp->getProperties (&properties));
103+ EXPECT_EQ (properties.maxLimit , static_cast <int32_t >(mockDefaultPowerLimitVal / milliFactor));
104+ EXPECT_EQ (properties.minLimit , -1 );
129105 }
130- EXPECT_EQ (pLinuxPowerImp->mutexLockCounter , testReadCount);
131106}
132107
133108TEST_F (SysmanDevicePowerFixtureI915, GivenValidPowerHandleWhenGettingPowerPropertiesAndExtPropertiesThenCallSucceeds) {
@@ -148,8 +123,8 @@ TEST_F(SysmanDevicePowerFixtureI915, GivenValidPowerHandleWhenGettingPowerProper
148123 EXPECT_EQ (properties.canControl , true );
149124 EXPECT_EQ (properties.isEnergyThresholdSupported , false );
150125 EXPECT_EQ (properties.defaultLimit , (int32_t )(mockDefaultPowerLimitVal / milliFactor));
151- EXPECT_EQ (properties.maxLimit , (int32_t )(mockMaxPowerLimitVal / milliFactor));
152- EXPECT_EQ (properties.minLimit , ( int32_t )(mockMinPowerLimitVal / milliFactor) );
126+ EXPECT_EQ (properties.maxLimit , (int32_t )(mockDefaultPowerLimitVal / milliFactor));
127+ EXPECT_EQ (properties.minLimit , - 1 );
153128 EXPECT_EQ (extProperties.domain , ZES_POWER_DOMAIN_CARD);
154129 EXPECT_TRUE (defaultLimit.limitValueLocked );
155130 EXPECT_TRUE (defaultLimit.enabledStateLocked );
@@ -177,8 +152,8 @@ TEST_F(SysmanDevicePowerFixtureI915, GivenValidPowerHandleWithNoStypeForExtPrope
177152 EXPECT_EQ (properties.canControl , true );
178153 EXPECT_EQ (properties.isEnergyThresholdSupported , false );
179154 EXPECT_EQ (properties.defaultLimit , (int32_t )(mockDefaultPowerLimitVal / milliFactor));
180- EXPECT_EQ (properties.maxLimit , (int32_t )(mockMaxPowerLimitVal / milliFactor));
181- EXPECT_EQ (properties.minLimit , ( int32_t )(mockMinPowerLimitVal / milliFactor) );
155+ EXPECT_EQ (properties.maxLimit , (int32_t )(mockDefaultPowerLimitVal / milliFactor));
156+ EXPECT_EQ (properties.minLimit , - 1 );
182157 }
183158}
184159
@@ -194,102 +169,6 @@ TEST_F(SysmanDevicePowerFixtureI915, GivenValidPowerHandleWhenGettingPowerProper
194169 EXPECT_EQ (properties.defaultLimit , -1 );
195170}
196171
197- TEST_F (SysmanDevicePowerFixtureI915, GivenValidPowerHandleWhenGettingPowerPropertiesAndSustainedLimitReadFailsThenFailureIsReturned) {
198- std::unique_ptr<PublicLinuxPowerImp> pLinuxPowerImp (new PublicLinuxPowerImp (pOsSysman, false , 0 ));
199- pLinuxPowerImp->pSysfsAccess = pSysfsAccess;
200- pLinuxPowerImp->pPmt = static_cast <MockPowerPmt *>(pLinuxSysmanImp->getPlatformMonitoringTechAccess (0 ));
201- pLinuxPowerImp->isPowerModuleSupported ();
202-
203- pSysfsAccess->mockReadValUnsignedLongResult .push_back (ZE_RESULT_SUCCESS);
204- pSysfsAccess->mockReadValUnsignedLongResult .push_back (ZE_RESULT_ERROR_NOT_AVAILABLE);
205- zes_power_properties_t properties{};
206- EXPECT_EQ (ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, pLinuxPowerImp->getProperties (&properties));
207- EXPECT_EQ (properties.minLimit , -1 );
208- EXPECT_EQ (properties.maxLimit , -1 );
209- }
210-
211- TEST_F (SysmanDevicePowerFixtureI915, GivenValidPowerHandleWhenGettingPowerPropertiesAndMinLimitReadFailsThenFailureIsReturned) {
212- std::unique_ptr<PublicLinuxPowerImp> pLinuxPowerImp (new PublicLinuxPowerImp (pOsSysman, false , 0 ));
213- pLinuxPowerImp->pSysfsAccess = pSysfsAccess;
214- pLinuxPowerImp->pPmt = static_cast <MockPowerPmt *>(pLinuxSysmanImp->getPlatformMonitoringTechAccess (0 ));
215- pLinuxPowerImp->isPowerModuleSupported ();
216-
217- pSysfsAccess->mockReadValUnsignedLongResult .push_back (ZE_RESULT_SUCCESS);
218- pSysfsAccess->mockReadValUnsignedLongResult .push_back (ZE_RESULT_SUCCESS);
219- pSysfsAccess->mockReadValUnsignedLongResult .push_back (ZE_RESULT_ERROR_NOT_AVAILABLE);
220- zes_power_properties_t properties{};
221- EXPECT_EQ (ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, pLinuxPowerImp->getProperties (&properties));
222- EXPECT_EQ (properties.minLimit , -1 );
223- }
224-
225- TEST_F (SysmanDevicePowerFixtureI915, GivenValidPowerHandleWhenGettingPowerPropertiesAndMaxLimitReadFailsThenFailureIsReturned) {
226- std::unique_ptr<PublicLinuxPowerImp> pLinuxPowerImp (new PublicLinuxPowerImp (pOsSysman, false , 0 ));
227- pLinuxPowerImp->pSysfsAccess = pSysfsAccess;
228- pLinuxPowerImp->pPmt = static_cast <MockPowerPmt *>(pLinuxSysmanImp->getPlatformMonitoringTechAccess (0 ));
229- pLinuxPowerImp->isPowerModuleSupported ();
230-
231- pSysfsAccess->mockReadValUnsignedLongResult .push_back (ZE_RESULT_SUCCESS);
232- pSysfsAccess->mockReadValUnsignedLongResult .push_back (ZE_RESULT_SUCCESS);
233- pSysfsAccess->mockReadValUnsignedLongResult .push_back (ZE_RESULT_SUCCESS);
234- pSysfsAccess->mockReadValUnsignedLongResult .push_back (ZE_RESULT_ERROR_NOT_AVAILABLE);
235- zes_power_properties_t properties{};
236- EXPECT_EQ (ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, pLinuxPowerImp->getProperties (&properties));
237- EXPECT_EQ (properties.maxLimit , -1 );
238- }
239-
240- TEST_F (SysmanDevicePowerFixtureI915, GivenValidPowerHandleWhenGettingPowerPropertiesAndSysfsWriteForMinLimitFailsThenFailureIsReturned) {
241- std::unique_ptr<PublicLinuxPowerImp> pLinuxPowerImp (new PublicLinuxPowerImp (pOsSysman, false , 0 ));
242- pLinuxPowerImp->pSysfsAccess = pSysfsAccess;
243- pLinuxPowerImp->pPmt = static_cast <MockPowerPmt *>(pLinuxSysmanImp->getPlatformMonitoringTechAccess (0 ));
244- pLinuxPowerImp->isPowerModuleSupported ();
245-
246- pSysfsAccess->mockWriteUnsignedResult .push_back (ZE_RESULT_ERROR_NOT_AVAILABLE);
247- zes_power_properties_t properties{};
248- EXPECT_EQ (ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, pLinuxPowerImp->getProperties (&properties));
249- EXPECT_EQ (properties.minLimit , -1 );
250- }
251-
252- TEST_F (SysmanDevicePowerFixtureI915, GivenValidPowerHandleWhenGettingPowerPropertiesAndSysfsWriteForMaxLimitFailsThenFailureIsReturned) {
253- std::unique_ptr<PublicLinuxPowerImp> pLinuxPowerImp (new PublicLinuxPowerImp (pOsSysman, false , 0 ));
254- pLinuxPowerImp->pSysfsAccess = pSysfsAccess;
255- pLinuxPowerImp->pPmt = static_cast <MockPowerPmt *>(pLinuxSysmanImp->getPlatformMonitoringTechAccess (0 ));
256- pLinuxPowerImp->isPowerModuleSupported ();
257-
258- pSysfsAccess->mockWriteUnsignedResult .push_back (ZE_RESULT_SUCCESS);
259- pSysfsAccess->mockWriteUnsignedResult .push_back (ZE_RESULT_ERROR_NOT_AVAILABLE);
260- zes_power_properties_t properties{};
261- EXPECT_EQ (ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, pLinuxPowerImp->getProperties (&properties));
262- EXPECT_EQ (properties.maxLimit , -1 );
263- }
264-
265- HWTEST2_F (SysmanDevicePowerFixtureI915, GivenValidPowerHandleWhenGettingPowerPropertiesAndSysfsWriteToOriginalLimitFailsThenVerifySustainedLimitIsMaximum, IsPVC) {
266- std::unique_ptr<PublicLinuxPowerImp> pLinuxPowerImp (new PublicLinuxPowerImp (pOsSysman, false , 0 ));
267- pLinuxPowerImp->pSysfsAccess = pSysfsAccess;
268- pLinuxPowerImp->pPmt = static_cast <MockPowerPmt *>(pLinuxSysmanImp->getPlatformMonitoringTechAccess (0 ));
269- pLinuxPowerImp->isPowerModuleSupported ();
270-
271- pSysfsAccess->mockWriteUnsignedResult .push_back (ZE_RESULT_SUCCESS);
272- pSysfsAccess->mockWriteUnsignedResult .push_back (ZE_RESULT_SUCCESS);
273- pSysfsAccess->mockWriteUnsignedResult .push_back (ZE_RESULT_ERROR_NOT_AVAILABLE);
274- zes_power_properties_t properties{};
275- EXPECT_EQ (ZE_RESULT_SUCCESS, pLinuxPowerImp->getProperties (&properties));
276-
277- std::vector<zes_power_limit_ext_desc_t > allLimits (mockLimitCount);
278- auto handles = getPowerHandles (powerHandleComponentCount);
279- for (auto handle : handles) {
280- ASSERT_NE (nullptr , handle);
281- uint32_t limitCount = mockLimitCount;
282- EXPECT_EQ (ZE_RESULT_SUCCESS, zesPowerGetLimitsExt (handle, &limitCount, allLimits.data ()));
283- for (uint32_t i = 0 ; i < limitCount; i++) {
284- if (allLimits[i].level == ZES_POWER_LEVEL_SUSTAINED) {
285- EXPECT_EQ (ZES_POWER_SOURCE_ANY, allLimits[i].source );
286- EXPECT_EQ (ZES_LIMIT_UNIT_POWER, allLimits[i].limitUnit );
287- EXPECT_EQ (allLimits[i].limit , (int32_t )(mockMaxPowerLimitVal / milliFactor));
288- }
289- }
290- }
291- }
292-
293172TEST_F (SysmanDevicePowerFixtureI915, GivenValidPowerHandleWhenGettingPowerEnergyCounterFailedWhenHwmonInterfaceExistThenValidErrorCodeReturned) {
294173 auto handles = getPowerHandles (powerHandleComponentCount);
295174 auto subDeviceCount = pLinuxSysmanImp->getSubDeviceCount ();
0 commit comments