From 8351bf2b7491373991aac37f9c5e441ccb5470c8 Mon Sep 17 00:00:00 2001 From: hashlag Date: Mon, 6 Jul 2026 03:25:30 +0300 Subject: [PATCH] Add sanitized test run to CI. --- .gitea/workflows/ChaosCi.yaml | 13 +++++++++++-- ChaosTests/CMakeLists.txt | 6 ++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/ChaosCi.yaml b/.gitea/workflows/ChaosCi.yaml index 30b2826..bfe6d8d 100644 --- a/.gitea/workflows/ChaosCi.yaml +++ b/.gitea/workflows/ChaosCi.yaml @@ -17,21 +17,30 @@ jobs: sudo apt-get update sudo apt-get install -y build-essential cmake valgrind lcov - - name: Configure and build tests [Debug] + - name: Configure and build tests [Debug and Coverage] run: | mkdir build-debug cmake -S . -B build-debug/ -D CMAKE_BUILD_TYPE=Debug -D CHAOS_COVERAGE=ON cmake --build build-debug/ -t ChaosTests + - name: Configure and build tests [Debug, ASan and UBSan] + run: | + mkdir build-debug-asanubsan + cmake -S . -B build-debug-asanubsan/ -D CMAKE_BUILD_TYPE=Debug -D CHAOS_ASANUBSAN=ON + cmake --build build-debug-asanubsan/ -t ChaosTests + - name: Configure and build benchmarks [Release] run: | mkdir build-release cmake -S . -B build-release/ -D CMAKE_BUILD_TYPE=Release cmake --build build-release/ -t ChaosBenches - - name: Run tests + - name: Run tests under valgrind run: valgrind --leak-check=full --track-origins=yes --show-leak-kinds=all ./build-debug/ChaosTests/ChaosTests + - name: Run tests under ASan and UBSan + run: ./build-debug-asanubsan/ChaosTests/ChaosTests + - name: Run benchmarks run: ./build-release/ChaosBenches/ChaosBenches diff --git a/ChaosTests/CMakeLists.txt b/ChaosTests/CMakeLists.txt index d1a20a7..95ff1cf 100644 --- a/ChaosTests/CMakeLists.txt +++ b/ChaosTests/CMakeLists.txt @@ -33,12 +33,18 @@ target_include_directories(ChaosTests PRIVATE target_compile_options(ChaosTests PRIVATE -Wunused -Werror=unused) option(CHAOS_COVERAGE "Enable coverage" OFF) +option(CHAOS_ASANUBSAN "Enable ASan and UBSan" OFF) if(CHAOS_COVERAGE) target_compile_options(ChaosTests PRIVATE --coverage) target_link_options(ChaosTests PRIVATE --coverage) endif() +if(CHAOS_ASANUBSAN) + target_compile_options(ChaosTests PRIVATE -fsanitize=address,undefined) + target_link_options(ChaosTests PRIVATE -fsanitize=address,undefined) +endif() + include(GoogleTest) gtest_discover_tests(ChaosTests)