Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jenkins tests code coverage build + SIGSEGV handler #9419

Merged
merged 2 commits into from
May 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,31 @@ 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'
}
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') {
agent {
docker {
Expand Down
5 changes: 0 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
28 changes: 21 additions & 7 deletions platforms/posix/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ extern "C" {
cout.flush();
_ExitFlag = true;
}

void _SigFpeHandler(int sig_num);
void _SigFpeHandler(int sig_num)
{
Expand All @@ -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)
Expand Down Expand Up @@ -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;
Expand Down