Skip to content

Commit 008bf6c

Browse files
committed
Add sanitizer support using GCC toolchain features
1 parent 6887761 commit 008bf6c

4 files changed

Lines changed: 96 additions & 2 deletions

File tree

.bazelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,6 @@ coverage --test_env=COVERAGE_GCOV_OPTIONS=-bcu
8686
coverage --test_env=LLVM_PROFILE_CONTINUOUS_MODE=1
8787
coverage --cxxopt -mllvm
8888
coverage --cxxopt -runtime-counter-relocation
89+
90+
# Dynamic analysis (sanitizers) for Linux host builds/tests.
91+
try-import %workspace%/quality/sanitizer/sanitizer.bazelrc

.github/workflows/sanitizers.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# *******************************************************************************
2+
# Copyright (c) 2026 Contributors to the Eclipse Foundation
3+
#
4+
# See the NOTICE file(s) distributed with this work for additional
5+
# information regarding copyright ownership.
6+
#
7+
# This program and the accompanying materials are made available under the
8+
# terms of the Apache License Version 2.0 which is available at
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# SPDX-License-Identifier: Apache-2.0
12+
# *******************************************************************************
13+
14+
name: Sanitizers
15+
16+
on:
17+
pull_request:
18+
types: [opened, reopened, synchronize]
19+
merge_group:
20+
types: [checks_requested]
21+
22+
permissions:
23+
contents: read
24+
25+
jobs:
26+
sanitizer-tests:
27+
name: Bazel Tests (${{ matrix.sanitizer_config }})
28+
runs-on: ubuntu-latest
29+
strategy:
30+
fail-fast: false
31+
matrix:
32+
sanitizer_config: [asan_ubsan_lsan, tsan]
33+
34+
steps:
35+
- name: Checkout repository
36+
uses: actions/checkout@v4.2.2
37+
with:
38+
ref: ${{ github.head_ref || github.event.pull_request.head.ref || github.ref }}
39+
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
40+
41+
- name: Setup Bazel with shared caching
42+
uses: bazel-contrib/setup-bazel@0.18.0
43+
with:
44+
bazelisk-version: 1.26.0
45+
disk-cache: true
46+
repository-cache: true
47+
bazelisk-cache: true
48+
cache-save: ${{ github.event_name == 'push' }}
49+
50+
- name: Run sanitizer tests via Bazel
51+
run: |
52+
set -euo pipefail
53+
echo "Running: bazel test --config=${{ matrix.sanitizer_config }} //score/... //tests/..."
54+
bazel test --config=${{ matrix.sanitizer_config }} //score/... //tests/...
55+
56+
- name: Upload Bazel test logs (always)
57+
if: always()
58+
uses: actions/upload-artifact@v6
59+
with:
60+
name: bazel-testlogs-${{ matrix.sanitizer_config }}
61+
path: bazel-testlogs/**/test.log
62+
if-no-files-found: warn

MODULE.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ bazel_dep(name = "platforms", version = "1.0.0")
2727

2828
# S-CORE process rules
2929
bazel_dep(name = "score_bazel_platforms", version = "0.0.4")
30-
bazel_dep(name = "score_docs_as_code", version = "2.2.0")
31-
bazel_dep(name = "score_tooling", version = "1.1.1")
30+
bazel_dep(name = "score_docs_as_code", version = "3.0.1")
31+
bazel_dep(name = "score_tooling", version = "1.1.2")
3232
bazel_dep(name = "score_rust_policies", version = "0.0.3")
3333

3434
bazel_dep(name = "score_process", version = "1.4.0", dev_dependency = True)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# *******************************************************************************
2+
# Copyright (c) 2026 Contributors to the Eclipse Foundation
3+
#
4+
# See the NOTICE file(s) distributed with this work for additional
5+
# information regarding copyright ownership.
6+
#
7+
# This program and the accompanying materials are made available under the
8+
# terms of the Apache License Version 2.0 which is available at
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# SPDX-License-Identifier: Apache-2.0
12+
# *******************************************************************************
13+
14+
# ASan + UBSan + LSan
15+
test:asan_ubsan_lsan --config=x86_64-linux
16+
test:asan_ubsan_lsan --compilation_mode=dbg
17+
test:asan_ubsan_lsan --features=asan
18+
test:asan_ubsan_lsan --features=ubsan
19+
test:asan_ubsan_lsan --features=lsan
20+
test:asan_ubsan_lsan --platform_suffix=asan_ubsan_lsan
21+
test:asan_ubsan_lsan --test_env=ASAN_OPTIONS=exitcode=55:allow_addr2line=1:verbosity=1:detect_leaks=1:halt_on_error=1:allocator_may_return_null=1
22+
test:asan_ubsan_lsan --test_env=UBSAN_OPTIONS=exitcode=55:allow_addr2line=1:verbosity=1:print_stacktrace=1:halt_on_error=1
23+
24+
# TSan
25+
test:tsan --config=x86_64-linux
26+
test:tsan --compilation_mode=dbg
27+
test:tsan --features=tsan
28+
test:tsan --platform_suffix=tsan
29+
test:tsan --test_env=TSAN_OPTIONS=exitcode=55:allow_addr2line=1:verbosity=1:halt_on_error=1:detect_deadlocks=1

0 commit comments

Comments
 (0)