Skip to content

Commit a54a663

Browse files
RossBruntonaarongreig
authored andcommitted
Partially reapply "Move conformance tests over to lit" (#18382) (#18392)
This reverts commit 44ed9b74e290bbd3a00575af974194c7b3d07e35, but excludes the problematic changes to jobs.
1 parent c621767 commit a54a663

36 files changed

Lines changed: 176 additions & 510 deletions

CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ set(UR_SYCL_LIBRARY_DIR "" CACHE PATH
6565
set(UR_CONFORMANCE_TARGET_TRIPLES "" CACHE STRING
6666
"List of sycl targets to build CTS device binaries for")
6767
set(UR_CONFORMANCE_AMD_ARCH "" CACHE STRING "AMD device target ID to build CTS binaries for")
68-
option(UR_CONFORMANCE_ENABLE_MATCH_FILES "Enable CTS match files" ON)
69-
option(UR_CONFORMANCE_TEST_LOADER "Also test the loader in the conformance tests" OFF)
68+
set(UR_CONFORMANCE_SELECTOR "" CACHE STRING "If nonempty, the device selector for conformance tests")
7069
option(UR_USE_DEBUG_POSTFIX "Enable debug postfix 'd' for libraries" OFF)
7170
set(UR_ADAPTER_LEVEL_ZERO_SOURCE_DIR "" CACHE PATH
7271
"Path to external 'level_zero' adapter source dir")

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,7 @@ List of options provided by CMake:
127127
| UR_ENABLE_SANITIZER | Enable device sanitizer layer | ON/OFF | ON |
128128
| UR_CONFORMANCE_TARGET_TRIPLES | SYCL triples to build CTS device binaries for | Comma-separated list | spir64 |
129129
| UR_CONFORMANCE_AMD_ARCH | AMD device target ID to build CTS binaries for | string | `""` |
130-
| UR_CONFORMANCE_ENABLE_MATCH_FILES | Enable CTS match files | ON/OFF | ON |
131-
| UR_CONFORMANCE_TEST_LOADER | Additionally build and run "loader" tests for the CTS | ON/OFF | OFF |
130+
| UR_CONFORMANCE_SELECTOR | `ONEAPI_DEVICE_SELECTOR` for conformance testing | string | All enabled adapters |
132131
| UR_BUILD_ADAPTER_L0 | Build the Level-Zero adapter | ON/OFF | OFF |
133132
| UR_BUILD_ADAPTER_OPENCL | Build the OpenCL adapter | ON/OFF | OFF |
134133
| UR_BUILD_ADAPTER_CUDA | Build the CUDA adapter | ON/OFF | OFF |

scripts/core/CONTRIB.rst

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -272,14 +272,21 @@ Conformance tests *must* not make assumptions about the adapter under test.
272272
Tests fixtures or cases *must* query for support of optional features and skip
273273
testing if unsupported by the adapter.
274274

275-
All tests in the Unified Runtime project are configured to use CTest to run.
276-
All conformance tests have the ``conformance`` label attached to them which
277-
allows them to be run independently. To run all the conformance tests, execute
278-
the following command from the build directory.
275+
Conformance tests are ran as part of the main ``test`` target, but can also be
276+
executed using the `check-unified-runtime-conformance` target as follows:
279277

280278
.. code-block:: console
281279
282-
ctest -L "conformance"
280+
cmake --build build --target check-unified-runtime-conformance
281+
282+
A specific device/adapter can be specified by using ``ONEAPI_DEVICE_SELECTOR``
283+
in the same way as in the `DPC++ compiler
284+
<https://github.com/intel/llvm/blob/sycl/sycl/doc/EnvironmentVariables.md#oneapi_device_selector>`_.
285+
286+
A number of tests are skipped on certain adapters due to being known failures.
287+
To force all tests to run, including known failures,
288+
``UR_CTS_ALSO_RUN_KNOWN_FAILURES`` may be set to ``1`` as an environment
289+
variable.
283290

284291
Experimental Features
285292
=====================

scripts/core/INTRO.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -417,12 +417,12 @@ CTS Environment Variables
417417

418418
The following environment variables are used by the CTS runner and can be used to specify the platform that the test
419419
framework should run on. This can be used during development and testing to run CTS tests in case multiple platforms
420-
are available. If both filters are specified, then they both must match a platform for it to be selected. If there are
421-
no valid platforms, then the tests will fail. Command line arguments take priority over these variables.
420+
are available. Conformance tests will be skipped if there are no valid platforms.
422421

423-
.. envvar:: UR_CTS_BACKEND
422+
.. envvar:: ONEAPI_DEVICE_SELECTOR
424423

425-
A (case insensitive) backend to force the test to use. For example, `opencl`, `level_zero`, `hip` and so on.
424+
If ``ONEAPI_DEVICE_SELECTOR`` is set in the environment, only devices
425+
matched by the selector will be tested.
426426

427427
.. envvar:: UR_CTS_ALSO_RUN_KNOWN_FAILURES
428428

scripts/ctest_parser.py

Lines changed: 0 additions & 175 deletions
This file was deleted.

test/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ configure_file(lit.site.cfg.py.in lit.site.cfg.py)
3131
add_custom_target(deps_check-unified-runtime)
3232
if(UR_STANDALONE_BUILD)
3333
add_custom_target(check-unified-runtime
34-
COMMAND "${URLIT_LIT_BINARY}" "${CMAKE_CURRENT_BINARY_DIR}" -v
34+
COMMAND "${URLIT_LIT_BINARY}" "${CMAKE_CURRENT_BINARY_DIR}" -sv
3535
DEPENDS deps_check-unified-runtime
36+
USES_TERMINAL
3637
)
3738
else()
3839
# Use the LLVM method to add the test suite - this also registers it under `check-all`
@@ -60,7 +61,8 @@ function(add_ur_lit_testsuite suite)
6061

6162
if(UR_STANDALONE_BUILD)
6263
add_custom_target(${TARGET}
63-
COMMAND "${URLIT_LIT_BINARY}" "${CMAKE_CURRENT_BINARY_DIR}" -v
64+
COMMAND "${URLIT_LIT_BINARY}" "${CMAKE_CURRENT_BINARY_DIR}" -sv
65+
USES_TERMINAL
6466
)
6567
else()
6668
add_lit_testsuite(${TARGET} "Running Unified Runtime ${suite} tests"

test/conformance/CMakeLists.txt

Lines changed: 35 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -3,94 +3,61 @@
33
# See LICENSE.TXT
44
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
55

6-
set(UR_CONFORMANCE_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR})
6+
add_ur_lit_testsuite(conformance DEPENDS urinfo)
7+
8+
set(UR_CONFORMANCE_TEST_DIR "${CMAKE_CURRENT_SOURCE_DIR}" CACHE INTERNAL
9+
"Internal cache variable for conformance test root")
710

811
set(UR_CONFORMANCE_DEVICE_BINARIES_DIR
912
"${CMAKE_CURRENT_BINARY_DIR}/device_binaries" CACHE INTERNAL
1013
"Internal cache variable for device binaries directory")
1114

12-
function(add_test_adapter name adapter backend)
13-
set(TEST_TARGET_NAME test-${name})
14-
set(TEST_NAME ${name}-${adapter})
15-
16-
set(TEST_COMMAND
17-
"${PROJECT_BINARY_DIR}/bin/${TEST_TARGET_NAME} --gtest_filter=*${backend}*"
18-
)
19-
20-
function(do_add_test tname env)
21-
separate_arguments(TEST_COMMAND)
22-
add_test(NAME ${tname}
23-
COMMAND ${TEST_COMMAND}
24-
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
25-
)
26-
27-
set_tests_properties(${tname} PROPERTIES
28-
ENVIRONMENT "${env}"
29-
LABELS "conformance;${adapter}")
30-
endfunction()
31-
32-
do_add_test(${TEST_NAME} UR_ADAPTERS_FORCE_LOAD="$<TARGET_FILE:ur_${adapter}>")
33-
if(UR_CONFORMANCE_TEST_LOADER)
34-
do_add_test(${TEST_NAME}-loader "")
35-
endif()
36-
endfunction()
37-
3815
function(add_conformance_test name)
39-
set(TEST_TARGET_NAME test-${name})
40-
add_ur_executable(${TEST_TARGET_NAME}
16+
add_gtest_test(${name}
4117
${ARGN}
4218
${UR_CONFORMANCE_TEST_DIR}/source/environment.cpp
43-
${UR_CONFORMANCE_TEST_DIR}/source/main.cpp)
44-
target_link_libraries(${TEST_TARGET_NAME}
45-
PRIVATE
46-
${PROJECT_NAME}::loader
47-
${PROJECT_NAME}::headers
48-
${PROJECT_NAME}::testing
49-
${PROJECT_NAME}::common
50-
GTest::gtest_main)
51-
52-
if(UR_USE_CFI)
53-
target_compile_definitions(${TEST_TARGET_NAME} PRIVATE UR_USE_CFI)
54-
endif()
55-
56-
if(UR_BUILD_ADAPTER_CUDA OR UR_BUILD_ADAPTER_ALL)
57-
add_test_adapter(${name} adapter_cuda CUDA)
58-
endif()
59-
if(UR_BUILD_ADAPTER_HIP OR UR_BUILD_ADAPTER_ALL)
60-
add_test_adapter(${name} adapter_hip HIP)
61-
endif()
62-
if(UR_BUILD_ADAPTER_L0 OR UR_BUILD_ADAPTER_ALL)
63-
add_test_adapter(${name} adapter_level_zero Level_Zero)
64-
endif()
65-
if(UR_BUILD_ADAPTER_L0_V2)
66-
add_test_adapter(${name} adapter_level_zero_v2 Level_Zero)
67-
endif()
68-
if(UR_BUILD_ADAPTER_OPENCL OR UR_BUILD_ADAPTER_ALL)
69-
add_test_adapter(${name} adapter_opencl OpenCL)
70-
endif()
71-
if(UR_BUILD_ADAPTER_NATIVE_CPU OR UR_BUILD_ADAPTER_ALL)
72-
add_test_adapter(${name} adapter_native_cpu NATIVE_CPU)
73-
endif()
19+
${UR_CONFORMANCE_TEST_DIR}/source/main.cpp
20+
)
7421
endfunction()
7522

76-
function(add_conformance_test_with_kernels_environment name)
23+
function(add_conformance_kernels_test name)
7724
add_conformance_test(${name} ${ARGN})
78-
target_compile_definitions("test-${name}" PRIVATE KERNELS_ENVIRONMENT PRIVATE
25+
target_compile_definitions(${name}-test PRIVATE KERNELS_ENVIRONMENT PRIVATE
7926
KERNELS_DEFAULT_DIR="${UR_CONFORMANCE_DEVICE_BINARIES_DIR}")
80-
target_include_directories("test-${name}" PRIVATE ${UR_CONFORMANCE_DEVICE_BINARIES_DIR})
81-
add_dependencies("test-${name}" generate_device_binaries)
27+
target_include_directories(${name}-test PRIVATE ${UR_CONFORMANCE_DEVICE_BINARIES_DIR})
28+
add_dependencies(${name}-test generate_device_binaries kernel_names_header)
8229
endfunction()
8330

84-
function(add_conformance_test_with_devices_environment name)
31+
function(add_conformance_devices_test name)
8532
add_conformance_test(${name} ${ARGN})
86-
target_compile_definitions("test-${name}" PRIVATE DEVICES_ENVIRONMENT)
33+
target_compile_definitions(${name}-test PRIVATE DEVICES_ENVIRONMENT)
8734
endfunction()
8835

89-
function(add_conformance_test_with_platform_environment name)
36+
function(add_conformance_platform_test name)
9037
add_conformance_test(${name} ${ARGN})
91-
target_compile_definitions("test-${name}" PRIVATE PLATFORM_ENVIRONMENT)
38+
target_compile_definitions(${name}-test PRIVATE PLATFORM_ENVIRONMENT)
9239
endfunction()
9340

41+
foreach(adapter ${UR_ADAPTERS_LIST})
42+
if(NOT "${adapter}" STREQUAL "mock")
43+
if(UR_STANDALONE_BUILD)
44+
add_custom_target(check-unified-runtime-conformance-${adapter}
45+
COMMAND "${URLIT_LIT_BINARY}" "${CMAKE_CURRENT_BINARY_DIR}"
46+
-v -Dselector=${adapter}:*
47+
DEPENDS deps_check-unified-runtime-conformance
48+
)
49+
else()
50+
add_lit_testsuite(check-unified-runtime-conformance-${adapter}
51+
"Running Unified Runtime ${adapter} conformance tests"
52+
${CMAKE_CURRENT_BINARY_DIR}
53+
DEPENDS FileCheck deps_check-unified-runtime-conformance
54+
PARAMS selector=${adapter}:*
55+
EXCLUDE_FROM_CHECK_ALL
56+
)
57+
endif()
58+
endif()
59+
endforeach()
60+
9461
add_subdirectory(testing)
9562

9663
add_subdirectory(adapter)

test/conformance/context/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# See LICENSE.TXT
44
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
55

6-
add_conformance_test_with_devices_environment(context
6+
add_conformance_devices_test(context
77
urContextCreate.cpp
88
urContextCreateWithNativeHandle.cpp
99
urContextGetInfo.cpp

0 commit comments

Comments
 (0)