Skip to content

Commit

Permalink
cmake and Jenkins add basic address santiizer test buld
Browse files Browse the repository at this point in the history
  • Loading branch information
dagar committed May 5, 2018
1 parent 1fba622 commit 3639087
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 0 deletions.
19 changes: 19 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions EKF/tests/base/base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,5 +143,7 @@ int main(int argc, char *argv[])
//base->printStoredMag();
//base->printStoredGps();

delete base;

return 0;
}
18 changes: 18 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
# --------------------------------------------------------------------
Expand Down

0 comments on commit 3639087

Please sign in to comment.