Skip to content

Commit 192c041

Browse files
Add CI sanitizer testing (uxlfoundation#874)
1 parent 38dc3d3 commit 192c041

4 files changed

Lines changed: 145 additions & 0 deletions

File tree

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: build run sanitizers
2+
description: build run sanitizers
3+
4+
inputs:
5+
san_type:
6+
description: 'sanitizer type: tsan OR aubsan'
7+
type: string
8+
required: true
9+
llvm_branch:
10+
description: 'The actual llvm branch to check out e.g. release/19.x'
11+
type: string
12+
required: true
13+
14+
runs:
15+
using: "composite"
16+
steps:
17+
18+
- name: Set sanitizer vars
19+
id: sanitizer_vars
20+
shell: 'bash'
21+
run: |
22+
if [ "${{ inputs.san_type }}" = "tsan" ]; then
23+
echo "build_type=SanitizeThread" >> "$GITHUB_OUTPUT"
24+
echo "ninja_options=-j3" >> "$GITHUB_OUTPUT"
25+
echo "ca_options=-DCA_ENABLE_EXTENDED_CHECKS=OFF" >> "$GITHUB_OUTPUT"
26+
else # aubsan
27+
echo "build_type=SanitizeAddress,Undefined" >> "$GITHUB_OUTPUT"
28+
echo "ninja_options=-j2" >> "$GITHUB_OUTPUT"
29+
echo "ca_options=" >> "$GITHUB_OUTPUT"
30+
fi
31+
cat $GITHUB_OUTPUT
32+
33+
- name: Install clang
34+
shell: 'bash'
35+
run: |
36+
sudo apt update
37+
sudo apt install -y clang-19
38+
39+
- name: Checkout llvm/llvm-project
40+
uses: actions/checkout@v4
41+
with:
42+
repository: llvm/llvm-project
43+
ref: ${{ inputs.llvm_branch }}
44+
path: external/llvm-project
45+
46+
- name: Build llvm
47+
shell: 'bash'
48+
run: |
49+
echo Build LLVM
50+
cd external
51+
cmake llvm-project/llvm \
52+
-GNinja \
53+
-Bbuild \
54+
-DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/external/llvm_install \
55+
-DCA_LLVM_PROJECT_DIR=$GITHUB_WORKSPACE/external/llvm-project \
56+
-DCA_LLVM_SPIRV_PROJECT_DIR=$GITHUB_WORKSPACE/external/llvm-spirv \
57+
-DLLVM_ENABLE_ZLIB=FALSE \
58+
-DLLVM_ENABLE_Z3_SOLVER=FALSE \
59+
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
60+
-DLLVM_USE_SANITIZER=Thread \
61+
-DLLVM_BUILD_LLVM_DYLIB=ON \
62+
-DLLVM_LINK_LLVM_DYLIB=ON \
63+
-DLLVM_ENABLE_DIA_SDK=OFF \
64+
-DLLVM_ENABLE_ZSTD=FALSE \
65+
-DLLVM_ENABLE_PROJECTS="clang;lld" \
66+
-DCMAKE_BUILD_TYPE=Release \
67+
-DCMAKE_C_COMPILER=/usr/bin/clang-19 \
68+
-DCMAKE_CXX_COMPILER=/usr/bin/clang++-19
69+
echo Install LLVM
70+
cmake --build $GITHUB_WORKSPACE/external/build --target install -- -j2
71+
72+
- name: Build OCK
73+
shell: 'bash'
74+
run: |
75+
echo Build OCK
76+
cmake \
77+
-Bbuild \
78+
-GNinja \
79+
-DCA_ENABLE_HOST_IMAGE_SUPPORT=OFF \
80+
-DOCL_EXTENSION_cl_khr_command_buffer=ON \
81+
-DOCL_EXTENSION_cl_khr_command_buffer_mutable_dispatch=ON \
82+
${{ steps.sanitizer_vars.outputs.ca_options }} \
83+
-DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/install \
84+
-DCA_LLVM_INSTALL_DIR=$GITHUB_WORKSPACE/external/llvm_install \
85+
-DCMAKE_BUILD_TYPE=Debug \
86+
-DCA_USE_SANITIZER=Thread \
87+
-DCMAKE_C_COMPILER=/usr/bin/clang-19 \
88+
-DCMAKE_CXX_COMPILER=/usr/bin/clang++-19 \
89+
-DCA_ENABLE_DEBUG_SUPPORT=ON \
90+
-DCA_BUILTINS_TOOLS_DIR=$GITHUB_WORKSPACE/external/llvm_install/bin \
91+
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
92+
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
93+
-DCA_GTEST_LAUNCHER="/usr/bin/python3;-u;$GITHUB_WORKSPACE/scripts/gtest-terse-runner.py" \
94+
.
95+
echo Build OCK all config=${{ steps.sanitizer_vars.outputs.build_type }}
96+
cmake --build $GITHUB_WORKSPACE/build --target all --config ${{ steps.sanitizer_vars.outputs.build_type }}
97+
98+
- name: Test OCK
99+
shell: 'bash'
100+
run: |
101+
echo Test OCK ninja
102+
ninja -C build ${{ steps.sanitizer_vars.outputs.ninja_options }} check-ock

.github/workflows/planned_testing_caller.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ on:
1717
type: boolean
1818
description: 'Enable testing tornado'
1919
default: true
20+
test_sanitizers:
21+
type: boolean
22+
description: 'Enable testing sanitizers'
23+
default: true
2024
test_remote_hal:
2125
type: boolean
2226
description: 'Enable testing remote_hal'
@@ -102,6 +106,7 @@ jobs:
102106
test_sycl_e2e: ${{ inputs.test_sycl_e2e }}
103107
test_opencl_cts: ${{ inputs.test_opencl_cts }}
104108
native_cpu: ${{ inputs.native_cpu }}
109+
llvm_branch: ${{ inputs.llvm_branch }}
105110
save_cache: ${{ inputs.save_cache }}
106111

107112
# The following can be used to download from a previous workflow run (change id)

.github/workflows/planned_testing_caller_19.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ jobs:
3333
# test_sycl_cts: true
3434
# test_sycl_e2e: true
3535
# test_opencl_cts: true
36+
# test_sanitizers: true
3637
# run_internal: true
3738
# run_external: true
3839
# build_llvm: true

.github/workflows/run_ock_external_tests.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ on:
2323
type: boolean
2424
description: 'Enable testing remote_hal'
2525
default: true
26+
test_sanitizers:
27+
required: false
28+
type: boolean
29+
description: 'Enable testing sanitizers'
30+
default: true
2631
test_sycl_cts:
2732
required: false
2833
type: boolean
@@ -47,6 +52,11 @@ on:
4752
type: string
4853
description: 'llvm major version (e.g 19,20, main) - to be used for llvm specific fails'
4954
default: 19
55+
llvm_branch:
56+
required: false
57+
type: string
58+
description: 'The actual llvm branch to check out e.g. release/19.x'
59+
default: 'release/19.x'
5060
download_ock_artefact:
5161
required: false
5262
type: string
@@ -211,6 +221,33 @@ jobs:
211221
with:
212222
target: ${{matrix.target}}
213223

224+
build_run_sanitizers:
225+
if: inputs.test_sanitizers
226+
needs: [ workflow_vars ]
227+
strategy:
228+
fail-fast: false # let all matrix jobs complete
229+
matrix:
230+
san_type: [ 'tsan', 'aubsan' ]
231+
runs-on: 'ubuntu-22.04'
232+
container:
233+
image: 'ghcr.io/uxlfoundation/ock_ubuntu_22.04-x86-64:latest'
234+
volumes:
235+
- ${{github.workspace}}:${{github.workspace}}
236+
steps:
237+
- name: Checkout repo
238+
uses: actions/checkout@v4
239+
- name: setup-ubuntu
240+
uses: ./.github/actions/setup_build
241+
with:
242+
llvm_version: ${{ inputs.llvm_version }}
243+
llvm_source: ${{ inputs.llvm_source}}
244+
github_token: ${{ secrets.GITHUB_TOKEN }}
245+
- name : build run sanitizers
246+
uses: ./.github/actions/do_build_run_sanitizers
247+
with:
248+
san_type: ${{ matrix.san_type }}
249+
llvm_branch: ${{ inputs.llvm_branch }}
250+
214251
build_run_remote_hal:
215252
if: inputs.test_remote_hal
216253
needs: [ workflow_vars ]

0 commit comments

Comments
 (0)