Skip to content

Commit

Permalink
Generate conformance test cases with adapters
Browse files Browse the repository at this point in the history
  • Loading branch information
wlemkows committed Aug 16, 2023
1 parent 9b9b970 commit 22b92af
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 9 deletions.
42 changes: 34 additions & 8 deletions test/conformance/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@

set(UR_CONFORMANCE_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR})

function(add_test_adapter name adapter)
set(TEST_TARGET_NAME test-${name})
set(TEST_NAME ${name}-${adapter})
add_test(NAME ${TEST_NAME}
COMMAND ${TEST_TARGET_NAME}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
set_tests_properties(${TEST_NAME} PROPERTIES
ENVIRONMENT "UR_ADAPTERS_FORCE_LOAD=\"$<TARGET_FILE:ur_${adapter}>\""
LABELS "conformance;${adapter}")
endfunction()

function(add_conformance_test name)
set(TEST_TARGET_NAME test-${name})
add_ur_executable(${TEST_TARGET_NAME}
Expand All @@ -18,10 +29,27 @@ function(add_conformance_test name)
${PROJECT_NAME}::testing
${PROJECT_NAME}::common
GTest::gtest_main)
add_test(NAME ${name}
COMMAND ${TEST_TARGET_NAME}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
set_tests_properties(${name} PROPERTIES LABELS "conformance")

if(USE_LOCAL_TEST_CONFIGURATION)
add_test(NAME ${name}
COMMAND ${TEST_TARGET_NAME}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
else()
if(UR_BUILD_ADAPTER_CUDA)
add_test_adapter(${name} adapter_cuda)
endif()
if(UR_BUILD_ADAPTER_HIP)
add_test_adapter(${name} adapter_hip)
endif()
if(UR_BUILD_ADAPTER_L0)
add_test_adapter(${name} adapter_level_zero)
endif()

if(NOT (UR_BUILD_ADAPTER_CUDA
OR UR_BUILD_ADAPTER_HIP OR UR_BUILD_ADAPTER_L0))
add_test_adapter(${name} adapter_null)
endif()
endif()
endfunction()

function(add_conformance_test_with_kernels_environment name)
Expand All @@ -33,14 +61,12 @@ function(add_conformance_test_with_kernels_environment name)
endfunction()

function(add_conformance_test_with_devices_environment name)
add_conformance_test(${name}
${ARGN})
add_conformance_test(${name} ${ARGN})
target_compile_definitions("test-${name}" PRIVATE DEVICES_ENVIRONMENT)
endfunction()

function(add_conformance_test_with_platform_environment name)
add_conformance_test(${name}
${ARGN})
add_conformance_test(${name} ${ARGN})
target_compile_definitions("test-${name}" PRIVATE PLATFORM_ENVIRONMENT)
endfunction()

Expand Down
3 changes: 2 additions & 1 deletion test/conformance/adapters/cuda/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
# See LICENSE.TXT
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

add_conformance_test_with_devices_environment(adapter-cuda
set(USE_LOCAL_TEST_CONFIGURATION ON)
add_conformance_test_with_devices_environment(adapter-cuda
cuda_fixtures.h
context_tests.cpp
cuda_urContextGetNativeHandle.cpp
Expand Down
1 change: 1 addition & 0 deletions test/conformance/adapters/hip/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# See LICENSE.TXT
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

set(USE_LOCAL_TEST_CONFIGURATION ON)
add_conformance_test_with_devices_environment(adapter-hip
hip_fixtures.h
hip_urContextGetNativeHandle.cpp
Expand Down

0 comments on commit 22b92af

Please sign in to comment.