]> git.sur5r.net Git - freertos/commitdiff
Import the code coverage test additions from the (unpublished) Visual Studio project...
authorrtel <rtel@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Wed, 14 Mar 2018 15:58:47 +0000 (15:58 +0000)
committerrtel <rtel@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Wed, 14 Mar 2018 15:58:47 +0000 (15:58 +0000)
Update the MingW/Eclipse project to add a code coverage build configuration in addition to the existing Debug build configuration.
Update StreamBufferDemo.c so functions are called directly, rather than via configASSERT(), so their code coverage can be measured when configASSERT() is not defined.
In the Win32 port, replace the call to TerminateProcess() in vPortEndScheduler() with exit( 0 ) - which triggers the writing of the code coverage data to the disk.
Fix bug in ucStreamBufferGetStreamBufferType() - which is only used by the Percepio trace tool.
Update the line within vTaskStartScheduler() that was setting xTickCount to 0 to instead set it to configINITIAL_TICK_COUNT.

git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@2534 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

14 files changed:
FreeRTOS/Demo/Common/Minimal/EventGroupsDemo.c
FreeRTOS/Demo/Common/Minimal/GenQTest.c
FreeRTOS/Demo/Common/Minimal/StaticAllocation.c
FreeRTOS/Demo/Common/Minimal/StreamBufferDemo.c
FreeRTOS/Demo/WIN32-MSVC/.vs/WIN32/v14/.suo
FreeRTOS/Demo/WIN32-MingW/.cproject
FreeRTOS/Demo/WIN32-MingW/FreeRTOSConfig.h
FreeRTOS/Demo/WIN32-MingW/code_coverage_additions.c [new file with mode: 0644]
FreeRTOS/Demo/WIN32-MingW/main.c
FreeRTOS/Demo/WIN32-MingW/main_full.c
FreeRTOS/Source/portable/MSVC-MingW/port.c
FreeRTOS/Source/queue.c
FreeRTOS/Source/stream_buffer.c
FreeRTOS/Source/tasks.c

index 22b7fb81d659c5a39347bbbe63770dc4aca878c1..abd72e878673ab80a567200a8ec8e2e4a10b021d 100644 (file)
@@ -78,6 +78,7 @@ that synchronise with the xEventGroupSync() function. */
 \r
 /* A block time of zero simply means "don't block". */\r
 #define ebDONT_BLOCK   ( 0 )\r
+#define ebONE_TICK             ( ( TickType_t ) 1 )\r
 \r
 /* A 5ms delay. */\r
 #define ebSHORT_DELAY  pdMS_TO_TICKS( ( TickType_t ) 5 )\r
@@ -281,7 +282,29 @@ EventBits_t uxSynchronisationBit, uxReturned;
                /* Set the bit that indicates this task is at the synchronisation\r
                point.  The first time this is done the 'test master' task has a lower\r
                priority than this task so this task will get to the sync point before\r
-               the set bits task. */\r
+               the set bits task - test this by first calling xEventGroupSync() with\r
+               a zero block time, and a block time that is too short for the other\r
+               task, before calling again with a max delay - the first two calls should\r
+               return before the rendezvous completes, the third only after the\r
+               rendezvous is complete. */\r
+               uxReturned = xEventGroupSync( xEventGroup,      /* The event group used for the synchronisation. */\r
+                                                                         uxSynchronisationBit, /* The bit to set in the event group to indicate this task is at the sync point. */\r
+                                                                         ebALL_SYNC_BITS,/* The bits to wait for - these bits are set by the other tasks taking part in the sync. */\r
+                                                                         ebDONT_BLOCK ); /* The maximum time to wait for the sync condition to be met before giving up. */\r
+\r
+               /* No block time was specified, so as per the comments above, the\r
+               rendezvous is not expected to have completed yet. */\r
+               configASSERT( ( uxReturned & ebALL_SYNC_BITS ) != ebALL_SYNC_BITS );\r
+\r
+               uxReturned = xEventGroupSync( xEventGroup,      /* The event group used for the synchronisation. */\r
+                                                                         uxSynchronisationBit, /* The bit to set in the event group to indicate this task is at the sync point. */\r
+                                                                         ebALL_SYNC_BITS, /* The bits to wait for - these bits are set by the other tasks taking part in the sync. */\r
+                                                                         ebONE_TICK ); /* The maximum time to wait for the sync condition to be met before giving up. */\r
+\r
+               /* A short block time was specified, so as per the comments above, the\r
+               rendezvous is not expected to have completed yet. */\r
+               configASSERT( ( uxReturned & ebALL_SYNC_BITS ) != ebALL_SYNC_BITS );\r
+\r
                uxReturned = xEventGroupSync( xEventGroup,      /* The event group used for the synchronisation. */\r
                                                                        uxSynchronisationBit, /* The bit to set in the event group to indicate this task is at the sync point. */\r
                                                                        ebALL_SYNC_BITS,/* The bits to wait for - these bits are set by the other tasks taking part in the sync. */\r
index 4d146054c78ded76132729ce49bf0eb454a473bc..66be41733fdd976b7d4f65dc6786cd55bfd41e38 100644 (file)
@@ -433,11 +433,20 @@ QueueHandle_t xQueue;
                /* The tests in this function are very similar, the slight variations\r
                are for code coverage purposes. */\r
 \r
-               /* Take the mutex.  It should be available now. */\r
+               /* Take the mutex.  It should be available now.  Check before and after\r
+               taking that the holder is reported correctly. */\r
+               if( xSemaphoreGetMutexHolder( xMutex ) != NULL )\r
+               {\r
+                       xErrorDetected = pdTRUE;\r
+               }\r
                if( xSemaphoreTake( xMutex, intsemNO_BLOCK ) != pdPASS )\r
                {\r
                        xErrorDetected = pdTRUE;\r
                }\r
+               if( xSemaphoreGetMutexHolder( xMutex ) != xTaskGetCurrentTaskHandle() )\r
+               {\r
+                       xErrorDetected = pdTRUE;\r
+               }\r
 \r
                /* This task's priority should be as per that assigned when the task was\r
                created. */\r
@@ -524,8 +533,17 @@ QueueHandle_t xQueue;
                        vTaskDelay( genqSHORT_BLOCK );\r
                }\r
 \r
-               /* Give the semaphore back ready for the next test. */\r
+               /* Give the semaphore back ready for the next test.  Check the mutex\r
+               holder before and after using the "FromISR" version for code coverage. */\r
+               if( xSemaphoreGetMutexHolderFromISR( xMutex ) != xTaskGetCurrentTaskHandle() )\r
+               {\r
+                       xErrorDetected = pdTRUE;\r
+               }\r
                xSemaphoreGive( xMutex );\r
+               if( xSemaphoreGetMutexHolderFromISR( xMutex ) != NULL )\r
+               {\r
+                       xErrorDetected = pdTRUE;\r
+               }\r
 \r
                configASSERT( xErrorDetected == pdFALSE );\r
 \r
index 013503a7b1bc437ec039c58c49bc82ce38df1359..dc5c8540797cf62d26808d832169b42e520ea5af 100644 (file)
@@ -695,8 +695,7 @@ StaticEventGroup_t xEventGroupBuffer;
        /* Create the event group.  xEventGroupCreateStatic() has an extra parameter\r
        than the normal xEventGroupCreate() API function.  The parameter is a\r
        pointer to the StaticEventGroup_t structure that will hold the event group\r
-       structure.  If the parameter is passed as NULL then the structure will be\r
-       allocated dynamically, just as if xEventGroupCreate() had been called. */\r
+       structure. */\r
        xEventGroup = xEventGroupCreateStatic( &xEventGroupBuffer );\r
 \r
        /* The event group handle should equal the static event group structure\r
index a0cdda6c4e4b00c3e4a2d7381f7c3f766eab098a..8250b13d9ed296ef5dd9a612b631b62794341a39 100644 (file)
@@ -92,6 +92,10 @@ static void prvEchoServer( void *pvParameters );
 static void prvNonBlockingReceiverTask( void *pvParameters );\r
 static void prvNonBlockingSenderTask( void *pvParameters );\r
 \r
+/* Performs an assert() like check in a way that won't get removed when\r
+performing a code coverage analysis. */\r
+static void prvCheckExpectedState( BaseType_t xState );\r
+\r
 /*\r
  * A task that creates a stream buffer with a specific trigger level, then\r
  * receives a string from an interrupt (the RTOS tick hook) byte by byte to\r
@@ -151,6 +155,10 @@ accidentally read out of the buffer. */
 static const char *pc55ByteString = "One two three four five six seven eight nine ten eleven";\r
 static const char *pc54ByteString = "01234567891abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQ";\r
 \r
+/* Used to log the status of the tests contained within this file for reporting\r
+to a monitoring task ('check' task). */\r
+static BaseType_t xErrorStatus = pdPASS;\r
+\r
 /*-----------------------------------------------------------*/\r
 \r
 void vStartStreamBufferTasks( void )\r
@@ -188,6 +196,16 @@ StreamBufferHandle_t xStreamBuffer;
 }\r
 /*-----------------------------------------------------------*/\r
 \r
+static void prvCheckExpectedState( BaseType_t xState )\r
+{\r
+       configASSERT( xState );\r
+       if( xState == pdFAIL )\r
+       {\r
+               xErrorStatus = pdFAIL;\r
+       }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
 static void prvSingleTaskTests( StreamBufferHandle_t xStreamBuffer )\r
 {\r
 size_t xReturned, xItem, xExpectedSpace;\r
@@ -213,15 +231,15 @@ UBaseType_t uxOriginalPriority;
        /* Nothing has been added or removed yet, so expect the free space to be\r
        exactly as created. */\r
        xExpectedSpace = xStreamBufferSpacesAvailable( xStreamBuffer );\r
-       configASSERT( xExpectedSpace == sbSTREAM_BUFFER_LENGTH_BYTES );\r
-       configASSERT( xStreamBufferIsEmpty( xStreamBuffer ) == pdTRUE );\r
+       prvCheckExpectedState( xExpectedSpace == sbSTREAM_BUFFER_LENGTH_BYTES );\r
+       prvCheckExpectedState( xStreamBufferIsEmpty( xStreamBuffer ) == pdTRUE );\r
 \r
 \r
        /* The buffer is 30 bytes long.  6 5 byte messages should fit before the\r
        buffer is completely full. */\r
        for( xItem = 0; xItem < xMax6ByteMessages; xItem++ )\r
        {\r
-               configASSERT( xStreamBufferIsFull( xStreamBuffer ) == pdFALSE );\r
+               prvCheckExpectedState( xStreamBufferIsFull( xStreamBuffer ) == pdFALSE );\r
 \r
                /* Generate recognisable data to write to the buffer.  This is just\r
                ascii characters that shows which loop iteration the data was written\r
@@ -235,27 +253,23 @@ UBaseType_t uxOriginalPriority;
                        xReturned = xStreamBufferSendFromISR( xStreamBuffer, ( void * ) pucData, x6ByteLength, NULL );\r
                }\r
                taskEXIT_CRITICAL();\r
-               configASSERT( xReturned == x6ByteLength );\r
-               ( void ) xReturned; /* In case configASSERT() is not defined. */\r
+               prvCheckExpectedState( xReturned == x6ByteLength );\r
 \r
                /* The space in the buffer will have reduced by the amount of user data\r
                written into the buffer. */\r
                xExpectedSpace -= x6ByteLength;\r
                xReturned = xStreamBufferSpacesAvailable( xStreamBuffer );\r
-               configASSERT( xReturned == xExpectedSpace );\r
-               ( void ) xReturned; /* In case configASSERT() is not defined. */\r
+               prvCheckExpectedState( xReturned == xExpectedSpace );\r
                xReturned = xStreamBufferBytesAvailable( xStreamBuffer );\r
                /* +1 as it is zero indexed. */\r
-               configASSERT( xReturned == ( ( xItem + 1 ) * x6ByteLength ) );\r
-               ( void ) xReturned; /* In case configASSERT() is not defined. */\r
+               prvCheckExpectedState( xReturned == ( ( xItem + 1 ) * x6ByteLength ) );\r
        }\r
 \r
        /* Now the buffer should be full, and attempting to add anything will should\r
        fail. */\r
-       configASSERT( xStreamBufferIsFull( xStreamBuffer ) == pdTRUE );\r
+       prvCheckExpectedState( xStreamBufferIsFull( xStreamBuffer ) == pdTRUE );\r
        xReturned = xStreamBufferSend( xStreamBuffer, ( void * ) pucData, sizeof( pucData[ 0 ] ), sbDONT_BLOCK );\r
-       configASSERT( xReturned == 0 );\r
-       ( void ) xReturned; /* In case configASSERT() is not defined. */\r
+       prvCheckExpectedState( xReturned == 0 );\r
 \r
        /* Adding with a timeout should also fail after the appropriate time.  The\r
        priority is temporarily boosted in this part of the test to keep the\r
@@ -266,12 +280,9 @@ UBaseType_t uxOriginalPriority;
        xReturned = xStreamBufferSend( xStreamBuffer, ( void * ) pucData, sizeof( pucData[ 0 ] ), xBlockTime );\r
        xTimeAfterCall = xTaskGetTickCount();\r
        vTaskPrioritySet( NULL, uxOriginalPriority );\r
-       configASSERT( ( xTimeAfterCall - xTimeBeforeCall ) >= xBlockTime );\r
-       configASSERT( ( xTimeAfterCall - xTimeBeforeCall ) < ( xBlockTime + xAllowableMargin ) );\r
-       configASSERT( xReturned == 0 ); /* In case configASSERT() is not defined. */\r
-       ( void ) xTimeAfterCall;\r
-       ( void ) xTimeBeforeCall;\r
-\r
+       prvCheckExpectedState( ( xTimeAfterCall - xTimeBeforeCall ) >= xBlockTime );\r
+       prvCheckExpectedState( ( xTimeAfterCall - xTimeBeforeCall ) < ( xBlockTime + xAllowableMargin ) );\r
+       prvCheckExpectedState( xReturned == 0 );\r
 \r
        /* The buffer is now full of data in the form "000000", "111111", etc.  Make\r
        sure the data is read out as expected. */\r
@@ -290,24 +301,24 @@ UBaseType_t uxOriginalPriority;
                        xReturned = xStreamBufferReceiveFromISR( xStreamBuffer, ( void * ) pucReadData, x6ByteLength, NULL );\r
                }\r
                taskEXIT_CRITICAL();\r
-               configASSERT( xReturned == x6ByteLength );\r
+               prvCheckExpectedState( xReturned == x6ByteLength );\r
 \r
                /* Does the data read out match that expected? */\r
-               configASSERT( memcmp( ( void * ) pucData, ( void * ) pucReadData, x6ByteLength ) == 0 );\r
+               prvCheckExpectedState( memcmp( ( void * ) pucData, ( void * ) pucReadData, x6ByteLength ) == 0 );\r
 \r
                /* The space in the buffer will have increased by the amount of user\r
                data removed from the buffer. */\r
                xExpectedSpace += x6ByteLength;\r
                xReturned = xStreamBufferSpacesAvailable( xStreamBuffer );\r
-               configASSERT( xReturned == xExpectedSpace );\r
+               prvCheckExpectedState( xReturned == xExpectedSpace );\r
                xReturned = xStreamBufferBytesAvailable( xStreamBuffer );\r
-               configASSERT( xReturned == ( sbSTREAM_BUFFER_LENGTH_BYTES - xExpectedSpace ) );\r
+               prvCheckExpectedState( xReturned == ( sbSTREAM_BUFFER_LENGTH_BYTES - xExpectedSpace ) );\r
        }\r
 \r
        /* The buffer should be empty again. */\r
-       configASSERT( xStreamBufferIsEmpty( xStreamBuffer ) == pdTRUE );\r
+       prvCheckExpectedState( xStreamBufferIsEmpty( xStreamBuffer ) == pdTRUE );\r
        xExpectedSpace = xStreamBufferSpacesAvailable( xStreamBuffer );\r
-       configASSERT( xExpectedSpace == sbSTREAM_BUFFER_LENGTH_BYTES );\r
+       prvCheckExpectedState( xExpectedSpace == sbSTREAM_BUFFER_LENGTH_BYTES );\r
 \r
        /* Reading with a timeout should also fail after the appropriate time.  The\r
        priority is temporarily boosted in this part of the test to keep the\r
@@ -317,9 +328,9 @@ UBaseType_t uxOriginalPriority;
        xReturned = xStreamBufferReceive( xStreamBuffer, ( void * ) pucReadData, x6ByteLength, xBlockTime );\r
        xTimeAfterCall = xTaskGetTickCount();\r
        vTaskPrioritySet( NULL, uxOriginalPriority );\r
-       configASSERT( ( xTimeAfterCall - xTimeBeforeCall ) >= xBlockTime );\r
-       configASSERT( ( xTimeAfterCall - xTimeBeforeCall ) < ( xBlockTime + xAllowableMargin ) );\r
-       configASSERT( xReturned == 0 );\r
+       prvCheckExpectedState( ( xTimeAfterCall - xTimeBeforeCall ) >= xBlockTime );\r
+       prvCheckExpectedState( ( xTimeAfterCall - xTimeBeforeCall ) < ( xBlockTime + xAllowableMargin ) );\r
+       prvCheckExpectedState( xReturned == 0 );\r
 \r
 \r
        /* In the next loop 17 bytes are written to then read out on each\r
@@ -333,38 +344,38 @@ UBaseType_t uxOriginalPriority;
                in. */\r
                memset( ( void * ) pucData, ( ( int ) '0' ) + ( int ) xItem, x17ByteLength );\r
                xReturned = xStreamBufferSend( xStreamBuffer, ( void * ) pucData, x17ByteLength, sbDONT_BLOCK );\r
-               configASSERT( xReturned == x17ByteLength );\r
+               prvCheckExpectedState( xReturned == x17ByteLength );\r
 \r
                /* The space in the buffer will have reduced by the amount of user data\r
                written into the buffer. */\r
                xReturned = xStreamBufferSpacesAvailable( xStreamBuffer );\r
-               configASSERT( xReturned == xExpectedSpace );\r
+               prvCheckExpectedState( xReturned == xExpectedSpace );\r
                xReturned = xStreamBufferBytesAvailable( xStreamBuffer );\r
-               configASSERT( xReturned == x17ByteLength );\r
-               configASSERT( xStreamBufferIsFull( xStreamBuffer ) == pdFALSE );\r
-               configASSERT( xStreamBufferIsEmpty( xStreamBuffer ) == pdFALSE );\r
+               prvCheckExpectedState( xReturned == x17ByteLength );\r
+               prvCheckExpectedState( xStreamBufferIsFull( xStreamBuffer ) == pdFALSE );\r
+               prvCheckExpectedState( xStreamBufferIsEmpty( xStreamBuffer ) == pdFALSE );\r
 \r
                /* Read the 17 bytes out again. */\r
                xReturned = xStreamBufferReceive( xStreamBuffer, ( void * ) pucReadData, x17ByteLength, sbDONT_BLOCK );\r
-               configASSERT( xReturned == x17ByteLength );\r
+               prvCheckExpectedState( xReturned == x17ByteLength );\r
 \r
                /* Does the data read out match that expected? */\r
-               configASSERT( memcmp( ( void * ) pucData, ( void * ) pucReadData, x17ByteLength ) == 0 );\r
+               prvCheckExpectedState( memcmp( ( void * ) pucData, ( void * ) pucReadData, x17ByteLength ) == 0 );\r
 \r
                /* Full buffer space available again. */\r
                xReturned = xStreamBufferSpacesAvailable( xStreamBuffer );\r
-               configASSERT( xReturned == sbSTREAM_BUFFER_LENGTH_BYTES );\r
+               prvCheckExpectedState( xReturned == sbSTREAM_BUFFER_LENGTH_BYTES );\r
                xReturned = xStreamBufferBytesAvailable( xStreamBuffer );\r
-               configASSERT( xReturned == 0 );\r
-               configASSERT( xStreamBufferIsFull( xStreamBuffer ) == pdFALSE );\r
-               configASSERT( xStreamBufferIsEmpty( xStreamBuffer ) == pdTRUE );\r
+               prvCheckExpectedState( xReturned == 0 );\r
+               prvCheckExpectedState( xStreamBufferIsFull( xStreamBuffer ) == pdFALSE );\r
+               prvCheckExpectedState( xStreamBufferIsEmpty( xStreamBuffer ) == pdTRUE );\r
        }\r
 \r
        /* Fill the buffer with one message, check it is full, then read it back\r
        again and check the correct data is received. */\r
        xStreamBufferSend( xStreamBuffer, ( const void * ) pc55ByteString, sbSTREAM_BUFFER_LENGTH_BYTES, sbDONT_BLOCK );\r
        xStreamBufferReceive( xStreamBuffer, ( void * ) pucFullBuffer, sbSTREAM_BUFFER_LENGTH_BYTES, sbDONT_BLOCK );\r
-       configASSERT( memcmp( pc55ByteString, pucFullBuffer, sbSTREAM_BUFFER_LENGTH_BYTES ) == 0 );\r
+       prvCheckExpectedState( memcmp( pc55ByteString, pucFullBuffer, sbSTREAM_BUFFER_LENGTH_BYTES ) == 0 );\r
 \r
        /* Fill the buffer one bytes at a time. */\r
        for( xItem = 0; xItem < sbSTREAM_BUFFER_LENGTH_BYTES; xItem++ )\r
@@ -375,23 +386,23 @@ UBaseType_t uxOriginalPriority;
        }\r
 \r
        /* The buffer should now be full. */\r
-       configASSERT( xStreamBufferIsFull( xStreamBuffer ) == pdTRUE );\r
+       prvCheckExpectedState( xStreamBufferIsFull( xStreamBuffer ) == pdTRUE );\r
 \r
        /* Read the message out in one go, even though it was written in individual\r
        bytes.  Try reading much more data than is actually available to ensure only\r
        the available bytes are returned (otherwise this read will write outside of\r
        the memory allocated anyway!). */\r
        xReturned = xStreamBufferReceive( xStreamBuffer, pucFullBuffer, sbSTREAM_BUFFER_LENGTH_BYTES * ( size_t ) 2, sbRX_TX_BLOCK_TIME );\r
-       configASSERT( xReturned == sbSTREAM_BUFFER_LENGTH_BYTES );\r
-       configASSERT( memcmp( ( const void * ) pc54ByteString, ( const void * ) pucFullBuffer, sbSTREAM_BUFFER_LENGTH_BYTES ) == 0 );\r
+       prvCheckExpectedState( xReturned == sbSTREAM_BUFFER_LENGTH_BYTES );\r
+       prvCheckExpectedState( memcmp( ( const void * ) pc54ByteString, ( const void * ) pucFullBuffer, sbSTREAM_BUFFER_LENGTH_BYTES ) == 0 );\r
 \r
        /* Now do the opposite, write in one go and read out in single bytes. */\r
        xReturned = xStreamBufferSend( xStreamBuffer, ( const void * ) pc55ByteString, sbSTREAM_BUFFER_LENGTH_BYTES, sbRX_TX_BLOCK_TIME );\r
-       configASSERT( xReturned == sbSTREAM_BUFFER_LENGTH_BYTES );\r
-       configASSERT( xStreamBufferIsFull( xStreamBuffer ) == pdTRUE );\r
-       configASSERT( xStreamBufferIsEmpty( xStreamBuffer ) == pdFALSE );\r
-       configASSERT( xStreamBufferBytesAvailable( xStreamBuffer ) == sbSTREAM_BUFFER_LENGTH_BYTES );\r
-       configASSERT( xStreamBufferSpacesAvailable( xStreamBuffer ) == 0 );\r
+       prvCheckExpectedState( xReturned == sbSTREAM_BUFFER_LENGTH_BYTES );\r
+       prvCheckExpectedState( xStreamBufferIsFull( xStreamBuffer ) == pdTRUE );\r
+       prvCheckExpectedState( xStreamBufferIsEmpty( xStreamBuffer ) == pdFALSE );\r
+       prvCheckExpectedState( xStreamBufferBytesAvailable( xStreamBuffer ) == sbSTREAM_BUFFER_LENGTH_BYTES );\r
+       prvCheckExpectedState( xStreamBufferSpacesAvailable( xStreamBuffer ) == 0 );\r
 \r
        /* Read from the buffer one byte at a time. */\r
        for( xItem = 0; xItem < sbSTREAM_BUFFER_LENGTH_BYTES; xItem++ )\r
@@ -399,10 +410,10 @@ UBaseType_t uxOriginalPriority;
                /* Block time is only for test coverage, the task should never actually\r
                block here. */\r
                xStreamBufferReceive( xStreamBuffer, ( void * ) pucFullBuffer, sizeof( char ), sbRX_TX_BLOCK_TIME );\r
-               configASSERT( pc55ByteString[ xItem ] == pucFullBuffer[ 0 ] );\r
+               prvCheckExpectedState( pc55ByteString[ xItem ] == pucFullBuffer[ 0 ] );\r
        }\r
-       configASSERT( xStreamBufferIsEmpty( xStreamBuffer ) == pdTRUE );\r
-       configASSERT( xStreamBufferIsFull( xStreamBuffer ) == pdFALSE );\r
+       prvCheckExpectedState( xStreamBufferIsEmpty( xStreamBuffer ) == pdTRUE );\r
+       prvCheckExpectedState( xStreamBufferIsFull( xStreamBuffer ) == pdFALSE );\r
 \r
        /* Try writing more bytes than there is space. */\r
        vTaskPrioritySet( NULL, configMAX_PRIORITIES - 1 );\r
@@ -410,23 +421,23 @@ UBaseType_t uxOriginalPriority;
        xReturned = xStreamBufferSend( xStreamBuffer, ( const void * ) pc54ByteString, sbSTREAM_BUFFER_LENGTH_BYTES * ( size_t ) 2, xMinimalBlockTime );\r
        xTimeAfterCall = xTaskGetTickCount();\r
        vTaskPrioritySet( NULL, uxOriginalPriority );\r
-       configASSERT( ( xTimeAfterCall - xTimeBeforeCall ) >= xMinimalBlockTime );\r
-       configASSERT( ( xTimeAfterCall - xTimeBeforeCall ) < ( xMinimalBlockTime + xAllowableMargin ) );\r
-       configASSERT( xReturned == sbSTREAM_BUFFER_LENGTH_BYTES );\r
-       configASSERT( xStreamBufferIsFull( xStreamBuffer ) == pdTRUE );\r
-       configASSERT( xStreamBufferIsEmpty( xStreamBuffer ) == pdFALSE );\r
+       prvCheckExpectedState( ( xTimeAfterCall - xTimeBeforeCall ) >= xMinimalBlockTime );\r
+       prvCheckExpectedState( ( xTimeAfterCall - xTimeBeforeCall ) < ( xMinimalBlockTime + xAllowableMargin ) );\r
+       prvCheckExpectedState( xReturned == sbSTREAM_BUFFER_LENGTH_BYTES );\r
+       prvCheckExpectedState( xStreamBufferIsFull( xStreamBuffer ) == pdTRUE );\r
+       prvCheckExpectedState( xStreamBufferIsEmpty( xStreamBuffer ) == pdFALSE );\r
 \r
        /* No space now though. */\r
        xReturned = xStreamBufferSend( xStreamBuffer, ( const void * ) pc54ByteString, sbSTREAM_BUFFER_LENGTH_BYTES * ( size_t ) 2, xMinimalBlockTime );\r
-       configASSERT( xReturned == 0 );\r
+       prvCheckExpectedState( xReturned == 0 );\r
 \r
        /* Ensure data was written as expected even when there was an attempt to\r
        write more than was available.  This also tries to read more bytes than are\r
        available. */\r
        xReturned = xStreamBufferReceive( xStreamBuffer, ( void * ) pucFullBuffer, xFullBufferSize, xMinimalBlockTime );\r
-       configASSERT( memcmp( ( const void * ) pucFullBuffer, ( const void * ) pc54ByteString, sbSTREAM_BUFFER_LENGTH_BYTES ) == 0 );\r
-       configASSERT( xStreamBufferIsFull( xStreamBuffer ) == pdFALSE );\r
-       configASSERT( xStreamBufferIsEmpty( xStreamBuffer ) == pdTRUE );\r
+       prvCheckExpectedState( memcmp( ( const void * ) pucFullBuffer, ( const void * ) pc54ByteString, sbSTREAM_BUFFER_LENGTH_BYTES ) == 0 );\r
+       prvCheckExpectedState( xStreamBufferIsFull( xStreamBuffer ) == pdFALSE );\r
+       prvCheckExpectedState( xStreamBufferIsEmpty( xStreamBuffer ) == pdTRUE );\r
 \r
        /* Clean up with data in the buffer to ensure the tests that follow don't\r
        see the data (the data should be discarded). */\r
@@ -458,12 +469,12 @@ const size_t xStringLength = strlen( pc54ByteString );
 \r
                /* Attempt to send right up to the end of the string. */\r
                xBytesActuallySent = xStreamBufferSend( xStreamBuffer, ( const void * ) &( pc54ByteString[ xNextChar ] ), xBytesToSend, sbDONT_BLOCK );\r
-               configASSERT( xBytesActuallySent <= xBytesToSend );\r
+               prvCheckExpectedState( xBytesActuallySent <= xBytesToSend );\r
 \r
                /* Move the index up the string to the next character to be sent,\r
                wrapping if the end of the string has been reached. */\r
                xNextChar += xBytesActuallySent;\r
-               configASSERT( xNextChar <= xStringLength );\r
+               prvCheckExpectedState( xNextChar <= xStringLength );\r
 \r
                if( xNextChar == xStringLength )\r
                {\r
@@ -565,7 +576,7 @@ BaseType_t xNonBlockingReceiveError = pdFALSE;
 \r
                /* Make sure a change in priority does not inadvertently result in an\r
                invalid array index. */\r
-               configASSERT( uxIndex < sbNUMBER_OF_ECHO_CLIENTS );\r
+               prvCheckExpectedState( uxIndex < sbNUMBER_OF_ECHO_CLIENTS );\r
 \r
                /* Avoid compiler warnings about unused parameters. */\r
                ( void ) pvParameters;\r
@@ -601,12 +612,12 @@ BaseType_t xNonBlockingReceiveError = pdFALSE;
 \r
                        /* Attempt to send right up to the end of the string. */\r
                        xBytesActuallySent = xStreamBufferSend( xStreamBuffer, ( const void * ) &( pc55ByteString[ xNextChar ] ), xBytesToSend, xTicksToWait );\r
-                       configASSERT( xBytesActuallySent <= xBytesToSend );\r
+                       prvCheckExpectedState( xBytesActuallySent <= xBytesToSend );\r
 \r
                        /* Move the index up the string to the next character to be sent,\r
                        wrapping if the end of the string has been reached. */\r
                        xNextChar += xBytesActuallySent;\r
-                       configASSERT( xNextChar <= xStringLength );\r
+                       prvCheckExpectedState( xNextChar <= xStringLength );\r
 \r
                        if( xNextChar == xStringLength )\r
                        {\r
@@ -661,7 +672,7 @@ BaseType_t xNonBlockingReceiveError = pdFALSE;
                        } while( xReceivedLength == 0 );\r
 \r
                        /* Ensure the received string matches the expected string. */\r
-                       configASSERT( memcmp( ( void * ) cRxString, ( const void * ) &( pc55ByteString[ xNextChar ] ), xReceivedLength ) == 0 );\r
+                       prvCheckExpectedState( memcmp( ( void * ) cRxString, ( const void * ) &( pc55ByteString[ xNextChar ] ), xReceivedLength ) == 0 );\r
 \r
                        /* Move the index into the string up to the end of the bytes\r
                        received so far - wrapping if the end of the string has been\r
@@ -743,7 +754,7 @@ EchoStreamBuffers_t *pxStreamBuffers = ( EchoStreamBuffers_t * ) pvParameters;
                memset( pcStringReceived, 0x00, sbSTREAM_BUFFER_LENGTH_BYTES );\r
                xStreamBufferReceive( pxStreamBuffers->xEchoServerBuffer, ( void * ) pcStringReceived, xSendLength, portMAX_DELAY );\r
 \r
-               configASSERT( strcmp( pcStringToSend, pcStringReceived ) == 0 );\r
+               prvCheckExpectedState( strcmp( pcStringToSend, pcStringReceived ) == 0 );\r
 \r
                /* Maintain a count of the number of times this code executes so a\r
                check task can determine if this task is still functioning as\r
@@ -787,9 +798,8 @@ const TickType_t xTicksToBlock = pdMS_TO_TICKS( 350UL );
        /* Don't expect to receive anything yet! */\r
        xTimeOnEntering = xTaskGetTickCount();\r
        xReceivedLength = xStreamBufferReceive( xStreamBuffers.xEchoClientBuffer, ( void * ) pcReceivedString, sbSTREAM_BUFFER_LENGTH_BYTES, xTicksToBlock );\r
-       configASSERT( ( xTaskGetTickCount() - xTimeOnEntering ) >= xTicksToBlock );\r
-       configASSERT( xReceivedLength == 0 );\r
-       ( void ) xTimeOnEntering;\r
+       prvCheckExpectedState( ( xTaskGetTickCount() - xTimeOnEntering ) >= xTicksToBlock );\r
+       prvCheckExpectedState( xReceivedLength == 0 );\r
 \r
        /* Now the stream buffers have been created the echo client task can be\r
        created.  If this server task has the higher priority then the client task\r
@@ -815,7 +825,7 @@ const TickType_t xTicksToBlock = pdMS_TO_TICKS( 350UL );
                xReceivedLength = xStreamBufferReceive( xStreamBuffers.xEchoClientBuffer, ( void * ) pcReceivedString, sbSTREAM_BUFFER_LENGTH_BYTES, xTicksToBlock );\r
 \r
                /* Should always receive data as a delay was used. */\r
-               configASSERT( xReceivedLength > 0 );\r
+               prvCheckExpectedState( xReceivedLength > 0 );\r
 \r
                /* Echo the received data back to the client. */\r
                xStreamBufferSend( xStreamBuffers.xEchoServerBuffer, ( void * ) pcReceivedString, xReceivedLength, portMAX_DELAY );\r
@@ -946,13 +956,13 @@ BaseType_t xAreStreamBufferTasksStillRunning( void )
 static uint32_t ulLastEchoLoopCounters[ sbNUMBER_OF_ECHO_CLIENTS ] = { 0 };\r
 static uint32_t ulLastNonBlockingRxCounter = 0;\r
 static uint32_t ulLastInterruptTriggerCounter = 0;\r
-BaseType_t xReturn = pdPASS, x;\r
+BaseType_t x;\r
 \r
        for( x = 0; x < sbNUMBER_OF_ECHO_CLIENTS; x++ )\r
        {\r
                if( ulLastEchoLoopCounters[ x ] == ulEchoLoopCounters[ x ] )\r
                {\r
-                       xReturn = pdFAIL;\r
+                       xErrorStatus = pdFAIL;\r
                }\r
                else\r
                {\r
@@ -962,7 +972,7 @@ BaseType_t xReturn = pdPASS, x;
 \r
        if( ulNonBlockingRxCounter == ulLastNonBlockingRxCounter )\r
        {\r
-               xReturn = pdFAIL;\r
+               xErrorStatus = pdFAIL;\r
        }\r
        else\r
        {\r
@@ -971,7 +981,7 @@ BaseType_t xReturn = pdPASS, x;
 \r
        if( ulLastInterruptTriggerCounter == ulInterruptTriggerCounter )\r
        {\r
-               xReturn = pdFAIL;\r
+               xErrorStatus = pdFAIL;\r
        }\r
        else\r
        {\r
@@ -986,7 +996,7 @@ BaseType_t xReturn = pdPASS, x;
                {\r
                        if( ulLastSenderLoopCounters[ x ] == ulSenderLoopCounters[ x ] )\r
                        {\r
-                               xReturn = pdFAIL;\r
+                               xErrorStatus = pdFAIL;\r
                        }\r
                        else\r
                        {\r
@@ -996,7 +1006,7 @@ BaseType_t xReturn = pdPASS, x;
        }\r
        #endif /* configSUPPORT_STATIC_ALLOCATION */\r
 \r
-       return xReturn;\r
+       return xErrorStatus;\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
index bb4718846ff2e2ac0118868b0a9b0feb09583b50..b50bd108f3bff098878054c2487aef0cdf7d5402 100644 (file)
Binary files a/FreeRTOS/Demo/WIN32-MSVC/.vs/WIN32/v14/.suo and b/FreeRTOS/Demo/WIN32-MSVC/.vs/WIN32/v14/.suo differ
index c2bd401d5f90adaa9b497a6579caccdc02a010ea..0cc3eaa93724bb37ddf538a56a8363ea77b26c75 100644 (file)
@@ -42,6 +42,7 @@
                                                                <option id="gnu.c.compiler.option.debugging.gprof.444112294" name="Generate gprof information (-pg)" superClass="gnu.c.compiler.option.debugging.gprof" useByScannerDiscovery="false" value="false" valueType="boolean"/>\r
                                                                <option id="gnu.c.compiler.option.preprocessor.def.symbols.1757027831" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" useByScannerDiscovery="false" valueType="definedSymbols">\r
                                                                        <listOptionValue builtIn="false" value="_WIN32_WINNT=0x0601"/>\r
+                                                                       <listOptionValue builtIn="false" value="projCOVERAGE_TEST=0"/>\r
                                                                </option>\r
                                                                <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.974248912" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>\r
                                                        </tool>\r
                                                                <option id="gnu.c.compiler.option.debugging.gprof.1677007018" name="Generate gprof information (-pg)" superClass="gnu.c.compiler.option.debugging.gprof" useByScannerDiscovery="false" value="false" valueType="boolean"/>\r
                                                                <option id="gnu.c.compiler.option.preprocessor.def.symbols.175065197" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" useByScannerDiscovery="false" valueType="definedSymbols">\r
                                                                        <listOptionValue builtIn="false" value="_WIN32_WINNT=0x0601"/>\r
+                                                                       <listOptionValue builtIn="false" value="projCOVERAGE_TEST=1"/>\r
                                                                </option>\r
                                                                <option id="gnu.c.compiler.option.debugging.codecov.1668225592" name="Generate gcov information (-ftest-coverage -fprofile-arcs)" superClass="gnu.c.compiler.option.debugging.codecov" useByScannerDiscovery="false" value="true" valueType="boolean"/>\r
                                                                <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.132282928" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>\r
                                                </toolChain>\r
                                        </folderInfo>\r
                                        <sourceEntries>\r
-                                               <entry excluding="FreeRTOS+Trace Recorder/streamports" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>\r
+                                               <entry excluding="FreeRTOS+Trace Recorder|FreeRTOS+Trace Recorder/streamports" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>\r
                                        </sourceEntries>\r
                                </configuration>\r
                        </storageModule>\r
index b73d975247457cc6cfbbfc01100e35f9d9b8e983..f66e45389c7cf0427bed0094b381375d50d0a08e 100644 (file)
@@ -47,7 +47,7 @@
 #define configUSE_DAEMON_TASK_STARTUP_HOOK             1\r
 #define configTICK_RATE_HZ                                             ( 1000 ) /* In this non-real time simulated environment the tick frequency has to be at least a multiple of the Win32 tick frequency, and therefore very slow. */\r
 #define configMINIMAL_STACK_SIZE                               ( ( unsigned short ) 70 ) /* In this simulated case, the stack only has to hold one small structure as the real stack is part of the win32 thread. */\r
-#define configTOTAL_HEAP_SIZE                                  ( ( size_t ) ( 45 * 1024 ) )\r
+#define configTOTAL_HEAP_SIZE                                  ( ( size_t ) ( 65 * 1024 ) )\r
 #define configMAX_TASK_NAME_LEN                                        ( 12 )\r
 #define configUSE_TRACE_FACILITY                               1\r
 #define configUSE_16_BIT_TICKS                                 0\r
@@ -56,7 +56,6 @@
 #define configCHECK_FOR_STACK_OVERFLOW                 0\r
 #define configUSE_RECURSIVE_MUTEXES                            1\r
 #define configQUEUE_REGISTRY_SIZE                              20\r
-#define configUSE_MALLOC_FAILED_HOOK                   1\r
 #define configUSE_APPLICATION_TASK_TAG                 1\r
 #define configUSE_COUNTING_SEMAPHORES                  1\r
 #define configUSE_ALTERNATIVE_API                              0\r
 #define configUSE_TASK_NOTIFICATIONS                   1\r
 #define configSUPPORT_STATIC_ALLOCATION                        1\r
 \r
-/* Software timer related configuration options. */\r
+/* Software timer related configuration options.  The maximum possible task\r
+priority is configMAX_PRIORITIES - 1.  The priority of the timer task is\r
+deliberately set higher to ensure it is correctly capped back to\r
+configMAX_PRIORITIES - 1. */\r
 #define configUSE_TIMERS                                               1\r
 #define configTIMER_TASK_PRIORITY                              ( configMAX_PRIORITIES - 1 )\r
 #define configTIMER_QUEUE_LENGTH                               20\r
@@ -80,14 +82,18 @@ void vConfigureTimerForRunTimeStats( void );        /* Prototype of function that initi
 #define portGET_RUN_TIME_COUNTER_VALUE() ulGetRunTimeCounterValue()\r
 \r
 /* Co-routine related configuration options. */\r
-#define configUSE_CO_ROUTINES                                  1\r
+#define configUSE_CO_ROUTINES                                  0\r
 #define configMAX_CO_ROUTINE_PRIORITIES                        ( 2 )\r
 \r
-/* This demo makes use of one or more example stats formatting functions.  These\r
+/* This demo can use of one or more example stats formatting functions.  These\r
 format the raw data provided by the uxTaskGetSystemState() function in to human\r
 readable ASCII form.  See the notes in the implementation of vTaskList() within\r
 FreeRTOS/Source/tasks.c for limitations. */\r
-#define configUSE_STATS_FORMATTING_FUNCTIONS   1\r
+#define configUSE_STATS_FORMATTING_FUNCTIONS   0\r
+\r
+/* Enables the test whereby a stack larger than the total heap size is\r
+requested. */\r
+#define configSTACK_DEPTH_TYPE uint32_t\r
 \r
 /* Set the following definitions to 1 to include the API function, or zero\r
 to exclude the API function.  In most cases the linker will remove unused\r
@@ -116,11 +122,24 @@ functions anyway. */
 #endif /* configINCLUDE_MESSAGE_BUFFER_AMP_DEMO */\r
 \r
 extern void vAssertCalled( unsigned long ulLine, const char * const pcFileName );\r
-#define configCOVERAGE_TEST 1\r
-#if( configCOVERAGE_TEST == 1 )\r
+\r
+/* projCOVERAGE_TEST should be defined on the command line so this file can be\r
+used with multiple project configurations.  If it is\r
+ */\r
+#ifndef projCOVERAGE_TEST\r
+       #error projCOVERAGE_TEST should be defined to 1 or 0 on the command line.\r
+#endif\r
+\r
+#if( projCOVERAGE_TEST == 1 )\r
        /* Insert NOPs in empty decision paths to ensure both true and false paths\r
        are being tested. */\r
        #define mtCOVERAGE_TEST_MARKER() __asm volatile( "NOP" )\r
+\r
+       /* Ensure the tick count overflows during the coverage test. */\r
+       #define configINITIAL_TICK_COUNT 0xffffd800UL\r
+\r
+       /* Allows tests of trying to allocate more than the heap has free. */\r
+       #define configUSE_MALLOC_FAILED_HOOK                    0\r
 #else\r
        /* It is a good idea to define configASSERT() while developing.  configASSERT()\r
        uses the same semantics as the standard C assert() macro.  Don't define\r
@@ -128,9 +147,12 @@ extern void vAssertCalled( unsigned long ulLine, const char * const pcFileName )
        intended to asserts() to fail, some some code is intended not to run if no\r
        errors are present. */\r
        #define configASSERT( x ) if( ( x ) == 0 ) vAssertCalled( __LINE__, __FILE__ )\r
+\r
+       #define configUSE_MALLOC_FAILED_HOOK                    1\r
+\r
+       /* Include the FreeRTOS+Trace FreeRTOS trace macro definitions. */\r
+       #include "trcRecorder.h"\r
 #endif\r
 \r
-/* Include the FreeRTOS+Trace FreeRTOS trace macro definitions. */\r
-#include "trcRecorder.h"\r
 \r
 #endif /* FREERTOS_CONFIG_H */\r
diff --git a/FreeRTOS/Demo/WIN32-MingW/code_coverage_additions.c b/FreeRTOS/Demo/WIN32-MingW/code_coverage_additions.c
new file mode 100644 (file)
index 0000000..86dc029
--- /dev/null
@@ -0,0 +1,594 @@
+/*\r
+ * FreeRTOS Kernel V10.0.1\r
+ * Copyright (C) 2017 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of\r
+ * this software and associated documentation files (the "Software"), to deal in\r
+ * the Software without restriction, including without limitation the rights to\r
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\r
+ * the Software, and to permit persons to whom the Software is furnished to do so,\r
+ * subject to the following conditions:\r
+ *\r
+ * The above copyright notice and this permission notice shall be included in all\r
+ * copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+ *\r
+ * http://www.FreeRTOS.org\r
+ * http://aws.amazon.com/freertos\r
+ *\r
+ * 1 tab == 4 spaces!\r
+ */\r
+\r
+/*\r
+ * Contains sundry tests to exercise code that is not touched by the standard\r
+ * demo tasks (which are predominantly test tasks).  Some tests are incldued\r
+ * here because they can only be executed when configASSERT() is not defined.\r
+ */\r
+\r
+#include "FreeRTOS.h"\r
+#include "task.h"\r
+#include "timers.h"\r
+#include "event_groups.h"\r
+#include "semphr.h"\r
+#include "stream_buffer.h"\r
+#include "message_buffer.h"\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+/*\r
+ * Try creating static objects with one of the mandatory parameters set to NULL.\r
+ * This can't be done in the standard demos as asserts() will get hit.\r
+ */\r
+static BaseType_t prvStaticAllocationsWithNullBuffers( void );\r
+\r
+/*\r
+ * Code coverage analysis is performed with tracing turned off, so this\r
+ * function executes the trace specific utility functions that would not\r
+ * otherwise be executed..\r
+ */\r
+static BaseType_t prvTraceUtils( void );\r
+\r
+/*\r
+ * The queue peek standard demo does not cover the case where an attempt to peek\r
+ * times out, so test that case.\r
+ */\r
+static BaseType_t prvPeekTimeout( void );\r
+\r
+/*\r
+ * Calls various interrupt safe functions designed to query the state of a\r
+ * queue.\r
+ */\r
+static BaseType_t prvQueueQueryFromISR( void );\r
+\r
+/*\r
+ * Hits a few paths in tasks state and status query functions not otherwise hit\r
+ * by standard demo and test files.\r
+ */\r
+static BaseType_t prvTaskQueryFunctions( void );\r
+\r
+/*\r
+ * None of the standard demo tasks use the task tags - exercise them here.\r
+ */\r
+static BaseType_t prvTaskTags( void );\r
+\r
+/*\r
+ * Exercises a few of the query functions that are not otherwise exercised in\r
+ * the standard demo and test functions.\r
+ */\r
+static BaseType_t prvTimerQuery( void );\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+static BaseType_t prvStaticAllocationsWithNullBuffers( void )\r
+{\r
+uint32_t ulReturned = 0;\r
+BaseType_t xReturn = pdPASS;\r
+UBaseType_t uxDummy = 10;\r
+\r
+       /* Don't expect to create any of the objects as a NULL parameter is always\r
+       passed in place of a required buffer.  Hence if all passes then none of the\r
+       |= will be against 0, and ulReturned will still be zero at the end of this\r
+       function. */\r
+       ulReturned |= ( uint32_t ) xEventGroupCreateStatic( NULL );\r
+\r
+       /* Try creating a task twice, once with puxStackBuffer NULL, and once with\r
+       pxTaskBuffer NULL. */\r
+       ulReturned |= ( uint32_t ) xTaskCreateStatic( NULL, /* Task to run, not needed as the task is not created. */\r
+                                                                                                 "Dummy", /* Task name. */\r
+                                                                                                 configMINIMAL_STACK_SIZE,\r
+                                                                                                 NULL,\r
+                                                                                                 tskIDLE_PRIORITY,\r
+                                                                                                 NULL,\r
+                                                                                                 ( StaticTask_t * ) &xReturn ); /* Dummy value just to pass a non NULL value in - won't get used. */\r
+\r
+       ulReturned |= ( uint32_t ) xTaskCreateStatic( NULL, /* Task to run, not needed as the task is not created. */\r
+                                                                                                 "Dummy", /* Task name. */\r
+                                                                                                 configMINIMAL_STACK_SIZE,\r
+                                                                                                 NULL,\r
+                                                                                                 tskIDLE_PRIORITY,\r
+                                                                                                 ( StackType_t  * ) &xReturn, /* Dummy value just to pass a non NULL value in - won't get used. */\r
+                                                                                                 NULL );\r
+\r
+       ulReturned |= ( uint32_t ) xQueueCreateStatic( uxDummy,\r
+                                                                                                  uxDummy,\r
+                                                                                                  ( uint8_t * ) &xReturn, /* Dummy value just to pass a non NULL value in - won't get used. */\r
+                                                                                                  NULL );\r
+\r
+       /* Try creating a stream buffer twice, once with pucStreamBufferStorageArea\r
+       set to NULL, and once with pxStaticStreamBuffer set to NULL. */\r
+       ulReturned |= ( uint32_t ) xStreamBufferCreateStatic( uxDummy,\r
+                                                                                                                 uxDummy,\r
+                                                                                                                 NULL,\r
+                                                                                                                 ( StaticStreamBuffer_t  * ) &xReturn ); /* Dummy value just to pass a non NULL value in - won't get used. */\r
+\r
+       ulReturned |= ( uint32_t ) xStreamBufferCreateStatic( uxDummy,\r
+                                                                                                                 uxDummy,\r
+                                                                                                                 ( uint8_t * ) &xReturn, /* Dummy value just to pass a non NULL value in - won't get used. */\r
+                                                                                                                 NULL );\r
+\r
+       /* Try to create a task with a stack that is too large to be allocated. */\r
+       if( xTaskCreate( NULL, "TooLarge", configTOTAL_HEAP_SIZE, NULL, tskIDLE_PRIORITY, NULL ) != errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY )\r
+       {\r
+               xReturn = pdFAIL;\r
+       }\r
+\r
+       if( ulReturned != 0 )\r
+       {\r
+               /* Something returned a non-NULL value. */\r
+               xReturn = pdFAIL;\r
+       }\r
+\r
+       return xReturn;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static BaseType_t prvTraceUtils( void )\r
+{\r
+EventGroupHandle_t xEventGroup;\r
+QueueHandle_t xQueue;\r
+BaseType_t xReturn = pdPASS;\r
+const UBaseType_t xNumber = ( UBaseType_t ) 100, xQueueLength = ( UBaseType_t ) 1;\r
+UBaseType_t uxValue;\r
+TaskHandle_t xTaskHandle;\r
+StreamBufferHandle_t xStreamBuffer;\r
+MessageBufferHandle_t xMessageBuffer;\r
+\r
+       /* Exercise the event group trace utilities. */\r
+       xEventGroup = xEventGroupCreate();\r
+\r
+       if( xEventGroup != NULL )\r
+       {\r
+               vEventGroupSetNumber( xEventGroup, xNumber );\r
+               if( uxEventGroupGetNumber( NULL ) != 0 )\r
+               {\r
+                       xReturn = pdFAIL;\r
+               }\r
+               if( uxEventGroupGetNumber( xEventGroup ) != xNumber )\r
+               {\r
+                       xReturn = pdFAIL;\r
+               }\r
+\r
+               vEventGroupDelete( xEventGroup );\r
+       }\r
+       else\r
+       {\r
+               xReturn = pdFAIL;\r
+       }\r
+\r
+       /* Exercise the queue trace utilities. */\r
+       xQueue = xQueueCreate( xQueueLength, ( UBaseType_t ) sizeof( uxValue ) );\r
+       if( xQueue != NULL )\r
+       {\r
+               vQueueSetQueueNumber( xQueue, xNumber );\r
+               if( uxQueueGetQueueNumber( xQueue ) != xNumber )\r
+               {\r
+                       xReturn = pdFAIL;\r
+               }\r
+               if( ucQueueGetQueueType( xQueue ) != queueQUEUE_TYPE_BASE )\r
+               {\r
+                       xReturn = pdFAIL;\r
+               }\r
+\r
+               vQueueDelete( xQueue );\r
+       }\r
+       else\r
+       {\r
+               xReturn = pdFAIL;\r
+       }\r
+\r
+       /* Exercise the task trace utilities.  Value of 100 is arbitrary, just want\r
+       to check the value that is set is also read back. */\r
+       uxValue = 100;\r
+       xTaskHandle = xTaskGetCurrentTaskHandle();\r
+       vTaskSetTaskNumber( xTaskHandle, uxValue );\r
+       if( uxTaskGetTaskNumber( xTaskHandle ) != uxValue )\r
+       {\r
+               xReturn = pdFAIL;\r
+       }\r
+       if( uxTaskGetTaskNumber( NULL ) != 0 )\r
+       {\r
+               xReturn = pdFAIL;\r
+       }\r
+\r
+       /* Timer trace util functions are exercised in prvTimerQuery(). */\r
+\r
+\r
+       /* Exercise the stream buffer utilities.  Try creating with a trigger level\r
+       of 0, it should then get capped to 1. */\r
+       xStreamBuffer = xStreamBufferCreate( sizeof( uint32_t ), 0 );\r
+       if( xStreamBuffer != NULL )\r
+       {\r
+               vStreamBufferSetStreamBufferNumber( xStreamBuffer, uxValue );\r
+               if( uxStreamBufferGetStreamBufferNumber( xStreamBuffer ) != uxValue )\r
+               {\r
+                       xReturn = pdFALSE;\r
+               }\r
+               if( ucStreamBufferGetStreamBufferType( xStreamBuffer ) != 0 )\r
+               {\r
+                       /* "Is Message Buffer" flag should have been 0. */\r
+                       xReturn = pdFALSE;\r
+               }\r
+\r
+               vStreamBufferDelete( xStreamBuffer );\r
+       }\r
+       else\r
+       {\r
+               xReturn = pdFALSE;\r
+       }\r
+\r
+       xMessageBuffer = xMessageBufferCreate( sizeof( uint32_t ) );\r
+       if( xMessageBuffer != NULL )\r
+       {\r
+               if( ucStreamBufferGetStreamBufferType( xMessageBuffer ) == 0 )\r
+               {\r
+                       /* "Is Message Buffer" flag should have been 1. */\r
+                       xReturn = pdFALSE;\r
+               }\r
+\r
+               vMessageBufferDelete( xMessageBuffer );\r
+       }\r
+       else\r
+       {\r
+               xReturn = pdFALSE;\r
+       }\r
+\r
+       return xReturn;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static BaseType_t prvPeekTimeout( void )\r
+{\r
+QueueHandle_t xHandle;\r
+const UBaseType_t xQueueLength = 1;\r
+BaseType_t xReturn = pdPASS;\r
+TickType_t xBlockTime = ( TickType_t ) 2;\r
+UBaseType_t uxReceived;\r
+\r
+       /* Create the queue just to try peeking it while it is empty. */\r
+       xHandle = xQueueCreate( xQueueLength, ( UBaseType_t ) sizeof( xQueueLength ) );\r
+\r
+       if( xHandle != NULL )\r
+       {\r
+               if( uxQueueMessagesWaiting( xHandle ) != 0 )\r
+               {\r
+                       xReturn = pdFAIL;\r
+               }\r
+\r
+               /* Ensure peeking from the queue times out as the queue is empty. */\r
+               if( xQueuePeek( xHandle, &uxReceived, xBlockTime ) != pdFALSE )\r
+               {\r
+                       xReturn = pdFAIL;\r
+               }\r
+\r
+               vQueueDelete( xHandle );\r
+       }\r
+       else\r
+       {\r
+               xReturn = pdFAIL;\r
+       }\r
+\r
+       return xReturn;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static BaseType_t prvQueueQueryFromISR( void )\r
+{\r
+BaseType_t xReturn = pdPASS, xValue = 1;\r
+const UBaseType_t xISRQueueLength = ( UBaseType_t ) 1;\r
+const char *pcISRQueueName = "ISRQueue";\r
+QueueHandle_t xISRQueue = NULL;\r
+\r
+       xISRQueue = xQueueCreate( xISRQueueLength, ( UBaseType_t ) sizeof( BaseType_t ) );\r
+\r
+       if( xISRQueue != NULL )\r
+       {\r
+               vQueueAddToRegistry( xISRQueue, pcISRQueueName );\r
+               if( strcmp( pcQueueGetName( xISRQueue ), pcISRQueueName ) )\r
+               {\r
+                       xReturn = pdFAIL;\r
+               }\r
+\r
+               /* Expect the queue to be empty here. */\r
+               if(     uxQueueMessagesWaitingFromISR( xISRQueue ) != 0 )\r
+               {\r
+                       xReturn = pdFAIL;\r
+               }\r
+\r
+               if( xQueueIsQueueEmptyFromISR( xISRQueue ) != pdTRUE )\r
+               {\r
+                       xReturn = pdFAIL;\r
+               }\r
+\r
+               if( xQueueIsQueueFullFromISR( xISRQueue ) != pdFALSE )\r
+               {\r
+                       xReturn = pdFAIL;\r
+               }\r
+\r
+               /* Now fill the queue - it only has one space. */\r
+               if( xQueueSendFromISR( xISRQueue, &xValue, NULL ) != pdPASS )\r
+               {\r
+                       xReturn = pdFAIL;\r
+               }\r
+\r
+               /* Check it now reports as full. */\r
+               if(     uxQueueMessagesWaitingFromISR( xISRQueue ) != 1 )\r
+               {\r
+                       xReturn = pdFAIL;\r
+               }\r
+\r
+               if( xQueueIsQueueEmptyFromISR( xISRQueue ) != pdFALSE )\r
+               {\r
+                       xReturn = pdFAIL;\r
+               }\r
+\r
+               if( xQueueIsQueueFullFromISR( xISRQueue ) != pdTRUE )\r
+               {\r
+                       xReturn = pdFAIL;\r
+               }\r
+\r
+               vQueueDelete( xISRQueue );\r
+       }\r
+       else\r
+       {\r
+               xReturn = pdFAIL;\r
+       }\r
+\r
+       return xReturn;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static BaseType_t prvTaskQueryFunctions( void )\r
+{\r
+static TaskStatus_t xStatus, *pxStatusArray;\r
+TaskHandle_t xTimerTask, xIdleTask;\r
+BaseType_t xReturn = pdPASS;\r
+UBaseType_t uxNumberOfTasks, uxReturned, ux;\r
+uint32_t ulTotalRunTime1, ulTotalRunTime2;\r
+const uint32_t ulRunTimeTollerance = ( uint32_t ) 0xfff;\r
+\r
+       /* Obtain task status with the stack high water mark and without the\r
+       state. */\r
+       vTaskGetInfo( NULL, &xStatus, pdTRUE, eRunning );\r
+\r
+       if( uxTaskGetStackHighWaterMark( NULL ) != xStatus.usStackHighWaterMark )\r
+       {\r
+               xReturn = pdFAIL;\r
+       }\r
+\r
+       /* Now obtain a task status without the high water mark but with the state,\r
+       which in the case of the idle task should be Read. */\r
+       xTimerTask = xTimerGetTimerDaemonTaskHandle();\r
+       vTaskSuspend( xTimerTask ); /* Should never suspend Timer task normally!. */\r
+       vTaskGetInfo( xTimerTask, &xStatus, pdFALSE, eInvalid );\r
+       if( xStatus.eCurrentState != eSuspended )\r
+       {\r
+               xReturn = pdFAIL;\r
+       }\r
+       if( xStatus.uxBasePriority != uxTaskPriorityGetFromISR( xTimerTask ) )\r
+       {\r
+               xReturn = pdFAIL;\r
+       }\r
+       if( xStatus.uxBasePriority != ( configMAX_PRIORITIES - 1 ) )\r
+       {\r
+               xReturn = pdFAIL;\r
+       }\r
+       xTaskResumeFromISR( xTimerTask );\r
+       vTaskGetInfo( xTimerTask, &xStatus, pdTRUE, eInvalid );\r
+       if( ( xStatus.eCurrentState != eReady ) && ( xStatus.eCurrentState != eBlocked ) )\r
+       {\r
+               xReturn = pdFAIL;\r
+       }\r
+       if( uxTaskGetStackHighWaterMark( xTimerTask ) != xStatus.usStackHighWaterMark )\r
+       {\r
+               xReturn = pdFAIL;\r
+       }\r
+\r
+       /* Attempting to abort a delay in the idle task should be guaranteed to\r
+       fail as the idle task should never block. */\r
+       xIdleTask = xTaskGetIdleTaskHandle();\r
+       if( xTaskAbortDelay( xIdleTask ) != pdFAIL )\r
+       {\r
+               xReturn = pdFAIL;\r
+       }\r
+\r
+       /* Create an array of task status objects large enough to hold information\r
+       on the number of tasks at this time - note this may change at any time if\r
+       higher priority tasks are executing and creating tasks. */\r
+       uxNumberOfTasks = uxTaskGetNumberOfTasks();\r
+       pxStatusArray = ( TaskStatus_t * ) pvPortMalloc( uxNumberOfTasks * sizeof( TaskStatus_t ) );\r
+\r
+       if( pxStatusArray != NULL )\r
+       {\r
+               /* Pass part of the array into uxTaskGetSystemState() to ensure it doesn't\r
+               try using more space than there is available. */\r
+               uxReturned = uxTaskGetSystemState( pxStatusArray, uxNumberOfTasks / ( UBaseType_t ) 2, NULL );\r
+               if( uxReturned != ( UBaseType_t ) 0 )\r
+               {\r
+                       xReturn = pdFAIL;\r
+               }\r
+\r
+               /* Now do the same but passing in the complete array size, this is done\r
+               twice to check for a difference in the total run time. */\r
+               uxTaskGetSystemState( pxStatusArray, uxNumberOfTasks, &ulTotalRunTime1 );\r
+               memset( ( void * ) pxStatusArray, 0xaa, uxNumberOfTasks * sizeof( TaskStatus_t ) );\r
+               uxReturned = uxTaskGetSystemState( pxStatusArray, uxNumberOfTasks, &ulTotalRunTime2 );\r
+               if( ( ulTotalRunTime2 - ulTotalRunTime1 ) > ulRunTimeTollerance )\r
+               {\r
+                       xReturn = pdFAIL;\r
+               }\r
+\r
+               /* Basic santity check of array contents. */\r
+               for( ux = 0; ux < uxReturned; ux++ )\r
+               {\r
+                       if( pxStatusArray[ ux ].eCurrentState >= ( UBaseType_t ) eInvalid )\r
+                       {\r
+                               xReturn = pdFAIL;\r
+                       }\r
+                       if( pxStatusArray[ ux ].uxCurrentPriority >= ( UBaseType_t ) configMAX_PRIORITIES )\r
+                       {\r
+                               xReturn = pdFAIL;\r
+                       }\r
+               }\r
+\r
+               vPortFree( pxStatusArray );\r
+       }\r
+       else\r
+       {\r
+               xReturn = pdFAIL;\r
+       }\r
+\r
+       return xReturn;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static BaseType_t prvDummyTagFunction( void *pvParameter )\r
+{\r
+       return ( BaseType_t ) pvParameter;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static BaseType_t prvTaskTags( void )\r
+{\r
+BaseType_t xReturn = pdPASS, xParameter = ( BaseType_t ) 0xDEADBEEF;\r
+TaskHandle_t xTask;\r
+\r
+       /* First try with the handle of a different task.  Use the timer task for\r
+       convenience. */\r
+       xTask = xTimerGetTimerDaemonTaskHandle();\r
+\r
+       vTaskSetApplicationTaskTag( xTask, prvDummyTagFunction );\r
+       if( xTaskGetApplicationTaskTag( xTask ) != prvDummyTagFunction )\r
+       {\r
+               xReturn = pdFAIL;\r
+       }\r
+       else\r
+       {\r
+               if( xTaskCallApplicationTaskHook( xTask, ( void * ) xParameter ) != xParameter )\r
+               {\r
+                       xReturn = pdFAIL;\r
+               }\r
+               if( xTaskCallApplicationTaskHook( xTask, ( void * ) NULL ) != pdFAIL )\r
+               {\r
+                       xReturn = pdFAIL;\r
+               }\r
+       }\r
+\r
+       /* Now try with a NULL handle, so using this task. */\r
+       vTaskSetApplicationTaskTag( NULL, NULL );\r
+       if( xTaskGetApplicationTaskTag( NULL ) != NULL )\r
+       {\r
+               xReturn = pdFAIL;\r
+       }\r
+\r
+       vTaskSetApplicationTaskTag( NULL, prvDummyTagFunction );\r
+       if( xTaskGetApplicationTaskTag( NULL ) != prvDummyTagFunction )\r
+       {\r
+               xReturn = pdFAIL;\r
+       }\r
+       else\r
+       {\r
+               if( xTaskCallApplicationTaskHook( NULL, ( void * ) xParameter ) != xParameter )\r
+               {\r
+                       xReturn = pdFAIL;\r
+               }\r
+               if( xTaskCallApplicationTaskHook( NULL, ( void * ) NULL ) != pdFAIL )\r
+               {\r
+                       xReturn = pdFAIL;\r
+               }\r
+       }\r
+\r
+       vTaskSetApplicationTaskTag( NULL, NULL );\r
+       if( xTaskGetApplicationTaskTag( NULL ) != NULL )\r
+       {\r
+               xReturn = pdFAIL;\r
+       }\r
+\r
+       return xReturn;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static BaseType_t prvTimerQuery( void )\r
+{\r
+TimerHandle_t xTimer;\r
+BaseType_t xReturn = pdPASS;\r
+const char *pcTimerName = "TestTimer";\r
+const TickType_t xTimerPeriod = ( TickType_t ) 100;\r
+const UBaseType_t uxTimerNumber = ( UBaseType_t ) 55;\r
+\r
+       xTimer = xTimerCreate(  pcTimerName,\r
+                                                       xTimerPeriod,\r
+                                                       pdFALSE,\r
+                                                       ( void * ) xTimerPeriod,\r
+                                                       NULL ); /* Not actually going to start timer so NULL callback is ok. */\r
+\r
+       if( xTimer != NULL )\r
+       {\r
+               if( xTimerGetPeriod( xTimer ) != xTimerPeriod )\r
+               {\r
+                       xReturn = pdFAIL;\r
+               }\r
+\r
+               if( strcmp( pcTimerGetName( xTimer ), pcTimerName ) != 0 )\r
+               {\r
+                       xReturn = pdFAIL;\r
+               }\r
+\r
+               vTimerSetTimerNumber( xTimer, uxTimerNumber );\r
+               if( uxTimerGetTimerNumber( xTimer ) != uxTimerNumber )\r
+               {\r
+                       xReturn = pdFAIL;\r
+               }\r
+\r
+               xTimerDelete( xTimer, portMAX_DELAY );\r
+       }\r
+       else\r
+       {\r
+               xReturn = pdFAIL;\r
+       }\r
+\r
+       return xReturn;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+BaseType_t xRunCodeCoverageTestAdditions( void )\r
+{\r
+BaseType_t xReturn = pdPASS;\r
+\r
+       xReturn &= prvStaticAllocationsWithNullBuffers();\r
+       xReturn &= prvTraceUtils();\r
+       xReturn &= prvPeekTimeout();\r
+       xReturn &= prvQueueQueryFromISR();\r
+       xReturn &= prvTaskQueryFunctions();\r
+       xReturn &= prvTaskTags();\r
+       xReturn &= prvTimerQuery();\r
+\r
+       return xReturn;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
index cfb16a4b0524b49411f624f28003d8d32776bc06..96a51cabef8a165f482f33247f55e911657443fe 100644 (file)
@@ -75,7 +75,7 @@ that make up the total heap.  heap_5 is only used for test and example purposes
 as this demo could easily create one large heap region instead of multiple\r
 smaller heap regions - in which case heap_4.c would be the more appropriate\r
 choice.  See http://www.freertos.org/a00111.html for an explanation. */\r
-#define mainREGION_1_SIZE      8201\r
+#define mainREGION_1_SIZE      10801\r
 #define mainREGION_2_SIZE      29905\r
 #define mainREGION_3_SIZE      6007\r
 \r
@@ -141,10 +141,6 @@ int main( void )
        http://www.freertos.org/a00111.html for an explanation. */\r
        prvInitialiseHeap();\r
 \r
-       /* Initialise the trace recorder.  Use of the trace recorder is optional.\r
-       See http://www.FreeRTOS.org/trace for more information. */\r
-       vTraceEnable( TRC_START );\r
-\r
        /* The mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting is described at the top\r
        of this file. */\r
        #if ( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1 )\r
@@ -153,11 +149,20 @@ int main( void )
        }\r
        #else\r
        {\r
-               /* Start the trace recording - the recording is written to a file if\r
-               configASSERT() is called. */\r
-               printf( "\r\nTrace started.\r\nThe trace will be dumped to disk if a call to configASSERT() fails.\r\n" );\r
-               printf( "Uncomment the call to kbhit() in this file to also dump trace with a key press.\r\n" );\r
-               uiTraceStart();\r
+               /* Do not include trace code when performing a code coverage analysis. */\r
+               #if( projCOVERAGE_TEST != 1 )\r
+               {\r
+                       /* Initialise the trace recorder.  Use of the trace recorder is optional.\r
+                       See http://www.FreeRTOS.org/trace for more information. */\r
+                       vTraceEnable( TRC_START );\r
+\r
+                       /* Start the trace recording - the recording is written to a file if\r
+                       configASSERT() is called. */\r
+                       printf( "\r\nTrace started.\r\nThe trace will be dumped to disk if a call to configASSERT() fails.\r\n" );\r
+                       printf( "Uncomment the call to kbhit() in this file to also dump trace with a key press.\r\n" );\r
+                       uiTraceStart();\r
+               }\r
+               #endif\r
 \r
                main_full();\r
        }\r
@@ -282,7 +287,6 @@ volatile uint32_t ulSetToNonZeroInDebuggerToContinue = 0;
                        xPrinted = pdTRUE;\r
                        if( xTraceRunning == pdTRUE )\r
                        {\r
-                               vTraceStop();\r
                                prvSaveTraceFile();\r
                        }\r
                }\r
@@ -302,20 +306,27 @@ volatile uint32_t ulSetToNonZeroInDebuggerToContinue = 0;
 \r
 static void prvSaveTraceFile( void )\r
 {\r
-FILE* pxOutputFile;\r
+       /* Tracing is not used when code coverage analysis is being performed. */\r
+       #if( projCOVERAGE_TEST != 1 )\r
+       {\r
+               FILE* pxOutputFile;\r
 \r
-       pxOutputFile = fopen( "Trace.dump", "wb");\r
+               vTraceStop();\r
 \r
-       if( pxOutputFile != NULL )\r
-       {\r
-               fwrite( RecorderDataPtr, sizeof( RecorderDataType ), 1, pxOutputFile );\r
-               fclose( pxOutputFile );\r
-               printf( "\r\nTrace output saved to Trace.dump\r\n" );\r
-       }\r
-       else\r
-       {\r
-               printf( "\r\nFailed to create trace dump file\r\n" );\r
+               pxOutputFile = fopen( "Trace.dump", "wb");\r
+\r
+               if( pxOutputFile != NULL )\r
+               {\r
+                       fwrite( RecorderDataPtr, sizeof( RecorderDataType ), 1, pxOutputFile );\r
+                       fclose( pxOutputFile );\r
+                       printf( "\r\nTrace output saved to Trace.dump\r\n" );\r
+               }\r
+               else\r
+               {\r
+                       printf( "\r\nFailed to create trace dump file\r\n" );\r
+               }\r
        }\r
+       #endif\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
index 96f02c4522a4ce0467f4965dac810b32524e7ee0..b8e06d184646cf1d7a8840e9b402f93356e9570d 100644 (file)
 \r
 #define mainTIMER_TEST_PERIOD                  ( 50 )\r
 \r
+/*\r
+ * Exercises code that is not otherwise covered by the standard demo/test\r
+ * tasks.\r
+ */\r
+extern BaseType_t xRunCodeCoverageTestAdditions( void );\r
+\r
 /* Task function prototypes. */\r
 static void prvCheckTask( void *pvParameters );\r
 \r
@@ -420,7 +426,6 @@ void *pvAllocated;
        timer. */\r
        prvDemonstrateTimerQueryFunctions();\r
 \r
-\r
        /* If xMutexToDelete has not already been deleted, then delete it now.\r
        This is done purely to demonstrate the use of, and test, the\r
        vSemaphoreDelete() macro.  Care must be taken not to delete a semaphore\r
@@ -448,13 +453,19 @@ void *pvAllocated;
 \r
        /* Exit after a fixed time so code coverage results are written to the\r
        disk. */\r
-       #if( configCOVERAGE_TEST == 1 )\r
+       #if( projCOVERAGE_TEST == 1 )\r
        {\r
-               const TickType_t xMaxRunTime = pdMS_TO_TICKS( 60000UL );\r
+               const TickType_t xMaxRunTime = pdMS_TO_TICKS( 30000UL );\r
+\r
+               /* Exercise code not otherwise executed by standard demo/test tasks. */\r
+               if( xRunCodeCoverageTestAdditions() != pdPASS )\r
+               {\r
+                       pcStatusMessage = "Code coverage additions failed.\r\n";\r
+               }\r
 \r
-               if( xTaskGetTickCount() >= xMaxRunTime )\r
+               if( ( xTaskGetTickCount() - configINITIAL_TICK_COUNT ) >= xMaxRunTime )\r
                {\r
-                       exit( 0 );\r
+                       vTaskEndScheduler();\r
                }\r
        }\r
        #endif\r
index 081eece5e48a79f31ce8af12c376121bde022813..a755621edd7433622e6ad083339838705f18b563 100644 (file)
@@ -508,8 +508,7 @@ uint32_t ulErrorCode;
 \r
 void vPortEndScheduler( void )\r
 {\r
-       /* This function IS NOT TESTED! */\r
-       TerminateProcess( GetCurrentProcess(), 0 );\r
+       exit( 0 );\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
index 80c976bd399aa901317dd932a5fc4c263a631035..a580ae7dcc59e05cfdff49ae6786ce6f27cfae4c 100644 (file)
@@ -301,7 +301,7 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
 \r
        QueueHandle_t xQueueGenericCreateStatic( const UBaseType_t uxQueueLength, const UBaseType_t uxItemSize, uint8_t *pucQueueStorage, StaticQueue_t *pxStaticQueue, const uint8_t ucQueueType )\r
        {\r
-       Queue_t *pxNewQueue;\r
+       Queue_t *pxNewQueue = NULL;\r
 \r
                configASSERT( uxQueueLength > ( UBaseType_t ) 0 );\r
 \r
@@ -345,6 +345,7 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
                else\r
                {\r
                        traceQUEUE_CREATE_FAILED( ucQueueType );\r
+                       mtCOVERAGE_TEST_MARKER();\r
                }\r
 \r
                return pxNewQueue;\r
@@ -397,6 +398,7 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
                else\r
                {\r
                        traceQUEUE_CREATE_FAILED( ucQueueType );\r
+                       mtCOVERAGE_TEST_MARKER();\r
                }\r
 \r
                return pxNewQueue;\r
index 963a35593c7225d182b199fa900f31c159270285..9e518907adffa68f9ce855825e8a1f86a179e6ce 100644 (file)
@@ -1234,7 +1234,7 @@ static void prvInitialiseNewStreamBuffer( StreamBuffer_t * const pxStreamBuffer,
 \r
        uint8_t ucStreamBufferGetStreamBufferType( StreamBufferHandle_t xStreamBuffer )\r
        {\r
-               return ( ( StreamBuffer_t * )xStreamBuffer )->ucFlags | sbFLAGS_IS_MESSAGE_BUFFER;\r
+               return ( ( StreamBuffer_t * )xStreamBuffer )->ucFlags & sbFLAGS_IS_MESSAGE_BUFFER;\r
        }\r
 \r
 #endif /* configUSE_TRACE_FACILITY */\r
index 3a0cbf4e9fbce212a6b1cb3d3dbe470583a91d27..129439caba03862cd212ea02ff900289038277b5 100644 (file)
@@ -1984,7 +1984,7 @@ BaseType_t xReturn;
 \r
                xNextTaskUnblockTime = portMAX_DELAY;\r
                xSchedulerRunning = pdTRUE;\r
-               xTickCount = ( TickType_t ) 0U;\r
+               xTickCount = ( TickType_t ) configINITIAL_TICK_COUNT;\r
 \r
                /* If configGENERATE_RUN_TIME_STATS is defined then the following\r
                macro must be defined to configure the timer/counter used to generate\r
@@ -2782,7 +2782,9 @@ BaseType_t xSwitchRequired = pdFALSE;
                /* Save the hook function in the TCB.  A critical section is required as\r
                the value can be accessed from an interrupt. */\r
                taskENTER_CRITICAL();\r
+               {\r
                        xTCB->pxTaskTag = pxHookFunction;\r
+               }\r
                taskEXIT_CRITICAL();\r
        }\r
 \r