diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index 64c32237f..b97c3a9a8 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -2,6 +2,7 @@ pipeline { environment { BUILDDIR_HOST = 'cmake-build-tests-host' BUILDDIR_LINUX = 'cmake-build-tests-linux' + BUILDDIR_FREERTOS = 'cmake-build-tests-freertos' DOCDDIR = 'cmake-build-documentation' } agent { @@ -12,76 +13,38 @@ pipeline { } stages { stage('Host') { - stages{ - stage('Clean') { - steps { - sh 'rm -rf $BUILDDIR_HOST' - } - } - stage('Configure') { - steps { - dir(BUILDDIR_HOST) { - sh 'cmake -DFSFW_OSAL=host -DFSFW_BUILD_TESTS=ON -DFSFW_CICD_BUILD=ON ..' - } - } - } - stage('Build') { - steps { - dir(BUILDDIR_HOST) { - sh 'cmake --build . -j4' - } - } - } - stage('Unittests') { - steps { - dir(BUILDDIR_HOST) { - sh 'cmake --build . -- fsfw-tests_coverage -j4' - } - } - } - stage('Valgrind') { - steps { - dir(BUILDDIR_HOST) { - sh 'valgrind --leak-check=full --error-exitcode=1 ./fsfw-tests' - } - } + steps { + sh 'rm -rf $BUILDDIR_HOST' + + dir(BUILDDIR_LINUX) { + sh 'cmake -DFSFW_OSAL=host -DFSFW_BUILD_TESTS=ON -DFSFW_CICD_BUILD=ON ..' + sh 'cmake --build . -j4' + sh 'cmake --build . -- fsfw-tests_coverage -j4' + sh 'valgrind --leak-check=full --error-exitcode=1 ./fsfw-tests' } } } stage('Linux') { - stages{ - stage('Clean') { - steps { - sh 'rm -rf $BUILDDIR_LINUX' - } + steps { + sh 'rm -rf $BUILDDIR_HOST' + + dir(BUILDDIR_HOST) { + sh 'cmake -DFSFW_OSAL=linux -DFSFW_BUILD_TESTS=ON -DFSFW_CICD_BUILD=ON ..' + sh 'cmake --build . -j4' + sh 'cmake --build . -- fsfw-tests_coverage -j4' + sh 'valgrind --leak-check=full --error-exitcode=1 ./fsfw-tests' } - stage('Configure') { - steps { - dir(BUILDDIR_LINUX) { - sh 'cmake -DFSFW_OSAL=linux -DFSFW_BUILD_TESTS=ON -DFSFW_CICD_BUILD=ON ..' - } - } - } - stage('Build') { - steps { - dir(BUILDDIR_LINUX) { - sh 'cmake --build . -j4' - } - } - } - stage('Unittests') { - steps { - dir(BUILDDIR_LINUX) { - sh 'cmake --build . -- fsfw-tests_coverage -j4' - } - } - } - stage('Valgrind') { - steps { - dir(BUILDDIR_LINUX) { - sh 'valgrind --leak-check=full --error-exitcode=1 ./fsfw-tests' - } - } + } + } + stage('FreeRTOS') { + steps { + sh 'rm -rf $BUILDDIR_FREERTOS' + + dir(BUILDDIR_FREERTOS) { + sh 'cmake -DFSFW_OSAL=freertos -DFSFW_BUILD_TESTS=ON -DFSFW_CICD_BUILD=ON ..' + sh 'cmake --build . -j4' + sh 'cmake --build . -- fsfw-tests_coverage -j4' + //sh 'valgrind --leak-check=full --error-exitcode=1 ./fsfw-tests' } } } diff --git a/src/fsfw/osal/freertos/Clock.cpp b/src/fsfw/osal/freertos/Clock.cpp index dc00ac7ea..4ff340f56 100644 --- a/src/fsfw/osal/freertos/Clock.cpp +++ b/src/fsfw/osal/freertos/Clock.cpp @@ -110,11 +110,13 @@ ReturnValue_t Clock::convertTimeOfDayToTimeval(const TimeOfDay_t* from, timeval* time_tm.tm_min = from->minute; time_tm.tm_sec = from->second; - time_t seconds = mktime(&time_tm); + time_tm.tm_isdst = 0; + + time_t seconds = timegm(&time_tm); to->tv_sec = seconds; to->tv_usec = from->usecond; - // Fails in 2038.. + return returnvalue::OK; } diff --git a/src/fsfw/timemanager/CCSDSTime.cpp b/src/fsfw/timemanager/CCSDSTime.cpp index cb0d57587..4ee5362a5 100644 --- a/src/fsfw/timemanager/CCSDSTime.cpp +++ b/src/fsfw/timemanager/CCSDSTime.cpp @@ -552,10 +552,7 @@ ReturnValue_t CCSDSTime::convertFromCDS(timeval* to, const CCSDSTime::CDS_short* if (to == nullptr or from == nullptr) { return returnvalue::FAILED; } - uint16_t days = (from->dayMSB << 8) + from->dayLSB; - if (days <= DAYS_CCSDS_TO_UNIX_EPOCH) { - return INVALID_TIME_FORMAT; - } + int32_t days = (from->dayMSB << 8) + from->dayLSB; days -= DAYS_CCSDS_TO_UNIX_EPOCH; to->tv_sec = days * SECONDS_PER_DAY; uint32_t msDay = diff --git a/unittests/CatchRunner.cpp b/unittests/CatchRunner.cpp index 5149f8b53..8478efbf6 100644 --- a/unittests/CatchRunner.cpp +++ b/unittests/CatchRunner.cpp @@ -24,15 +24,19 @@ extern int customTeardown(); #ifdef FSFW_OSAL_FREERTOS struct Taskparameters { - int argc; char** argv; + int argc; char** argv;TaskHandle_t catchTask; } taskParameters; void unittestTaskFunction( void *pvParameters ) { - puts("go"); Taskparameters* parameters = (Taskparameters*)pvParameters; + int result = Catch::Session().run(parameters->argc, parameters->argv); - puts("gone"); - vTaskDelete( NULL ); + + vTaskDelay(pdMS_TO_TICKS(10)); + vTaskSuspendAll(); + vTaskDelete(parameters->catchTask); + customTeardown(); + exit(result); } #endif @@ -42,21 +46,17 @@ int main(int argc, char* argv[]) { 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.catchTask); /* The task handle is not required, so NULL is passed. */ taskParameters.argc = argc; taskParameters.argv = argv; vTaskStartScheduler(); #else - puts("nom"); // Catch internal function call result = Catch::Session().run(argc, argv); #endif diff --git a/unittests/osal/TestClock.cpp b/unittests/osal/TestClock.cpp index 5d198db1a..663bcf331 100644 --- a/unittests/osal/TestClock.cpp +++ b/unittests/osal/TestClock.cpp @@ -5,6 +5,8 @@ #include #include +#include + #include "CatchDefinitions.h" TEST_CASE("OSAL::Clock Test", "[OSAL::Clock Test]") { diff --git a/unittests/testcfg/freertos/FreeRTOSConfig.h b/unittests/testcfg/freertos/FreeRTOSConfig.h index 0c4d78f8a..2f58e3545 100644 --- a/unittests/testcfg/freertos/FreeRTOSConfig.h +++ b/unittests/testcfg/freertos/FreeRTOSConfig.h @@ -4,11 +4,9 @@ #define configUSE_PREEMPTION 1 #define configUSE_PORT_OPTIMISED_TASK_SELECTION 0 #define configUSE_TICKLESS_IDLE 0 -#define configCPU_CLOCK_HZ 60000000 -#define configSYSTICK_CLOCK_HZ 1000000 -#define configTICK_RATE_HZ 250 +#define configTICK_RATE_HZ 1000 #define configMAX_PRIORITIES 5 -#define configMINIMAL_STACK_SIZE 128 +#define configMINIMAL_STACK_SIZE ( ( unsigned short ) PTHREAD_STACK_MIN ) #define configMAX_TASK_NAME_LEN 16 #define configUSE_16_BIT_TICKS 0 #define configIDLE_SHOULD_YIELD 1 @@ -18,7 +16,7 @@ #define configUSE_RECURSIVE_MUTEXES 0 #define configUSE_COUNTING_SEMAPHORES 1 #define configUSE_ALTERNATIVE_API 0 /* Deprecated! */ -#define configQUEUE_REGISTRY_SIZE 10 +#define configQUEUE_REGISTRY_SIZE 20 #define configUSE_QUEUE_SETS 0 #define configUSE_TIME_SLICING 0 #define configUSE_NEWLIB_REENTRANT 0 @@ -32,7 +30,7 @@ /* Memory allocation related definitions. */ #define configSUPPORT_STATIC_ALLOCATION 0 #define configSUPPORT_DYNAMIC_ALLOCATION 1 -#define configTOTAL_HEAP_SIZE 10240 +#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 1024 * 1024 ) ) #define configAPPLICATION_ALLOCATED_HEAP 1 #define configSTACK_ALLOCATION_FROM_SEPARATE_HEAP 0