mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-22 10:22:52 +01:00
Add sanitizers
Leak sanitizer - tracks leaks. Address sanitizer - like above and prohibiteted operations on memory. Thread sanitizer - tracks data races. Undefined behaviour - like name says. ;)
This commit is contained in:
parent
d03a33c284
commit
ec92476818
@ -18,6 +18,8 @@ set(_ARGS_BOOL
|
||||
|
||||
RUN_MEMCHECK
|
||||
|
||||
ENABLE_SANITIZERS
|
||||
|
||||
APPEND_RESULTS
|
||||
RUN_COVERAGE
|
||||
SUBMIT
|
||||
@ -93,6 +95,7 @@ set(_CONFIGURE_OPTIONS
|
||||
"-DSEPARATE_TEST_SUITES=${SEPARATE_TEST_SUITES}"
|
||||
"-DCHECK_INCLUDES=${CHECK_INCLUDES}"
|
||||
"-DCMAKE_BUILD_TYPE=${_CMAKE_BUILD_TYPE}"
|
||||
"-DENABLE_SANITIZERS=${ENABLE_SANITIZERS}"
|
||||
)
|
||||
|
||||
message(STATUS "Configuring...")
|
||||
|
@ -4,6 +4,7 @@ set(CONFIGURE_EXTRA_OPTIONS ";")
|
||||
set(BUILD_VIEWER TRUE)
|
||||
set(COVERAGE_COMMAND gcov)
|
||||
set(CHECK_INCLUDES FALSE)
|
||||
set(ENABLE_SANITIZERS "none")
|
||||
|
||||
if(MODEL_NAME STREQUAL "EXPERIMENTAL")
|
||||
set(CHECK_INCLUDES FALSE)
|
||||
|
@ -4,6 +4,7 @@ set(CONFIGURE_EXTRA_OPTIONS ";")
|
||||
set(BUILD_VIEWER TRUE)
|
||||
set(COVERAGE_COMMAND gcov)
|
||||
set(CHECK_INCLUDES FALSE)
|
||||
set(ENABLE_SANITIZERS "address")
|
||||
|
||||
if(MODEL_NAME STREQUAL "EXPERIMENTAL")
|
||||
set(CHECK_INCLUDES FALSE)
|
||||
|
@ -102,3 +102,4 @@ set(CONFIGURE_EXTRA_OPTIONS
|
||||
set(BUILD_VIEWER FALSE) #FIXME: ENABLE
|
||||
set(COVERAGE_COMMAND "echo") #FIXME: ENABLE
|
||||
set(CHECK_INCLUDES FALSE) #FIXME: ENABLE
|
||||
set(ENABLE_SANITIZERS "none")
|
||||
|
@ -123,6 +123,28 @@ if(TEST_COVERAGE)
|
||||
)
|
||||
endif()
|
||||
|
||||
foreach(SAN ${ENABLE_SANITIZERS})
|
||||
if(${SAN} STREQUAL "address")
|
||||
message(STATUS "Address sanitizer enabled.")
|
||||
target_compile_options(rw_interface INTERFACE "-fsanitize=address")
|
||||
target_link_libraries(rw_interface INTERFACE "-fsanitize=address")
|
||||
elseif(${SAN} STREQUAL "leak")
|
||||
message(STATUS "Leak sanitizer enabled.")
|
||||
target_compile_options(rw_interface INTERFACE "-fsanitize=leak")
|
||||
target_link_libraries(rw_interface INTERFACE "-fsanitize=leak")
|
||||
elseif(${SAN} STREQUAL "thread" )
|
||||
message(STATUS "Thread sanitizer enabled.")
|
||||
target_compile_options(rw_interface INTERFACE "-fsanitize=thread")
|
||||
target_link_libraries(rw_interface INTERFACE "-fsanitize=thread")
|
||||
elseif(${SAN} STREQUAL "undefined" )
|
||||
message(STATUS "Undefined behaviour sanitizer enabled.")
|
||||
target_compile_options(rw_interface INTERFACE "-fsanitize=undefined")
|
||||
target_link_libraries(rw_interface INTERFACE "-fsanitize=undefined")
|
||||
elseif(NOT ${SAN} STREQUAL "none" )
|
||||
message(FATAL_ERROR "Illegal sanitizer")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
include(CMakeParseArguments)
|
||||
|
||||
if(CHECK_INCLUDES)
|
||||
|
@ -25,3 +25,5 @@ option(CHECK_INCLUDES "Analyze #includes in C and C++ source files")
|
||||
|
||||
option(TEST_COVERAGE "Enable coverage analysis (implies CMAKE_BUILD_TYPE=Debug)")
|
||||
option(SEPARATE_TEST_SUITES "Add each test suite as separate test to CTest")
|
||||
|
||||
option(ENABLE_SANITIZERS "Enable selected sanitizer.")
|
||||
|
@ -16,6 +16,7 @@ RUN dnf update -y \
|
||||
glm-devel \
|
||||
openal-soft-devel \
|
||||
SDL2-devel \
|
||||
qt5-devel
|
||||
qt5-devel \
|
||||
libasan
|
||||
|
||||
CMD ["/bin/bash"]
|
||||
|
Loading…
Reference in New Issue
Block a user