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