From 2e14d37061408a868c097eb6ab611c3a31f79c2d Mon Sep 17 00:00:00 2001 From: Daniel Agar Date: Sat, 5 May 2018 16:55:36 -0400 Subject: [PATCH 1/2] Jenkins code coverage build --- Jenkinsfile | 19 +++++++++++++++++++ Makefile | 5 ----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index fe42ac87e68b..ea9153946f5c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -292,6 +292,25 @@ pipeline { } } + stage('tests (code coverage)') { + agent { + docker { + image 'px4io/px4-dev-ros:2018-03-30' + args '-e CCACHE_BASEDIR=$WORKSPACE -v ${CCACHE_DIR}:${CCACHE_DIR}:rw' + } + } + steps { + sh 'export' + sh 'make distclean' + sh 'ulimit -c unlimited; make tests_coverage' + sh 'ls' + withCredentials([string(credentialsId: 'FIRMWARE_CODECOV_TOKEN', variable: 'CODECOV_TOKEN')]) { + sh 'curl -s https://codecov.io/bash | bash -s' + } + sh 'make distclean' + } + } + stage('check stack') { agent { docker { diff --git a/Makefile b/Makefile index 3cffdb0613cc..9804923431b3 100644 --- a/Makefile +++ b/Makefile @@ -288,11 +288,6 @@ tests: tests_coverage: @$(MAKE) clean - @$(MAKE) --no-print-directory posix_sitl_default PX4_CMAKE_BUILD_TYPE=Coverage - @$(MAKE) --no-print-directory posix_sitl_default sitl_gazebo PX4_CMAKE_BUILD_TYPE=Coverage - @$(SRC_DIR)/test/rostest_px4_run.sh mavros_posix_tests_missions.test - @$(SRC_DIR)/test/rostest_px4_run.sh mavros_posix_tests_offboard_attctl.test - @$(SRC_DIR)/test/rostest_px4_run.sh mavros_posix_tests_offboard_posctl.test @$(MAKE) --no-print-directory posix_sitl_default test_coverage_genhtml PX4_CMAKE_BUILD_TYPE=Coverage @echo "Open $(SRC_DIR)/build/posix_sitl_default/coverage-html/index.html to see coverage" From bff74185e70e49737a303ce0f05d9932ccf32260 Mon Sep 17 00:00:00 2001 From: Daniel Agar Date: Thu, 17 May 2018 20:08:03 -0400 Subject: [PATCH 2/2] posix main add SIGSEGV handler --- Jenkinsfile | 6 ++++++ platforms/posix/src/main.cpp | 28 +++++++++++++++++++++------- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index ea9153946f5c..d9f33bb318d4 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -309,6 +309,12 @@ pipeline { } sh 'make distclean' } + post { + failure { + sh('find . -name core') + sh('gdb --batch --quiet -ex "thread apply all bt full" -ex "quit" build/posix_sitl_default/px4 core') + } + } } stage('check stack') { diff --git a/platforms/posix/src/main.cpp b/platforms/posix/src/main.cpp index d0b19233a74d..790d8f494751 100644 --- a/platforms/posix/src/main.cpp +++ b/platforms/posix/src/main.cpp @@ -83,6 +83,7 @@ extern "C" { cout.flush(); _ExitFlag = true; } + void _SigFpeHandler(int sig_num); void _SigFpeHandler(int sig_num) { @@ -91,6 +92,15 @@ extern "C" { PX4_BACKTRACE(); cout.flush(); } + + void _SigSegvHandler(int sig_num); + void _SigSegvHandler(int sig_num) + { + cout.flush(); + cout << endl << "segmentation fault" << endl; + PX4_BACKTRACE(); + cout.flush(); + } } static inline bool fileExists(const string &name) @@ -299,20 +309,24 @@ int main(int argc, char **argv) tcgetattr(0, &orig_term); atexit(restore_term); - struct sigaction sig_int; - memset(&sig_int, 0, sizeof(struct sigaction)); + // SIGINT + struct sigaction sig_int {}; sig_int.sa_handler = _SigIntHandler; sig_int.sa_flags = 0;// not SA_RESTART!; + sigaction(SIGINT, &sig_int, nullptr); - struct sigaction sig_fpe; - memset(&sig_fpe, 0, sizeof(struct sigaction)); + // SIGFPE + struct sigaction sig_fpe {}; sig_fpe.sa_handler = _SigFpeHandler; sig_fpe.sa_flags = 0;// not SA_RESTART!; - - sigaction(SIGINT, &sig_int, nullptr); - //sigaction(SIGTERM, &sig_int, NULL); sigaction(SIGFPE, &sig_fpe, nullptr); + // SIGSEGV + struct sigaction sig_segv {}; + sig_segv.sa_handler = _SigSegvHandler; + sig_segv.sa_flags = SA_RESTART | SA_SIGINFO; + sigaction(SIGSEGV, &sig_segv, nullptr); + set_cpu_scaling(); int index = 1;