Add Sanitizers to Github Actions

This commit is contained in:
Sebastian Messmer 2021-04-18 18:49:59 -07:00
parent a51a6f88eb
commit 18b7cc63ec
2 changed files with 62 additions and 9 deletions

View File

@ -1,5 +1,9 @@
name: 'Test' name: 'Test'
description: 'Run CryFS Tests' description: 'Run CryFS Tests'
inputs:
gtest_args:
description: "Extra arguments for gtest runners, for example tests to exclude"
required: true
runs: runs:
using: "composite" using: "composite"
steps: steps:
@ -9,17 +13,20 @@ runs:
set -v set -v
echo Running on ${{runner.os}} echo Running on ${{runner.os}}
cd build cd build
./test/gitversion/gitversion-test ./test/gitversion/gitversion-test ${{inputs.gtest_args}}
./test/cpp-utils/cpp-utils-test ./test/cpp-utils/cpp-utils-test ${{inputs.gtest_args}}
./test/parallelaccessstore/parallelaccessstore-test ./test/parallelaccessstore/parallelaccessstore-test ${{inputs.gtest_args}}
./test/blockstore/blockstore-test ./test/blockstore/blockstore-test ${{inputs.gtest_args}}
./test/blobstore/blobstore-test ./test/blobstore/blobstore-test ${{inputs.gtest_args}}
./test/cryfs/cryfs-test ./test/cryfs/cryfs-test ${{inputs.gtest_args}}
# TODO Also run on macOS once fixed # TODO Also run on macOS once fixed
if [[ "${{runner.os}}" == "macOS" ]]; then if [[ "${{runner.os}}" == "macOS" ]]; then
echo Skipping some tests because they are not fixed for macOS yet echo Skipping some tests because they are not fixed for macOS yet
else else
./test/fspp/fspp-test # TODO Also run with TSAN once fixed
./test/cryfs-cli/cryfs-cli-test if [[ "${{matrix.name}}" != "TSAN" ]]; then
./test/fspp/fspp-test ${{inputs.gtest_args}}
fi
./test/cryfs-cli/cryfs-cli-test ${{inputs.gtest_args}}
fi fi

View File

@ -130,11 +130,55 @@ jobs:
extra_cmake_flags: "" extra_cmake_flags: ""
extra_cxxflags: "-DCRYFS_NO_COMPATIBILITY" extra_cxxflags: "-DCRYFS_NO_COMPATIBILITY"
install_dependencies_manually: false install_dependencies_manually: false
run_tests: false run_tests: true
- name: ASAN
os: ubuntu-20.04
compiler:
cxx: clang++-11
cc: clang-11
apt_package: clang++-11
build_type: Debug
# OpenMP crashes under asan. Disable OpenMP.
# TODO is it enough to replace this with omp_num_threads: 1 ?
extra_cmake_flags: "-DDISABLE_OPENMP=ON"
extra_cxxflags: "-O1 -fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-common -fsanitize-address-use-after-scope"
asan_options: "detect_leaks=1 check_initialization_order=1 detect_stack_use_after_return=1 detect_invalid_pointer_pairs=1 atexit=1"
install_dependencies_manually: false
run_tests: true
- name: UBSAN
os: ubuntu-20.04
compiler:
cxx: clang++-11
cc: clang-11
apt_package: clang++-11
build_type: Debug
# OpenMP crashes under ubsan. Disable OpenMP.
# TODO is it enough to replace this with omp_num_threads: 1 ?
extra_cmake_flags: "-DDISABLE_OPENMP=ON"
extra_cxxflags: "-O1 -fno-sanitize-recover=undefined,nullability,implicit-conversion,unsigned-integer-overflow,local-bounds,float-divide-by-zero -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-common"
ubsan_options: "print_stacktrace=1"
install_dependencies_manually: false
run_tests: true
- name: TSAN
os: ubuntu-20.04
compiler:
cxx: clang++-11
cc: clang-11
apt_package: clang++-11
build_type: Debug
extra_cmake_flags: ""
extra_cxxflags: "-O2 -fsanitize=thread -fno-omit-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-common"
install_dependencies_manually: false
run_tests: true
gtest_args: "--gtest_filter=-LoggingTest.LoggingAlsoWorksAfterFork:AssertTest_*:BacktraceTest.*:SignalCatcherTest.*_thenDies:SignalHandlerTest.*_thenDies:SignalHandlerTest.givenMultipleSigIntHandlers_whenRaising_thenCatchesCorrectSignal:CliTest_Setup.*:CliTest_IntegrityCheck.*:*/CliTest_WrongEnvironment.*:CliTest_Unmount.*:CliTest.WorksWithCommasInBasedir"
omp_num_threads: 1
runs-on: ${{matrix.os}} runs-on: ${{matrix.os}}
env: env:
# Setting conan cache dir to a location where our Github Cache Action can find it # Setting conan cache dir to a location where our Github Cache Action can find it
CONAN_USER_HOME: "${{ github.workspace }}/conan-cache/" CONAN_USER_HOME: "${{ github.workspace }}/conan-cache/"
ASAN_OPTIONS: ${{matrix.asan_options}}
UBSAN_OPTIONS: ${{matrix.ubsan_options}}
OMP_NUM_THREADS: ${{matrix.omp_num_threads}}
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v1 uses: actions/checkout@v1
@ -309,3 +353,5 @@ jobs:
- name: Test - name: Test
if: ${{ matrix.run_tests }} if: ${{ matrix.run_tests }}
uses: ./.github/workflows/actions/run_tests uses: ./.github/workflows/actions/run_tests
with:
gtest_args: ${{matrix.gtest_args}}