unittests running but failing

This commit is contained in:
Ulrich Mohr 2023-01-13 12:48:14 +01:00
parent a993c4e0d4
commit 39dad5f45b
5 changed files with 49 additions and 5 deletions

View File

@ -174,7 +174,7 @@ if(FSFW_BUILD_TESTS)
configure_file(unittests/testcfg/FSFWConfig.h.in FSFWConfig.h)
configure_file(unittests/testcfg/TestsConfig.h.in tests/TestsConfig.h)
if(FSFW_OSAL MATCHES "freertos")
if(FSFW_OSAL MATCHES "freertos")
message(
STATUS
"${MSG_PREFIX} Downloading FreeRTOS with FetchContent"
@ -193,7 +193,6 @@ if(FSFW_BUILD_TESTS)
set(LIB_OS_NAME FreeRTOS)
target_include_directories(FreeRTOS PUBLIC unittests/testcfg/freertos)
endif()
project(${FSFW_TEST_TGT} CXX C)
@ -385,6 +384,9 @@ if(FSFW_BUILD_TESTS)
endif()
target_link_libraries(${FSFW_TEST_TGT} PRIVATE Catch2::Catch2
${LIB_FSFW_NAME})
if(FSFW_OSAL MATCHES "freertos")
target_link_libraries(${FSFW_TEST_TGT} PRIVATE FreeRTOS)
endif()
endif()
# The project CMakeLists file has to set the FSFW_CONFIG_PATH and add it. If

View File

@ -11,15 +11,55 @@
#define CATCH_CONFIG_COLOUR_WINDOWS
#include <catch2/catch_session.hpp>
#include <fsfw/osal/osal.h>
#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;
} taskParameters;
void unittestTaskFunction( void *pvParameters ) {
puts("go");
Taskparameters* parameters = (Taskparameters*)pvParameters;
int result = Catch::Session().run(parameters->argc, parameters->argv);
puts("gone");
vTaskDelete( NULL );
}
#endif
int main(int argc, char* argv[]) {
customSetup();
int result = 0;
puts("pre");
#ifdef FSFW_OSAL_FREERTOS
puts("task");
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. */
NULL ); /* The task handle is not required, so NULL is passed. */
taskParameters.argc = argc;
taskParameters.argv = argv;
vTaskStartScheduler();
#else
puts("nom");
// Catch internal function call
int result = Catch::Session().run(argc, argv);
result = Catch::Session().run(argc, argv);
#endif
// global clean-up
customTeardown();

View File

@ -6,6 +6,8 @@
#include <gcov.h>
#endif
#include "fsfw/objectmanager/ObjectManager.h"
#include "fsfw/serviceinterface/ServiceInterface.h"
#include "fsfw/storagemanager/StorageManagerIF.h"

View File

@ -5,7 +5,7 @@
#include <catch2/catch_test_macros.hpp>
// binary semaphores currently only supported on linux
#ifdef FSFW_OSAL_LINUX
#if defined(FSFW_OSAL_LINUX) || defined(FSFW_OSAL_FREERTOS)
TEST_CASE("Binary Semaphore Test", "[BinSemaphore]") {
// perform set-up here

View File

@ -16,7 +16,7 @@
#define configTASK_NOTIFICATION_ARRAY_ENTRIES 3
#define configUSE_MUTEXES 1
#define configUSE_RECURSIVE_MUTEXES 0
#define configUSE_COUNTING_SEMAPHORES 0
#define configUSE_COUNTING_SEMAPHORES 1
#define configUSE_ALTERNATIVE_API 0 /* Deprecated! */
#define configQUEUE_REGISTRY_SIZE 10
#define configUSE_QUEUE_SETS 0