From: rtel Date: Wed, 14 Mar 2018 15:58:47 +0000 (+0000) Subject: Import the code coverage test additions from the (unpublished) Visual Studio project... X-Git-Tag: V10.1.0~31 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=cd1ad55ff8962389a69bcdcf56f129a017cd6bac;p=freertos Import the code coverage test additions from the (unpublished) Visual Studio project to the (published) MingW/Eclipse project. 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 --- diff --git a/FreeRTOS/Demo/Common/Minimal/EventGroupsDemo.c b/FreeRTOS/Demo/Common/Minimal/EventGroupsDemo.c index 22b7fb81d..abd72e878 100644 --- a/FreeRTOS/Demo/Common/Minimal/EventGroupsDemo.c +++ b/FreeRTOS/Demo/Common/Minimal/EventGroupsDemo.c @@ -78,6 +78,7 @@ that synchronise with the xEventGroupSync() function. */ /* A block time of zero simply means "don't block". */ #define ebDONT_BLOCK ( 0 ) +#define ebONE_TICK ( ( TickType_t ) 1 ) /* A 5ms delay. */ #define ebSHORT_DELAY pdMS_TO_TICKS( ( TickType_t ) 5 ) @@ -281,7 +282,29 @@ EventBits_t uxSynchronisationBit, uxReturned; /* Set the bit that indicates this task is at the synchronisation point. The first time this is done the 'test master' task has a lower priority than this task so this task will get to the sync point before - the set bits task. */ + the set bits task - test this by first calling xEventGroupSync() with + a zero block time, and a block time that is too short for the other + task, before calling again with a max delay - the first two calls should + return before the rendezvous completes, the third only after the + rendezvous is complete. */ + uxReturned = xEventGroupSync( xEventGroup, /* The event group used for the synchronisation. */ + uxSynchronisationBit, /* The bit to set in the event group to indicate this task is at the sync point. */ + ebALL_SYNC_BITS,/* The bits to wait for - these bits are set by the other tasks taking part in the sync. */ + ebDONT_BLOCK ); /* The maximum time to wait for the sync condition to be met before giving up. */ + + /* No block time was specified, so as per the comments above, the + rendezvous is not expected to have completed yet. */ + configASSERT( ( uxReturned & ebALL_SYNC_BITS ) != ebALL_SYNC_BITS ); + + uxReturned = xEventGroupSync( xEventGroup, /* The event group used for the synchronisation. */ + uxSynchronisationBit, /* The bit to set in the event group to indicate this task is at the sync point. */ + ebALL_SYNC_BITS, /* The bits to wait for - these bits are set by the other tasks taking part in the sync. */ + ebONE_TICK ); /* The maximum time to wait for the sync condition to be met before giving up. */ + + /* A short block time was specified, so as per the comments above, the + rendezvous is not expected to have completed yet. */ + configASSERT( ( uxReturned & ebALL_SYNC_BITS ) != ebALL_SYNC_BITS ); + uxReturned = xEventGroupSync( xEventGroup, /* The event group used for the synchronisation. */ uxSynchronisationBit, /* The bit to set in the event group to indicate this task is at the sync point. */ ebALL_SYNC_BITS,/* The bits to wait for - these bits are set by the other tasks taking part in the sync. */ diff --git a/FreeRTOS/Demo/Common/Minimal/GenQTest.c b/FreeRTOS/Demo/Common/Minimal/GenQTest.c index 4d146054c..66be41733 100644 --- a/FreeRTOS/Demo/Common/Minimal/GenQTest.c +++ b/FreeRTOS/Demo/Common/Minimal/GenQTest.c @@ -433,11 +433,20 @@ QueueHandle_t xQueue; /* The tests in this function are very similar, the slight variations are for code coverage purposes. */ - /* Take the mutex. It should be available now. */ + /* Take the mutex. It should be available now. Check before and after + taking that the holder is reported correctly. */ + if( xSemaphoreGetMutexHolder( xMutex ) != NULL ) + { + xErrorDetected = pdTRUE; + } if( xSemaphoreTake( xMutex, intsemNO_BLOCK ) != pdPASS ) { xErrorDetected = pdTRUE; } + if( xSemaphoreGetMutexHolder( xMutex ) != xTaskGetCurrentTaskHandle() ) + { + xErrorDetected = pdTRUE; + } /* This task's priority should be as per that assigned when the task was created. */ @@ -524,8 +533,17 @@ QueueHandle_t xQueue; vTaskDelay( genqSHORT_BLOCK ); } - /* Give the semaphore back ready for the next test. */ + /* Give the semaphore back ready for the next test. Check the mutex + holder before and after using the "FromISR" version for code coverage. */ + if( xSemaphoreGetMutexHolderFromISR( xMutex ) != xTaskGetCurrentTaskHandle() ) + { + xErrorDetected = pdTRUE; + } xSemaphoreGive( xMutex ); + if( xSemaphoreGetMutexHolderFromISR( xMutex ) != NULL ) + { + xErrorDetected = pdTRUE; + } configASSERT( xErrorDetected == pdFALSE ); diff --git a/FreeRTOS/Demo/Common/Minimal/StaticAllocation.c b/FreeRTOS/Demo/Common/Minimal/StaticAllocation.c index 013503a7b..dc5c85407 100644 --- a/FreeRTOS/Demo/Common/Minimal/StaticAllocation.c +++ b/FreeRTOS/Demo/Common/Minimal/StaticAllocation.c @@ -695,8 +695,7 @@ StaticEventGroup_t xEventGroupBuffer; /* Create the event group. xEventGroupCreateStatic() has an extra parameter than the normal xEventGroupCreate() API function. The parameter is a pointer to the StaticEventGroup_t structure that will hold the event group - structure. If the parameter is passed as NULL then the structure will be - allocated dynamically, just as if xEventGroupCreate() had been called. */ + structure. */ xEventGroup = xEventGroupCreateStatic( &xEventGroupBuffer ); /* The event group handle should equal the static event group structure diff --git a/FreeRTOS/Demo/Common/Minimal/StreamBufferDemo.c b/FreeRTOS/Demo/Common/Minimal/StreamBufferDemo.c index a0cdda6c4..8250b13d9 100644 --- a/FreeRTOS/Demo/Common/Minimal/StreamBufferDemo.c +++ b/FreeRTOS/Demo/Common/Minimal/StreamBufferDemo.c @@ -92,6 +92,10 @@ static void prvEchoServer( void *pvParameters ); static void prvNonBlockingReceiverTask( void *pvParameters ); static void prvNonBlockingSenderTask( void *pvParameters ); +/* Performs an assert() like check in a way that won't get removed when +performing a code coverage analysis. */ +static void prvCheckExpectedState( BaseType_t xState ); + /* * A task that creates a stream buffer with a specific trigger level, then * receives a string from an interrupt (the RTOS tick hook) byte by byte to @@ -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"; static const char *pc54ByteString = "01234567891abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQ"; +/* Used to log the status of the tests contained within this file for reporting +to a monitoring task ('check' task). */ +static BaseType_t xErrorStatus = pdPASS; + /*-----------------------------------------------------------*/ void vStartStreamBufferTasks( void ) @@ -188,6 +196,16 @@ StreamBufferHandle_t xStreamBuffer; } /*-----------------------------------------------------------*/ +static void prvCheckExpectedState( BaseType_t xState ) +{ + configASSERT( xState ); + if( xState == pdFAIL ) + { + xErrorStatus = pdFAIL; + } +} +/*-----------------------------------------------------------*/ + static void prvSingleTaskTests( StreamBufferHandle_t xStreamBuffer ) { size_t xReturned, xItem, xExpectedSpace; @@ -213,15 +231,15 @@ UBaseType_t uxOriginalPriority; /* Nothing has been added or removed yet, so expect the free space to be exactly as created. */ xExpectedSpace = xStreamBufferSpacesAvailable( xStreamBuffer ); - configASSERT( xExpectedSpace == sbSTREAM_BUFFER_LENGTH_BYTES ); - configASSERT( xStreamBufferIsEmpty( xStreamBuffer ) == pdTRUE ); + prvCheckExpectedState( xExpectedSpace == sbSTREAM_BUFFER_LENGTH_BYTES ); + prvCheckExpectedState( xStreamBufferIsEmpty( xStreamBuffer ) == pdTRUE ); /* The buffer is 30 bytes long. 6 5 byte messages should fit before the buffer is completely full. */ for( xItem = 0; xItem < xMax6ByteMessages; xItem++ ) { - configASSERT( xStreamBufferIsFull( xStreamBuffer ) == pdFALSE ); + prvCheckExpectedState( xStreamBufferIsFull( xStreamBuffer ) == pdFALSE ); /* Generate recognisable data to write to the buffer. This is just ascii characters that shows which loop iteration the data was written @@ -235,27 +253,23 @@ UBaseType_t uxOriginalPriority; xReturned = xStreamBufferSendFromISR( xStreamBuffer, ( void * ) pucData, x6ByteLength, NULL ); } taskEXIT_CRITICAL(); - configASSERT( xReturned == x6ByteLength ); - ( void ) xReturned; /* In case configASSERT() is not defined. */ + prvCheckExpectedState( xReturned == x6ByteLength ); /* The space in the buffer will have reduced by the amount of user data written into the buffer. */ xExpectedSpace -= x6ByteLength; xReturned = xStreamBufferSpacesAvailable( xStreamBuffer ); - configASSERT( xReturned == xExpectedSpace ); - ( void ) xReturned; /* In case configASSERT() is not defined. */ + prvCheckExpectedState( xReturned == xExpectedSpace ); xReturned = xStreamBufferBytesAvailable( xStreamBuffer ); /* +1 as it is zero indexed. */ - configASSERT( xReturned == ( ( xItem + 1 ) * x6ByteLength ) ); - ( void ) xReturned; /* In case configASSERT() is not defined. */ + prvCheckExpectedState( xReturned == ( ( xItem + 1 ) * x6ByteLength ) ); } /* Now the buffer should be full, and attempting to add anything will should fail. */ - configASSERT( xStreamBufferIsFull( xStreamBuffer ) == pdTRUE ); + prvCheckExpectedState( xStreamBufferIsFull( xStreamBuffer ) == pdTRUE ); xReturned = xStreamBufferSend( xStreamBuffer, ( void * ) pucData, sizeof( pucData[ 0 ] ), sbDONT_BLOCK ); - configASSERT( xReturned == 0 ); - ( void ) xReturned; /* In case configASSERT() is not defined. */ + prvCheckExpectedState( xReturned == 0 ); /* Adding with a timeout should also fail after the appropriate time. The priority is temporarily boosted in this part of the test to keep the @@ -266,12 +280,9 @@ UBaseType_t uxOriginalPriority; xReturned = xStreamBufferSend( xStreamBuffer, ( void * ) pucData, sizeof( pucData[ 0 ] ), xBlockTime ); xTimeAfterCall = xTaskGetTickCount(); vTaskPrioritySet( NULL, uxOriginalPriority ); - configASSERT( ( xTimeAfterCall - xTimeBeforeCall ) >= xBlockTime ); - configASSERT( ( xTimeAfterCall - xTimeBeforeCall ) < ( xBlockTime + xAllowableMargin ) ); - configASSERT( xReturned == 0 ); /* In case configASSERT() is not defined. */ - ( void ) xTimeAfterCall; - ( void ) xTimeBeforeCall; - + prvCheckExpectedState( ( xTimeAfterCall - xTimeBeforeCall ) >= xBlockTime ); + prvCheckExpectedState( ( xTimeAfterCall - xTimeBeforeCall ) < ( xBlockTime + xAllowableMargin ) ); + prvCheckExpectedState( xReturned == 0 ); /* The buffer is now full of data in the form "000000", "111111", etc. Make sure the data is read out as expected. */ @@ -290,24 +301,24 @@ UBaseType_t uxOriginalPriority; xReturned = xStreamBufferReceiveFromISR( xStreamBuffer, ( void * ) pucReadData, x6ByteLength, NULL ); } taskEXIT_CRITICAL(); - configASSERT( xReturned == x6ByteLength ); + prvCheckExpectedState( xReturned == x6ByteLength ); /* Does the data read out match that expected? */ - configASSERT( memcmp( ( void * ) pucData, ( void * ) pucReadData, x6ByteLength ) == 0 ); + prvCheckExpectedState( memcmp( ( void * ) pucData, ( void * ) pucReadData, x6ByteLength ) == 0 ); /* The space in the buffer will have increased by the amount of user data removed from the buffer. */ xExpectedSpace += x6ByteLength; xReturned = xStreamBufferSpacesAvailable( xStreamBuffer ); - configASSERT( xReturned == xExpectedSpace ); + prvCheckExpectedState( xReturned == xExpectedSpace ); xReturned = xStreamBufferBytesAvailable( xStreamBuffer ); - configASSERT( xReturned == ( sbSTREAM_BUFFER_LENGTH_BYTES - xExpectedSpace ) ); + prvCheckExpectedState( xReturned == ( sbSTREAM_BUFFER_LENGTH_BYTES - xExpectedSpace ) ); } /* The buffer should be empty again. */ - configASSERT( xStreamBufferIsEmpty( xStreamBuffer ) == pdTRUE ); + prvCheckExpectedState( xStreamBufferIsEmpty( xStreamBuffer ) == pdTRUE ); xExpectedSpace = xStreamBufferSpacesAvailable( xStreamBuffer ); - configASSERT( xExpectedSpace == sbSTREAM_BUFFER_LENGTH_BYTES ); + prvCheckExpectedState( xExpectedSpace == sbSTREAM_BUFFER_LENGTH_BYTES ); /* Reading with a timeout should also fail after the appropriate time. The priority is temporarily boosted in this part of the test to keep the @@ -317,9 +328,9 @@ UBaseType_t uxOriginalPriority; xReturned = xStreamBufferReceive( xStreamBuffer, ( void * ) pucReadData, x6ByteLength, xBlockTime ); xTimeAfterCall = xTaskGetTickCount(); vTaskPrioritySet( NULL, uxOriginalPriority ); - configASSERT( ( xTimeAfterCall - xTimeBeforeCall ) >= xBlockTime ); - configASSERT( ( xTimeAfterCall - xTimeBeforeCall ) < ( xBlockTime + xAllowableMargin ) ); - configASSERT( xReturned == 0 ); + prvCheckExpectedState( ( xTimeAfterCall - xTimeBeforeCall ) >= xBlockTime ); + prvCheckExpectedState( ( xTimeAfterCall - xTimeBeforeCall ) < ( xBlockTime + xAllowableMargin ) ); + prvCheckExpectedState( xReturned == 0 ); /* In the next loop 17 bytes are written to then read out on each @@ -333,38 +344,38 @@ UBaseType_t uxOriginalPriority; in. */ memset( ( void * ) pucData, ( ( int ) '0' ) + ( int ) xItem, x17ByteLength ); xReturned = xStreamBufferSend( xStreamBuffer, ( void * ) pucData, x17ByteLength, sbDONT_BLOCK ); - configASSERT( xReturned == x17ByteLength ); + prvCheckExpectedState( xReturned == x17ByteLength ); /* The space in the buffer will have reduced by the amount of user data written into the buffer. */ xReturned = xStreamBufferSpacesAvailable( xStreamBuffer ); - configASSERT( xReturned == xExpectedSpace ); + prvCheckExpectedState( xReturned == xExpectedSpace ); xReturned = xStreamBufferBytesAvailable( xStreamBuffer ); - configASSERT( xReturned == x17ByteLength ); - configASSERT( xStreamBufferIsFull( xStreamBuffer ) == pdFALSE ); - configASSERT( xStreamBufferIsEmpty( xStreamBuffer ) == pdFALSE ); + prvCheckExpectedState( xReturned == x17ByteLength ); + prvCheckExpectedState( xStreamBufferIsFull( xStreamBuffer ) == pdFALSE ); + prvCheckExpectedState( xStreamBufferIsEmpty( xStreamBuffer ) == pdFALSE ); /* Read the 17 bytes out again. */ xReturned = xStreamBufferReceive( xStreamBuffer, ( void * ) pucReadData, x17ByteLength, sbDONT_BLOCK ); - configASSERT( xReturned == x17ByteLength ); + prvCheckExpectedState( xReturned == x17ByteLength ); /* Does the data read out match that expected? */ - configASSERT( memcmp( ( void * ) pucData, ( void * ) pucReadData, x17ByteLength ) == 0 ); + prvCheckExpectedState( memcmp( ( void * ) pucData, ( void * ) pucReadData, x17ByteLength ) == 0 ); /* Full buffer space available again. */ xReturned = xStreamBufferSpacesAvailable( xStreamBuffer ); - configASSERT( xReturned == sbSTREAM_BUFFER_LENGTH_BYTES ); + prvCheckExpectedState( xReturned == sbSTREAM_BUFFER_LENGTH_BYTES ); xReturned = xStreamBufferBytesAvailable( xStreamBuffer ); - configASSERT( xReturned == 0 ); - configASSERT( xStreamBufferIsFull( xStreamBuffer ) == pdFALSE ); - configASSERT( xStreamBufferIsEmpty( xStreamBuffer ) == pdTRUE ); + prvCheckExpectedState( xReturned == 0 ); + prvCheckExpectedState( xStreamBufferIsFull( xStreamBuffer ) == pdFALSE ); + prvCheckExpectedState( xStreamBufferIsEmpty( xStreamBuffer ) == pdTRUE ); } /* Fill the buffer with one message, check it is full, then read it back again and check the correct data is received. */ xStreamBufferSend( xStreamBuffer, ( const void * ) pc55ByteString, sbSTREAM_BUFFER_LENGTH_BYTES, sbDONT_BLOCK ); xStreamBufferReceive( xStreamBuffer, ( void * ) pucFullBuffer, sbSTREAM_BUFFER_LENGTH_BYTES, sbDONT_BLOCK ); - configASSERT( memcmp( pc55ByteString, pucFullBuffer, sbSTREAM_BUFFER_LENGTH_BYTES ) == 0 ); + prvCheckExpectedState( memcmp( pc55ByteString, pucFullBuffer, sbSTREAM_BUFFER_LENGTH_BYTES ) == 0 ); /* Fill the buffer one bytes at a time. */ for( xItem = 0; xItem < sbSTREAM_BUFFER_LENGTH_BYTES; xItem++ ) @@ -375,23 +386,23 @@ UBaseType_t uxOriginalPriority; } /* The buffer should now be full. */ - configASSERT( xStreamBufferIsFull( xStreamBuffer ) == pdTRUE ); + prvCheckExpectedState( xStreamBufferIsFull( xStreamBuffer ) == pdTRUE ); /* Read the message out in one go, even though it was written in individual bytes. Try reading much more data than is actually available to ensure only the available bytes are returned (otherwise this read will write outside of the memory allocated anyway!). */ xReturned = xStreamBufferReceive( xStreamBuffer, pucFullBuffer, sbSTREAM_BUFFER_LENGTH_BYTES * ( size_t ) 2, sbRX_TX_BLOCK_TIME ); - configASSERT( xReturned == sbSTREAM_BUFFER_LENGTH_BYTES ); - configASSERT( memcmp( ( const void * ) pc54ByteString, ( const void * ) pucFullBuffer, sbSTREAM_BUFFER_LENGTH_BYTES ) == 0 ); + prvCheckExpectedState( xReturned == sbSTREAM_BUFFER_LENGTH_BYTES ); + prvCheckExpectedState( memcmp( ( const void * ) pc54ByteString, ( const void * ) pucFullBuffer, sbSTREAM_BUFFER_LENGTH_BYTES ) == 0 ); /* Now do the opposite, write in one go and read out in single bytes. */ xReturned = xStreamBufferSend( xStreamBuffer, ( const void * ) pc55ByteString, sbSTREAM_BUFFER_LENGTH_BYTES, sbRX_TX_BLOCK_TIME ); - configASSERT( xReturned == sbSTREAM_BUFFER_LENGTH_BYTES ); - configASSERT( xStreamBufferIsFull( xStreamBuffer ) == pdTRUE ); - configASSERT( xStreamBufferIsEmpty( xStreamBuffer ) == pdFALSE ); - configASSERT( xStreamBufferBytesAvailable( xStreamBuffer ) == sbSTREAM_BUFFER_LENGTH_BYTES ); - configASSERT( xStreamBufferSpacesAvailable( xStreamBuffer ) == 0 ); + prvCheckExpectedState( xReturned == sbSTREAM_BUFFER_LENGTH_BYTES ); + prvCheckExpectedState( xStreamBufferIsFull( xStreamBuffer ) == pdTRUE ); + prvCheckExpectedState( xStreamBufferIsEmpty( xStreamBuffer ) == pdFALSE ); + prvCheckExpectedState( xStreamBufferBytesAvailable( xStreamBuffer ) == sbSTREAM_BUFFER_LENGTH_BYTES ); + prvCheckExpectedState( xStreamBufferSpacesAvailable( xStreamBuffer ) == 0 ); /* Read from the buffer one byte at a time. */ for( xItem = 0; xItem < sbSTREAM_BUFFER_LENGTH_BYTES; xItem++ ) @@ -399,10 +410,10 @@ UBaseType_t uxOriginalPriority; /* Block time is only for test coverage, the task should never actually block here. */ xStreamBufferReceive( xStreamBuffer, ( void * ) pucFullBuffer, sizeof( char ), sbRX_TX_BLOCK_TIME ); - configASSERT( pc55ByteString[ xItem ] == pucFullBuffer[ 0 ] ); + prvCheckExpectedState( pc55ByteString[ xItem ] == pucFullBuffer[ 0 ] ); } - configASSERT( xStreamBufferIsEmpty( xStreamBuffer ) == pdTRUE ); - configASSERT( xStreamBufferIsFull( xStreamBuffer ) == pdFALSE ); + prvCheckExpectedState( xStreamBufferIsEmpty( xStreamBuffer ) == pdTRUE ); + prvCheckExpectedState( xStreamBufferIsFull( xStreamBuffer ) == pdFALSE ); /* Try writing more bytes than there is space. */ vTaskPrioritySet( NULL, configMAX_PRIORITIES - 1 ); @@ -410,23 +421,23 @@ UBaseType_t uxOriginalPriority; xReturned = xStreamBufferSend( xStreamBuffer, ( const void * ) pc54ByteString, sbSTREAM_BUFFER_LENGTH_BYTES * ( size_t ) 2, xMinimalBlockTime ); xTimeAfterCall = xTaskGetTickCount(); vTaskPrioritySet( NULL, uxOriginalPriority ); - configASSERT( ( xTimeAfterCall - xTimeBeforeCall ) >= xMinimalBlockTime ); - configASSERT( ( xTimeAfterCall - xTimeBeforeCall ) < ( xMinimalBlockTime + xAllowableMargin ) ); - configASSERT( xReturned == sbSTREAM_BUFFER_LENGTH_BYTES ); - configASSERT( xStreamBufferIsFull( xStreamBuffer ) == pdTRUE ); - configASSERT( xStreamBufferIsEmpty( xStreamBuffer ) == pdFALSE ); + prvCheckExpectedState( ( xTimeAfterCall - xTimeBeforeCall ) >= xMinimalBlockTime ); + prvCheckExpectedState( ( xTimeAfterCall - xTimeBeforeCall ) < ( xMinimalBlockTime + xAllowableMargin ) ); + prvCheckExpectedState( xReturned == sbSTREAM_BUFFER_LENGTH_BYTES ); + prvCheckExpectedState( xStreamBufferIsFull( xStreamBuffer ) == pdTRUE ); + prvCheckExpectedState( xStreamBufferIsEmpty( xStreamBuffer ) == pdFALSE ); /* No space now though. */ xReturned = xStreamBufferSend( xStreamBuffer, ( const void * ) pc54ByteString, sbSTREAM_BUFFER_LENGTH_BYTES * ( size_t ) 2, xMinimalBlockTime ); - configASSERT( xReturned == 0 ); + prvCheckExpectedState( xReturned == 0 ); /* Ensure data was written as expected even when there was an attempt to write more than was available. This also tries to read more bytes than are available. */ xReturned = xStreamBufferReceive( xStreamBuffer, ( void * ) pucFullBuffer, xFullBufferSize, xMinimalBlockTime ); - configASSERT( memcmp( ( const void * ) pucFullBuffer, ( const void * ) pc54ByteString, sbSTREAM_BUFFER_LENGTH_BYTES ) == 0 ); - configASSERT( xStreamBufferIsFull( xStreamBuffer ) == pdFALSE ); - configASSERT( xStreamBufferIsEmpty( xStreamBuffer ) == pdTRUE ); + prvCheckExpectedState( memcmp( ( const void * ) pucFullBuffer, ( const void * ) pc54ByteString, sbSTREAM_BUFFER_LENGTH_BYTES ) == 0 ); + prvCheckExpectedState( xStreamBufferIsFull( xStreamBuffer ) == pdFALSE ); + prvCheckExpectedState( xStreamBufferIsEmpty( xStreamBuffer ) == pdTRUE ); /* Clean up with data in the buffer to ensure the tests that follow don't see the data (the data should be discarded). */ @@ -458,12 +469,12 @@ const size_t xStringLength = strlen( pc54ByteString ); /* Attempt to send right up to the end of the string. */ xBytesActuallySent = xStreamBufferSend( xStreamBuffer, ( const void * ) &( pc54ByteString[ xNextChar ] ), xBytesToSend, sbDONT_BLOCK ); - configASSERT( xBytesActuallySent <= xBytesToSend ); + prvCheckExpectedState( xBytesActuallySent <= xBytesToSend ); /* Move the index up the string to the next character to be sent, wrapping if the end of the string has been reached. */ xNextChar += xBytesActuallySent; - configASSERT( xNextChar <= xStringLength ); + prvCheckExpectedState( xNextChar <= xStringLength ); if( xNextChar == xStringLength ) { @@ -565,7 +576,7 @@ BaseType_t xNonBlockingReceiveError = pdFALSE; /* Make sure a change in priority does not inadvertently result in an invalid array index. */ - configASSERT( uxIndex < sbNUMBER_OF_ECHO_CLIENTS ); + prvCheckExpectedState( uxIndex < sbNUMBER_OF_ECHO_CLIENTS ); /* Avoid compiler warnings about unused parameters. */ ( void ) pvParameters; @@ -601,12 +612,12 @@ BaseType_t xNonBlockingReceiveError = pdFALSE; /* Attempt to send right up to the end of the string. */ xBytesActuallySent = xStreamBufferSend( xStreamBuffer, ( const void * ) &( pc55ByteString[ xNextChar ] ), xBytesToSend, xTicksToWait ); - configASSERT( xBytesActuallySent <= xBytesToSend ); + prvCheckExpectedState( xBytesActuallySent <= xBytesToSend ); /* Move the index up the string to the next character to be sent, wrapping if the end of the string has been reached. */ xNextChar += xBytesActuallySent; - configASSERT( xNextChar <= xStringLength ); + prvCheckExpectedState( xNextChar <= xStringLength ); if( xNextChar == xStringLength ) { @@ -661,7 +672,7 @@ BaseType_t xNonBlockingReceiveError = pdFALSE; } while( xReceivedLength == 0 ); /* Ensure the received string matches the expected string. */ - configASSERT( memcmp( ( void * ) cRxString, ( const void * ) &( pc55ByteString[ xNextChar ] ), xReceivedLength ) == 0 ); + prvCheckExpectedState( memcmp( ( void * ) cRxString, ( const void * ) &( pc55ByteString[ xNextChar ] ), xReceivedLength ) == 0 ); /* Move the index into the string up to the end of the bytes received so far - wrapping if the end of the string has been @@ -743,7 +754,7 @@ EchoStreamBuffers_t *pxStreamBuffers = ( EchoStreamBuffers_t * ) pvParameters; memset( pcStringReceived, 0x00, sbSTREAM_BUFFER_LENGTH_BYTES ); xStreamBufferReceive( pxStreamBuffers->xEchoServerBuffer, ( void * ) pcStringReceived, xSendLength, portMAX_DELAY ); - configASSERT( strcmp( pcStringToSend, pcStringReceived ) == 0 ); + prvCheckExpectedState( strcmp( pcStringToSend, pcStringReceived ) == 0 ); /* Maintain a count of the number of times this code executes so a check task can determine if this task is still functioning as @@ -787,9 +798,8 @@ const TickType_t xTicksToBlock = pdMS_TO_TICKS( 350UL ); /* Don't expect to receive anything yet! */ xTimeOnEntering = xTaskGetTickCount(); xReceivedLength = xStreamBufferReceive( xStreamBuffers.xEchoClientBuffer, ( void * ) pcReceivedString, sbSTREAM_BUFFER_LENGTH_BYTES, xTicksToBlock ); - configASSERT( ( xTaskGetTickCount() - xTimeOnEntering ) >= xTicksToBlock ); - configASSERT( xReceivedLength == 0 ); - ( void ) xTimeOnEntering; + prvCheckExpectedState( ( xTaskGetTickCount() - xTimeOnEntering ) >= xTicksToBlock ); + prvCheckExpectedState( xReceivedLength == 0 ); /* Now the stream buffers have been created the echo client task can be created. If this server task has the higher priority then the client task @@ -815,7 +825,7 @@ const TickType_t xTicksToBlock = pdMS_TO_TICKS( 350UL ); xReceivedLength = xStreamBufferReceive( xStreamBuffers.xEchoClientBuffer, ( void * ) pcReceivedString, sbSTREAM_BUFFER_LENGTH_BYTES, xTicksToBlock ); /* Should always receive data as a delay was used. */ - configASSERT( xReceivedLength > 0 ); + prvCheckExpectedState( xReceivedLength > 0 ); /* Echo the received data back to the client. */ xStreamBufferSend( xStreamBuffers.xEchoServerBuffer, ( void * ) pcReceivedString, xReceivedLength, portMAX_DELAY ); @@ -946,13 +956,13 @@ BaseType_t xAreStreamBufferTasksStillRunning( void ) static uint32_t ulLastEchoLoopCounters[ sbNUMBER_OF_ECHO_CLIENTS ] = { 0 }; static uint32_t ulLastNonBlockingRxCounter = 0; static uint32_t ulLastInterruptTriggerCounter = 0; -BaseType_t xReturn = pdPASS, x; +BaseType_t x; for( x = 0; x < sbNUMBER_OF_ECHO_CLIENTS; x++ ) { if( ulLastEchoLoopCounters[ x ] == ulEchoLoopCounters[ x ] ) { - xReturn = pdFAIL; + xErrorStatus = pdFAIL; } else { @@ -962,7 +972,7 @@ BaseType_t xReturn = pdPASS, x; if( ulNonBlockingRxCounter == ulLastNonBlockingRxCounter ) { - xReturn = pdFAIL; + xErrorStatus = pdFAIL; } else { @@ -971,7 +981,7 @@ BaseType_t xReturn = pdPASS, x; if( ulLastInterruptTriggerCounter == ulInterruptTriggerCounter ) { - xReturn = pdFAIL; + xErrorStatus = pdFAIL; } else { @@ -986,7 +996,7 @@ BaseType_t xReturn = pdPASS, x; { if( ulLastSenderLoopCounters[ x ] == ulSenderLoopCounters[ x ] ) { - xReturn = pdFAIL; + xErrorStatus = pdFAIL; } else { @@ -996,7 +1006,7 @@ BaseType_t xReturn = pdPASS, x; } #endif /* configSUPPORT_STATIC_ALLOCATION */ - return xReturn; + return xErrorStatus; } /*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Demo/WIN32-MSVC/.vs/WIN32/v14/.suo b/FreeRTOS/Demo/WIN32-MSVC/.vs/WIN32/v14/.suo index bb4718846..b50bd108f 100644 Binary files a/FreeRTOS/Demo/WIN32-MSVC/.vs/WIN32/v14/.suo and b/FreeRTOS/Demo/WIN32-MSVC/.vs/WIN32/v14/.suo differ diff --git a/FreeRTOS/Demo/WIN32-MingW/.cproject b/FreeRTOS/Demo/WIN32-MingW/.cproject index c2bd401d5..0cc3eaa93 100644 --- a/FreeRTOS/Demo/WIN32-MingW/.cproject +++ b/FreeRTOS/Demo/WIN32-MingW/.cproject @@ -42,6 +42,7 @@ @@ -112,6 +113,7 @@