@@ -338,4 +338,100 @@ TEST_F(
338338 }
339339}
340340
341+ TEST_F (
342+ VF_MANAGEMENT_TEST,
343+ GivenValidDeviceWhenRetrievingVfEngineUtilizationThenExpectValidUtilization) {
344+ for (auto device : devices) {
345+ uint32_t count = lzt::get_vf_handles_count (device);
346+ if (count > 0 ) {
347+ is_vf_enabled = true ;
348+ LOG_INFO << " VF is enabled on this device!!" ;
349+ auto vf_handles = lzt::get_vf_handles (device, count);
350+
351+ for (const auto &vf_handle : vf_handles) {
352+ uint32_t engine_util_count = lzt::get_vf_engine_util_count (vf_handle);
353+ ASSERT_GT (engine_util_count, 0 );
354+ auto vf_engine_util =
355+ lzt::get_vf_engine_util (vf_handle, engine_util_count);
356+
357+ for (const auto &engine_util : vf_engine_util) {
358+ EXPECT_GE (engine_util.vfEngineType , ZES_ENGINE_GROUP_ALL);
359+ EXPECT_LE (engine_util.vfEngineType ,
360+ ZES_ENGINE_GROUP_MEDIA_CODEC_SINGLE);
361+ EXPECT_GT (engine_util.activeCounterValue , 0 );
362+ EXPECT_GT (engine_util.samplingCounterValue , 0 );
363+ }
364+ }
365+ } else {
366+ LOG_INFO << " No VF handles found for this device!!" ;
367+ }
368+ }
369+
370+ if (!is_vf_enabled) {
371+ FAIL () << " No VF handles found in any of the devices!!" ;
372+ }
373+ }
374+
375+ TEST_F (
376+ VF_MANAGEMENT_TEST,
377+ GivenValidDeviceWhenRetrievingVfEngineUtilizationWithCountGreaterThanActualThenExpectActualCountIsReturned) {
378+ for (auto device : devices) {
379+ uint32_t count = lzt::get_vf_handles_count (device);
380+ if (count > 0 ) {
381+ is_vf_enabled = true ;
382+ LOG_INFO << " VF is enabled on this device!!" ;
383+ auto vf_handles = lzt::get_vf_handles (device, count);
384+
385+ for (const auto &vf_handle : vf_handles) {
386+ uint32_t engine_util_count = lzt::get_vf_engine_util_count (vf_handle);
387+ ASSERT_GT (engine_util_count, 0 );
388+ uint32_t test_count = engine_util_count + 1 ;
389+ auto vf_engine_util =
390+ lzt::get_vf_engine_util (vf_handle, engine_util_count);
391+ EXPECT_EQ (test_count, engine_util_count);
392+ }
393+ } else {
394+ LOG_INFO << " No VF handles found for this device!!" ;
395+ }
396+ }
397+
398+ if (!is_vf_enabled) {
399+ FAIL () << " No VF handles found in any of the devices!!" ;
400+ }
401+ }
402+
403+ TEST_F (
404+ VF_MANAGEMENT_TEST,
405+ GivenValidDeviceWhenRetrievingVfEngineUtilizationWithCountLessThanActualThenExpectReducedCountIsReturned) {
406+ for (auto device : devices) {
407+ uint32_t count = lzt::get_vf_handles_count (device);
408+ if (count > 0 ) {
409+ is_vf_enabled = true ;
410+ LOG_INFO << " VF is enabled on this device!!" ;
411+ auto vf_handles = lzt::get_vf_handles (device, count);
412+
413+ for (const auto &vf_handle : vf_handles) {
414+ uint32_t engine_util_count = lzt::get_vf_engine_util_count (vf_handle);
415+ ASSERT_GT (engine_util_count, 0 );
416+
417+ if (engine_util_count > 1 ) {
418+ uint32_t test_count = engine_util_count - 1 ;
419+ auto vf_engine_util =
420+ lzt::get_vf_engine_util (vf_handle, engine_util_count);
421+ EXPECT_EQ (test_count, engine_util_count - 1 );
422+ } else {
423+ LOG_INFO << " Insufficient number of engine util count to validate "
424+ " this test" ;
425+ }
426+ }
427+ } else {
428+ LOG_INFO << " No VF handles found for this device!!" ;
429+ }
430+ }
431+
432+ if (!is_vf_enabled) {
433+ FAIL () << " No VF handles found in any of the devices!!" ;
434+ }
435+ }
436+
341437} // namespace
0 commit comments