From 3639087ac62b089a0a6c29ccd3f9c8b1d51d5648 Mon Sep 17 00:00:00 2001 From: Daniel Agar Date: Sat, 5 May 2018 15:49:04 -0400 Subject: [PATCH] cmake and Jenkins add basic address santiizer test buld --- CMakeLists.txt | 19 +++++++++++++++++++ EKF/tests/base/base.cpp | 2 ++ Jenkinsfile | 18 ++++++++++++++++++ Makefile | 5 +++++ 4 files changed, 44 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 610490691b..157452d321 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,6 +57,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # code coverage support option(COV_HTML "Display html for coverage" OFF) +option(ECL_ASAN "Enable ECL address sanitizer" OFF) set(CMAKE_CXX_FLAGS_COVERAGE "--coverage -fprofile-arcs -ftest-coverage -fno-default-inline -fno-inline -fno-inline-small-functions -fno-elide-constructors" @@ -137,6 +138,24 @@ if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR) endif() +# santiziers (ASAN) +if(ECL_ASAN) + message(STATUS "ecl address sanitizer enabled ") + + # environment variables + # ASAN_OPTIONS=detect_stack_use_after_return=1 + # ASAN_OPTIONS=check_initialization_order=1 + + add_compile_options( + -fsanitize=address + -g3 + -O1 + -fno-omit-frame-pointer + ) + + set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address) +endif() + add_subdirectory(airdata) add_subdirectory(attitude_fw) add_subdirectory(EKF) diff --git a/EKF/tests/base/base.cpp b/EKF/tests/base/base.cpp index 6b6ca5a183..0cd4a7cb75 100644 --- a/EKF/tests/base/base.cpp +++ b/EKF/tests/base/base.cpp @@ -143,5 +143,7 @@ int main(int argc, char *argv[]) //base->printStoredMag(); //base->printStoredGps(); + delete base; + return 0; } diff --git a/Jenkinsfile b/Jenkinsfile index 39eeed636f..f8cd5e9961 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -137,6 +137,24 @@ pipeline { } } + stage('test (asan)') { + agent { + docker { + image 'px4io/px4-dev-ecl:2018-04-22' + args '-v ${CCACHE_DIR}:${CCACHE_DIR}:rw' + } + } + steps { + sh 'export' + sh 'ccache -z' + sh 'make distclean' + sh 'make test_asan' + sh 'ccache -s' + sh 'make distclean' + } + } + + stage('doxygen') { agent { docker { diff --git a/Makefile b/Makefile index 98cea21dea..41f7c52a66 100644 --- a/Makefile +++ b/Makefile @@ -109,6 +109,11 @@ test_EKF: test_build test_EKF_plots: test_build @cmake --build $(SRC_DIR)/build/test_build --target ecl_EKF_pytest-plots +test_build_asan: + @$(call cmake-build,$@,$(SRC_DIR), "-DECL_ASAN=ON") + +test_asan: test_build_asan + @cmake --build $(SRC_DIR)/build/test_build_asan --target check # Code coverage # --------------------------------------------------------------------