110 lines
2.4 KiB
C++
110 lines
2.4 KiB
C++
/**
|
|
* @file CatchRunner.cpp
|
|
* @brief Source file to compile catch framework.
|
|
* @details All tests should be written in other files.
|
|
* For eclipse console output, install ANSI Escape in Console
|
|
* from the eclipse market place to get colored characters.
|
|
*/
|
|
|
|
#include "CatchRunner.h"
|
|
|
|
#define CATCH_CONFIG_COLOUR_WINDOWS
|
|
|
|
#include <fsfw/osal/osal.h>
|
|
|
|
#include <catch2/catch_session.hpp>
|
|
|
|
#ifdef FSFW_OSAL_FREERTOS
|
|
#include <FreeRTOS.h>
|
|
|
|
#include "task.h"
|
|
#endif
|
|
|
|
extern int customSetup();
|
|
extern int customTeardown();
|
|
|
|
#ifdef FSFW_OSAL_FREERTOS
|
|
struct Taskparameters {
|
|
int argc;
|
|
char** argv;
|
|
TaskHandle_t catchTask;
|
|
} taskParameters;
|
|
|
|
void unittestTaskFunction(void* pvParameters) {
|
|
Taskparameters* parameters = (Taskparameters*)pvParameters;
|
|
|
|
int result = Catch::Session().run(parameters->argc, parameters->argv);
|
|
|
|
vTaskDelay(pdMS_TO_TICKS(10));
|
|
vTaskSuspendAll();
|
|
vTaskDelete(parameters->catchTask);
|
|
customTeardown();
|
|
exit(result);
|
|
}
|
|
#endif
|
|
|
|
#ifdef FSFW_OSAL_RTEMS
|
|
#include <signal.h>
|
|
|
|
int sigaltstack(const stack_t * ss, stack_t * old_ss){
|
|
return 0;
|
|
}
|
|
extern "C" {
|
|
|
|
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
|
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
|
|
|
|
#define CONFIGURE_UNLIMITED_OBJECTS
|
|
#define CONFIGURE_UNIFIED_WORK_AREAS
|
|
|
|
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
|
|
|
|
#define CONFIGURE_INIT
|
|
|
|
#include <rtems/confdefs.h>
|
|
|
|
|
|
#include <rtems.h>
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
|
|
rtems_task Init(
|
|
rtems_task_argument ignored
|
|
)
|
|
{
|
|
printf( "\nHello World\n" );
|
|
char* argv[] = {"fsfw-test"};
|
|
int result = Catch::Session().run(1, argv);
|
|
exit( result );
|
|
}
|
|
|
|
}
|
|
#endif
|
|
|
|
int main(int argc, char* argv[]) {
|
|
customSetup();
|
|
|
|
int result = 0;
|
|
|
|
#ifdef FSFW_OSAL_FREERTOS
|
|
xTaskCreate(
|
|
unittestTaskFunction, /* The function that implements the task. */
|
|
"Unittests", /* The text name assigned to the task - for debug only as it is not used by the
|
|
kernel. */
|
|
configMINIMAL_STACK_SIZE, /* The size of the stack to allocate to the task. */
|
|
&taskParameters, /* The parameter passed to the task - not used in this simple case. */
|
|
1, /* The priority assigned to the task. */
|
|
&taskParameters.catchTask); /* The task handle is not required, so NULL is passed. */
|
|
taskParameters.argc = argc;
|
|
taskParameters.argv = argv;
|
|
vTaskStartScheduler();
|
|
#else
|
|
// Catch internal function call
|
|
result = Catch::Session().run(argc, argv);
|
|
#endif
|
|
|
|
// global clean-up
|
|
customTeardown();
|
|
return result;
|
|
}
|