Skip to content

Commit 3144053

Browse files
committed
test: Add Sysman VF Management CTS
Related-To: VLCLJ-2312 Signed-off-by: Vishnu Khanth <[email protected]>
1 parent 3986f1c commit 3144053

File tree

3 files changed

+121
-7
lines changed

3 files changed

+121
-7
lines changed

conformance_tests/sysman/test_sysman_vf_management/src/test_sysman_vf_management.cpp

Lines changed: 100 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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

utils/test_harness/sysman/include/test_harness_sysman_vf_management.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ uint32_t get_vf_handles_count(zes_device_handle_t device);
1717
std::vector<zes_vf_handle_t> get_vf_handles(zes_device_handle_t device,
1818
uint32_t &count);
1919
zes_vf_exp_capabilities_t get_vf_capabilities(zes_vf_handle_t vf_handle);
20+
uint32_t get_vf_mem_util_count(zes_vf_handle_t vf_handle);
21+
std::vector<zes_vf_util_mem_exp2_t> get_vf_mem_util(zes_vf_handle_t vf_handle,
22+
uint32_t &count);
2023

2124
} // namespace level_zero_tests
2225

utils/test_harness/sysman/src/test_harness_sysman_vf_management.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,22 @@ zes_vf_exp_capabilities_t get_vf_capabilities(zes_vf_handle_t vf_handle) {
3838
return vf_capabilities;
3939
}
4040

41+
uint32_t get_vf_mem_util_count(zes_vf_handle_t vf_handle) {
42+
uint32_t count = 0;
43+
EXPECT_EQ(ZE_RESULT_SUCCESS, zesVFManagementGetVFMemoryUtilizationExp2(
44+
vf_handle, &count, nullptr));
45+
return count;
46+
}
47+
48+
std::vector<zes_vf_util_mem_exp2_t> get_vf_mem_util(zes_vf_handle_t vf_handle,
49+
uint32_t &count) {
50+
if (count == 0) {
51+
count = get_vf_mem_util_count(vf_handle);
52+
}
53+
std::vector<zes_vf_util_mem_exp2_t> vf_util_mem_exp(count);
54+
EXPECT_EQ(ZE_RESULT_SUCCESS, zesVFManagementGetVFMemoryUtilizationExp2(
55+
vf_handle, &count, vf_util_mem_exp.data()));
56+
return vf_util_mem_exp;
57+
}
58+
4159
} // namespace level_zero_tests

0 commit comments

Comments
 (0)