diff --git a/FreeRTOS-Plus/Test/CMock b/FreeRTOS-Plus/Test/CMock index afa294982e..150573c742 160000 --- a/FreeRTOS-Plus/Test/CMock +++ b/FreeRTOS-Plus/Test/CMock @@ -1 +1 @@ -Subproject commit afa294982e8a28bc06f341cc77fd4276641b42bd +Subproject commit 150573c742ce15061a0b675aa0f8e29c85008062 diff --git a/FreeRTOS/Demo/Common/Minimal/AbortDelay.c b/FreeRTOS/Demo/Common/Minimal/AbortDelay.c index 44dd36106b..0714645407 100644 --- a/FreeRTOS/Demo/Common/Minimal/AbortDelay.c +++ b/FreeRTOS/Demo/Common/Minimal/AbortDelay.c @@ -294,23 +294,29 @@ BaseType_t xReturned; static void prvTestAbortingTaskDelayUntil( void ) { TickType_t xTimeAtStart, xLastBlockTime; +BaseType_t xReturned; /* Note the time before the delay so the length of the delay is known. */ xTimeAtStart = xTaskGetTickCount(); /* Take a copy of the time as it is updated in the call to - vTaskDelayUntil() but its original value is needed to determine the actual + xTaskDelayUntil() but its original value is needed to determine the actual time spend in the Blocked state. */ xLastBlockTime = xTimeAtStart; /* This first delay should just time out. */ - vTaskDelayUntil( &xLastBlockTime, xMaxBlockTime ); + xReturned = xTaskDelayUntil( &xLastBlockTime, xMaxBlockTime ); prvCheckExpectedTimeIsWithinAnAcceptableMargin( xTimeAtStart, xMaxBlockTime ); + configASSERT( xReturned == pdTRUE ); + /* Remove compiler warning about value being set but not used in the case + configASSERT() is not defined. */ + ( void ) xReturned; /* This second delay should be aborted by the primary task half way through. Again take a copy of the time as it is updated in the call to vTaskDelayUntil() buts its original value is needed to determine the amount - of time actually spent in the Blocked state. */ + of time actually spent in the Blocked state. This uses vTaskDelayUntil() + in place of xTaskDelayUntil() for test coverage. */ xTimeAtStart = xTaskGetTickCount(); xLastBlockTime = xTimeAtStart; vTaskDelayUntil( &xLastBlockTime, xMaxBlockTime ); @@ -319,8 +325,12 @@ TickType_t xTimeAtStart, xLastBlockTime; /* As with the other tests, the third block period should not time out. */ xTimeAtStart = xTaskGetTickCount(); xLastBlockTime = xTimeAtStart; - vTaskDelayUntil( &xLastBlockTime, xMaxBlockTime ); + xReturned = xTaskDelayUntil( &xLastBlockTime, xMaxBlockTime ); prvCheckExpectedTimeIsWithinAnAcceptableMargin( xTimeAtStart, xMaxBlockTime ); + configASSERT( xReturned == pdTRUE ); + /* Remove compiler warning about value being set but not used in the case + configASSERT() is not defined. */ + ( void ) xReturned; } /*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Demo/Common/Minimal/TaskNotifyArray.c b/FreeRTOS/Demo/Common/Minimal/TaskNotifyArray.c index e80f7c103b..9683e53936 100644 --- a/FreeRTOS/Demo/Common/Minimal/TaskNotifyArray.c +++ b/FreeRTOS/Demo/Common/Minimal/TaskNotifyArray.c @@ -195,7 +195,7 @@ static void prvSingleTaskTests( void ) const TickType_t xTicksToWait = pdMS_TO_TICKS( 100UL ); BaseType_t xReturned; uint32_t ulNotifiedValue, ulLoop, ulNotifyingValue, ulPreviousValue, ulExpectedValue; -TickType_t xTimeOnEntering; +TickType_t xTimeOnEntering, xTimeNow, xTimeDifference; const uint32_t ulFirstNotifiedConst = 100001UL, ulSecondNotifiedValueConst = 5555UL, ulMaxLoops = 5UL; const uint32_t ulBit0 = 0x01UL, ulBit1 = 0x02UL; UBaseType_t uxIndexToTest, uxOtherIndexes; @@ -221,7 +221,9 @@ UBaseType_t uxIndexToTest, uxOtherIndexes; ( void ) xReturned; /* Remove compiler warnings in case configASSERT() is not defined. */ /* Should have blocked for the entire block time. */ - configASSERT( ( xTaskGetTickCount() - xTimeOnEntering ) >= xTicksToWait ); + xTimeNow = xTaskGetTickCount(); + xTimeDifference = xTimeNow - xTimeOnEntering; + configASSERT( xTimeDifference >= xTicksToWait ); configASSERT( xReturned == pdFAIL ); configASSERT( ulNotifiedValue == 0UL ); ( void ) xReturned; /* Remove compiler warnings in case configASSERT() is not defined. */ @@ -268,7 +270,9 @@ UBaseType_t uxIndexToTest, uxOtherIndexes; and so not time out. */ xTimeOnEntering = xTaskGetTickCount(); xReturned = xTaskNotifyWaitIndexed( uxIndexToTest, notifyUINT32_MAX, 0, &ulNotifiedValue, xTicksToWait ); - configASSERT( ( xTaskGetTickCount() - xTimeOnEntering ) < xTicksToWait ); + xTimeNow = xTaskGetTickCount(); + xTimeDifference = xTimeNow - xTimeOnEntering; + configASSERT( xTimeDifference < xTicksToWait ); /* The task should have been notified, and the notified value should be equal to ulFirstNotifiedConst. */ @@ -992,7 +996,7 @@ const TickType_t xTimerPeriod = pdMS_TO_TICKS( 100 ), xMargin = pdMS_TO_TICKS( 5 UBaseType_t uxIndex, uxIndexToNotify; uint32_t ulReceivedValue; BaseType_t xReturned; -TickType_t xTimeBeforeBlocking; +TickType_t xTimeBeforeBlocking, xTimeNow, xTimeDifference; /* Set all notify values within the array of tasks notifications to zero ready for the next test. */ @@ -1028,13 +1032,16 @@ TickType_t xTimeBeforeBlocking; xReturned = xTaskNotifyWaitIndexed( uxIndex, 0, 0, &ulReceivedValue, xTimerPeriod + xMargin ); /* The notification will have been sent to task notification at index - uxIndexToNotify in this task by the timer callback after xTimerPeriodTicks. - The notification should not have woken this task, so xReturned should + uxIndexToNotify in this task by the timer callback after xTimerPeriodTicks. + The notification should not have woken this task, so xReturned should be false and at least xTimerPeriod + xMargin ticks should have passed. */ configASSERT( xReturned == pdFALSE ); - configASSERT( ( xTaskGetTickCount() - xTimeBeforeBlocking ) >= ( xTimerPeriod + xMargin ) ); + xTimeNow = xTaskGetTickCount(); + xTimeDifference = xTimeNow - xTimeBeforeBlocking; + configASSERT( xTimeDifference >= ( xTimerPeriod + xMargin ) ); ( void ) xReturned; /* Remove compiler warnings if configASSERT() is not defined. */ ( void ) xTimeBeforeBlocking; + ( void ) xTimeDifference; /* Only the notification at index position uxIndexToNotify should be set. Calling this function will clear it again. */ diff --git a/FreeRTOS/Demo/Common/Minimal/blocktim.c b/FreeRTOS/Demo/Common/Minimal/blocktim.c index f297dafaad..90ffc59a81 100644 --- a/FreeRTOS/Demo/Common/Minimal/blocktim.c +++ b/FreeRTOS/Demo/Common/Minimal/blocktim.c @@ -472,7 +472,8 @@ BaseType_t xData; static void prvBasicDelayTests( void ) { TickType_t xPreTime, xPostTime, x, xLastUnblockTime, xExpectedUnblockTime; -const TickType_t xPeriod = 75, xCycles = 5, xAllowableMargin = ( bktALLOWABLE_MARGIN >> 1 ); +const TickType_t xPeriod = 75, xCycles = 5, xAllowableMargin = ( bktALLOWABLE_MARGIN >> 1 ), xHalfPeriod = xPeriod / ( TickType_t ) 2; +BaseType_t xDidBlock; /* Temporarily increase priority so the timing is more accurate, but not so high as to disrupt the timer tests. */ @@ -511,6 +512,48 @@ const TickType_t xPeriod = 75, xCycles = 5, xAllowableMargin = ( bktALLOWABLE_MA xPrimaryCycles++; } + /* Crude tests for return value of xTaskDelayUntil(). First a standard block + should return that the task does block. */ + xDidBlock = xTaskDelayUntil( &xLastUnblockTime, xPeriod ); + if( xDidBlock != pdTRUE ) + { + xErrorOccurred = pdTRUE; + } + + /* Now delay a few ticks so repeating the above block period will not block for + the full amount of time, but will still block. */ + vTaskDelay( xHalfPeriod ); + xDidBlock = xTaskDelayUntil( &xLastUnblockTime, xPeriod ); + if( xDidBlock != pdTRUE ) + { + xErrorOccurred = pdTRUE; + } + + /* This time block for longer than xPeriod before calling xTaskDelayUntil() so + the call to xTaskDelayUntil() should not block. */ + vTaskDelay( xPeriod ); + xDidBlock = xTaskDelayUntil( &xLastUnblockTime, xPeriod ); + if( xDidBlock != pdFALSE ) + { + xErrorOccurred = pdTRUE; + } + + /* Catch up. */ + xDidBlock = xTaskDelayUntil( &xLastUnblockTime, xPeriod ); + if( xDidBlock != pdTRUE ) + { + xErrorOccurred = pdTRUE; + } + + /* Again block for slightly longer than a period so ensure the time is in the + past next time xTaskDelayUntil() gets called. */ + vTaskDelay( xPeriod + xAllowableMargin ); + xDidBlock = xTaskDelayUntil( &xLastUnblockTime, xPeriod ); + if( xDidBlock != pdFALSE ) + { + xErrorOccurred = pdTRUE; + } + /* Reset to the original task priority ready for the other tests. */ vTaskPrioritySet( NULL, bktPRIMARY_PRIORITY ); } diff --git a/FreeRTOS/Source b/FreeRTOS/Source index 44aecd4e10..5fb26de019 160000 --- a/FreeRTOS/Source +++ b/FreeRTOS/Source @@ -1 +1 @@ -Subproject commit 44aecd4e105040a511137e8fee3dae7ee6b73804 +Subproject commit 5fb26de0194b4ebfd09b37128bf9f3ff6d34c1b7