Skip to content

Commit

Permalink
Build with address sanitizer
Browse files Browse the repository at this point in the history
Signed-off-by: Alan Jowett <[email protected]>
  • Loading branch information
Alan-Jowett committed Mar 11, 2024
1 parent 6d092f4 commit 2b87706
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
strategy:
matrix:
configurations: [Debug, Release]
sanitizer: [true, false]
runs-on: ubuntu-latest
env:
# Configuration type to build. For documentation on how build matrices work, see
Expand All @@ -35,14 +36,22 @@ jobs:

- name: Build
run: |
if [ "${{matrix.sanitizer}}" = "true" ]; then
export SANITIZER_FLAGS="-fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -fsanitize-coverage=inline-bool-flag -fsanitize-coverage=edge -fsanitize-coverage=trace-cmp -fsanitize-coverage=trace-div"
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 18
sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang-18 100
fi
mkdir build
cmake -B build -DCMAKE_BUILD_TYPE=${{env.BUILD_CONFIGURATION}}
cmake -B build -DCMAKE_BUILD_TYPE=${{env.BUILD_CONFIGURATION}} -DCMAKE_CXX_FLAGS="${SANITIZER_FLAGS}" -DCMAKE_C_FLAGS="${SANITIZER_FLAGS}"
cmake --build build -j $(nproc)
- name: Run unit tests
run: ./tests -d yes

- name: Test for memory leaks
if: matrix.sanitizer == 'false'
# Any memory leaks will cause the test to fail
# This BPF program was chosen because it is the largest one in the repo
run: valgrind --leak-check=full --errors-for-leak-kinds=all --show-leak-kinds=all --error-exitcode=1 ./check ebpf-samples/cilium/bpf_xdp_snat_linux_v1.o 2/1
Expand Down

0 comments on commit 2b87706

Please sign in to comment.