@@ -76,7 +76,7 @@ TEST_F(
7676 }
7777
7878 if (!is_vf_enabled) {
79- FAIL () << " No VF handles found in all devices!!" ;
79+ FAIL () << " No VF handles found in any of the devices!!" ;
8080 }
8181}
8282
@@ -108,7 +108,7 @@ TEST_F(
108108 }
109109
110110 if (!is_vf_enabled) {
111- FAIL () << " No VF handles found in all devices!!" ;
111+ FAIL () << " No VF handles found in any of the devices!!" ;
112112 }
113113}
114114
@@ -134,7 +134,7 @@ TEST_F(
134134 }
135135
136136 if (!is_vf_enabled) {
137- FAIL () << " No VF handles found in all devices!!" ;
137+ FAIL () << " No VF handles found in any of the devices!!" ;
138138 }
139139}
140140
@@ -162,7 +162,7 @@ TEST_F(
162162 }
163163
164164 if (!is_vf_enabled) {
165- FAIL () << " No VF handles found in all devices!!" ;
165+ FAIL () << " No VF handles found in any of the devices!!" ;
166166 }
167167}
168168
@@ -186,7 +186,7 @@ TEST_F(
186186 }
187187
188188 if (!is_vf_enabled) {
189- FAIL () << " No VF handles found in all devices!!" ;
189+ FAIL () << " No VF handles found in any of the devices!!" ;
190190 }
191191}
192192
@@ -211,7 +211,7 @@ TEST_F(
211211 }
212212
213213 if (!is_vf_enabled) {
214- FAIL () << " No VF handles found in all devices!!" ;
214+ FAIL () << " No VF handles found in any of the devices!!" ;
215215 }
216216}
217217
@@ -241,7 +241,100 @@ TEST_F(VF_MANAGEMENT_TEST,
241241 }
242242
243243 if (!is_vf_enabled) {
244- FAIL () << " No VF handles found in all devices!!" ;
244+ FAIL () << " No VF handles found in any of the devices!!" ;
245+ }
246+ }
247+
248+ TEST_F (
249+ VF_MANAGEMENT_TEST,
250+ GivenValidDeviceWhenRetrievingVfMemoryUtilizationThenExpectValidUtilization) {
251+ for (auto device : devices) {
252+ uint32_t count = lzt::get_vf_handles_count (device);
253+ if (count > 0 ) {
254+ is_vf_enabled = true ;
255+ LOG_INFO << " VF is enabled on this device!!" ;
256+ auto vf_handles = lzt::get_vf_handles (device, count);
257+
258+ for (const auto &vf_handle : vf_handles) {
259+ auto vf_capabilities = lzt::get_vf_capabilities (vf_handle);
260+ uint32_t mem_util_count = lzt::get_vf_mem_util_count (vf_handle);
261+ ASSERT_GT (mem_util_count, 0 );
262+ auto vf_mem_util = lzt::get_vf_mem_util (vf_handle, mem_util_count);
263+
264+ for (const auto &mem_util : vf_mem_util) {
265+ EXPECT_GE (mem_util.vfMemLocation , ZES_MEM_LOC_SYSTEM);
266+ EXPECT_LE (mem_util.vfMemLocation , ZES_MEM_LOC_DEVICE);
267+ EXPECT_GT (mem_util.vfMemUtilized , 0 );
268+ EXPECT_LE (mem_util.vfMemUtilized , vf_capabilities.vfDeviceMemSize );
269+ }
270+ }
271+ } else {
272+ LOG_INFO << " No VF handles found for this device!!" ;
273+ }
274+ }
275+
276+ if (!is_vf_enabled) {
277+ FAIL () << " No VF handles found in any of the devices!!" ;
278+ }
279+ }
280+
281+ TEST_F (
282+ VF_MANAGEMENT_TEST,
283+ GivenValidDeviceWhenRetrievingVfMemoryUtilizationWithCountGreaterThanActualThenExpectActualCountIsReturned) {
284+ for (auto device : devices) {
285+ uint32_t count = lzt::get_vf_handles_count (device);
286+ if (count > 0 ) {
287+ is_vf_enabled = true ;
288+ LOG_INFO << " VF is enabled on this device!!" ;
289+ auto vf_handles = lzt::get_vf_handles (device, count);
290+
291+ for (const auto &vf_handle : vf_handles) {
292+ uint32_t mem_util_count = lzt::get_vf_mem_util_count (vf_handle);
293+ ASSERT_GT (mem_util_count, 0 );
294+ uint32_t test_count = mem_util_count + 1 ;
295+ auto vf_mem_util = lzt::get_vf_mem_util (vf_handle, test_count);
296+ EXPECT_EQ (test_count, mem_util_count);
297+ }
298+ } else {
299+ LOG_INFO << " No VF handles found for this device!!" ;
300+ }
301+ }
302+
303+ if (!is_vf_enabled) {
304+ FAIL () << " No VF handles found in any of the devices!!" ;
305+ }
306+ }
307+
308+ TEST_F (
309+ VF_MANAGEMENT_TEST,
310+ GivenValidDeviceWhenRetrievingVfMemoryUtilizationWithCountLessThanActualThenExpectReducedCountIsReturned) {
311+ for (auto device : devices) {
312+ uint32_t count = lzt::get_vf_handles_count (device);
313+ if (count > 0 ) {
314+ is_vf_enabled = true ;
315+ LOG_INFO << " VF is enabled on this device!!" ;
316+ auto vf_handles = lzt::get_vf_handles (device, count);
317+
318+ for (const auto &vf_handle : vf_handles) {
319+ uint32_t mem_util_count = lzt::get_vf_mem_util_count (vf_handle);
320+ ASSERT_GT (mem_util_count, 0 );
321+
322+ if (mem_util_count > 1 ) {
323+ uint32_t test_count = mem_util_count - 1 ;
324+ auto vf_mem_util = lzt::get_vf_mem_util (vf_handle, test_count);
325+ EXPECT_EQ (test_count, mem_util_count - 1 );
326+ } else {
327+ LOG_INFO
328+ << " Insufficient number of mem util count to validate this test" ;
329+ }
330+ }
331+ } else {
332+ LOG_INFO << " No VF handles found for this device!!" ;
333+ }
334+ }
335+
336+ if (!is_vf_enabled) {
337+ FAIL () << " No VF handles found in any of the devices!!" ;
245338 }
246339}
247340
0 commit comments