Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cts] Generate conformance tests for adapters #799

Merged
merged 1 commit into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
lukaszstolarczuk marked this conversation as resolved.
Show resolved Hide resolved
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)
lukaszstolarczuk marked this conversation as resolved.
Show resolved Hide resolved
add_conformance_test_with_devices_environment(adapter-hip
hip_fixtures.h
hip_urContextGetNativeHandle.cpp
Expand Down