From c3b18eb23c882446d3ccc94dea485bf73dadadcb Mon Sep 17 00:00:00 2001 From: delet-this <33498862+delet-this@users.noreply.github.com> Date: Sun, 19 Apr 2026 19:42:43 +0300 Subject: [PATCH 1/3] tests: Add build to gitignore --- tests/.gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 tests/.gitignore diff --git a/tests/.gitignore b/tests/.gitignore new file mode 100644 index 0000000..84c048a --- /dev/null +++ b/tests/.gitignore @@ -0,0 +1 @@ +/build/ From f682a704fe2a882f513eb1f3fd226d4dc3ddba62 Mon Sep 17 00:00:00 2001 From: delet-this <33498862+delet-this@users.noreply.github.com> Date: Sun, 19 Apr 2026 19:43:20 +0300 Subject: [PATCH 2/3] tests: Add build options for ASan and UBSan --- tests/CMakeLists.txt | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index ec7b07a..40604d1 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -3,6 +3,10 @@ project(YeetMouseTests) set(CMAKE_CXX_STANDARD 17) +option(YEETMOUSETESTS_ASAN "Build YeetMouseTests with ASan enabled" OFF) +option(YEETMOUSETESTS_UBSAN "Build YeetMouseTests with UBSan enabled" OFF) +option(YEETMOUSETESTS_NO_SANITIZE_RECOVER "Exit immediately on all sanitizer errors" OFF) + # Add flags based on build type if (CMAKE_BUILD_TYPE STREQUAL "Debug") message(STATUS "Configuring with debug flags.") @@ -25,6 +29,25 @@ if (CMAKE_SYSTEM_PROCESSOR STREQUAL "ppc64le") add_compile_definitions(__ppc64le__) endif() + +if(YEETMOUSETESTS_ASAN) + message(STATUS "Building with ASan enabled") + add_compile_options(-fsanitize=address -fno-omit-frame-pointer) + add_link_options(-fsanitize=address -fno-omit-frame-pointer) +endif() + +if(YEETMOUSETESTS_UBSAN) + message(STATUS "Building with UBSan enabled") + add_compile_options(-fsanitize=undefined -fno-omit-frame-pointer) + add_link_options(-fsanitize=undefined -fno-omit-frame-pointer) +endif() + +if(YEETMOUSETESTS_NO_SANITIZE_RECOVER) + message(STATUS "Enabled -fno-sanitize-recover=all") + add_compile_options(-fno-sanitize-recover=all) + add_link_options(-fno-sanitize-recover=all) +endif() + add_executable(YeetMouseTests main.cpp TestManager.cpp Tests.cpp From b22e532177da2882a4e777485a2ea02e46a5f992 Mon Sep 17 00:00:00 2001 From: delet-this <33498862+delet-this@users.noreply.github.com> Date: Sun, 19 Apr 2026 19:45:17 +0300 Subject: [PATCH 3/3] ci: Enable ASan for unit tests --- .github/workflows/build_and_test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 9a01096..d8920d5 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -32,7 +32,8 @@ jobs: - name: Build tests run: | - cmake -S tests -B tests/build + # TODO: Use UBSan as well + cmake -DYEETMOUSETESTS_ASAN=ON -DYEETMOUSETESTS_NO_SANITIZE_RECOVER=ON -S tests -B tests/build cmake --build tests/build if: ${{ !cancelled() }}