diff --git a/FreeRTOS/Demo/Posix_GCC/CMakeLists.txt b/FreeRTOS/Demo/Posix_GCC/CMakeLists.txt index 8abeb4ef87..4917ed3f21 100644 --- a/FreeRTOS/Demo/Posix_GCC/CMakeLists.txt +++ b/FreeRTOS/Demo/Posix_GCC/CMakeLists.txt @@ -10,7 +10,7 @@ else() add_compile_options( -DTRACE_ON_ENTER=0 ) endif() -if( COVERAGE_TEST ) +if( ( COVERAGE_TEST ) OR ( NO_TRACING ) ) set( COVERAGE_TEST 1 ) add_compile_options( -DprojCOVERAGE_TEST=1 ) else() diff --git a/FreeRTOS/Demo/Posix_GCC/code_coverage_additions.c b/FreeRTOS/Demo/Posix_GCC/code_coverage_additions.c index f0336bc29d..00af569dff 100644 --- a/FreeRTOS/Demo/Posix_GCC/code_coverage_additions.c +++ b/FreeRTOS/Demo/Posix_GCC/code_coverage_additions.c @@ -143,129 +143,133 @@ static BaseType_t prvStaticAllocationsWithNullBuffers( void ) } /*-----------------------------------------------------------*/ -static BaseType_t prvTraceUtils( void ) -{ - EventGroupHandle_t xEventGroup; - QueueHandle_t xQueue; - BaseType_t xReturn = pdPASS; - const UBaseType_t xNumber = ( UBaseType_t ) 100, xQueueLength = ( UBaseType_t ) 1; - UBaseType_t uxValue; - TaskHandle_t xTaskHandle; - StreamBufferHandle_t xStreamBuffer; - MessageBufferHandle_t xMessageBuffer; - - /* Exercise the event group trace utilities. */ - xEventGroup = xEventGroupCreate(); +#if( configUSE_TRACE_FACILITY == 1 ) - if( xEventGroup != NULL ) + static BaseType_t prvTraceUtils( void ) { - vEventGroupSetNumber( xEventGroup, xNumber ); + EventGroupHandle_t xEventGroup; + QueueHandle_t xQueue; + BaseType_t xReturn = pdPASS; + const UBaseType_t xNumber = ( UBaseType_t ) 100, xQueueLength = ( UBaseType_t ) 1; + UBaseType_t uxValue; + TaskHandle_t xTaskHandle; + StreamBufferHandle_t xStreamBuffer; + MessageBufferHandle_t xMessageBuffer; - if( uxEventGroupGetNumber( NULL ) != 0 ) + /* Exercise the event group trace utilities. */ + xEventGroup = xEventGroupCreate(); + + if( xEventGroup != NULL ) { - xReturn = pdFAIL; - } + vEventGroupSetNumber( xEventGroup, xNumber ); + + if( uxEventGroupGetNumber( NULL ) != 0 ) + { + xReturn = pdFAIL; + } - if( uxEventGroupGetNumber( xEventGroup ) != xNumber ) + if( uxEventGroupGetNumber( xEventGroup ) != xNumber ) + { + xReturn = pdFAIL; + } + + vEventGroupDelete( xEventGroup ); + } + else { xReturn = pdFAIL; } - vEventGroupDelete( xEventGroup ); - } - else - { - xReturn = pdFAIL; - } + /* Exercise the queue trace utilities. */ + xQueue = xQueueCreate( xQueueLength, ( UBaseType_t ) sizeof( uxValue ) ); - /* Exercise the queue trace utilities. */ - xQueue = xQueueCreate( xQueueLength, ( UBaseType_t ) sizeof( uxValue ) ); + if( xQueue != NULL ) + { + vQueueSetQueueNumber( xQueue, xNumber ); - if( xQueue != NULL ) - { - vQueueSetQueueNumber( xQueue, xNumber ); + if( uxQueueGetQueueNumber( xQueue ) != xNumber ) + { + xReturn = pdFAIL; + } + + if( ucQueueGetQueueType( xQueue ) != queueQUEUE_TYPE_BASE ) + { + xReturn = pdFAIL; + } - if( uxQueueGetQueueNumber( xQueue ) != xNumber ) + vQueueDelete( xQueue ); + } + else { xReturn = pdFAIL; } - if( ucQueueGetQueueType( xQueue ) != queueQUEUE_TYPE_BASE ) + /* Exercise the task trace utilities. Value of 100 is arbitrary, just + * want to check the value that is set is also read back. */ + uxValue = 100; + xTaskHandle = xTaskGetCurrentTaskHandle(); + vTaskSetTaskNumber( xTaskHandle, uxValue ); + + if( uxTaskGetTaskNumber( xTaskHandle ) != uxValue ) { xReturn = pdFAIL; } - vQueueDelete( xQueue ); - } - else - { - xReturn = pdFAIL; - } - - /* Exercise the task trace utilities. Value of 100 is arbitrary, just want - * to check the value that is set is also read back. */ - uxValue = 100; - xTaskHandle = xTaskGetCurrentTaskHandle(); - vTaskSetTaskNumber( xTaskHandle, uxValue ); + if( uxTaskGetTaskNumber( NULL ) != 0 ) + { + xReturn = pdFAIL; + } - if( uxTaskGetTaskNumber( xTaskHandle ) != uxValue ) - { - xReturn = pdFAIL; - } + /* Timer trace util functions are exercised in prvTimerQuery(). */ - if( uxTaskGetTaskNumber( NULL ) != 0 ) - { - xReturn = pdFAIL; - } - /* Timer trace util functions are exercised in prvTimerQuery(). */ + /* Exercise the stream buffer utilities. Try creating with a trigger + * level of 0, it should then get capped to 1. */ + xStreamBuffer = xStreamBufferCreate( sizeof( uint32_t ), 0 ); + if( xStreamBuffer != NULL ) + { + vStreamBufferSetStreamBufferNumber( xStreamBuffer, uxValue ); - /* Exercise the stream buffer utilities. Try creating with a trigger level - * of 0, it should then get capped to 1. */ - xStreamBuffer = xStreamBufferCreate( sizeof( uint32_t ), 0 ); + if( uxStreamBufferGetStreamBufferNumber( xStreamBuffer ) != uxValue ) + { + xReturn = pdFALSE; + } - if( xStreamBuffer != NULL ) - { - vStreamBufferSetStreamBufferNumber( xStreamBuffer, uxValue ); + if( ucStreamBufferGetStreamBufferType( xStreamBuffer ) != 0 ) + { + /* "Is Message Buffer" flag should have been 0. */ + xReturn = pdFALSE; + } - if( uxStreamBufferGetStreamBufferNumber( xStreamBuffer ) != uxValue ) - { - xReturn = pdFALSE; + vStreamBufferDelete( xStreamBuffer ); } - - if( ucStreamBufferGetStreamBufferType( xStreamBuffer ) != 0 ) + else { - /* "Is Message Buffer" flag should have been 0. */ xReturn = pdFALSE; } - vStreamBufferDelete( xStreamBuffer ); - } - else - { - xReturn = pdFALSE; - } + xMessageBuffer = xMessageBufferCreate( sizeof( uint32_t ) ); - xMessageBuffer = xMessageBufferCreate( sizeof( uint32_t ) ); + if( xMessageBuffer != NULL ) + { + if( ucStreamBufferGetStreamBufferType( xMessageBuffer ) == 0 ) + { + /* "Is Message Buffer" flag should have been 1. */ + xReturn = pdFALSE; + } - if( xMessageBuffer != NULL ) - { - if( ucStreamBufferGetStreamBufferType( xMessageBuffer ) == 0 ) + vMessageBufferDelete( xMessageBuffer ); + } + else { - /* "Is Message Buffer" flag should have been 1. */ xReturn = pdFALSE; } - vMessageBufferDelete( xMessageBuffer ); - } - else - { - xReturn = pdFALSE; + return xReturn; } - return xReturn; -} +#endif /* #if( configUSE_TRACE_FACILITY == 1 ) */ /*-----------------------------------------------------------*/ static BaseType_t prvPeekTimeout( void ) @@ -370,128 +374,132 @@ static BaseType_t prvQueueQueryFromISR( void ) } /*-----------------------------------------------------------*/ -static BaseType_t prvTaskQueryFunctions( void ) -{ - static TaskStatus_t xStatus, * pxStatusArray; - TaskHandle_t xTimerTask, xIdleTask; - BaseType_t xReturn = pdPASS; - UBaseType_t uxNumberOfTasks, uxReturned, ux; - uint32_t ulTotalRunTime1, ulTotalRunTime2; - const uint32_t ulRunTimeTollerance = ( uint32_t ) 0xfff; +#if( configUSE_TRACE_FACILITY == 1) - /* Obtain task status with the stack high water mark and without the - * state. */ - vTaskGetInfo( NULL, &xStatus, pdTRUE, eRunning ); - - if( uxTaskGetStackHighWaterMark( NULL ) != xStatus.usStackHighWaterMark ) + static BaseType_t prvTaskQueryFunctions( void ) { - xReturn = pdFAIL; - } + static TaskStatus_t xStatus, * pxStatusArray; + TaskHandle_t xTimerTask, xIdleTask; + BaseType_t xReturn = pdPASS; + UBaseType_t uxNumberOfTasks, uxReturned, ux; + uint32_t ulTotalRunTime1, ulTotalRunTime2; + const uint32_t ulRunTimeTollerance = ( uint32_t ) 0xfff; - if( uxTaskGetStackHighWaterMark2( NULL ) != ( configSTACK_DEPTH_TYPE ) xStatus.usStackHighWaterMark ) - { - xReturn = pdFAIL; - } - - /* Now obtain a task status without the high water mark but with the state, - * which in the case of the idle task should be Read. */ - xTimerTask = xTimerGetTimerDaemonTaskHandle(); - vTaskSuspend( xTimerTask ); /* Should never suspend Timer task normally!. */ - vTaskGetInfo( xTimerTask, &xStatus, pdFALSE, eInvalid ); - - if( xStatus.eCurrentState != eSuspended ) - { - xReturn = pdFAIL; - } + /* Obtain task status with the stack high water mark and without the + * state. */ + vTaskGetInfo( NULL, &xStatus, pdTRUE, eRunning ); - if( xStatus.uxBasePriority != uxTaskPriorityGetFromISR( xTimerTask ) ) - { - xReturn = pdFAIL; - } - - if( xStatus.uxBasePriority != ( configMAX_PRIORITIES - 1 ) ) - { - xReturn = pdFAIL; - } + if( uxTaskGetStackHighWaterMark( NULL ) != xStatus.usStackHighWaterMark ) + { + xReturn = pdFAIL; + } - xTaskResumeFromISR( xTimerTask ); - vTaskGetInfo( xTimerTask, &xStatus, pdTRUE, eInvalid ); + if( uxTaskGetStackHighWaterMark2( NULL ) != ( configSTACK_DEPTH_TYPE ) xStatus.usStackHighWaterMark ) + { + xReturn = pdFAIL; + } - if( ( xStatus.eCurrentState != eReady ) && ( xStatus.eCurrentState != eBlocked ) ) - { - xReturn = pdFAIL; - } + /* Now obtain a task status without the high water mark but with the state, + * which in the case of the idle task should be Read. */ + xTimerTask = xTimerGetTimerDaemonTaskHandle(); + vTaskSuspend( xTimerTask ); /* Should never suspend Timer task normally!. */ + vTaskGetInfo( xTimerTask, &xStatus, pdFALSE, eInvalid ); - if( uxTaskGetStackHighWaterMark( xTimerTask ) != xStatus.usStackHighWaterMark ) - { - xReturn = pdFAIL; - } + if( xStatus.eCurrentState != eSuspended ) + { + xReturn = pdFAIL; + } - if( uxTaskGetStackHighWaterMark2( xTimerTask ) != ( configSTACK_DEPTH_TYPE ) xStatus.usStackHighWaterMark ) - { - xReturn = pdFAIL; - } + if( xStatus.uxBasePriority != uxTaskPriorityGetFromISR( xTimerTask ) ) + { + xReturn = pdFAIL; + } - /* Attempting to abort a delay in the idle task should be guaranteed to - * fail as the idle task should never block. */ - xIdleTask = xTaskGetIdleTaskHandle(); + if( xStatus.uxBasePriority != ( configMAX_PRIORITIES - 1 ) ) + { + xReturn = pdFAIL; + } - if( xTaskAbortDelay( xIdleTask ) != pdFAIL ) - { - xReturn = pdFAIL; - } + xTaskResumeFromISR( xTimerTask ); + vTaskGetInfo( xTimerTask, &xStatus, pdTRUE, eInvalid ); - /* Create an array of task status objects large enough to hold information - * on the number of tasks at this time - note this may change at any time if - * higher priority tasks are executing and creating tasks. */ - uxNumberOfTasks = uxTaskGetNumberOfTasks(); - pxStatusArray = ( TaskStatus_t * ) pvPortMalloc( uxNumberOfTasks * sizeof( TaskStatus_t ) ); + if( ( xStatus.eCurrentState != eReady ) && ( xStatus.eCurrentState != eBlocked ) ) + { + xReturn = pdFAIL; + } - if( pxStatusArray != NULL ) - { - /* Pass part of the array into uxTaskGetSystemState() to ensure it doesn't - * try using more space than there is available. */ - uxReturned = uxTaskGetSystemState( pxStatusArray, uxNumberOfTasks / ( UBaseType_t ) 2, NULL ); + if( uxTaskGetStackHighWaterMark( xTimerTask ) != xStatus.usStackHighWaterMark ) + { + xReturn = pdFAIL; + } - if( uxReturned != ( UBaseType_t ) 0 ) + if( uxTaskGetStackHighWaterMark2( xTimerTask ) != ( configSTACK_DEPTH_TYPE ) xStatus.usStackHighWaterMark ) { xReturn = pdFAIL; } - /* Now do the same but passing in the complete array size, this is done - * twice to check for a difference in the total run time. */ - uxTaskGetSystemState( pxStatusArray, uxNumberOfTasks, &ulTotalRunTime1 ); - memset( ( void * ) pxStatusArray, 0xaa, uxNumberOfTasks * sizeof( TaskStatus_t ) ); - uxReturned = uxTaskGetSystemState( pxStatusArray, uxNumberOfTasks, &ulTotalRunTime2 ); + /* Attempting to abort a delay in the idle task should be guaranteed to + * fail as the idle task should never block. */ + xIdleTask = xTaskGetIdleTaskHandle(); - if( ( ulTotalRunTime2 - ulTotalRunTime1 ) > ulRunTimeTollerance ) + if( xTaskAbortDelay( xIdleTask ) != pdFAIL ) { xReturn = pdFAIL; } - /* Basic santity check of array contents. */ - for( ux = 0; ux < uxReturned; ux++ ) + /* Create an array of task status objects large enough to hold information + * on the number of tasks at this time - note this may change at any time if + * higher priority tasks are executing and creating tasks. */ + uxNumberOfTasks = uxTaskGetNumberOfTasks(); + pxStatusArray = ( TaskStatus_t * ) pvPortMalloc( uxNumberOfTasks * sizeof( TaskStatus_t ) ); + + if( pxStatusArray != NULL ) { - if( pxStatusArray[ ux ].eCurrentState >= ( UBaseType_t ) eInvalid ) + /* Pass part of the array into uxTaskGetSystemState() to ensure it doesn't + * try using more space than there is available. */ + uxReturned = uxTaskGetSystemState( pxStatusArray, uxNumberOfTasks / ( UBaseType_t ) 2, NULL ); + + if( uxReturned != ( UBaseType_t ) 0 ) { xReturn = pdFAIL; } - if( pxStatusArray[ ux ].uxCurrentPriority >= ( UBaseType_t ) configMAX_PRIORITIES ) + /* Now do the same but passing in the complete array size, this is done + * twice to check for a difference in the total run time. */ + uxTaskGetSystemState( pxStatusArray, uxNumberOfTasks, &ulTotalRunTime1 ); + memset( ( void * ) pxStatusArray, 0xaa, uxNumberOfTasks * sizeof( TaskStatus_t ) ); + uxReturned = uxTaskGetSystemState( pxStatusArray, uxNumberOfTasks, &ulTotalRunTime2 ); + + if( ( ulTotalRunTime2 - ulTotalRunTime1 ) > ulRunTimeTollerance ) { xReturn = pdFAIL; } + + /* Basic sanity check of array contents. */ + for( ux = 0; ux < uxReturned; ux++ ) + { + if( pxStatusArray[ ux ].eCurrentState >= ( UBaseType_t ) eInvalid ) + { + xReturn = pdFAIL; + } + + if( pxStatusArray[ ux ].uxCurrentPriority >= ( UBaseType_t ) configMAX_PRIORITIES ) + { + xReturn = pdFAIL; + } + } + + vPortFree( pxStatusArray ); + } + else + { + xReturn = pdFAIL; } - vPortFree( pxStatusArray ); - } - else - { - xReturn = pdFAIL; + return xReturn; } - return xReturn; -} +#endif /* #if( configUSE_TRACE_FACILITY == 1) */ /*-----------------------------------------------------------*/ static BaseType_t prvDummyTagFunction( void * pvParameter ) @@ -609,12 +617,16 @@ static BaseType_t prvTimerQuery( void ) xReturn = pdFAIL; } - vTimerSetTimerNumber( xTimer, uxTimerNumber ); - - if( uxTimerGetTimerNumber( xTimer ) != uxTimerNumber ) + #if( configUSE_TRACE_FACILITY == 1 ) { - xReturn = pdFAIL; + vTimerSetTimerNumber( xTimer, uxTimerNumber ); + + if( uxTimerGetTimerNumber( xTimer ) != uxTimerNumber ) + { + xReturn = pdFAIL; + } } + #endif /* #if( configUSE_TRACE_FACILITY == 1 ) */ xTimerDelete( xTimer, portMAX_DELAY ); } @@ -632,10 +644,16 @@ BaseType_t xRunCodeCoverageTestAdditions( void ) BaseType_t xReturn = pdPASS; xReturn &= prvStaticAllocationsWithNullBuffers(); - xReturn &= prvTraceUtils(); + + #if( configUSE_TRACE_FACILITY == 1 ) + { + xReturn &= prvTraceUtils(); + xReturn &= prvTaskQueryFunctions(); + } + #endif + xReturn &= prvPeekTimeout(); xReturn &= prvQueueQueryFromISR(); - xReturn &= prvTaskQueryFunctions(); xReturn &= prvTaskTags(); xReturn &= prvTimerQuery(); diff --git a/FreeRTOS/Demo/Posix_GCC/main_full.c b/FreeRTOS/Demo/Posix_GCC/main_full.c index 0e966f6a2f..fe395b2b84 100644 --- a/FreeRTOS/Demo/Posix_GCC/main_full.c +++ b/FreeRTOS/Demo/Posix_GCC/main_full.c @@ -737,22 +737,26 @@ static void prvDemonstrateTaskStateAndHandleGetFunctions( void ) xErrorCount++; } - /* Also with the vTaskGetInfo() function. */ - vTaskGetInfo( xTimerTaskHandle, /* The task being queried. */ - &xTaskInfo, /* The structure into which information on the task will be written. */ - pdTRUE, /* Include the task's high watermark in the structure. */ - eInvalid ); /* Include the task state in the structure. */ - - /* Check the information returned by vTaskGetInfo() is as expected. */ - if( ( xTaskInfo.eCurrentState != eBlocked ) || - ( strcmp( xTaskInfo.pcTaskName, "Tmr Svc" ) != 0 ) || - ( xTaskInfo.uxCurrentPriority != configTIMER_TASK_PRIORITY ) || - ( xTaskInfo.pxStackBase != uxTimerTaskStack ) || - ( xTaskInfo.xHandle != xTimerTaskHandle ) ) + #if( configUSE_TRACE_FACILITY == 1 ) { - pcStatusMessage = "Error: vTaskGetInfo() returned incorrect information about the timer task"; - xErrorCount++; + /* Also with the vTaskGetInfo() function. */ + vTaskGetInfo( xTimerTaskHandle, /* The task being queried. */ + &xTaskInfo, /* The structure into which information on the task will be written. */ + pdTRUE, /* Include the task's high watermark in the structure. */ + eInvalid ); /* Include the task state in the structure. */ + + /* Check the information returned by vTaskGetInfo() is as expected. */ + if( ( xTaskInfo.eCurrentState != eBlocked ) || + ( strcmp( xTaskInfo.pcTaskName, "Tmr Svc" ) != 0 ) || + ( xTaskInfo.uxCurrentPriority != configTIMER_TASK_PRIORITY ) || + ( xTaskInfo.pxStackBase != uxTimerTaskStack ) || + ( xTaskInfo.xHandle != xTimerTaskHandle ) ) + { + pcStatusMessage = "Error: vTaskGetInfo() returned incorrect information about the timer task"; + xErrorCount++; + } } + #endif /* #if( configUSE_TRACE_FACILITY == 1 ) */ /* Other tests that should only be performed once follow. The test task * is not created on each iteration because to do so would cause the death