diff --git a/unittests/CatchRunner.cpp b/unittests/CatchRunner.cpp index 59dde71ec..37767b5fe 100644 --- a/unittests/CatchRunner.cpp +++ b/unittests/CatchRunner.cpp @@ -74,6 +74,16 @@ void exit_qemu_failing(int error) { #include "testcfg/rtems/rtemsConfig.h" +void user_handle_fatal(Internal_errors_Source source, bool internal, Internal_errors_t error_code){ + if ( source == RTEMS_FATAL_SOURCE_EXIT ) { + if (error_code != 0) { + printk("*** EXIT STATUS NOT ZERO ***\n"); + printk("Quitting qemu with exit code %i\n", error_code); + exit_qemu_failing(error_code); + } + } +} + rtems_task Init(rtems_task_argument ignored) { rtems_time_of_day now; now.year = 2023; @@ -88,9 +98,6 @@ rtems_task Init(rtems_task_argument ignored) { const char* argv[] = {"fsfw-test", ""}; int result = Catch::Session().run(1, argv); customTeardown(); - if (result != 0) { - exit_qemu_failing(result); - } exit(result); } } diff --git a/unittests/testcfg/rtems/rtemsConfig.h b/unittests/testcfg/rtems/rtemsConfig.h index e9af11079..5988258e5 100644 --- a/unittests/testcfg/rtems/rtemsConfig.h +++ b/unittests/testcfg/rtems/rtemsConfig.h @@ -1,5 +1,10 @@ #pragma once + +#include +#include +void user_handle_fatal(Internal_errors_Source source, bool internal, Internal_errors_t error_code); + #define RTEMS_USE_UNLIMITED_OBJECTS_ALLOCATION 0 #define CONFIGURE_MICROSECONDS_PER_TICK 1000 @@ -19,6 +24,8 @@ //! Around 41 kB extra task stack for now. #define CONFIGURE_EXTRA_TASK_STACKS (10 * RTEMS_MINIMUM_STACK_SIZE) +#define CONFIGURE_INITIAL_EXTENSIONS { NULL, NULL, NULL, NULL, NULL, NULL, NULL, user_handle_fatal, NULL } + #define CONFIGURE_INIT #include