-static void prvSanityCheckCreatedEventGroup( EventGroupHandle_t xEventGroup )\r
-{\r
-EventBits_t xEventBits;\r
-const EventBits_t xFirstTestBits = ( EventBits_t ) 0xaa, xSecondTestBits = ( EventBits_t ) 0x55;\r
-\r
- /* The event group should not have any bits set yet. */\r
- xEventBits = xEventGroupGetBits( xEventGroup );\r
-\r
- if( xEventBits != ( EventBits_t ) 0 )\r
- {\r
- xErrorOccurred = pdTRUE;\r
- }\r
-\r
- /* Some some bits, then read them back to check they are as expected. */\r
- xEventGroupSetBits( xEventGroup, xFirstTestBits );\r
-\r
- xEventBits = xEventGroupGetBits( xEventGroup );\r
-\r
- if( xEventBits != xFirstTestBits )\r
- {\r
- xErrorOccurred = pdTRUE;\r
- }\r
-\r
- xEventGroupSetBits( xEventGroup, xSecondTestBits );\r
-\r
- xEventBits = xEventGroupGetBits( xEventGroup );\r
-\r
- if( xEventBits != ( xFirstTestBits | xSecondTestBits ) )\r
- {\r
- xErrorOccurred = pdTRUE;\r
- }\r
-\r
- /* Finally try clearing some bits too and check that operation proceeds as\r
- expected. */\r
- xEventGroupClearBits( xEventGroup, xFirstTestBits );\r
-\r
- xEventBits = xEventGroupGetBits( xEventGroup );\r
-\r
- if( xEventBits != xSecondTestBits )\r
- {\r
- xErrorOccurred = pdTRUE;\r
- }\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
-static void prvSanityCheckCreatedSemaphore( SemaphoreHandle_t xSemaphore, UBaseType_t uxMaxCount )\r
-{\r
-BaseType_t xReturned;\r
-UBaseType_t x;\r
-const TickType_t xShortBlockTime = pdMS_TO_TICKS( 10 );\r
-TickType_t xTickCount;\r
-\r
- /* The binary semaphore should start 'empty', so a call to xSemaphoreTake()\r
- should fail. */\r
- xTickCount = xTaskGetTickCount();\r
- xReturned = xSemaphoreTake( xSemaphore, xShortBlockTime );\r
-\r
- if( ( ( TickType_t ) ( xTaskGetTickCount() - xTickCount ) ) < xShortBlockTime )\r
- {\r
- /* Did not block on the semaphore as long as expected. */\r
- xErrorOccurred = pdTRUE;\r
- }\r
-\r
- if( xReturned != pdFAIL )\r
- {\r
- xErrorOccurred = pdTRUE;\r
- }\r
-\r
- /* Should be possible to 'give' the semaphore up to a maximum of uxMaxCount\r
- times. */\r
- for( x = 0; x < uxMaxCount; x++ )\r
- {\r
- xReturned = xSemaphoreGive( xSemaphore );\r
-\r
- if( xReturned == pdFAIL )\r
- {\r
- xErrorOccurred = pdTRUE;\r
- }\r
- }\r
-\r
- /* Giving the semaphore again should fail, as it is 'full'. */\r
- xReturned = xSemaphoreGive( xSemaphore );\r
-\r
- if( xReturned != pdFAIL )\r
- {\r
- xErrorOccurred = pdTRUE;\r
- }\r
-\r
- configASSERT( uxSemaphoreGetCount( xSemaphore ) == uxMaxCount );\r
-\r
- /* Should now be possible to 'take' the semaphore up to a maximum of\r
- uxMaxCount times without blocking. */\r
- for( x = 0; x < uxMaxCount; x++ )\r
- {\r
- xReturned = xSemaphoreTake( xSemaphore, staticDONT_BLOCK );\r
-\r
- if( xReturned == pdFAIL )\r
- {\r
- xErrorOccurred = pdTRUE;\r
- }\r
- }\r
-\r
- /* Back to the starting condition, where the semaphore should not be\r
- available. */\r
- xTickCount = xTaskGetTickCount();\r
- xReturned = xSemaphoreTake( xSemaphore, xShortBlockTime );\r
-\r
- if( ( ( TickType_t ) ( xTaskGetTickCount() - xTickCount ) ) < xShortBlockTime )\r
- {\r
- /* Did not block on the semaphore as long as expected. */\r
- xErrorOccurred = pdTRUE;\r
- }\r
-\r
- if( xReturned != pdFAIL )\r
- {\r
- xErrorOccurred = pdTRUE;\r
- }\r
-\r
- configASSERT( uxSemaphoreGetCount( xSemaphore ) == 0 );\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
-static void prvSanityCheckCreatedQueue( QueueHandle_t xQueue )\r
-{\r
-uint64_t ull, ullRead;\r
-BaseType_t xReturned, xLoop;\r
-\r
- /* This test is done twice to ensure the queue storage area wraps. */\r
- for( xLoop = 0; xLoop < 2; xLoop++ )\r
- {\r
- /* A very basic test that the queue can be written to and read from as\r
- expected. First the queue should be empty. */\r
- xReturned = xQueueReceive( xQueue, &ull, staticDONT_BLOCK );\r
- if( xReturned != errQUEUE_EMPTY )\r
- {\r
- xErrorOccurred = pdTRUE;\r
- }\r
-\r
- /* Now it should be possible to write to the queue staticQUEUE_LENGTH_IN_ITEMS\r
- times. */\r
- for( ull = 0; ull < staticQUEUE_LENGTH_IN_ITEMS; ull++ )\r
- {\r
- xReturned = xQueueSend( xQueue, &ull, staticDONT_BLOCK );\r
- if( xReturned != pdPASS )\r
- {\r
- xErrorOccurred = pdTRUE;\r
- }\r
- }\r
-\r
- /* Should not now be possible to write to the queue again. */\r
- xReturned = xQueueSend( xQueue, &ull, staticDONT_BLOCK );\r
- if( xReturned != errQUEUE_FULL )\r
- {\r
- xErrorOccurred = pdTRUE;\r
- }\r
-\r
- /* Now read back from the queue to ensure the data read back matches that\r
- written. */\r
- for( ull = 0; ull < staticQUEUE_LENGTH_IN_ITEMS; ull++ )\r
- {\r
- xReturned = xQueueReceive( xQueue, &ullRead, staticDONT_BLOCK );\r
-\r
- if( xReturned != pdPASS )\r
- {\r
- xErrorOccurred = pdTRUE;\r
- }\r
-\r
- if( ullRead != ull )\r
- {\r
- xErrorOccurred = pdTRUE;\r
- }\r
- }\r
-\r
- /* The queue should be empty again. */\r
- xReturned = xQueueReceive( xQueue, &ull, staticDONT_BLOCK );\r
- if( xReturned != errQUEUE_EMPTY )\r
- {\r
- xErrorOccurred = pdTRUE;\r
- }\r
- }\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
-static void prvSanityCheckCreatedRecursiveMutex( SemaphoreHandle_t xSemaphore )\r
-{\r
-const BaseType_t xLoops = 5;\r
-BaseType_t x, xReturned;\r
-\r
- /* A very basic test that the recursive semaphore behaved like a recursive\r
- semaphore. First the semaphore should not be able to be given, as it has not\r
- yet been taken. */\r
- xReturned = xSemaphoreGiveRecursive( xSemaphore );\r
-\r
- if( xReturned != pdFAIL )\r
- {\r
- xErrorOccurred = pdTRUE;\r
- }\r
-\r
- /* Now it should be possible to take the mutex a number of times. */\r
- for( x = 0; x < xLoops; x++ )\r
- {\r
- xReturned = xSemaphoreTakeRecursive( xSemaphore, staticDONT_BLOCK );\r
-\r
- if( xReturned != pdPASS )\r
- {\r
- xErrorOccurred = pdTRUE;\r
- }\r
- }\r
-\r
- /* Should be possible to give the semaphore the same number of times as it\r
- was given in the loop above. */\r
- for( x = 0; x < xLoops; x++ )\r
- {\r
- xReturned = xSemaphoreGiveRecursive( xSemaphore );\r
-\r
- if( xReturned != pdPASS )\r
- {\r
- xErrorOccurred = pdTRUE;\r
- }\r
- }\r
-\r
- /* No more gives should be possible though. */\r
- xReturned = xSemaphoreGiveRecursive( xSemaphore );\r
-\r
- if( xReturned != pdFAIL )\r
- {\r
- xErrorOccurred = pdTRUE;\r
- }\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r