From 2323020714f9fa958c8ffb78477e2f0b2b6b962e Mon Sep 17 00:00:00 2001 From: hashlag Date: Mon, 3 Aug 2026 01:46:21 +0300 Subject: [PATCH] Define sanitizer callbacks that fail tests when triggered. --- ChaosTests/CMakeLists.txt | 3 ++- ChaosTests/SanCallbacks.cpp | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 ChaosTests/SanCallbacks.cpp diff --git a/ChaosTests/CMakeLists.txt b/ChaosTests/CMakeLists.txt index 062ff50..a564a66 100644 --- a/ChaosTests/CMakeLists.txt +++ b/ChaosTests/CMakeLists.txt @@ -11,7 +11,8 @@ FetchContent_Declare( set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) FetchContent_MakeAvailable(googletest) -set(ChaosTests_SOURCE Hash/Md4HasherTests.cpp +set(ChaosTests_SOURCE SanCallbacks.cpp + Hash/Md4HasherTests.cpp Hash/Md5HasherTests.cpp Hash/Sha1HasherTests.cpp Mac/HmacTests.cpp diff --git a/ChaosTests/SanCallbacks.cpp b/ChaosTests/SanCallbacks.cpp new file mode 100644 index 0000000..783800c --- /dev/null +++ b/ChaosTests/SanCallbacks.cpp @@ -0,0 +1,21 @@ +#include + +extern "C" +{ + +void __ubsan_on_report() +{ + FAIL() << "Encountered an undefined behavior sanitizer error"; +} + +void __asan_on_error() +{ + FAIL() << "Encountered an address sanitizer error"; +} + +void __tsan_on_report() +{ + FAIL() << "Encountered a thread sanitizer error"; +} + +} // extern "C"