Skip to content

Commit 57acba7

Browse files
committed
simplify cmake and UMF_ZE_LOADER_LIB_NAME use
1 parent e0af7eb commit 57acba7

File tree

3 files changed

+27
-25
lines changed

3 files changed

+27
-25
lines changed

src/provider/provider_level_zero.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,9 @@ static umf_result_t ze_memory_provider_alloc_helper(void *provider, size_t size,
513513
}
514514

515515
if (ze_result != ZE_RESULT_SUCCESS) {
516+
LOG_ERR("failed to allocate memory, type:%d, size:%lu, alignment:%lu, "
517+
"result:%d",
518+
ze_provider->memory_type, size, alignment, ze_result);
516519
return ze2umf_result(ze_result);
517520
}
518521

test/CMakeLists.txt

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,7 @@ function(add_umf_test)
151151
set(DLL_PATH_LIST
152152
"${DLL_PATH_LIST};"
153153
"PATH=path_list_append:${CMAKE_BINARY_DIR}/bin/;"
154-
"PATH=path_list_append:${CMAKE_BINARY_DIR}/bin/$<CONFIG>/;"
155-
"PATH=path_list_append:${CMAKE_BINARY_DIR}/test/common/;"
156-
"PATH=path_list_append:${CMAKE_BINARY_DIR}/test/common/$<CONFIG>/")
154+
"PATH=path_list_append:${CMAKE_BINARY_DIR}/bin/$<CONFIG>/")
157155

158156
# append PATH to DLLs NOTE: this would work only for the CMake ver >= #
159157
# 3.22. For the older versions, the PATH variable should be set in the
@@ -163,6 +161,22 @@ function(add_umf_test)
163161
endif()
164162
endfunction()
165163

164+
function(add_umf_mocked_test test_name test_source_file)
165+
add_umf_test(
166+
NAME ${test_name}
167+
SRCS ${test_source_file} ${UMF_UTILS_DIR}/utils_level_zero.cpp
168+
LIBS ${UMF_UTILS_FOR_TEST} ${UMF_BA_FOR_TEST} umf_test_mocks
169+
GTest::gmock)
170+
171+
set_tests_properties(
172+
test_${test_name} PROPERTIES
173+
ENVIRONMENT
174+
"UMF_LOG=level:debug\\\\\\\\;flush:debug\\\\\\\\;output:stdout;UMF_ZE_LOADER_LIB_NAME=$<TARGET_FILE:umf_ze_loopback>"
175+
)
176+
target_compile_definitions(test_${test_name} PUBLIC USE_DLOPEN=1)
177+
add_dependencies(test_${test_name} umf_ze_loopback)
178+
endfunction()
179+
166180
add_subdirectory(common)
167181

168182
if(UMF_BUILD_SHARED_LIBRARY)
@@ -435,21 +449,9 @@ else()
435449
endif()
436450

437451
if(UMF_BUILD_LEVEL_ZERO_PROVIDER)
438-
add_umf_test(
439-
NAME provider_level_zero_residency
440-
SRCS providers/provider_level_zero_residency.cpp
441-
${UMF_UTILS_DIR}/utils_level_zero.cpp
442-
LIBS ${UMF_UTILS_FOR_TEST} umf_ze_loopback umf_test_mocks GTest::gmock
443-
ENVS "UMF_LOG=level:debug\\\\\\\\;flush:debug\\\\\\\\;output:stdout")
444-
add_umf_test(
445-
NAME pool_residency
446-
SRCS pools/pool_residency.cpp ${UMF_UTILS_DIR}/utils_level_zero.cpp
447-
LIBS ${UMF_UTILS_FOR_TEST}
448-
${UMF_BA_FOR_TEST}
449-
umf_ze_loopback
450-
umf_test_mocks
451-
GTest::gmock
452-
ENVS "UMF_LOG=level:debug\\\\\\\\;flush:debug\\\\\\\\;output:stdout")
452+
add_umf_mocked_test(provider_level_zero_residency
453+
providers/provider_level_zero_residency.cpp)
454+
add_umf_mocked_test(pool_residency pools/pool_residency.cpp)
453455
endif()
454456

455457
if(UMF_BUILD_GPU_TESTS AND UMF_LEVEL_ZERO_ENABLED)

test/common/level_zero_mocks.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,9 @@ TestCreateMemoryAllocationProperties(uint32_t modifier) {
9696
}
9797

9898
void MockedLevelZeroTestEnvironment::SetUp() {
99-
#ifdef _WIN32
100-
const char *lib_name = "umf_ze_loopback.dll";
101-
_putenv_s("UMF_ZE_LOADER_LIB_NAME", lib_name);
102-
#else
103-
const char *lib_name = "libumf_ze_loopback.so";
104-
setenv("UMF_ZE_LOADER_LIB_NAME", lib_name, 1);
105-
#endif
99+
const char *lib_name = getenv("UMF_ZE_LOADER_LIB_NAME");
100+
ASSERT_NE(lib_name, nullptr);
101+
ASSERT_NE(lib_name[0], '\0');
106102

107103
lib_handle = utils_open_library(lib_name, 0);
108104
ASSERT_NE(lib_handle, nullptr);
@@ -116,6 +112,7 @@ void MockedLevelZeroTestEnvironment::SetUp() {
116112

117113
ASSERT_EQ(*l0interface, nullptr);
118114
}
115+
119116
void MockedLevelZeroTestEnvironment::TearDown() {
120117
utils_close_library(lib_handle);
121118
}

0 commit comments

Comments
 (0)