Skip to content

Commit e83c803

Browse files
authored
[Offload] Split offload unittests into multiple files (#142418)
Rather than a single `offload.unittests` file, this will produce `device.unittests`, `event.unittests`, etc.. This should reduce time spent building tests, and make it easier to manually run a subset of the tests. Note that `check-offload-unit` will still run all the tests.
1 parent 11713e8 commit e83c803

File tree

2 files changed

+41
-25
lines changed

2 files changed

+41
-25
lines changed

offload/unittests/CMakeLists.txt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,17 @@ add_custom_target(OffloadUnitTests)
22
set_target_properties(OffloadUnitTests PROPERTIES FOLDER "Tests/UnitTests")
33

44
function(add_offload_unittest test_dirname)
5-
add_unittest(OffloadUnitTests ${test_dirname} ${ARGN})
5+
set(target_name "${test_dirname}.unittests")
6+
7+
list(TRANSFORM ARGN PREPEND "${CMAKE_CURRENT_SOURCE_DIR}/" OUTPUT_VARIABLE files)
8+
9+
add_unittest(OffloadUnitTests "${target_name}"
10+
${CMAKE_CURRENT_SOURCE_DIR}/common/Environment.cpp
11+
${files})
12+
add_dependencies(${target_name} ${PLUGINS_TEST_COMMON} OffloadUnitTestsDeviceBins)
13+
target_compile_definitions(${target_name} PRIVATE DEVICE_CODE_PATH="${OFFLOAD_TEST_DEVICE_CODE_PATH}")
14+
target_link_libraries(${target_name} PRIVATE ${PLUGINS_TEST_COMMON})
15+
target_include_directories(${target_name} PRIVATE ${PLUGINS_TEST_INCLUDE})
616
endfunction()
717

818
add_subdirectory(OffloadAPI)

offload/unittests/OffloadAPI/CMakeLists.txt

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,33 @@ set(PLUGINS_TEST_INCLUDE ${LIBOMPTARGET_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}
33

44
add_subdirectory(device_code)
55

6-
add_offload_unittest("offload.unittests"
7-
${CMAKE_CURRENT_SOURCE_DIR}/common/Environment.cpp
8-
${CMAKE_CURRENT_SOURCE_DIR}/platform/olGetPlatformInfo.cpp
9-
${CMAKE_CURRENT_SOURCE_DIR}/platform/olGetPlatformInfoSize.cpp
10-
${CMAKE_CURRENT_SOURCE_DIR}/device/olIterateDevices.cpp
11-
${CMAKE_CURRENT_SOURCE_DIR}/device/olGetDeviceInfo.cpp
12-
${CMAKE_CURRENT_SOURCE_DIR}/device/olGetDeviceInfoSize.cpp
13-
${CMAKE_CURRENT_SOURCE_DIR}/queue/olCreateQueue.cpp
14-
${CMAKE_CURRENT_SOURCE_DIR}/queue/olWaitQueue.cpp
15-
${CMAKE_CURRENT_SOURCE_DIR}/queue/olDestroyQueue.cpp
16-
${CMAKE_CURRENT_SOURCE_DIR}/memory/olMemAlloc.cpp
17-
${CMAKE_CURRENT_SOURCE_DIR}/memory/olMemFree.cpp
18-
${CMAKE_CURRENT_SOURCE_DIR}/memory/olMemcpy.cpp
19-
${CMAKE_CURRENT_SOURCE_DIR}/program/olCreateProgram.cpp
20-
${CMAKE_CURRENT_SOURCE_DIR}/program/olDestroyProgram.cpp
21-
${CMAKE_CURRENT_SOURCE_DIR}/kernel/olGetKernel.cpp
22-
${CMAKE_CURRENT_SOURCE_DIR}/kernel/olLaunchKernel.cpp
23-
${CMAKE_CURRENT_SOURCE_DIR}/event/olDestroyEvent.cpp
24-
${CMAKE_CURRENT_SOURCE_DIR}/event/olWaitEvent.cpp
25-
)
26-
add_dependencies("offload.unittests" ${PLUGINS_TEST_COMMON} OffloadUnitTestsDeviceBins)
27-
target_compile_definitions("offload.unittests" PRIVATE DEVICE_CODE_PATH="${OFFLOAD_TEST_DEVICE_CODE_PATH}")
28-
target_link_libraries("offload.unittests" PRIVATE ${PLUGINS_TEST_COMMON})
29-
target_include_directories("offload.unittests" PRIVATE ${PLUGINS_TEST_INCLUDE})
6+
add_offload_unittest("device"
7+
device/olIterateDevices.cpp
8+
device/olGetDeviceInfo.cpp
9+
device/olGetDeviceInfoSize.cpp)
10+
11+
add_offload_unittest("event"
12+
event/olDestroyEvent.cpp
13+
event/olWaitEvent.cpp)
14+
15+
add_offload_unittest("kernel"
16+
kernel/olGetKernel.cpp
17+
kernel/olLaunchKernel.cpp)
18+
19+
add_offload_unittest("memory"
20+
memory/olMemAlloc.cpp
21+
memory/olMemFree.cpp
22+
memory/olMemcpy.cpp)
23+
24+
add_offload_unittest("platform"
25+
platform/olGetPlatformInfo.cpp
26+
platform/olGetPlatformInfoSize.cpp)
27+
28+
add_offload_unittest("program"
29+
program/olCreateProgram.cpp
30+
program/olDestroyProgram.cpp)
31+
32+
add_offload_unittest("queue"
33+
queue/olCreateQueue.cpp
34+
queue/olWaitQueue.cpp
35+
queue/olDestroyQueue.cpp)

0 commit comments

Comments
 (0)