Add Asan profile, fix multiple bugs.

Added Asan profile to help catch and fix various bugs (and indeed, there
were few of them).

Additionally, fixed bhunit macro to process arguments only once.
This commit is contained in:
2025-01-29 09:19:34 +03:00
parent 47c21a2035
commit 6ede63e18f
8 changed files with 78 additions and 21 deletions

View File

@@ -2,9 +2,6 @@ set(CMAKE_C_STANDARD 90)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)
# Enable warnings and pedantics
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -pedantic")
# Enable testing
include(CTest)
enable_testing()
@@ -13,10 +10,20 @@ enable_testing()
file(GLOB TEST_FILES "src/*.c")
foreach(TEST_FILENAME ${TEST_FILES})
# Add test
get_filename_component(TEST_NAME ${TEST_FILENAME} NAME_WE)
add_executable("${TEST_NAME}" ${TEST_FILENAME})
target_link_libraries("${TEST_NAME}" bhlib bhunit)
add_test(NAME "${TEST_NAME}" COMMAND "${TEST_NAME}")
# Enable all compiler warnings
if(MSVC)
target_compile_options("${TEST_NAME}" PRIVATE /W4 /WX)
else()
target_compile_options("${TEST_NAME}" PRIVATE -Wall -Wextra -Wpedantic -Werror -fstrict-aliasing)
endif()
# Enable coverage
if(COVERAGE)
target_compile_options("${TEST_NAME}" PRIVATE -coverage)
target_link_options("${TEST_NAME}" PRIVATE -coverage)