]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Demo/Common/Minimal/StreamBufferDemo.c
Import the code coverage test additions from the (unpublished) Visual Studio project...
[freertos] / FreeRTOS / Demo / Common / Minimal / StreamBufferDemo.c
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