Skip to content

Commit

Permalink
CI: enable backtrace using cpptrace
Browse files Browse the repository at this point in the history
Trying to get a backtrace from the hunter crash.

Signed-off-by: Julian Oes <julian@oes.ch>
  • Loading branch information
julianoes committed Aug 28, 2023
1 parent 6d2d17d commit 488e6a5
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 26 deletions.
27 changes: 2 additions & 25 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,41 +128,18 @@ jobs:
with:
path: ~/.hunter
key: ${{ github.job }}-${{ hashFiles('~/.hunter/**') }}-3
- name: install GDB
run: sudo apt-get install gdb
- name: install mavlink on the system
run: |
cmake -Bthird_party/mavlink/build -Sthird_party/mavlink
sudo cmake --build third_party/mavlink/build
- name: configure
run: cmake -DSUPERBUILD=OFF -DHUNTER_ENABLED=ON -DCMAKE_TOOLCHAIN_FILE=$(pwd)/src/cmake/fpic_toolchain.cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_MAVSDK_SERVER=OFF -DBUILD_SHARED_LIBS=OFF -Bbuild -H.
run: cmake -DSUPERBUILD=OFF -DHUNTER_ENABLED=ON -DCMAKE_TOOLCHAIN_FILE=$(pwd)/src/cmake/fpic_toolchain.cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_MAVSDK_SERVER=OFF -DBUILD_SHARED_LIBS=OFF -Bbuild -H. -DENABLE_CPPTRACE=On
- name: build
run: cmake --build build -j2
- name: enable core dumps
run: |
sudo bash -c 'echo "/home/runner/work/cores/%e.%p.%t" > /proc/sys/kernel/core_pattern'
sudo cat /proc/sys/kernel/core_pattern
mkdir /home/runner/work/cores/
- name: test enabling cores
run: |
ulimit -c # should output 0 if disabled
ulimit -c unlimited
ulimit -c
- name: unit tests
run: ./build/src/unit_tests/unit_tests_runner
- name: system tests
run: gdb -batch -ex "run" -ex "bt" --args ./build/src/system_tests/system_tests_runner --gtest_catch_exceptions=0
- name: check core files
if: failure()
run: |
ls -l /home/runner/work/cores/
- uses: actions/upload-artifact@v3
if: failure()
with:
name: crashes
path: |
/home/runner/work/cores/
./build/
run: ./build/src/system_tests/system_tests_runner --gtest_catch_exceptions=0

ubuntu22-style-and-proto-check:
name: ubuntu-22.04 (style and proto check)
Expand Down
14 changes: 13 additions & 1 deletion src/system_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
add_executable(system_tests_runner
../mavsdk/core/unittests_main.cpp
camera_take_photo.cpp
component_information.cpp
action_arm_disarm.cpp
Expand All @@ -18,6 +17,7 @@ add_executable(system_tests_runner
ftp_remove_dir.cpp
ftp_compare_files.cpp
ftp_list_dir.cpp
system_tests_runner.cpp
)

target_include_directories(system_tests_runner
Expand All @@ -32,3 +32,15 @@ target_link_libraries(system_tests_runner
gtest_main
gmock
)

if(ENABLE_CPPTRACE)
find_package(cpptrace REQUIRED)
target_link_libraries(system_tests_runner
PRIVATE
cpptrace::cpptrace
)
target_compile_definitions(system_tests_runner
PRIVATE
-DENABLE_CPPTRACE
)
endif()
32 changes: 32 additions & 0 deletions src/system_tests/system_tests_runner.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#if defined(ENABLE_CPPTRACE)
#include <signal.h>
#include <cpptrace/cpptrace.hpp>
#include "log.h"
#include <cstring>
#endif
#include <gtest/gtest.h>

#if defined(ENABLE_CPPTRACE)
void handler(int sig)
{
mavsdk::LogErr() << "Got signal: " << strsignal(sig) << " (" << sig << ")";
cpptrace::print_trace();
exit(1);
}
#endif

int main(int argc, char** argv)
{
#if defined(ENABLE_CPPTRACE)
signal(SIGSEGV, handler);
signal(SIGQUIT, handler);
signal(SIGABRT, handler);
signal(SIGILL, handler);
signal(SIGBUS, handler);
signal(SIGPIPE, handler);
signal(SIGFPE, handler);
#endif

::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
4 changes: 4 additions & 0 deletions third_party/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,9 @@ if (SUPERBUILD)
build_target(re2)
build_target(grpc)
endif()

endif()

if (ENABLE_CPPTRACE)
build_target(cpptrace)
endif()

0 comments on commit 488e6a5

Please sign in to comment.