@@ -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 ()
164162endfunction ()
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+
166180add_subdirectory (common)
167181
168182if (UMF_BUILD_SHARED_LIBRARY)
@@ -435,21 +449,9 @@ else()
435449endif ()
436450
437451if (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)
453455endif ()
454456
455457if (UMF_BUILD_GPU_TESTS AND UMF_LEVEL_ZERO_ENABLED)
0 commit comments