Add optional CSA checker to tests

To run full tests with the static analyzer:
cmake -DBUILD_TESTING_ANALYZER=1 -DCMAKE_BUILD_TYPE=Debug .. && make CTEST_OUTPUT_ON_FAILURE=1 all test
This commit is contained in:
Christian W. Zuckschwerdt 2019-11-03 11:57:07 +01:00
parent 829527aa8a
commit 70c506e6b9
2 changed files with 25 additions and 0 deletions

View file

@ -195,6 +195,12 @@ if(BUILD_DOCUMENTATION)
# install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc/html DESTINATION share/doc)
endif()
########################################################################
# Build tests with analyzer
########################################################################
option(BUILD_TESTING_ANALYZER "Build the testing tree with static
analyzer (requires Clang)" OFF)
########################################################################
# Build tests
########################################################################

View file

@ -42,3 +42,22 @@ list(REMOVE_ITEM STYLE_CHECK_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/../include/mongoose.h"
"${CMAKE_CURRENT_SOURCE_DIR}/../src/mongoose.c")
add_test(style-check style-check ${STYLE_CHECK_FILES})
########################################################################
# Define clang static analyzer checks
########################################################################
if(BUILD_TESTING_ANALYZER)
file(GLOB ANALYZER_CHECK_FILES ../include/*.h ../src/*.c ../src/devices/*.c)
list(REMOVE_ITEM ANALYZER_CHECK_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/../include/mongoose.h"
"${CMAKE_CURRENT_SOURCE_DIR}/../src/mongoose.c")
add_test(clang-analyzer
clang
-I${CMAKE_CURRENT_SOURCE_DIR}/../include
--analyze
-Xanalyzer
-analyzer-output=text
-Xanalyzer
-analyzer-disable-checker=deadcode.DeadStores
${ANALYZER_CHECK_FILES})
endif()