[llvm] [libsycl] Run unittests using lit (PR #214778)
Nick Sarnie via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 14 07:49:09 PDT 2026
================
@@ -8,15 +8,9 @@ function(add_sycl_unittest test_name)
target_compile_definitions(${test_name}
PRIVATE _LIBSYCL_BUILDING_LIBRARY)
- add_custom_target(check-sycl-${test_name}
- ${CMAKE_COMMAND} -E env
- ${CMAKE_CURRENT_BINARY_DIR}/${test_name}
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
- DEPENDS
- ${test_name}
- )
-
- add_dependencies(check-sycl-unittests check-sycl-${test_name})
+ # Use a common suffix so the test executables can be discovered and run by
+ # lit's GoogleTest format (see unittests/lit.cfg.py).
+ set_target_properties(${test_name} PROPERTIES OUTPUT_NAME ${test_name}.unittests)
----------------
sarnex wrote:
Thanks for the review and for testing.
Right, we don't have the
```
[----------] Global test environment set-up.
[----------] 4 tests from Queue
[ RUN ] Queue.Memcpy
[ OK ] Queue.Memcpy (0 ms)
```
output that we had before.
If we see a test failure, it looks like this (I made the test fail for this example)
```
AIL: SYCL-Unit :: queue/./QueueTests.unittests/0/8 (5 of 23)
******************** TEST 'SYCL-Unit :: queue/./QueueTests.unittests/0/8' FAILED ********************
Script(shard):
--
GTEST_OUTPUT=json:/iusers/nsarnie/llvm_upstream_sycltests/build/runtimes/runtimes-bins/libsycl/unittests/queue/./QueueTests.unittests-SYCL-Unit-2838643-0-8.json GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=8 GTEST_SHARD_INDEX=0 /iusers/nsarnie/llvm_upstream_sycltests/build/runtimes/runtimes-bins/libsycl/unittests/queue/./QueueTests.unittests
--
Script:
--
/iusers/nsarnie/llvm_upstream_sycltests/build/runtimes/runtimes-bins/libsycl/unittests/queue/./QueueTests.unittests --gtest_filter=Queue.Memcpy
--
/iusers/nsarnie/llvm_upstream_sycltests/libsycl/unittests/queue/memcpy.cpp:16: Failure
Expected: (1) != (1), actual: 1 vs 1
/iusers/nsarnie/llvm_upstream_sycltests/libsycl/unittests/queue/memcpy.cpp:16
Expected: (1) != (1), actual: 1 vs 1
********************
********************
Failed Tests (1):
SYCL-Unit :: queue/./QueueTests.unittests/Queue/Memcpy
Testing Time: 0.12s
Total Discovered Tests: 23
Passed: 22 (95.65%)
Failed: 1 (4.35%)
```
and the unittests are indeed running with `check-sycl`, it's in this part of the CI output from this job:
```
[94/96] Running libsycl unit tests
-- Testing: 15 tests, 4 workers --
Testing: 0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
Testing Time: 0.07s
```
as we can see even more info if we use `LIT_OPTS=--show-pass`:
```
sarnex at machine:/iusers/nsarnie/llvm_upstream_sycltests/build$ LIT_OPTS="--show-pass" ninja check-sycl
[0/1] cd /iusers/nsarnie/llvm_upstream_sycltests/build/runtimes/runtimes-b...cltests/build/runtimes/runtimes-bins/ --target check-sycl --config Release
[0/2] Re-checking globbed directories...
[0/2] Running libsycl unit tests
********************
Passed Tests (23):
SYCL-Unit :: device_selector/./DeviceSelectorTests.unittests/DeviceSelector/AspectSelector
SYCL-Unit :: device_selector/./DeviceSelectorTests.unittests/DeviceSelectorScoreTest/CPUAndGPU
<...>
[1/2] Running libsycl tests
llvm-lit: /iusers/nsarnie/llvm_upstream_sycltests/libsycl/test/lit.cfg.py:149: note: Targeted devices: all
********************
Passed Tests (16):
libsycl :: basic/get_backend.cpp
libsycl :: basic/group.cpp
<...>
```
If you would prefer we have the exact same output as before, I'm happy to do that, but it would be different from what we usually do as far as I can tell.
https://github.com/llvm/llvm-project/pull/214778
More information about the llvm-commits
mailing list