Skip to content
Snippets Groups Projects
Commit c1a58bda authored by Lukas Woodtli's avatar Lukas Woodtli Committed by Lorenz Meier
Browse files

Add address sanitizer to SITL pipeline


- Environment variables for building with asan
- Docker argument for leak sanitizer
- Regex for tests to fail on sanitizer error

Signed-off-by: default avatarLukas Woodtli <woodtli.lukas@gmail.com>
parent eb4f8473
No related branches found
No related tags found
No related merge requests found
......@@ -12,12 +12,27 @@ pipeline {
}
stages {
stage('Setup Environment') {
steps {
script {
env.CTEST_OUTPUT_ON_FAILURE=1
if (env.PX4_CMAKE_BUILD_TYPE == 'AddressSanitizer') {
env.PX4_ASAN=1
env.ASAN_OPTIONS="detect_stack_use_after_return=1:check_initialization_order=1"
}
}
}
}
stage('Build') {
agent {
docker {
image 'px4io/px4-dev-ros-kinetic:2018-09-11'
args '-e CCACHE_BASEDIR=$WORKSPACE -v ${CCACHE_DIR}:${CCACHE_DIR}:rw -e HOME=$WORKSPACE'
args '-e CCACHE_BASEDIR=$WORKSPACE -v ${CCACHE_DIR}:${CCACHE_DIR}:rw -e HOME=$WORKSPACE --cap-add SYS_PTRACE'
}
}
......@@ -128,7 +143,7 @@ pipeline {
],
]
def test_nodes = [:]
for (def i = 0; i < missions.size(); i++) {
test_nodes.put(missions[i].name, createTestNode(missions[i]))
......@@ -146,7 +161,7 @@ pipeline {
agent {
docker {
image 'px4io/px4-dev-base:2018-09-11'
args '-e CCACHE_BASEDIR=$WORKSPACE -v ${CCACHE_DIR}:${CCACHE_DIR}:rw'
args '-e CCACHE_BASEDIR=$WORKSPACE -v ${CCACHE_DIR}:${CCACHE_DIR}:rw --cap-add SYS_PTRACE'
}
}
steps {
......@@ -169,7 +184,7 @@ pipeline {
agent {
docker {
image 'px4io/px4-dev-base:2018-09-11'
args '-e CCACHE_BASEDIR=$WORKSPACE -v ${CCACHE_DIR}:${CCACHE_DIR}:rw'
args '-e CCACHE_BASEDIR=$WORKSPACE -v ${CCACHE_DIR}:${CCACHE_DIR}:rw --cap-add SYS_PTRACE'
}
}
steps {
......@@ -204,7 +219,7 @@ def createTestNode(Map test_def) {
return {
node {
cleanWs()
docker.image("px4io/px4-dev-ros-kinetic:2018-09-11").inside('-e HOME=${WORKSPACE}') {
docker.image("px4io/px4-dev-ros-kinetic:2018-09-11").inside('-e HOME=${WORKSPACE} --cap-add SYS_PTRACE') {
stage(test_def.name) {
try {
......
......@@ -60,6 +60,13 @@ if (SANITIZE_ADDRESS)
-fno-optimize-sibling-calls
)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address" CACHE INTERNAL "" FORCE)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=address" CACHE INTERNAL "" FORCE)
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fsanitize=address" CACHE INTERNAL "" FORCE)
function(sanitizer_fail_test_on_error test_name)
set_tests_properties(${test_name} PROPERTIES FAIL_REGULAR_EXPRESSION "ERROR: AddressSanitizer")
set_tests_properties(${test_name} PROPERTIES FAIL_REGULAR_EXPRESSION "ERROR: LeakSanitizer")
endfunction(sanitizer_fail_test_on_error)
elseif(SANITIZE_MEMORY)
message(STATUS "MemorySanitizer enabled")
......@@ -68,7 +75,11 @@ elseif(SANITIZE_MEMORY)
-g3
-fsanitize=memory
)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=memory" CACHE INTERNAL "" FORCE)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=memory" CACHE INTERNAL "" FORCE)
function(sanitizer_fail_test_on_error test_name)
# TODO add right check here
endfunction(sanitizer_fail_test_on_error)
elseif(SANITIZE_THREAD)
message(STATUS "ThreadSanitizer enabled")
......@@ -79,6 +90,10 @@ elseif(SANITIZE_THREAD)
)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=thread" CACHE INTERNAL "" FORCE)
function(sanitizer_fail_test_on_error test_name)
# TODO add right check here
endfunction(sanitizer_fail_test_on_error)
elseif(SANITIZE_UNDEFINED)
message(STATUS "UndefinedBehaviorSanitizer enabled")
......@@ -113,4 +128,13 @@ elseif(SANITIZE_UNDEFINED)
)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=undefined" CACHE INTERNAL "" FORCE)
function(sanitizer_fail_test_on_error test_name)
# TODO add right check here
endfunction(sanitizer_fail_test_on_error)
else()
function(sanitizer_fail_test_on_error test_name)
# default: don't do anything
endfunction(sanitizer_fail_test_on_error)
endif()
......@@ -58,6 +58,8 @@ foreach(test_name ${tests})
set_tests_properties(${test_name} PROPERTIES FAIL_REGULAR_EXPRESSION "${test_name} FAILED")
set_tests_properties(${test_name} PROPERTIES PASS_REGULAR_EXPRESSION "${test_name} PASSED")
sanitizer_fail_test_on_error(${test_name})
endforeach()
......@@ -75,6 +77,7 @@ add_test(NAME mavlink
set_tests_properties(mavlink PROPERTIES FAIL_REGULAR_EXPRESSION "mavlink FAILED")
set_tests_properties(mavlink PROPERTIES PASS_REGULAR_EXPRESSION "mavlink PASSED")
sanitizer_fail_test_on_error(mavlink)
# run arbitrary commands
set(test_cmds
......@@ -97,6 +100,7 @@ foreach(cmd_name ${test_cmds})
${PX4_BINARY_DIR}
WORKING_DIRECTORY ${SITL_WORKING_DIR})
sanitizer_fail_test_on_error(posix_${cmd_name})
set_tests_properties(posix_${cmd_name} PROPERTIES PASS_REGULAR_EXPRESSION "Shutting down")
endforeach()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment