From 259e8de76174e7fcd8e07f8fe7936f9bcf58855b Mon Sep 17 00:00:00 2001 From: Soren Ptak Date: Mon, 19 Feb 2024 00:49:02 -0500 Subject: [PATCH 01/15] GitHub ci.yml formatting (#1140) * Add in a comment of the step name on the Install Dependencies job step to create a nicer log on github * See if we can use the owner of the repo as the check for if the CBMC proofs should run * Allow manually running the CBMC proofs --------- Co-authored-by: Rahul Kar <118818625+kar-rahul-aws@users.noreply.github.com> --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 92398c9416..4747d4904b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,7 +2,7 @@ name: CI Checks env: bashPass: \033[32;1mPASSED - - bashWarn: \033[33;1mWARNING - + bashInfo: \033[33;1mINFO - bashFail: \033[31;1mFAILED - bashEnd: \033[0m @@ -151,7 +151,7 @@ jobs: retention-days: 2 proof_ci: - if: ${{ github.event.pull_request }} + if: ${{ github.event.pull_request }} || ${{ github.event.workflow }} runs-on: cbmc_ubuntu-latest_16-core steps: - uses: actions/checkout@v3 @@ -159,9 +159,9 @@ jobs: stepName: Install Dependencies run: | # ${{ env.stepName }} - echo -e "::group::${{ env.stepName }}" + echo -e "::group:: ${{ env.bashInfo }} ${{ env.stepName }} ${{ env.bashEnd }}" git submodule update --init --checkout --recursive --depth 1 - sudo apt-get update + sudo apt-get update -y sudo apt-get install --yes --no-install-recommends gcc-multilib echo -e "::endgroup::" echo -e "${{ env.bashPass }} ${{env.stepName}} ${{ env.bashEnd }}" From 8e8dad2b09a82d35621497f88f654b88c5dd9f50 Mon Sep 17 00:00:00 2001 From: RichardBarry <3073890+RichardBarry@users.noreply.github.com> Date: Sun, 18 Feb 2024 22:37:43 -0800 Subject: [PATCH 02/15] Update some tests to report error line numbers (#747) * To assist debugging, update a subset of demos to store the line number on which an error is detected rather than just storing a boolean as to whether an error detected or not. * Correct return value of xAreInterruptSemaphoreTasksStillRunning() made incorrect by the prior commit. * Uncrustify: triggered by comment. --------- Co-authored-by: none <> Co-authored-by: Rahul Kar <118818625+kar-rahul-aws@users.noreply.github.com> Co-authored-by: Rahul Kar Co-authored-by: GitHub Action Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com> --- FreeRTOS/Demo/Common/Minimal/AbortDelay.c | 48 ++++++------ FreeRTOS/Demo/Common/Minimal/IntSemTest.c | 71 +++++++++-------- .../Demo/Common/Minimal/StaticAllocation.c | 76 +++++++++---------- FreeRTOS/Demo/Common/Minimal/blocktim.c | 60 +++++++-------- FreeRTOS/Demo/Common/Minimal/readme.txt | 2 +- FreeRTOS/Demo/Common/Minimal/recmutex.c | 30 ++++---- 6 files changed, 147 insertions(+), 140 deletions(-) diff --git a/FreeRTOS/Demo/Common/Minimal/AbortDelay.c b/FreeRTOS/Demo/Common/Minimal/AbortDelay.c index 027151282b..55f0ba638e 100644 --- a/FreeRTOS/Demo/Common/Minimal/AbortDelay.c +++ b/FreeRTOS/Demo/Common/Minimal/AbortDelay.c @@ -177,7 +177,7 @@ if( xTaskAbortDelay( xBlockingTask ) != pdPASS ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } /* Reset the priority to the normal controlling priority. */ @@ -288,7 +288,7 @@ if( xReturned != pdFALSE ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } } /*-----------------------------------------------------------*/ @@ -379,7 +379,7 @@ if( ulReturn != 0 ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } prvCheckExpectedTimeIsWithinAnAcceptableMargin( xTimeAtStart, xMaxBlockTime ); @@ -393,7 +393,7 @@ if( ulReturn != 0 ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } prvCheckExpectedTimeIsWithinAnAcceptableMargin( xTimeAtStart, xHalfMaxBlockTime ); @@ -406,7 +406,7 @@ if( ulReturn != 0 ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } prvCheckExpectedTimeIsWithinAnAcceptableMargin( xTimeAtStart, xMaxBlockTime ); @@ -442,7 +442,7 @@ if( xReturn != 0x00 ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } prvCheckExpectedTimeIsWithinAnAcceptableMargin( xTimeAtStart, xMaxBlockTime ); @@ -456,7 +456,7 @@ if( xReturn != 0x00 ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } prvCheckExpectedTimeIsWithinAnAcceptableMargin( xTimeAtStart, xHalfMaxBlockTime ); @@ -469,7 +469,7 @@ if( xReturn != 0x00 ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } prvCheckExpectedTimeIsWithinAnAcceptableMargin( xTimeAtStart, xMaxBlockTime ); @@ -517,7 +517,7 @@ if( xReturn != 0x00 ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } prvCheckExpectedTimeIsWithinAnAcceptableMargin( xTimeAtStart, xMaxBlockTime ); @@ -531,7 +531,7 @@ if( xReturn != 0x00 ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } prvCheckExpectedTimeIsWithinAnAcceptableMargin( xTimeAtStart, xHalfMaxBlockTime ); @@ -544,7 +544,7 @@ if( xReturn != 0x00 ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } prvCheckExpectedTimeIsWithinAnAcceptableMargin( xTimeAtStart, xMaxBlockTime ); @@ -584,7 +584,7 @@ if( xReturn != pdPASS ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } /* Note the time before the delay so the length of the delay is known. */ @@ -595,7 +595,7 @@ if( xReturn != pdFALSE ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } prvCheckExpectedTimeIsWithinAnAcceptableMargin( xTimeAtStart, xMaxBlockTime ); @@ -609,7 +609,7 @@ if( xReturn != pdFALSE ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } prvCheckExpectedTimeIsWithinAnAcceptableMargin( xTimeAtStart, xHalfMaxBlockTime ); @@ -622,7 +622,7 @@ if( xReturn != pdFALSE ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } prvCheckExpectedTimeIsWithinAnAcceptableMargin( xTimeAtStart, xMaxBlockTime ); @@ -660,7 +660,7 @@ if( xReturn != pdFALSE ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } prvCheckExpectedTimeIsWithinAnAcceptableMargin( xTimeAtStart, xMaxBlockTime ); @@ -674,7 +674,7 @@ if( xReturn != pdFALSE ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } prvCheckExpectedTimeIsWithinAnAcceptableMargin( xTimeAtStart, xHalfMaxBlockTime ); @@ -687,7 +687,7 @@ if( xReturn != pdFALSE ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } prvCheckExpectedTimeIsWithinAnAcceptableMargin( xTimeAtStart, xMaxBlockTime ); @@ -710,7 +710,7 @@ if( xReturn != pdFALSE ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } prvCheckExpectedTimeIsWithinAnAcceptableMargin( xTimeAtStart, xMaxBlockTime ); @@ -724,7 +724,7 @@ if( xReturn != pdFALSE ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } prvCheckExpectedTimeIsWithinAnAcceptableMargin( xTimeAtStart, xHalfMaxBlockTime ); @@ -737,7 +737,7 @@ if( xReturn != pdFALSE ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } prvCheckExpectedTimeIsWithinAnAcceptableMargin( xTimeAtStart, xMaxBlockTime ); @@ -755,7 +755,7 @@ /* The actual block time should not be less than the expected block time. */ if( xActualBlockTime < xExpectedBlockTime ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } /* The actual block time can be greater than the expected block time, as it @@ -763,7 +763,7 @@ * acceptable margin. */ if( xActualBlockTime > ( xExpectedBlockTime + xAllowableMargin ) ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } } /*-----------------------------------------------------------*/ @@ -785,7 +785,7 @@ xReturn = pdFAIL; } - if( xErrorOccurred == pdTRUE ) + if( xErrorOccurred != pdFALSE ) { xReturn = pdFAIL; } diff --git a/FreeRTOS/Demo/Common/Minimal/IntSemTest.c b/FreeRTOS/Demo/Common/Minimal/IntSemTest.c index 1990d6e26d..e4be9b83c3 100644 --- a/FreeRTOS/Demo/Common/Minimal/IntSemTest.c +++ b/FreeRTOS/Demo/Common/Minimal/IntSemTest.c @@ -184,13 +184,13 @@ static void prvTakeAndGiveInTheSameOrder( void ) if( uxTaskPriorityGet( NULL ) != intsemMASTER_PRIORITY ) { - xErrorDetected = pdTRUE; + xErrorDetected = __LINE__; } /* Take the semaphore that is shared with the slave. */ if( xSemaphoreTake( xMasterSlaveMutex, intsemNO_BLOCK ) != pdPASS ) { - xErrorDetected = pdTRUE; + xErrorDetected = __LINE__; } /* This task now has the mutex. Unsuspend the slave so it too @@ -209,7 +209,7 @@ static void prvTakeAndGiveInTheSameOrder( void ) * task. */ if( uxTaskPriorityGet( NULL ) != intsemSLAVE_PRIORITY ) { - xErrorDetected = pdTRUE; + xErrorDetected = __LINE__; } /* Now wait a little longer than the time between ISR gives to also @@ -218,7 +218,7 @@ static void prvTakeAndGiveInTheSameOrder( void ) if( xSemaphoreTake( xISRMutex, ( xInterruptGivePeriod * 2 ) ) != pdPASS ) { - xErrorDetected = pdTRUE; + xErrorDetected = __LINE__; } xOkToGiveMutex = pdFALSE; @@ -227,13 +227,13 @@ static void prvTakeAndGiveInTheSameOrder( void ) * already held. */ if( xSemaphoreTake( xISRMutex, intsemNO_BLOCK ) != pdFAIL ) { - xErrorDetected = pdTRUE; + xErrorDetected = __LINE__; } /* Should still be at the priority of the slave task. */ if( uxTaskPriorityGet( NULL ) != intsemSLAVE_PRIORITY ) { - xErrorDetected = pdTRUE; + xErrorDetected = __LINE__; } /* Give back the ISR semaphore to ensure the priority is not @@ -241,12 +241,12 @@ static void prvTakeAndGiveInTheSameOrder( void ) * attempting to obtain) is still held. */ if( xSemaphoreGive( xISRMutex ) != pdPASS ) { - xErrorDetected = pdTRUE; + xErrorDetected = __LINE__; } if( uxTaskPriorityGet( NULL ) != intsemSLAVE_PRIORITY ) { - xErrorDetected = pdTRUE; + xErrorDetected = __LINE__; } /* Finally give back the shared mutex. This time the higher priority @@ -255,12 +255,12 @@ static void prvTakeAndGiveInTheSameOrder( void ) * suspended state again. */ if( xSemaphoreGive( xMasterSlaveMutex ) != pdPASS ) { - xErrorDetected = pdTRUE; + xErrorDetected = __LINE__; } if( uxTaskPriorityGet( NULL ) != intsemMASTER_PRIORITY ) { - xErrorDetected = pdTRUE; + xErrorDetected = __LINE__; } #if ( INCLUDE_eTaskGetState == 1 ) @@ -286,13 +286,13 @@ static void prvTakeAndGiveInTheOppositeOrder( void ) if( uxTaskPriorityGet( NULL ) != intsemMASTER_PRIORITY ) { - xErrorDetected = pdTRUE; + xErrorDetected = __LINE__; } /* Take the semaphore that is shared with the slave. */ if( xSemaphoreTake( xMasterSlaveMutex, intsemNO_BLOCK ) != pdPASS ) { - xErrorDetected = pdTRUE; + xErrorDetected = __LINE__; } /* This task now has the mutex. Unsuspend the slave so it too @@ -311,7 +311,7 @@ static void prvTakeAndGiveInTheOppositeOrder( void ) * task. */ if( uxTaskPriorityGet( NULL ) != intsemSLAVE_PRIORITY ) { - xErrorDetected = pdTRUE; + xErrorDetected = __LINE__; } /* Now wait a little longer than the time between ISR gives to also @@ -320,7 +320,7 @@ static void prvTakeAndGiveInTheOppositeOrder( void ) if( xSemaphoreTake( xISRMutex, ( xInterruptGivePeriod * 2 ) ) != pdPASS ) { - xErrorDetected = pdTRUE; + xErrorDetected = __LINE__; } xOkToGiveMutex = pdFALSE; @@ -329,13 +329,13 @@ static void prvTakeAndGiveInTheOppositeOrder( void ) * already held. */ if( xSemaphoreTake( xISRMutex, intsemNO_BLOCK ) != pdFAIL ) { - xErrorDetected = pdTRUE; + xErrorDetected = __LINE__; } /* Should still be at the priority of the slave task. */ if( uxTaskPriorityGet( NULL ) != intsemSLAVE_PRIORITY ) { - xErrorDetected = pdTRUE; + xErrorDetected = __LINE__; } /* Give back the shared semaphore to ensure the priority is not disinherited @@ -343,7 +343,7 @@ static void prvTakeAndGiveInTheOppositeOrder( void ) * before this task runs again. */ if( xSemaphoreGive( xMasterSlaveMutex ) != pdPASS ) { - xErrorDetected = pdTRUE; + xErrorDetected = __LINE__; } /* Should still be at the priority of the slave task as this task still @@ -351,19 +351,19 @@ static void prvTakeAndGiveInTheOppositeOrder( void ) * mechanism. */ if( uxTaskPriorityGet( NULL ) != intsemSLAVE_PRIORITY ) { - xErrorDetected = pdTRUE; + xErrorDetected = __LINE__; } /* Give back the ISR semaphore, which should result in the priority being * disinherited as it was the last mutex held. */ if( xSemaphoreGive( xISRMutex ) != pdPASS ) { - xErrorDetected = pdTRUE; + xErrorDetected = __LINE__; } if( uxTaskPriorityGet( NULL ) != intsemMASTER_PRIORITY ) { - xErrorDetected = pdTRUE; + xErrorDetected = __LINE__; } /* Reset the mutex ready for the next round. */ @@ -387,12 +387,12 @@ static void vInterruptMutexSlaveTask( void * pvParameters ) * state. */ if( xSemaphoreTake( xMasterSlaveMutex, portMAX_DELAY ) != pdPASS ) { - xErrorDetected = pdTRUE; + xErrorDetected = __LINE__; } if( xSemaphoreGive( xMasterSlaveMutex ) != pdPASS ) { - xErrorDetected = pdTRUE; + xErrorDetected = __LINE__; } } } @@ -410,7 +410,7 @@ static void vInterruptCountingSemaphoreTask( void * pvParameters ) /* Expect to start with the counting semaphore empty. */ if( uxQueueMessagesWaiting( ( QueueHandle_t ) xISRCountingSemaphore ) != 0 ) { - xErrorDetected = pdTRUE; + xErrorDetected = __LINE__; } /* Wait until it is expected that the interrupt will have filled the @@ -422,12 +422,12 @@ static void vInterruptCountingSemaphoreTask( void * pvParameters ) /* Now it is expected that the counting semaphore is full. */ if( uxQueueMessagesWaiting( ( QueueHandle_t ) xISRCountingSemaphore ) != intsemMAX_COUNT ) { - xErrorDetected = pdTRUE; + xErrorDetected = __LINE__; } if( uxQueueSpacesAvailable( ( QueueHandle_t ) xISRCountingSemaphore ) != 0 ) { - xErrorDetected = pdTRUE; + xErrorDetected = __LINE__; } ulCountingSemaphoreLoops++; @@ -444,7 +444,7 @@ static void vInterruptCountingSemaphoreTask( void * pvParameters ) if( xCount != intsemMAX_COUNT ) { - xErrorDetected = pdTRUE; + xErrorDetected = __LINE__; } /* Now raise the priority of this task so it runs immediately that the @@ -457,7 +457,7 @@ static void vInterruptCountingSemaphoreTask( void * pvParameters ) xSemaphoreTake( xISRCountingSemaphore, portMAX_DELAY ); xOkToGiveCountingSemaphore = pdFALSE; - /* Reset the priority so as not to disturbed other tests too much. */ + /* Reset the priority so as not to disturb other tests too much. */ vTaskPrioritySet( NULL, tskIDLE_PRIORITY ); ulCountingSemaphoreLoops++; @@ -506,25 +506,32 @@ void vInterruptSemaphorePeriodicTest( void ) BaseType_t xAreInterruptSemaphoreTasksStillRunning( void ) { static uint32_t ulLastMasterLoopCounter = 0, ulLastCountingSemaphoreLoops = 0; + BaseType_t xReturn; /* If the demo tasks are running then it is expected that the loop counters * will have changed since this function was last called. */ if( ulLastMasterLoopCounter == ulMasterLoops ) { - xErrorDetected = pdTRUE; + xErrorDetected = __LINE__; } ulLastMasterLoopCounter = ulMasterLoops; if( ulLastCountingSemaphoreLoops == ulCountingSemaphoreLoops ) { - xErrorDetected = pdTRUE; + xErrorDetected = __LINE__; } ulLastCountingSemaphoreLoops = ulCountingSemaphoreLoops++; - /* Errors detected in the task itself will have latched xErrorDetected - * to true. */ + if( xErrorDetected != pdFALSE ) + { + xReturn = pdFALSE; + } + else + { + xReturn = pdTRUE; + } - return ( BaseType_t ) !xErrorDetected; + return xReturn; } diff --git a/FreeRTOS/Demo/Common/Minimal/StaticAllocation.c b/FreeRTOS/Demo/Common/Minimal/StaticAllocation.c index 1e921e0f54..0cc08d9779 100644 --- a/FreeRTOS/Demo/Common/Minimal/StaticAllocation.c +++ b/FreeRTOS/Demo/Common/Minimal/StaticAllocation.c @@ -362,7 +362,7 @@ * items it is possible for the queue to hold at any one time, which equals the * queue length (in items, not bytes) multiplied by the size of each item. In this * case the queue will hold staticQUEUE_LENGTH_IN_ITEMS 64-bit items. See - * https://www.FreeRTOS.org/Embedded-RTOS-Queues.html */ + * http://www.freertos.org/Embedded-RTOS-Queues.html */ static uint8_t ucQueueStorageArea[ staticQUEUE_LENGTH_IN_ITEMS * sizeof( uint64_t ) ]; /* Create the queue. xQueueCreateStatic() has two more parameters than the @@ -440,7 +440,7 @@ if( xReturned != pdPASS ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } /* Ensure the semaphore passes a few sanity checks as a valid semaphore. */ @@ -466,7 +466,7 @@ if( xReturned != pdPASS ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } /* Ensure the semaphore passes a few sanity checks as a valid semaphore. */ @@ -535,7 +535,7 @@ * function expects it to be unavailable. */ if( xSemaphoreTake( xSemaphore, staticDONT_BLOCK ) == pdFAIL ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } prvSanityCheckCreatedSemaphore( xSemaphore, staticBINARY_SEMAPHORE_MAX_COUNT ); @@ -563,12 +563,12 @@ if( *puxVariableToIncrement == staticMAX_TIMER_CALLBACK_EXECUTIONS ) { /* This is called from a timer callback so must not block. See - * https://www.FreeRTOS.org/FreeRTOS-timers-xTimerStop.html */ + * http://www.FreeRTOS.org/FreeRTOS-timers-xTimerStop.html */ xReturned = xTimerStop( xExpiredTimer, staticDONT_BLOCK ); if( xReturned != pdPASS ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } } } @@ -615,7 +615,7 @@ if( xReturned != pdPASS ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } vTaskDelay( xTimerPeriod * staticMAX_TIMER_CALLBACK_EXECUTIONS ); @@ -624,7 +624,7 @@ * times, and then stopped itself. */ if( uxVariableToIncrement != staticMAX_TIMER_CALLBACK_EXECUTIONS ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } /* Finished with the timer, delete it. */ @@ -634,7 +634,7 @@ * command will have been sent even without a block time being used. */ if( xReturned != pdPASS ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } /* Just to show the check task that this task is still executing. */ @@ -658,21 +658,21 @@ if( xReturned != pdPASS ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } vTaskDelay( xTimerPeriod * staticMAX_TIMER_CALLBACK_EXECUTIONS ); if( uxVariableToIncrement != staticMAX_TIMER_CALLBACK_EXECUTIONS ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } xReturned = xTimerDelete( xTimer, staticDONT_BLOCK ); if( xReturned != pdPASS ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } } #endif /* if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) */ @@ -757,13 +757,13 @@ /* Check the task was created correctly, then delete the task. */ if( xCreatedTask == NULL ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } else if( eTaskGetState( xCreatedTask ) != eSuspended ) { /* The created task had a higher priority so should have executed and * suspended itself by now. */ - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } else { @@ -787,14 +787,14 @@ if( eTaskGetState( xCreatedTask ) != eSuspended ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } configASSERT( xReturned == pdPASS ); if( xReturned != pdPASS ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } vTaskDelete( xCreatedTask ); @@ -856,7 +856,7 @@ if( xEventBits != ( EventBits_t ) 0 ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } /* Some some bits, then read them back to check they are as expected. */ @@ -866,7 +866,7 @@ if( xEventBits != xFirstTestBits ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } xEventGroupSetBits( xEventGroup, xSecondTestBits ); @@ -875,7 +875,7 @@ if( xEventBits != ( xFirstTestBits | xSecondTestBits ) ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } /* Finally try clearing some bits too and check that operation proceeds as @@ -886,7 +886,7 @@ if( xEventBits != xSecondTestBits ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } } /*-----------------------------------------------------------*/ @@ -907,12 +907,12 @@ if( ( ( TickType_t ) ( xTaskGetTickCount() - xTickCount ) ) < xShortBlockTime ) { /* Did not block on the semaphore as long as expected. */ - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } if( xReturned != pdFAIL ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } /* Should be possible to 'give' the semaphore up to a maximum of uxMaxCount @@ -923,7 +923,7 @@ if( xReturned == pdFAIL ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } } @@ -932,7 +932,7 @@ if( xReturned != pdFAIL ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } configASSERT( uxSemaphoreGetCount( xSemaphore ) == uxMaxCount ); @@ -945,7 +945,7 @@ if( xReturned == pdFAIL ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } } @@ -957,12 +957,12 @@ if( ( ( TickType_t ) ( xTaskGetTickCount() - xTickCount ) ) < xShortBlockTime ) { /* Did not block on the semaphore as long as expected. */ - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } if( xReturned != pdFAIL ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } configASSERT( uxSemaphoreGetCount( xSemaphore ) == 0 ); @@ -983,7 +983,7 @@ if( xReturned != errQUEUE_EMPTY ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } /* Now it should be possible to write to the queue staticQUEUE_LENGTH_IN_ITEMS @@ -994,7 +994,7 @@ if( xReturned != pdPASS ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } } @@ -1003,7 +1003,7 @@ if( xReturned != errQUEUE_FULL ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } /* Now read back from the queue to ensure the data read back matches that @@ -1014,12 +1014,12 @@ if( xReturned != pdPASS ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } if( ullRead != ull ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } } @@ -1028,7 +1028,7 @@ if( xReturned != errQUEUE_EMPTY ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } } } @@ -1046,7 +1046,7 @@ if( xReturned != pdFAIL ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } /* Now it should be possible to take the mutex a number of times. */ @@ -1056,7 +1056,7 @@ if( xReturned != pdPASS ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } } @@ -1068,7 +1068,7 @@ if( xReturned != pdPASS ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } } @@ -1077,7 +1077,7 @@ if( xReturned != pdFAIL ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } } /*-----------------------------------------------------------*/ @@ -1089,7 +1089,7 @@ if( uxCycleCounter == uxLastCycleCounter ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } else { diff --git a/FreeRTOS/Demo/Common/Minimal/blocktim.c b/FreeRTOS/Demo/Common/Minimal/blocktim.c index f5e8ef2b77..e7a0385a51 100644 --- a/FreeRTOS/Demo/Common/Minimal/blocktim.c +++ b/FreeRTOS/Demo/Common/Minimal/blocktim.c @@ -152,7 +152,7 @@ static void vPrimaryBlockTimeTestTask( void * pvParameters ) * anything on the queue. */ if( xQueueReceive( xTestQueue, &xData, xTimeToBlock ) != errQUEUE_EMPTY ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } /* How long were we blocked for? */ @@ -161,7 +161,7 @@ static void vPrimaryBlockTimeTestTask( void * pvParameters ) if( xBlockedTime < xTimeToBlock ) { /* Should not have blocked for less than we requested. */ - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } if( xBlockedTime > ( xTimeToBlock + bktALLOWABLE_MARGIN ) ) @@ -169,7 +169,7 @@ static void vPrimaryBlockTimeTestTask( void * pvParameters ) /* Should not have blocked for longer than we requested, * although we would not necessarily run as soon as we were * unblocked so a margin is allowed. */ - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } } @@ -183,7 +183,7 @@ static void vPrimaryBlockTimeTestTask( void * pvParameters ) { if( xQueueSend( xTestQueue, &xItem, bktDONT_BLOCK ) != pdPASS ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } #if configUSE_PREEMPTION == 0 @@ -203,7 +203,7 @@ static void vPrimaryBlockTimeTestTask( void * pvParameters ) * anything on the queue. */ if( xQueueSend( xTestQueue, &xItem, xTimeToBlock ) != errQUEUE_FULL ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } /* How long were we blocked for? */ @@ -212,7 +212,7 @@ static void vPrimaryBlockTimeTestTask( void * pvParameters ) if( xBlockedTime < xTimeToBlock ) { /* Should not have blocked for less than we requested. */ - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } if( xBlockedTime > ( xTimeToBlock + bktALLOWABLE_MARGIN ) ) @@ -220,7 +220,7 @@ static void vPrimaryBlockTimeTestTask( void * pvParameters ) /* Should not have blocked for longer than we requested, * although we would not necessarily run as soon as we were * unblocked so a margin is allowed. */ - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } } @@ -256,7 +256,7 @@ static void vPrimaryBlockTimeTestTask( void * pvParameters ) * but not execute as this task has higher priority. */ if( xQueueReceive( xTestQueue, &xData, bktDONT_BLOCK ) != pdPASS ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } /* Now fill the queue again before the other task gets a chance to @@ -264,13 +264,13 @@ static void vPrimaryBlockTimeTestTask( void * pvParameters ) * full ourselves, and the other task have set xRunIndicator. */ if( xQueueSend( xTestQueue, &xItem, bktDONT_BLOCK ) != pdPASS ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } if( xRunIndicator == bktRUN_INDICATOR ) { /* The other task should not have executed. */ - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } /* Raise the priority of the other task so it executes and blocks @@ -283,7 +283,7 @@ static void vPrimaryBlockTimeTestTask( void * pvParameters ) { /* The other task should not have executed outside of the * queue function. */ - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } /* Set the priority back down. */ @@ -311,7 +311,7 @@ static void vPrimaryBlockTimeTestTask( void * pvParameters ) { if( xQueueReceive( xTestQueue, &xData, bktDONT_BLOCK ) != pdPASS ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } } @@ -334,7 +334,7 @@ static void vPrimaryBlockTimeTestTask( void * pvParameters ) * wake but not execute as this task has higher priority. */ if( xQueueSend( xTestQueue, &xItem, bktDONT_BLOCK ) != pdPASS ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } /* Now empty the queue again before the other task gets a chance to @@ -342,13 +342,13 @@ static void vPrimaryBlockTimeTestTask( void * pvParameters ) * empty ourselves, and the other task would be suspended. */ if( xQueueReceive( xTestQueue, &xData, bktDONT_BLOCK ) != pdPASS ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } if( xRunIndicator == bktRUN_INDICATOR ) { /* The other task should not have executed. */ - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } /* Raise the priority of the other task so it executes and blocks @@ -361,7 +361,7 @@ static void vPrimaryBlockTimeTestTask( void * pvParameters ) { /* The other task should not have executed outside of the * queue function. */ - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } vTaskPrioritySet( xSecondary, bktSECONDARY_PRIORITY ); @@ -411,7 +411,7 @@ static void vSecondaryBlockTimeTestTask( void * pvParameters ) if( xQueueSend( xTestQueue, &xData, bktTIME_TO_BLOCK ) != errQUEUE_FULL ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } /* How long were we inside the send function? */ @@ -420,7 +420,7 @@ static void vSecondaryBlockTimeTestTask( void * pvParameters ) /* We should not have blocked for less time than bktTIME_TO_BLOCK. */ if( xBlockedTime < bktTIME_TO_BLOCK ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } /* We should of not blocked for much longer than bktALLOWABLE_MARGIN @@ -428,7 +428,7 @@ static void vSecondaryBlockTimeTestTask( void * pvParameters ) * soon as we unblocked. */ if( xBlockedTime > ( bktTIME_TO_BLOCK + bktALLOWABLE_MARGIN ) ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } /* Suspend ready for test 3. */ @@ -447,7 +447,7 @@ static void vSecondaryBlockTimeTestTask( void * pvParameters ) if( xQueueReceive( xTestQueue, &xData, bktTIME_TO_BLOCK ) != errQUEUE_EMPTY ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } xBlockedTime = xTaskGetTickCount() - xTimeWhenBlocking; @@ -455,7 +455,7 @@ static void vSecondaryBlockTimeTestTask( void * pvParameters ) /* We should not have blocked for less time than bktTIME_TO_BLOCK. */ if( xBlockedTime < bktTIME_TO_BLOCK ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } /* We should of not blocked for much longer than bktALLOWABLE_MARGIN @@ -463,7 +463,7 @@ static void vSecondaryBlockTimeTestTask( void * pvParameters ) * as we unblocked. */ if( xBlockedTime > ( bktTIME_TO_BLOCK + bktALLOWABLE_MARGIN ) ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } xRunIndicator = bktRUN_INDICATOR; @@ -493,7 +493,7 @@ static void prvBasicDelayTests( void ) * to the other tests in this file. */ if( ( xPostTime - xPreTime ) > ( bktTIME_TO_BLOCK + xAllowableMargin ) ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } /* Now crude tests to check the vTaskDelayUntil() functionality. */ @@ -510,7 +510,7 @@ static void prvBasicDelayTests( void ) if( ( xTaskGetTickCount() - xExpectedUnblockTime ) > ( bktTIME_TO_BLOCK + xAllowableMargin ) ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } xPrimaryCycles++; @@ -522,7 +522,7 @@ static void prvBasicDelayTests( void ) if( xDidBlock != pdTRUE ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } /* Now delay a few ticks so repeating the above block period will not block for @@ -532,7 +532,7 @@ static void prvBasicDelayTests( void ) if( xDidBlock != pdTRUE ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } /* This time block for longer than xPeriod before calling xTaskDelayUntil() so @@ -542,7 +542,7 @@ static void prvBasicDelayTests( void ) if( xDidBlock != pdFALSE ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } /* Catch up. */ @@ -550,7 +550,7 @@ static void prvBasicDelayTests( void ) if( xDidBlock != pdTRUE ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } /* Again block for slightly longer than a period so ensure the time is in the @@ -560,7 +560,7 @@ static void prvBasicDelayTests( void ) if( xDidBlock != pdFALSE ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } /* Reset to the original task priority ready for the other tests. */ @@ -585,7 +585,7 @@ BaseType_t xAreBlockTimeTestTasksStillRunning( void ) xReturn = pdFAIL; } - if( xErrorOccurred == pdTRUE ) + if( xErrorOccurred != pdFALSE ) { xReturn = pdFAIL; } diff --git a/FreeRTOS/Demo/Common/Minimal/readme.txt b/FreeRTOS/Demo/Common/Minimal/readme.txt index 48668dcba2..9e5ee6c682 100644 --- a/FreeRTOS/Demo/Common/Minimal/readme.txt +++ b/FreeRTOS/Demo/Common/Minimal/readme.txt @@ -1,2 +1,2 @@ -This directory contains the implementation of the "common demo tasks". These +This directory contains the implementation of the "common demo tasks". These are test tasks and demo tasks that are used by nearly all the demo applications. \ No newline at end of file diff --git a/FreeRTOS/Demo/Common/Minimal/recmutex.c b/FreeRTOS/Demo/Common/Minimal/recmutex.c index d3de03a5c1..39bf9a4b0c 100644 --- a/FreeRTOS/Demo/Common/Minimal/recmutex.c +++ b/FreeRTOS/Demo/Common/Minimal/recmutex.c @@ -144,7 +144,7 @@ static void prvRecursiveMutexControllingTask( void * pvParameters ) * polling task. */ if( xSemaphoreGiveRecursive( xMutex ) == pdPASS ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } for( ux = 0; ux < recmuMAX_COUNT; ux++ ) @@ -161,7 +161,7 @@ static void prvRecursiveMutexControllingTask( void * pvParameters ) * flag will be set here. */ if( xSemaphoreTakeRecursive( xMutex, recmu15ms_DELAY ) != pdPASS ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } /* Ensure the other task attempting to access the mutex (and the @@ -185,7 +185,7 @@ static void prvRecursiveMutexControllingTask( void * pvParameters ) * as it too has a lower priority than this task. */ if( xSemaphoreGiveRecursive( xMutex ) != pdPASS ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } #if ( configUSE_PREEMPTION == 0 ) @@ -197,7 +197,7 @@ static void prvRecursiveMutexControllingTask( void * pvParameters ) * should no longer be the mutex owner, so the next give should fail. */ if( xSemaphoreGiveRecursive( xMutex ) == pdPASS ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } /* Keep count of the number of cycles this task has performed so a @@ -232,7 +232,7 @@ static void prvRecursiveMutexBlockingTask( void * pvParameters ) { /* Did not expect to execute until the controlling task was * suspended. */ - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } else { @@ -240,7 +240,7 @@ static void prvRecursiveMutexBlockingTask( void * pvParameters ) * the polling task to obtain the mutex. */ if( xSemaphoreGiveRecursive( xMutex ) != pdPASS ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } xBlockingIsSuspended = pdTRUE; @@ -252,13 +252,13 @@ static void prvRecursiveMutexBlockingTask( void * pvParameters ) { /* We should not leave the xSemaphoreTakeRecursive() function * until the mutex was obtained. */ - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } /* The controlling and blocking tasks should be in lock step. */ if( uxControllingCycles != ( UBaseType_t ) ( uxBlockingCycles + 1 ) ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } /* Keep count of the number of cycles this task has performed so a @@ -290,7 +290,7 @@ static void prvRecursiveMutexPollingTask( void * pvParameters ) /* Is the blocking task suspended? */ if( ( xBlockingIsSuspended != pdTRUE ) || ( xControllingIsSuspended != pdTRUE ) ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } else { @@ -321,7 +321,7 @@ static void prvRecursiveMutexPollingTask( void * pvParameters ) * be suspended. */ if( ( xBlockingIsSuspended == pdTRUE ) || ( xControllingIsSuspended == pdTRUE ) ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } #if ( INCLUDE_uxTaskPriorityGet == 1 ) @@ -341,7 +341,7 @@ static void prvRecursiveMutexPollingTask( void * pvParameters ) /* Release the mutex, disinheriting the higher priority again. */ if( xSemaphoreGiveRecursive( xMutex ) != pdPASS ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } #if ( INCLUDE_uxTaskPriorityGet == 1 ) @@ -371,7 +371,7 @@ BaseType_t xAreRecursiveMutexTasksStillRunning( void ) /* Is the controlling task still cycling? */ if( uxLastControllingCycles == uxControllingCycles ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } else { @@ -381,7 +381,7 @@ BaseType_t xAreRecursiveMutexTasksStillRunning( void ) /* Is the blocking task still cycling? */ if( uxLastBlockingCycles == uxBlockingCycles ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } else { @@ -391,14 +391,14 @@ BaseType_t xAreRecursiveMutexTasksStillRunning( void ) /* Is the polling task still cycling? */ if( uxLastPollingCycles == uxPollingCycles ) { - xErrorOccurred = pdTRUE; + xErrorOccurred = __LINE__; } else { uxLastPollingCycles = uxPollingCycles; } - if( xErrorOccurred == pdTRUE ) + if( xErrorOccurred != pdFALSE ) { xReturn = pdFAIL; } From 7cd180d914612173fd3654113c4176aadcb4a124 Mon Sep 17 00:00:00 2001 From: RichardBarry <3073890+RichardBarry@users.noreply.github.com> Date: Mon, 19 Feb 2024 07:20:02 -0800 Subject: [PATCH 03/15] Add register test tasks to QEMU project (#765) * Add register test tasks to the CORTEX_MPS2_QEMU_IAR GCC and IAR builds. * Update header comment in the two added files. * Fix header checks * Fix build issue * update IAR version --------- Co-authored-by: none <> Co-authored-by: Rahul Kar Co-authored-by: Rahul Kar <118818625+kar-rahul-aws@users.noreply.github.com> --- .../CORTEX_MPS2_QEMU_IAR_GCC/FreeRTOSConfig.h | 167 ++++++++-------- .../build/gcc/.project | 40 ++-- .../build/gcc/Makefile | 3 +- .../build/gcc/RegTest.c | 187 ++++++++++++++++++ .../build/iar/RTOSDemo.ewp | 79 ++++++-- .../build/iar/RTOSDemo.ewt | 147 +++++++++----- .../build/iar/RegTest.S | 181 +++++++++++++++++ FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/main.c | 2 +- .../CORTEX_MPS2_QEMU_IAR_GCC/main_blinky.c | 6 +- .../Demo/CORTEX_MPS2_QEMU_IAR_GCC/main_full.c | 87 ++++++++ 10 files changed, 728 insertions(+), 171 deletions(-) create mode 100644 FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/build/gcc/RegTest.c create mode 100644 FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/build/iar/RegTest.S diff --git a/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/FreeRTOSConfig.h b/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/FreeRTOSConfig.h index 095f3df763..20e59ea311 100644 --- a/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/FreeRTOSConfig.h +++ b/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/FreeRTOSConfig.h @@ -28,104 +28,107 @@ #define FREERTOS_CONFIG_H /*----------------------------------------------------------- - * Application specific definitions. - * - * These definitions should be adjusted for your particular hardware and - * application requirements. - * - * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE - * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. - * - * See http://www.freertos.org/a00110.html - *----------------------------------------------------------*/ - -#define configUSE_TRACE_FACILITY 0 -#define configGENERATE_RUN_TIME_STATS 0 - -#define configUSE_TICKLESS_IDLE 0 -#define configUSE_PREEMPTION 1 -#define configUSE_IDLE_HOOK 0 -#define configUSE_TICK_HOOK 1 -#define configCPU_CLOCK_HZ ( ( unsigned long ) 25000000 ) -#define configTICK_RATE_HZ ( ( TickType_t ) 1000 ) -#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 80 ) -#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 60 * 1024 ) ) -#define configMAX_TASK_NAME_LEN ( 12 ) -#define configUSE_16_BIT_TICKS 0 -#define configIDLE_SHOULD_YIELD 0 -#define configUSE_CO_ROUTINES 0 -#define configUSE_MUTEXES 1 -#define configUSE_RECURSIVE_MUTEXES 1 -#define configCHECK_FOR_STACK_OVERFLOW 2 -#define configUSE_MALLOC_FAILED_HOOK 1 -#define configUSE_QUEUE_SETS 1 -#define configUSE_COUNTING_SEMAPHORES 1 - -#define configMAX_PRIORITIES ( 9UL ) -#define configMAX_CO_ROUTINE_PRIORITIES ( 2 ) -#define configQUEUE_REGISTRY_SIZE 10 -#define configSUPPORT_STATIC_ALLOCATION 1 +* Application specific definitions. +* +* These definitions should be adjusted for your particular hardware and +* application requirements. +* +* THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE +* FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. +* +* See http://www.freertos.org/a00110.html +*----------------------------------------------------------*/ + +#define configUSE_TRACE_FACILITY 0 +#define configGENERATE_RUN_TIME_STATS 0 + +#define configUSE_PREEMPTION 1 +#define configUSE_IDLE_HOOK 0 +#define configUSE_TICK_HOOK 1 +#define configCPU_CLOCK_HZ ( ( unsigned long ) 25000000 ) +#define configTICK_RATE_HZ ( ( TickType_t ) 1000 ) +#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 80 ) +#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 60 * 1024 ) ) +#define configMAX_TASK_NAME_LEN ( 12 ) +#define configUSE_TRACE_FACILITY 0 +#define configUSE_16_BIT_TICKS 0 +#define configIDLE_SHOULD_YIELD 0 +#define configUSE_CO_ROUTINES 0 +#define configUSE_MUTEXES 1 +#define configUSE_RECURSIVE_MUTEXES 1 +#define configCHECK_FOR_STACK_OVERFLOW 2 +#define configUSE_MALLOC_FAILED_HOOK 1 +#define configUSE_QUEUE_SETS 1 +#define configUSE_COUNTING_SEMAPHORES 1 + +#define configMAX_PRIORITIES ( 9UL ) +#define configMAX_CO_ROUTINE_PRIORITIES ( 2 ) +#define configQUEUE_REGISTRY_SIZE 10 +#define configSUPPORT_STATIC_ALLOCATION 1 /* Timer related defines. */ -#define configUSE_TIMERS 1 -#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 4 ) -#define configTIMER_QUEUE_LENGTH 20 -#define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE * 2 ) +#define configUSE_TIMERS 1 +#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 4 ) +#define configTIMER_QUEUE_LENGTH 20 +#define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE * 2 ) -#define configUSE_TASK_NOTIFICATIONS 1 -#define configTASK_NOTIFICATION_ARRAY_ENTRIES 3 +#define configUSE_TASK_NOTIFICATIONS 1 +#define configTASK_NOTIFICATION_ARRAY_ENTRIES 3 /* Set the following definitions to 1 to include the API function, or zero -to exclude the API function. */ - -#define INCLUDE_vTaskPrioritySet 1 -#define INCLUDE_uxTaskPriorityGet 1 -#define INCLUDE_vTaskDelete 1 -#define INCLUDE_vTaskCleanUpResources 0 -#define INCLUDE_vTaskSuspend 1 -#define INCLUDE_vTaskDelayUntil 1 -#define INCLUDE_vTaskDelay 1 -#define INCLUDE_uxTaskGetStackHighWaterMark 1 -#define INCLUDE_xTaskGetSchedulerState 1 -#define INCLUDE_xTimerGetTimerDaemonTaskHandle 1 -#define INCLUDE_xTaskGetIdleTaskHandle 1 -#define INCLUDE_xSemaphoreGetMutexHolder 1 -#define INCLUDE_eTaskGetState 1 -#define INCLUDE_xTimerPendFunctionCall 1 -#define INCLUDE_xTaskAbortDelay 1 -#define INCLUDE_xTaskGetHandle 1 - -/* This demo makes use of one or more example stats formatting functions. These -format the raw data provided by the uxTaskGetSystemState() function in to human -readable ASCII form. See the notes in the implementation of vTaskList() within -FreeRTOS/Source/tasks.c for limitations. */ -#define configUSE_STATS_FORMATTING_FUNCTIONS 0 - -#define configKERNEL_INTERRUPT_PRIORITY ( 255 ) /* All eight bits as QEMU doesn't model the priority bits. */ + * to exclude the API function. */ + +#define INCLUDE_vTaskPrioritySet 1 +#define INCLUDE_uxTaskPriorityGet 1 +#define INCLUDE_vTaskDelete 1 +#define INCLUDE_vTaskCleanUpResources 0 +#define INCLUDE_vTaskSuspend 1 +#define INCLUDE_vTaskDelayUntil 1 +#define INCLUDE_vTaskDelay 1 +#define INCLUDE_uxTaskGetStackHighWaterMark 1 +#define INCLUDE_xTaskGetSchedulerState 1 +#define INCLUDE_xTimerGetTimerDaemonTaskHandle 1 +#define INCLUDE_xTaskGetIdleTaskHandle 1 +#define INCLUDE_xSemaphoreGetMutexHolder 1 +#define INCLUDE_eTaskGetState 1 +#define INCLUDE_xTimerPendFunctionCall 1 +#define INCLUDE_xTaskAbortDelay 1 +#define INCLUDE_xTaskGetHandle 1 + +/* This demo makes use of one or more example stats formatting functions. These + * format the raw data provided by the uxTaskGetSystemState() function in to human + * readable ASCII form. See the notes in the implementation of vTaskList() within + * FreeRTOS/Source/tasks.c for limitations. */ +#define configUSE_STATS_FORMATTING_FUNCTIONS 0 + +#define configKERNEL_INTERRUPT_PRIORITY ( 255 ) /* All eight bits as QEMU doesn't model the priority bits. */ + + /* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!! -See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */ -#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( 4 ) + * See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */ +#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( 4 ) /* Use the Cortex-M3 optimised task selection rather than the generic C code -version. */ -#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1 + * version. */ +#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1 /* The Win32 target is capable of running all the tests tasks at the same * time. */ -#define configRUN_ADDITIONAL_TESTS 1 +#define configRUN_ADDITIONAL_TESTS 1 /* The test that checks the trigger level on stream buffers requires an -allowable margin of error on slower processors (slower than the Win32 -machine on which the test is developed). */ -#define configSTREAM_BUFFER_TRIGGER_LEVEL_TEST_MARGIN 4 + * allowable margin of error on slower processors (slower than the Win32 + * machine on which the test is developed). */ +#define configSTREAM_BUFFER_TRIGGER_LEVEL_TEST_MARGIN 4 #ifndef __IASMARM__ /* Prevent C code being included in IAR asm files. */ - void vAssertCalled( const char *pcFileName, uint32_t ulLine ); - #define configASSERT( x ) if( ( x ) == 0 ) vAssertCalled( __FILE__, __LINE__ ); + void vAssertCalled( const char * pcFileName, + uint32_t ulLine ); + #define configASSERT( x ) if( ( x ) == 0 ) vAssertCalled( __FILE__, __LINE__ ); #endif -#define intqHIGHER_PRIORITY ( configMAX_PRIORITIES - 5 ) -#define bktPRIMARY_PRIORITY ( configMAX_PRIORITIES - 3 ) -#define bktSECONDARY_PRIORITY ( configMAX_PRIORITIES - 4 ) +#define intqHIGHER_PRIORITY ( configMAX_PRIORITIES - 5 ) +#define bktPRIMARY_PRIORITY ( configMAX_PRIORITIES - 3 ) +#define bktSECONDARY_PRIORITY ( configMAX_PRIORITIES - 4 ) #endif /* FREERTOS_CONFIG_H */ diff --git a/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/build/gcc/.project b/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/build/gcc/.project index da12b7d9b3..f634908225 100644 --- a/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/build/gcc/.project +++ b/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/build/gcc/.project @@ -25,11 +25,6 @@ org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - - CommonDemoSource - 2 - FREERTOS_ROOT/Demo/Common/Minimal - FreeRTOS_kernel 2 @@ -40,35 +35,50 @@ 2 virtual:/virtual + + Source/Blinky_Demo + 2 + virtual:/virtual + Source/FreeRTOSConfig.h 1 FREERTOS_ROOT/Demo/CORTEX_MPS2_QEMU_IAR_GCC/FreeRTOSConfig.h - Source/IntQueueTimer.c + Source/Full_Demo + 2 + virtual:/virtual + + + Source/main.c 1 - FREERTOS_ROOT/Demo/CORTEX_MPS2_QEMU_IAR_GCC/IntQueueTimer.c + FREERTOS_ROOT/Demo/CORTEX_MPS2_QEMU_IAR_GCC/main.c - Source/IntQueueTimer.h + Source/Blinky_Demo/main_blinky.c 1 - FREERTOS_ROOT/Demo/CORTEX_MPS2_QEMU_IAR_GCC/IntQueueTimer.h + PARENT-2-PROJECT_LOC/main_blinky.c - Source/main.c + Source/Full_Demo/CommonDemoSource + 2 + FREERTOS_ROOT/Demo/Common/Minimal + + + Source/Full_Demo/IntQueueTimer.c 1 - FREERTOS_ROOT/Demo/CORTEX_MPS2_QEMU_IAR_GCC/main.c + PARENT-2-PROJECT_LOC/IntQueueTimer.c - Source/main_blinky.c + Source/Full_Demo/IntQueueTimer.h 1 - FREERTOS_ROOT/Demo/CORTEX_MPS2_QEMU_IAR_GCC/main_blinky.c + PARENT-2-PROJECT_LOC/IntQueueTimer.h - Source/main_full.c + Source/Full_Demo/main_full.c 1 - FREERTOS_ROOT/Demo/CORTEX_MPS2_QEMU_IAR_GCC/main_full.c + PARENT-2-PROJECT_LOC/main_full.c diff --git a/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/build/gcc/Makefile b/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/build/gcc/Makefile index 33e0cdde62..b8ced5da37 100644 --- a/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/build/gcc/Makefile +++ b/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/build/gcc/Makefile @@ -12,7 +12,7 @@ MAKE = make CFLAGS += $(INCLUDE_DIRS) -nostartfiles -ffreestanding -mthumb -mcpu=cortex-m3 \ - -Wall -Wextra -g3 -O0 -ffunction-sections -fdata-sections \ + -Wall -Wextra -g3 -Os -ffunction-sections -fdata-sections \ -MMD -MP -MF"$(@:%.o=%.d)" -MT $@ # @@ -79,6 +79,7 @@ SOURCE_FILES += (DEMO_PROJECT)/main.c SOURCE_FILES += (DEMO_PROJECT)/main_blinky.c SOURCE_FILES += (DEMO_PROJECT)/main_full.c SOURCE_FILES += ./startup_gcc.c +SOURCE_FILES += ./RegTest.c # Lightweight print formatting to use in place of the heavier GCC equivalent. SOURCE_FILES += ./printf-stdarg.c diff --git a/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/build/gcc/RegTest.c b/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/build/gcc/RegTest.c new file mode 100644 index 0000000000..f2fb17f677 --- /dev/null +++ b/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/build/gcc/RegTest.c @@ -0,0 +1,187 @@ +/* + * FreeRTOS V202212.00 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * + */ + +/* + * "Reg test" tasks - These fill the registers with known values, then check + * that each register maintains its expected value for the lifetime of the + * task. Each task uses a different set of values. The reg test tasks execute + * with a very low priority, so get preempted very frequently. A register + * containing an unexpected value is indicative of an error in the context + * switching mechanism. + */ + +void vRegTest1Implementation( void ) __attribute__ ((naked)); +void vRegTest2Implementation( void ) __attribute__ ((naked)); + +void vRegTest1Implementation( void ) +{ + __asm volatile + ( + ".extern ulRegTest1LoopCounter \n" + + /* Fill the core registers with known values. */ + "mov r0, #100 \n" + "mov r1, #101 \n" + "mov r2, #102 \n" + "mov r3, #103 \n" + "mov r4, #104 \n" + "mov r5, #105 \n" + "mov r6, #106 \n" + "mov r7, #107 \n" + "mov r8, #108 \n" + "mov r9, #109 \n" + "mov r10, #110 \n" + "mov r11, #111 \n" + "mov r12, #112 \n" + + "reg1_loop: \n" + + "cmp r0, #100 \n" + "bne reg1_error_loop \n" + "cmp r1, #101 \n" + "bne reg1_error_loop \n" + "cmp r2, #102 \n" + "bne reg1_error_loop \n" + "cmp r3, #103 \n" + "bne reg1_error_loop \n" + "cmp r4, #104 \n" + "bne reg1_error_loop \n" + "cmp r5, #105 \n" + "bne reg1_error_loop \n" + "cmp r6, #106 \n" + "bne reg1_error_loop \n" + "cmp r7, #107 \n" + "bne reg1_error_loop \n" + "cmp r8, #108 \n" + "bne reg1_error_loop \n" + "cmp r9, #109 \n" + "bne reg1_error_loop \n" + "cmp r10, #110 \n" + "bne reg1_error_loop \n" + "cmp r11, #111 \n" + "bne reg1_error_loop \n" + "cmp r12, #112 \n" + "bne reg1_error_loop \n" + + /* Everything passed, increment the loop counter. */ + "push { r0-r1 } \n" + "ldr r0, =ulRegTest1LoopCounter \n" + "ldr r1, [r0] \n" + "adds r1, r1, #1 \n" + "str r1, [r0] \n" + "pop { r0-r1 } \n" + + /* Start again. */ + "b reg1_loop \n" + + "reg1_error_loop: \n" + /* If this line is hit then there was an error in a core register value. + The loop ensures the loop counter stops incrementing. */ + "b reg1_error_loop \n" + "nop \n" + ); /* __asm volatile. */ +} +/*-----------------------------------------------------------*/ + +void vRegTest2Implementation( void ) +{ + __asm volatile + ( + ".extern ulRegTest2LoopCounter \n" + + /* Set all the core registers to known values. */ + "mov r0, #-1 \n" + "mov r1, #1 \n" + "mov r2, #2 \n" + "mov r3, #3 \n" + "mov r4, #4 \n" + "mov r5, #5 \n" + "mov r6, #6 \n" + "mov r7, #7 \n" + "mov r8, #8 \n" + "mov r9, #9 \n" + "mov r10, #10 \n" + "mov r11, #11 \n" + "mov r12, #12 \n" + + "reg2_loop : \n" + + "cmp r0, #-1 \n" + "bne reg2_error_loop \n" + "cmp r1, #1 \n" + "bne reg2_error_loop \n" + "cmp r2, #2 \n" + "bne reg2_error_loop \n" + "cmp r3, #3 \n" + "bne reg2_error_loop \n" + "cmp r4, #4 \n" + "bne reg2_error_loop \n" + "cmp r5, #5 \n" + "bne reg2_error_loop \n" + "cmp r6, #6 \n" + "bne reg2_error_loop \n" + "cmp r7, #7 \n" + "bne reg2_error_loop \n" + "cmp r8, #8 \n" + "bne reg2_error_loop \n" + "cmp r9, #9 \n" + "bne reg2_error_loop \n" + "cmp r10, #10 \n" + "bne reg2_error_loop \n" + "cmp r11, #11 \n" + "bne reg2_error_loop \n" + "cmp r12, #12 \n" + "bne reg2_error_loop \n" + + /* Increment the loop counter to indicate this test is still functioning + correctly. */ + "push { r0-r1 } \n" + "ldr r0, =ulRegTest2LoopCounter \n" + "ldr r1, [r0] \n" + "adds r1, r1, #1 \n" + "str r1, [r0] \n" + + /* Yield to increase test coverage. */ + "movs r0, #0x01 \n" + "ldr r1, =0xe000ed04 \n" /*NVIC_INT_CTRL */ + "lsl r0, r0, #28 \n" /* Shift to PendSV bit */ + "str r0, [r1] \n" + "dsb \n" + + "pop { r0-r1 } \n" + + /* Start again. */ + "b reg2_loop \n" + + "reg2_error_loop: \n" + /* If this line is hit then there was an error in a core register value. + This loop ensures the loop counter variable stops incrementing. */ + "b reg2_error_loop \n" + + ); /* __asm volatile */ +} +/*-----------------------------------------------------------*/ + diff --git a/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/build/iar/RTOSDemo.ewp b/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/build/iar/RTOSDemo.ewp index 2af9104f3a..e7955f066d 100644 --- a/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/build/iar/RTOSDemo.ewp +++ b/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/build/iar/RTOSDemo.ewp @@ -1,6 +1,6 @@ - 3 + 4 Debug @@ -11,7 +11,7 @@ General 3 - 33 + 36 1 1 + + + + ICCARM 2 - 37 + 38 1 1 + + AARM 2 - 11 + 12 1 1 + @@ -659,19 +688,11 @@ inputOutputBased - - BUILDACTION - 1 - - - - - ILINK 0 - 25 + 27 1 1 + + + + @@ -1046,6 +1083,11 @@ + + BUILDACTION + 2 + + Blinky Demo @@ -1208,6 +1250,9 @@ $PROJ_DIR$\..\..\main_full.c + + $PROJ_DIR$\RegTest.S + System files diff --git a/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/build/iar/RTOSDemo.ewt b/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/build/iar/RTOSDemo.ewt index 5e4ad93a2a..41f7a12e6d 100644 --- a/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/build/iar/RTOSDemo.ewt +++ b/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/build/iar/RTOSDemo.ewt @@ -1,6 +1,6 @@ - 3 + 4 Debug @@ -9,9 +9,9 @@ 1 C-STAT - 515 + 518 - 515 + 518 0 @@ -25,7 +25,7 @@ Debug\C-STAT - 2.3.1 + 2.6.0 @@ -356,6 +356,7 @@ + @@ -798,6 +799,7 @@ + @@ -817,6 +819,7 @@ + @@ -830,6 +833,7 @@ + @@ -840,7 +844,15 @@ - + + + + + + + + + @@ -876,6 +888,7 @@ + @@ -883,6 +896,7 @@ + @@ -900,6 +914,9 @@ + + + @@ -922,6 +939,7 @@ + @@ -946,6 +964,7 @@ + @@ -1002,6 +1021,11 @@ + + + + + @@ -1018,6 +1042,7 @@ + @@ -1048,6 +1073,7 @@ + @@ -1063,6 +1089,10 @@ + + + + @@ -1081,6 +1111,16 @@ + + + + + + + + + + @@ -1423,7 +1463,7 @@ Blinky Demo - $PROJ_DIR$\main_blinky.c + $PROJ_DIR$\..\..\main_blinky.c @@ -1431,25 +1471,25 @@ include - $PROJ_DIR$\..\..\Source\include\event_groups.h + $PROJ_DIR$\..\..\..\..\Source\include\event_groups.h - $PROJ_DIR$\..\..\Source\include\message_buffer.h + $PROJ_DIR$\..\..\..\..\Source\include\message_buffer.h - $PROJ_DIR$\..\..\Source\include\queue.h + $PROJ_DIR$\..\..\..\..\Source\include\queue.h - $PROJ_DIR$\..\..\Source\include\semphr.h + $PROJ_DIR$\..\..\..\..\Source\include\semphr.h - $PROJ_DIR$\..\..\Source\include\stream_buffer.h + $PROJ_DIR$\..\..\..\..\Source\include\stream_buffer.h - $PROJ_DIR$\..\..\Source\include\task.h + $PROJ_DIR$\..\..\..\..\Source\include\task.h - $PROJ_DIR$\..\..\Source\include\timers.h + $PROJ_DIR$\..\..\..\..\Source\include\timers.h @@ -1459,37 +1499,37 @@ ARM_CM3 - $PROJ_DIR$\..\..\Source\portable\IAR\ARM_CM3\port.c + $PROJ_DIR$\..\..\..\..\Source\portable\IAR\ARM_CM3\port.c - $PROJ_DIR$\..\..\Source\portable\IAR\ARM_CM3\portasm.s + $PROJ_DIR$\..\..\..\..\Source\portable\IAR\ARM_CM3\portasm.s MemMang - $PROJ_DIR$\..\..\Source\portable\MemMang\heap_4.c + $PROJ_DIR$\..\..\..\..\Source\portable\MemMang\heap_4.c - $PROJ_DIR$\..\..\Source\event_groups.c + $PROJ_DIR$\..\..\..\..\Source\event_groups.c - $PROJ_DIR$\..\..\Source\list.c + $PROJ_DIR$\..\..\..\..\Source\list.c - $PROJ_DIR$\..\..\Source\queue.c + $PROJ_DIR$\..\..\..\..\Source\queue.c - $PROJ_DIR$\..\..\Source\stream_buffer.c + $PROJ_DIR$\..\..\..\..\Source\stream_buffer.c - $PROJ_DIR$\..\..\Source\tasks.c + $PROJ_DIR$\..\..\..\..\Source\tasks.c - $PROJ_DIR$\..\..\Source\timers.c + $PROJ_DIR$\..\..\..\..\Source\timers.c @@ -1497,89 +1537,92 @@ Standard Demo Tasks - $PROJ_DIR$\..\Common\Minimal\AbortDelay.c + $PROJ_DIR$\..\..\..\Common\Minimal\AbortDelay.c - $PROJ_DIR$\..\Common\Minimal\BlockQ.c + $PROJ_DIR$\..\..\..\Common\Minimal\BlockQ.c - $PROJ_DIR$\..\Common\Minimal\blocktim.c + $PROJ_DIR$\..\..\..\Common\Minimal\blocktim.c - $PROJ_DIR$\..\Common\Minimal\countsem.c + $PROJ_DIR$\..\..\..\Common\Minimal\countsem.c - $PROJ_DIR$\..\Common\Minimal\death.c + $PROJ_DIR$\..\..\..\Common\Minimal\death.c - $PROJ_DIR$\..\Common\Minimal\dynamic.c + $PROJ_DIR$\..\..\..\Common\Minimal\dynamic.c - $PROJ_DIR$\..\Common\Minimal\EventGroupsDemo.c + $PROJ_DIR$\..\..\..\Common\Minimal\EventGroupsDemo.c - $PROJ_DIR$\..\Common\Minimal\GenQTest.c + $PROJ_DIR$\..\..\..\Common\Minimal\GenQTest.c - $PROJ_DIR$\..\Common\Minimal\integer.c + $PROJ_DIR$\..\..\..\Common\Minimal\integer.c - $PROJ_DIR$\..\Common\Minimal\IntQueue.c + $PROJ_DIR$\..\..\..\Common\Minimal\IntQueue.c - $PROJ_DIR$\IntQueueTimer.c + $PROJ_DIR$\..\..\IntQueueTimer.c - $PROJ_DIR$\..\Common\Minimal\IntSemTest.c + $PROJ_DIR$\..\..\..\Common\Minimal\IntSemTest.c - $PROJ_DIR$\..\Common\Minimal\MessageBufferAMP.c + $PROJ_DIR$\..\..\..\Common\Minimal\MessageBufferAMP.c - $PROJ_DIR$\..\Common\Minimal\MessageBufferDemo.c + $PROJ_DIR$\..\..\..\Common\Minimal\MessageBufferDemo.c - $PROJ_DIR$\..\Common\Minimal\PollQ.c + $PROJ_DIR$\..\..\..\Common\Minimal\PollQ.c - $PROJ_DIR$\..\Common\Minimal\QPeek.c + $PROJ_DIR$\..\..\..\Common\Minimal\QPeek.c - $PROJ_DIR$\..\Common\Minimal\QueueOverwrite.c + $PROJ_DIR$\..\..\..\Common\Minimal\QueueOverwrite.c - $PROJ_DIR$\..\Common\Minimal\QueueSet.c + $PROJ_DIR$\..\..\..\Common\Minimal\QueueSet.c - $PROJ_DIR$\..\Common\Minimal\QueueSetPolling.c + $PROJ_DIR$\..\..\..\Common\Minimal\QueueSetPolling.c - $PROJ_DIR$\..\Common\Minimal\recmutex.c + $PROJ_DIR$\..\..\..\Common\Minimal\recmutex.c - $PROJ_DIR$\..\Common\Minimal\semtest.c + $PROJ_DIR$\..\..\..\Common\Minimal\semtest.c - $PROJ_DIR$\..\Common\Minimal\StaticAllocation.c + $PROJ_DIR$\..\..\..\Common\Minimal\StaticAllocation.c - $PROJ_DIR$\..\Common\Minimal\StreamBufferDemo.c + $PROJ_DIR$\..\..\..\Common\Minimal\StreamBufferDemo.c - $PROJ_DIR$\..\Common\Minimal\StreamBufferInterrupt.c + $PROJ_DIR$\..\..\..\Common\Minimal\StreamBufferInterrupt.c - $PROJ_DIR$\..\Common\Minimal\TaskNotify.c + $PROJ_DIR$\..\..\..\Common\Minimal\TaskNotify.c - $PROJ_DIR$\..\Common\Minimal\TaskNotifyArray.c + $PROJ_DIR$\..\..\..\Common\Minimal\TaskNotifyArray.c - $PROJ_DIR$\..\Common\Minimal\TimerDemo.c + $PROJ_DIR$\..\..\..\Common\Minimal\TimerDemo.c - $PROJ_DIR$\main_full.c + $PROJ_DIR$\..\..\main_full.c + + + $PROJ_DIR$\RegTest.S @@ -1589,9 +1632,9 @@ - $PROJ_DIR$\FreeRTOSConfig.h + $PROJ_DIR$\..\..\FreeRTOSConfig.h - $PROJ_DIR$\main.c + $PROJ_DIR$\..\..\main.c diff --git a/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/build/iar/RegTest.S b/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/build/iar/RegTest.S new file mode 100644 index 0000000000..5b0541fc8a --- /dev/null +++ b/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/build/iar/RegTest.S @@ -0,0 +1,181 @@ +/* + * FreeRTOS V202212.00 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * + */ + +#include + + + RSEG CODE:CODE(2) + thumb + + EXTERN ulRegTest1LoopCounter + EXTERN ulRegTest2LoopCounter + + PUBLIC vRegTest1Implementation + PUBLIC vRegTest2Implementation + +/*-----------------------------------------------------------*/ + +vRegTest1Implementation + + /* Fill the core registers with known values. */ + mov r0, #100 + mov r1, #101 + mov r2, #102 + mov r3, #103 + mov r4, #104 + mov r5, #105 + mov r6, #106 + mov r7, #107 + mov r8, #108 + mov r9, #109 + mov r10, #110 + mov r11, #111 + mov r12, #112 + +reg1_loop: + + cmp r0, #100 + bne reg1_error_loop + cmp r1, #101 + bne reg1_error_loop + cmp r2, #102 + bne reg1_error_loop + cmp r3, #103 + bne reg1_error_loop + cmp r4, #104 + bne reg1_error_loop + cmp r5, #105 + bne reg1_error_loop + cmp r6, #106 + bne reg1_error_loop + cmp r7, #107 + bne reg1_error_loop + cmp r8, #108 + bne reg1_error_loop + cmp r9, #109 + bne reg1_error_loop + cmp r10, #110 + bne reg1_error_loop + cmp r11, #111 + bne reg1_error_loop + cmp r12, #112 + bne reg1_error_loop + + /* Everything passed, increment the loop counter. */ + push { r0-r1 } + ldr r0, =ulRegTest1LoopCounter + ldr r1, [r0] + adds r1, r1, #1 + str r1, [r0] + pop { r0-r1 } + + /* Start again. */ + b reg1_loop + +reg1_error_loop: + /* If this line is hit then there was an error in a core register value. + The loop ensures the loop counter stops incrementing. */ + b reg1_error_loop + +/*-----------------------------------------------------------*/ + + +vRegTest2Implementation + + /* Set all the core registers to known values. */ + mov r0, #-1 + mov r1, #1 + mov r2, #2 + mov r3, #3 + mov r4, #4 + mov r5, #5 + mov r6, #6 + mov r7, #7 + mov r8, #8 + mov r9, #9 + mov r10, #10 + mov r11, #11 + mov r12, #12 + +reg2_loop: + + cmp r0, #-1 + bne reg2_error_loop + cmp r1, #1 + bne reg2_error_loop + cmp r2, #2 + bne reg2_error_loop + cmp r3, #3 + bne reg2_error_loop + cmp r4, #4 + bne reg2_error_loop + cmp r5, #5 + bne reg2_error_loop + cmp r6, #6 + bne reg2_error_loop + cmp r7, #7 + bne reg2_error_loop + cmp r8, #8 + bne reg2_error_loop + cmp r9, #9 + bne reg2_error_loop + cmp r10, #10 + bne reg2_error_loop + cmp r11, #11 + bne reg2_error_loop + cmp r12, #12 + bne reg2_error_loop + + /* Increment the loop counter to indicate this test is still functioning + correctly. */ + push { r0-r1 } + ldr r0, =ulRegTest2LoopCounter + ldr r1, [r0] + adds r1, r1, #1 + str r1, [r0] + + /* Yield to increase test coverage. */ + movs r0, #0x01 + ldr r1, =0xe000ed04 /*NVIC_INT_CTRL */ + lsl r0, r0, #28 /* Shift to PendSV bit */ + str r0, [r1] + dsb + + pop { r0-r1 } + + /* Start again. */ + b reg2_loop + +reg2_error_loop: + /* If this line is hit then there was an error in a core register value. + This loop ensures the loop counter variable stops incrementing. */ + b reg2_error_loop + +/*-----------------------------------------------------------*/ + + + END + diff --git a/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/main.c b/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/main.c index e24439f3e8..bf8b07901c 100644 --- a/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/main.c +++ b/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/main.c @@ -43,7 +43,7 @@ * Use the following commands to start the application running in a way that * enables the debugger to connect, omit the "-s -S" to run the project without * the debugger: - * qemu-system-arm -machine mps2-an385 -cpu cortex-m3 -kernel [path-to]/RTOSDemo.out -nographic -serial stdio -semihosting -semihosting-config enable=on,target=native -s -S + * qemu-system-arm -machine mps2-an385 -cpu cortex-m3 -kernel [path-to]/RTOSDemo.out -monitor none -nographic -serial stdio -s -S */ /* FreeRTOS includes. */ diff --git a/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/main_blinky.c b/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/main_blinky.c index 7fcc3b8050..ad136e6e4b 100644 --- a/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/main_blinky.c +++ b/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/main_blinky.c @@ -166,9 +166,9 @@ static void prvQueueSendTask( void * pvParameters ) for( ; ; ) { /* Place this task in the blocked state until it is time to run again. - * The block time is specified in ticks, pdMS_TO_TICKS() was used to - * convert a time specified in milliseconds into a time specified in ticks. - * While in the Blocked state this task will not consume any CPU time. */ + * The block time is specified in ticks, pdMS_TO_TICKS() was used to + * convert a time specified in milliseconds into a time specified in ticks. + * While in the Blocked state this task will not consume any CPU time. */ vTaskDelayUntil( &xNextWakeTime, xBlockTime ); /* Send to the queue - causing the queue receive task to unblock and diff --git a/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/main_full.c b/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/main_full.c index fd205845b4..38d50c4d5b 100644 --- a/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/main_full.c +++ b/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/main_full.c @@ -109,14 +109,40 @@ * constant is different depending on the compiler in use. */ #define mainMESSAGE_BUFFER_STACK_SIZE ( configMINIMAL_STACK_SIZE + ( configMINIMAL_STACK_SIZE >> 1 ) ) #define mainCHECK_TASK_STACK_SIZE ( configMINIMAL_STACK_SIZE + ( configMINIMAL_STACK_SIZE >> 1 ) ) + +/* Parameters that are passed into the register check tasks solely for the + * purpose of ensuring parameters are passed into tasks correctly. */ +#define mainREG_TEST_TASK_1_PARAMETER ( ( void * ) 0x12345678 ) +#define mainREG_TEST_TASK_2_PARAMETER ( ( void * ) 0x87654321 ) + /*-----------------------------------------------------------*/ +/* + * Register check tasks, and the tasks used to write over and check the contents + * of the FPU registers, as described at the top of this file. The nature of + * these files necessitates that they are written in an assembly file, but the + * entry points are kept in the C file for the convenience of checking the task + * parameter. + */ +static void prvRegTestTaskEntry1( void * pvParameters ); +extern void vRegTest1Implementation( void ); +static void prvRegTestTaskEntry2( void * pvParameters ); +extern void vRegTest2Implementation( void ); + /* The task that checks the operation of all the other standard demo tasks, as * described at the top of this file. */ static void prvCheckTask( void * pvParameters ); /*-----------------------------------------------------------*/ +/* The following two variables are used to communicate the status of the + * register test tasks to the check task. If the variables keep incrementing, + * then the register test tasks have not discovered any errors. If a variable + * stops incrementing, then an error has been found. */ +volatile unsigned long ulRegTest1LoopCounter = 0UL, ulRegTest2LoopCounter = 0UL; + +/*-----------------------------------------------------------*/ + void main_full( void ) { /* Start the standard demo tasks. */ @@ -144,6 +170,15 @@ void main_full( void ) vStartStreamBufferInterruptDemo(); vStartInterruptSemaphoreTasks(); + /* Create the register check tasks, as described at the top of this file */ + xTaskCreate( prvRegTestTaskEntry1, /* Function that implements the task. */ + "Reg1", /* Human readable name for the task - not used by the kernel but helps debugging. */ + configMINIMAL_STACK_SIZE, /* Size of stack to allocate for the task - in words not bytes. */ + mainREG_TEST_TASK_1_PARAMETER, /* A parameter passed into the task to check parameter passing is working correctly. */ + tskIDLE_PRIORITY, /* Priority assigned to the task - must be between 0 (tskIDLE_PRIORITY) and (configMAX_PRIORITIES - 1). */ + NULL ); /* Can be used to pass a handle to the create task out of the xTaskCreate() function. */ + xTaskCreate( prvRegTestTaskEntry2, "Reg2", configMINIMAL_STACK_SIZE, mainREG_TEST_TASK_2_PARAMETER, tskIDLE_PRIORITY, NULL ); + /* The suicide tasks must be created last as they need to know how many * tasks were running prior to their creation in order to ascertain whether * or not the correct/expected number of tasks are running at any given time. */ @@ -168,6 +203,8 @@ void main_full( void ) static void prvCheckTask( void * pvParameters ) { static const char * pcMessage = "PASS"; + unsigned long ulLastRegTest1Value = 0, ulLastRegTest2Value = 0; + const TickType_t xTaskPeriod = pdMS_TO_TICKS( 5000UL ); TickType_t xPreviousWakeTime; extern uint32_t ulNestCount; @@ -279,6 +316,19 @@ static void prvCheckTask( void * pvParameters ) { pcMessage = "xAreInterruptSemaphoreTasksStillRunning() returned false"; } + else if( ulLastRegTest1Value == ulRegTest1LoopCounter ) + { + /* Check that the register test 1 task is still running. */ + pcMessage = "Error in RegTest 1"; + } + else if( ulLastRegTest2Value == ulRegTest2LoopCounter ) + { + /* Check that the register test 2 task is still running. */ + pcMessage = "Error in RegTest 2"; + } + + ulLastRegTest1Value = ulRegTest1LoopCounter; + ulLastRegTest2Value = ulRegTest2LoopCounter; /* It is normally not good to call printf() from an embedded system, * although it is ok in this simulated case. */ @@ -319,3 +369,40 @@ void vFullDemoTickHookFunction( void ) vInterruptSemaphorePeriodicTest(); } /*-----------------------------------------------------------*/ + +static void prvRegTestTaskEntry1( void * pvParameters ) +{ + /* Although the regtest task is written in assembler, its entry point is + * written in C for convenience of checking the task parameter is being passed + * in correctly. */ + if( pvParameters == mainREG_TEST_TASK_1_PARAMETER ) + { + /* Start the part of the test that is written in assembler. */ + vRegTest1Implementation(); + } + + /* The following line will only execute if the task parameter is found to + * be incorrect. The check task will detect that the regtest loop counter is + * not being incremented and flag an error. */ + vTaskDelete( NULL ); +} +/*-----------------------------------------------------------*/ + +static void prvRegTestTaskEntry2( void * pvParameters ) +{ + /* Although the regtest task is written in assembler, its entry point is + * written in C for convenience of checking the task parameter is being passed + * in correctly. */ + if( pvParameters == mainREG_TEST_TASK_2_PARAMETER ) + { + /* Start the part of the test that is written in assembler. */ + vRegTest2Implementation(); + } + + /* The following line will only execute if the task parameter is found to + * be incorrect. The check task will detect that the regtest loop counter is + * not being incremented and flag an error. */ + vTaskDelete( NULL ); +} +/*-----------------------------------------------------------*/ + From d1ef345165c034bdc2c0e3e75951b7bf7a0c9962 Mon Sep 17 00:00:00 2001 From: chinglee-iot <61685396+chinglee-iot@users.noreply.github.com> Date: Tue, 27 Feb 2024 01:10:00 +0800 Subject: [PATCH 04/15] Calling vTaskEndScheduler in application created task (#1187) --- FreeRTOS/Demo/WIN32-MingW/main_full.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/FreeRTOS/Demo/WIN32-MingW/main_full.c b/FreeRTOS/Demo/WIN32-MingW/main_full.c index 03317e22b2..0eae31e8c4 100644 --- a/FreeRTOS/Demo/WIN32-MingW/main_full.c +++ b/FreeRTOS/Demo/WIN32-MingW/main_full.c @@ -405,6 +405,16 @@ static void prvCheckTask( void * pvParameters ) } /*-----------------------------------------------------------*/ +static void prvEndSchedulerTask( void * pvParameters ) +{ + ( void ) pvParameters; + + /* Calling vTaskEndScheduler in an application created task. */ + vTaskEndScheduler(); +} + +/*-----------------------------------------------------------*/ + static void prvTestTask( void * pvParameters ) { const unsigned long ulMSToSleep = 5; @@ -428,6 +438,7 @@ void vFullDemoIdleFunction( void ) { const unsigned long ulMSToSleep = 15; void * pvAllocated; + BaseType_t xReturn; /* Sleep to reduce CPU load, but don't sleep indefinitely in case there are * tasks waiting to be terminated by the idle task. */ @@ -484,7 +495,10 @@ void vFullDemoIdleFunction( void ) if( ( xTaskGetTickCount() - configINITIAL_TICK_COUNT ) >= xMaxRunTime ) { - vTaskEndScheduler(); + /* Creating another task to end the scheduler to prevent deleting idle + * task itself in vTaskEndScheduler. */ + xReturn = xTaskCreate( prvEndSchedulerTask, "TestEnd", configMINIMAL_STACK_SIZE, NULL, configMAX_PRIORITIES - 1, NULL ); + configASSERT( xReturn == pdPASS ); } } #endif /* if ( projCOVERAGE_TEST == 1 ) */ From 731a4f05fd46afb76b67892599b26bc126c451dc Mon Sep 17 00:00:00 2001 From: chinglee-iot <61685396+chinglee-iot@users.noreply.github.com> Date: Tue, 27 Feb 2024 11:29:15 +0800 Subject: [PATCH 05/15] Add SMP schedule highest priority on-target test (#1167) * Add SMP scheduler highest priority task on target test --------- Signed-off-by: Gaurav Aggarwal Co-authored-by: Rahul Kar <118818625+kar-rahul-aws@users.noreply.github.com> Co-authored-by: Gaurav Aggarwal Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com> --- .../Test/Target/boards/pico/FreeRTOSConfig.h | 2 +- .../schedule_highest_priority/CMakeLists.txt | 33 +++ .../schedule_highest_priority_test_runner.c | 73 ++++++ .../schedule_highest_priority.c | 220 ++++++++++++++++++ .../schedule_highest_priority/test_config.h | 63 +++++ 5 files changed, 390 insertions(+), 1 deletion(-) create mode 100644 FreeRTOS/Test/Target/boards/pico/tests/smp/schedule_highest_priority/CMakeLists.txt create mode 100644 FreeRTOS/Test/Target/boards/pico/tests/smp/schedule_highest_priority/schedule_highest_priority_test_runner.c create mode 100644 FreeRTOS/Test/Target/tests/smp/schedule_highest_priority/schedule_highest_priority.c create mode 100644 FreeRTOS/Test/Target/tests/smp/schedule_highest_priority/test_config.h diff --git a/FreeRTOS/Test/Target/boards/pico/FreeRTOSConfig.h b/FreeRTOS/Test/Target/boards/pico/FreeRTOSConfig.h index 22d7b7720b..57ee878e3f 100644 --- a/FreeRTOS/Test/Target/boards/pico/FreeRTOSConfig.h +++ b/FreeRTOS/Test/Target/boards/pico/FreeRTOSConfig.h @@ -105,7 +105,7 @@ #define configTICK_CORE 1 #define configRUN_MULTIPLE_PRIORITIES 1 #define configUSE_CORE_AFFINITY 1 -#define configUSE_MINIMAL_IDLE_HOOK 0 +#define configUSE_PASSIVE_IDLE_HOOK 0 #define configUSE_TASK_PREEMPTION_DISABLE 0 /* RP2040 specific */ diff --git a/FreeRTOS/Test/Target/boards/pico/tests/smp/schedule_highest_priority/CMakeLists.txt b/FreeRTOS/Test/Target/boards/pico/tests/smp/schedule_highest_priority/CMakeLists.txt new file mode 100644 index 0000000000..d0b96e7bf9 --- /dev/null +++ b/FreeRTOS/Test/Target/boards/pico/tests/smp/schedule_highest_priority/CMakeLists.txt @@ -0,0 +1,33 @@ +cmake_minimum_required(VERSION 3.13) + +project(example C CXX ASM) +set(CMAKE_C_STANDARD 11) +set(CMAKE_CXX_STANDARD 17) + +set(TEST_INCLUDE_PATHS ${CMAKE_CURRENT_LIST_DIR}/../../../../../tests/smp/schedule_highest_priority) +set(TEST_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../../../../../tests/smp/schedule_highest_priority) + +add_library(schedule_highest_priority INTERFACE) +target_sources(schedule_highest_priority INTERFACE + ${BOARD_LIBRARY_DIR}/main.c + ${CMAKE_CURRENT_LIST_DIR}/schedule_highest_priority_test_runner.c + ${TEST_SOURCE_DIR}/schedule_highest_priority.c) + +target_include_directories(schedule_highest_priority INTERFACE + ${CMAKE_CURRENT_LIST_DIR}/../../.. + ${TEST_INCLUDE_PATHS} + ) + +target_link_libraries(schedule_highest_priority INTERFACE + FreeRTOS-Kernel + FreeRTOS-Kernel-Heap4 + ${BOARD_LINK_LIBRARIES}) + +add_executable(test_schedule_highest_priority) +enable_board_functions(test_schedule_highest_priority) +target_link_libraries(test_schedule_highest_priority schedule_highest_priority) +target_include_directories(test_schedule_highest_priority PUBLIC + ${BOARD_INCLUDE_PATHS}) +target_compile_definitions(test_schedule_highest_priority PRIVATE + ${BOARD_DEFINES} +) diff --git a/FreeRTOS/Test/Target/boards/pico/tests/smp/schedule_highest_priority/schedule_highest_priority_test_runner.c b/FreeRTOS/Test/Target/boards/pico/tests/smp/schedule_highest_priority/schedule_highest_priority_test_runner.c new file mode 100644 index 0000000000..e6c0cb8ada --- /dev/null +++ b/FreeRTOS/Test/Target/boards/pico/tests/smp/schedule_highest_priority/schedule_highest_priority_test_runner.c @@ -0,0 +1,73 @@ +/* + * FreeRTOS V202212.00 + * Copyright (C) 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * + */ + +/** + * @file schedule_highest_priority_test_runner.c + * @brief The implementation of main function to start test runner task. + * + * Procedure: + * - Initialize environment. + * - Run the test case. + */ + +/* Kernel includes. */ +#include "FreeRTOS.h" +#include "task.h" + +/* Unit testing support functions. */ +#include "unity.h" + +/* Pico includes. */ +#include "pico/multicore.h" +#include "pico/stdlib.h" + +/*-----------------------------------------------------------*/ + +static void prvTestRunnerTask( void * pvParameters ); + +/*-----------------------------------------------------------*/ + +static void prvTestRunnerTask( void * pvParameters ) +{ + ( void ) pvParameters; + + /* Run test case. */ + vRunScheduleHighestPriorityTest(); + + vTaskDelete( NULL ); +} +/*-----------------------------------------------------------*/ + +void vRunTest( void ) +{ + xTaskCreate( prvTestRunnerTask, + "testRunner", + configMINIMAL_STACK_SIZE, + NULL, + configMAX_PRIORITIES - 1, + NULL ); +} +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Test/Target/tests/smp/schedule_highest_priority/schedule_highest_priority.c b/FreeRTOS/Test/Target/tests/smp/schedule_highest_priority/schedule_highest_priority.c new file mode 100644 index 0000000000..e34d7456a0 --- /dev/null +++ b/FreeRTOS/Test/Target/tests/smp/schedule_highest_priority/schedule_highest_priority.c @@ -0,0 +1,220 @@ +/* + * FreeRTOS V202212.00 + * Copyright (C) 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * + */ + +/** + * @file schedule_highest_priority.c + * @brief The scheduler shall correctly schedule the highest priority ready tasks. + * + * Procedure: + * - Create ( num of cores ) tasks ( T0~Tn-1 ). Priority T0 > T1 > ... > Tn-2 > Tn-1. + * - for each task Ti in [T0..Tn-1]: + * - Tasks T0..Ti-1 are running. If any of the task in T0..Ti-1 is not + * running notify the test runner task about error. + * - If i == n -1: + * - Notify test runner task about success. + * Expected: + * - When a task runs, all tasks of higher priority are running. + */ + +/* Standard includes. */ +#include + +/* Kernel includes. */ +#include "FreeRTOS.h" +#include "task.h" + +/* Unit testing support functions. */ +#include "unity.h" +/*-----------------------------------------------------------*/ + +#if ( configNUMBER_OF_CORES < 2 ) + #error This test is for FreeRTOS SMP and therefore, requires at least 2 cores. +#endif /* #if ( configNUMBER_OF_CORES < 2 ) */ + +#if ( configMAX_PRIORITIES <= configNUMBER_OF_CORES ) + #error This test creates tasks with different priority, requires configMAX_PRIORITIES to be larger than configNUMBER_OF_CORES. +#endif /* #if ( configMAX_PRIORITIES <= configNUMBER_OF_CORES ) */ +/*-----------------------------------------------------------*/ + +/** + * @brief Timeout value to stop test. + */ +#define TEST_TIMEOUT_MS ( 10000U ) + +/** + * @brief Nop operation for busy looping. + */ +#ifdef portNOP + #define TEST_NOP portNOP +#else + #define TEST_NOP() __asm volatile ( "nop" ) +#endif + +/*-----------------------------------------------------------*/ + +/** + * @brief Function that implements a never blocking FreeRTOS task. + */ +static void prvEverRunningTask( void * pvParameters ); +/*-----------------------------------------------------------*/ + +/** + * @brief Handle of the test runner task. + */ +static TaskHandle_t xTestRunnerTaskHandle; + +/** + * @brief Handles of the tasks created in this test. + */ +static TaskHandle_t xTaskHandles[ configNUMBER_OF_CORES ]; + +/** + * @brief Indexes of the tasks created in this test. + */ +static uint32_t xTaskIndexes[ configNUMBER_OF_CORES ]; +/*-----------------------------------------------------------*/ + +/** + * @brief Ever running task function. + * + * Test runner task is notified with the following values: + * - A value between 0 and ( configNUMBER_OF_CORES -1 ) : Task with the index + * equal to value encountered an error during the test. + * - configNUMBER_OF_CORES : The test finished without any error. + */ +static void prvEverRunningTask( void * pvParameters ) +{ + uint32_t i; + uint32_t uxCurrentTaskIdx = *( ( uint32_t * ) pvParameters ); + eTaskState xTaskState; + + /* Tasks with index smaller than the current task are of higher priority and + * must be running when this task is running. */ + for( i = 0; i < uxCurrentTaskIdx; i++ ) + { + xTaskState = eTaskGetState( xTaskHandles[ i ] ); + + if( eRunning != xTaskState ) + { + /* Notify the test runner task about the error. */ + ( void ) xTaskNotify( xTestRunnerTaskHandle, uxCurrentTaskIdx, eSetValueWithoutOverwrite ); + } + } + + /* If current task is the last task, then we finish the check because all + * tasks are checked. */ + if( uxCurrentTaskIdx == ( configNUMBER_OF_CORES - 1 ) ) + { + /* Notify the test runner task about success. */ + ( void ) xTaskNotify( xTestRunnerTaskHandle, configNUMBER_OF_CORES, eSetValueWithoutOverwrite ); + } + + for( ; ; ) + { + /* Busy looping in this task. */ + TEST_NOP(); + } +} +/*-----------------------------------------------------------*/ + +/** + * @brief Test running task. + * + * It waits for a notification from one of the ever running tasks. + */ +void Test_ScheduleHighestPriority( void ) +{ + uint32_t ulNotifiedValue; + BaseType_t xReturn; + + xReturn = xTaskNotifyWait( 0U, ULONG_MAX, &ulNotifiedValue, pdMS_TO_TICKS( TEST_TIMEOUT_MS ) ); + + /* Test runner task is notified within TEST_TIMEOUT_MS. */ + TEST_ASSERT_EQUAL( pdTRUE, xReturn ); + + /* The notified value indicates that no error occurred during the test. */ + TEST_ASSERT_EQUAL_INT( configNUMBER_OF_CORES, ulNotifiedValue ); +} +/*-----------------------------------------------------------*/ + +/** + * @brief Runs before every test, put init calls here. + */ +void setUp( void ) +{ + uint32_t i; + BaseType_t xTaskCreationResult; + + /* Save the test runner task handle here. It is used to notify test runner + * from ever running tasks. */ + xTestRunnerTaskHandle = xTaskGetCurrentTaskHandle(); + + /* Create configNUMBER_OF_CORES tasks with decending priority. */ + for( i = 0; i < configNUMBER_OF_CORES; i++ ) + { + xTaskIndexes[ i ] = i; + xTaskCreationResult = xTaskCreate( prvEverRunningTask, + "EverRun", + configMINIMAL_STACK_SIZE * 2, + &( xTaskIndexes[ i ] ), + configMAX_PRIORITIES - 1 - i, + &( xTaskHandles[ i ] ) ); + + TEST_ASSERT_EQUAL_MESSAGE( pdPASS, xTaskCreationResult, "Task creation failed." ); + } +} +/*-----------------------------------------------------------*/ + +/** + * @brief Runs after every test, put clean-up calls here. + */ +void tearDown( void ) +{ + uint32_t i; + + /* Delete all the tasks. */ + for( i = 0; i < configNUMBER_OF_CORES; i++ ) + { + if( xTaskHandles[ i ] != NULL ) + { + vTaskDelete( xTaskHandles[ i ] ); + } + } +} +/*-----------------------------------------------------------*/ + +/** + * @brief Entry point for test runner to run highest priority test. + */ +void vRunScheduleHighestPriorityTest( void ) +{ + UNITY_BEGIN(); + + RUN_TEST( Test_ScheduleHighestPriority ); + + UNITY_END(); +} +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Test/Target/tests/smp/schedule_highest_priority/test_config.h b/FreeRTOS/Test/Target/tests/smp/schedule_highest_priority/test_config.h new file mode 100644 index 0000000000..c258ebeb06 --- /dev/null +++ b/FreeRTOS/Test/Target/tests/smp/schedule_highest_priority/test_config.h @@ -0,0 +1,63 @@ +/* + * FreeRTOS V202212.00 + * Copyright (C) 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * + */ + +#ifndef TEST_CONFIG_H +#define TEST_CONFIG_H + +/* This file must be included at the end of the FreeRTOSConfig.h. It contains + * any FreeRTOS specific configurations that the test requires. */ + +#ifdef configRUN_MULTIPLE_PRIORITIES + #undef configRUN_MULTIPLE_PRIORITIES +#endif /* #ifdef configRUN_MULTIPLE_PRIORITIES */ + +#ifdef configUSE_TIME_SLICING + #undef configUSE_TIME_SLICING +#endif /* #ifdef configUSE_TIME_SLICING */ + +#ifdef configUSE_PREEMPTION + #undef configUSE_PREEMPTION +#endif /* #ifdef configUSE_PREEMPTION */ + +#ifdef configUSE_TASK_NOTIFICATIONS + #undef configUSE_TASK_NOTIFICATIONS +#endif /* #ifdef configUSE_TASK_NOTIFICATIONS */ + +#define configRUN_MULTIPLE_PRIORITIES 1 +#define configUSE_TIME_SLICING 1 +#define configUSE_PREEMPTION 1 +#define configUSE_TASK_NOTIFICATIONS 1 + +/*-----------------------------------------------------------*/ + +/** + * @brief Entry point for test runner to run highest priority test. + */ +void vRunScheduleHighestPriorityTest( void ); + +/*-----------------------------------------------------------*/ + +#endif /* ifndef TEST_CONFIG_H */ From ec0eae4c0f719c9918837b3394585648a7fe1692 Mon Sep 17 00:00:00 2001 From: chinglee-iot <61685396+chinglee-iot@users.noreply.github.com> Date: Tue, 27 Feb 2024 11:45:38 +0800 Subject: [PATCH 06/15] Add SMP disable multiple priorities on target test (#1171) * Add SMP disable multiple priorities on target test --------- Signed-off-by: Gaurav Aggarwal Co-authored-by: Gaurav Aggarwal Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com> Co-authored-by: Rahul Kar <118818625+kar-rahul-aws@users.noreply.github.com> --- .../CMakeLists.txt | 33 +++ .../disable_multiple_priorities_test_runner.c | 73 ++++++ .../disable_multiple_priorities.c | 244 ++++++++++++++++++ .../disable_multiple_priorities/test_config.h | 73 ++++++ 4 files changed, 423 insertions(+) create mode 100644 FreeRTOS/Test/Target/boards/pico/tests/smp/disable_multiple_priorities/CMakeLists.txt create mode 100644 FreeRTOS/Test/Target/boards/pico/tests/smp/disable_multiple_priorities/disable_multiple_priorities_test_runner.c create mode 100644 FreeRTOS/Test/Target/tests/smp/disable_multiple_priorities/disable_multiple_priorities.c create mode 100644 FreeRTOS/Test/Target/tests/smp/disable_multiple_priorities/test_config.h diff --git a/FreeRTOS/Test/Target/boards/pico/tests/smp/disable_multiple_priorities/CMakeLists.txt b/FreeRTOS/Test/Target/boards/pico/tests/smp/disable_multiple_priorities/CMakeLists.txt new file mode 100644 index 0000000000..647c561ef3 --- /dev/null +++ b/FreeRTOS/Test/Target/boards/pico/tests/smp/disable_multiple_priorities/CMakeLists.txt @@ -0,0 +1,33 @@ +cmake_minimum_required(VERSION 3.13) + +project(example C CXX ASM) +set(CMAKE_C_STANDARD 11) +set(CMAKE_CXX_STANDARD 17) + +set(TEST_INCLUDE_PATHS ${CMAKE_CURRENT_LIST_DIR}/../../../../../tests/smp/disable_multiple_priorities) +set(TEST_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../../../../../tests/smp/disable_multiple_priorities) + +add_library(disable_multiple_priorities INTERFACE) +target_sources(disable_multiple_priorities INTERFACE + ${BOARD_LIBRARY_DIR}/main.c + ${CMAKE_CURRENT_LIST_DIR}/disable_multiple_priorities_test_runner.c + ${TEST_SOURCE_DIR}/disable_multiple_priorities.c) + +target_include_directories(disable_multiple_priorities INTERFACE + ${CMAKE_CURRENT_LIST_DIR}/../../.. + ${TEST_INCLUDE_PATHS} + ) + +target_link_libraries(disable_multiple_priorities INTERFACE + FreeRTOS-Kernel + FreeRTOS-Kernel-Heap4 + ${BOARD_LINK_LIBRARIES}) + +add_executable(test_disable_multiple_priorities) +enable_board_functions(test_disable_multiple_priorities) +target_link_libraries(test_disable_multiple_priorities disable_multiple_priorities) +target_include_directories(test_disable_multiple_priorities PUBLIC + ${BOARD_INCLUDE_PATHS}) +target_compile_definitions(test_disable_multiple_priorities PRIVATE + ${BOARD_DEFINES} +) diff --git a/FreeRTOS/Test/Target/boards/pico/tests/smp/disable_multiple_priorities/disable_multiple_priorities_test_runner.c b/FreeRTOS/Test/Target/boards/pico/tests/smp/disable_multiple_priorities/disable_multiple_priorities_test_runner.c new file mode 100644 index 0000000000..78d5d6c701 --- /dev/null +++ b/FreeRTOS/Test/Target/boards/pico/tests/smp/disable_multiple_priorities/disable_multiple_priorities_test_runner.c @@ -0,0 +1,73 @@ +/* + * FreeRTOS V202212.00 + * Copyright (C) 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * + */ + +/** + * @file disable_multiple_priorities_test_runner.c + * @brief The implementation of main function to start test runner task. + * + * Procedure: + * - Initialize environment. + * - Run the test case. + */ + +/* Kernel includes. */ +#include "FreeRTOS.h" +#include "task.h" + +/* Unit testing support functions. */ +#include "unity.h" + +/* Pico includes. */ +#include "pico/multicore.h" +#include "pico/stdlib.h" + +/*-----------------------------------------------------------*/ + +static void prvTestRunnerTask( void * pvParameters ); + +/*-----------------------------------------------------------*/ + +static void prvTestRunnerTask( void * pvParameters ) +{ + ( void ) pvParameters; + + /* Run test case. */ + vRunDisableMultiplePrioritiesTest(); + + vTaskDelete( NULL ); +} +/*-----------------------------------------------------------*/ + +void vRunTest( void ) +{ + xTaskCreate( prvTestRunnerTask, + "testRunner", + configMINIMAL_STACK_SIZE, + NULL, + configMAX_PRIORITIES - 1, + NULL ); +} +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Test/Target/tests/smp/disable_multiple_priorities/disable_multiple_priorities.c b/FreeRTOS/Test/Target/tests/smp/disable_multiple_priorities/disable_multiple_priorities.c new file mode 100644 index 0000000000..53764bb278 --- /dev/null +++ b/FreeRTOS/Test/Target/tests/smp/disable_multiple_priorities/disable_multiple_priorities.c @@ -0,0 +1,244 @@ +/* + * FreeRTOS V202212.00 + * Copyright (C) 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * + */ + +/** + * @file disable_multiple_priorities.c + * @brief The user shall be able to configure the scheduler to not run a + * lower priority task and a higher priority task simultaneously. + * + * Procedure: + * - Create ( num of cores ) test tasks ( T0~Tn-1 ). Priority T0 > T1 > ... > Tn-2 > Tn-1. + * - Verify the following conditions: + * - for each task Ti in [T0..Tn-1]: + * - Tasks T0~Ti-1 are in suspended state. + * - Task Ti is running. + * - Tasks Ti+1~Tn-1 are in ready state. + * - Suspend task Ti. + * Expected: + * - Only one task is running at the same time since all the test test tasks + * are of different priorities. + */ + +/* Standard includes. */ +#include + +/* Kernel includes. */ +#include "FreeRTOS.h" +#include "task.h" + +/* Unit testing support functions. */ +#include "unity.h" +/*-----------------------------------------------------------*/ + +/** + * @brief Timeout value to stop test. + */ +#define TEST_TIMEOUT_MS ( 1000 ) +/*-----------------------------------------------------------*/ + +#if ( configNUMBER_OF_CORES < 2 ) + #error This test is for FreeRTOS SMP and therefore, requires at least 2 cores. +#endif /* if configNUMBER_OF_CORES != 2 */ + +#if ( configRUN_MULTIPLE_PRIORITIES != 0 ) + #error configRUN_MULTIPLE_PRIORITIES must be disabled by including test_config.h in FreeRTOSConfig.h. +#endif /* if configRUN_MULTIPLE_PRIORITIES != 0 */ + +#if ( configUSE_CORE_AFFINITY != 0 ) + #error configUSE_CORE_AFFINITY must be disabled by including test_config.h in FreeRTOSConfig.h. +#endif /* if configUSE_CORE_AFFINITY != 0 */ + +#if ( configMAX_PRIORITIES <= ( configNUMBER_OF_CORES + 2 ) ) + #error This test creates tasks with different priority, requires configMAX_PRIORITIES to be larger than configNUMBER_OF_CORES. +#endif /* if ( configMAX_PRIORITIES <= ( configNUMBER_OF_CORES + 2 ) ) */ +/*-----------------------------------------------------------*/ + +/** + * @brief Test case "Disable Multiple Priorities". + */ +void Test_DisableMultiplePriorities( void ); + +/** + * @brief Task function that verifies that it is the only running task. + */ +static void prvCheckRunningTask( void * pvParameters ); +/*-----------------------------------------------------------*/ + +/** + * @brief Handles of the tasks created in this test. + */ +static TaskHandle_t xTaskHandles[ configNUMBER_OF_CORES ]; + +/** + * @brief Indexes of the tasks created in this test. + */ +static uint32_t xTaskIndexes[ configNUMBER_OF_CORES ]; + +/** + * @brief Test results. + */ +static BaseType_t xTestResults[ configNUMBER_OF_CORES ] = { pdFAIL }; +/*-----------------------------------------------------------*/ + +static void prvCheckRunningTask( void * pvParameters ) +{ + uint32_t i = 0; + uint32_t currentTaskIdx = *( ( uint32_t * ) pvParameters ); + eTaskState taskState; + BaseType_t xTestResult = pdPASS; + + for( i = 0; i < configNUMBER_OF_CORES; i++ ) + { + /* All the test tasks are created by the test runner task which runs + * at the highest priority. The test runs with multiple priorities + * disabled. Therefore, xTaskHandles[ i ] can not be NULL because none + * of the test tasks can run until the test runner task has created all + * the tasks and then blocked itself by calling vTaskDelay. Return + * pdFAIL in xTestResults to indicate test failure if any of the test + * task is not created yet. */ + if( xTaskHandles[ i ] == NULL ) + { + xTestResult = pdFAIL; + } + else + { + taskState = eTaskGetState( xTaskHandles[ i ] ); + + if( i > currentTaskIdx ) + { + /* Tasks with index greater than current task are of lower + * priority than the current task and must be in the ready + * state. */ + if( taskState != eReady ) + { + xTestResult = pdFAIL; + } + } + else if( i == currentTaskIdx ) + { + /* Current task must be running. */ + if( taskState != eRunning ) + { + xTestResult = pdFAIL; + } + } + else + { + /* Tasks with index smaller than current task are of higher + * priority than the current task and must be in the suspended + * state. */ + if( taskState != eSuspended ) + { + xTestResult = pdFAIL; + } + } + } + + if( xTestResult != pdPASS ) + { + break; + } + } + + xTestResults[ currentTaskIdx ] = xTestResult; + + /* Suspend the test task itself. */ + vTaskSuspend( NULL ); +} +/*-----------------------------------------------------------*/ + +void Test_DisableMultiplePriorities( void ) +{ + uint32_t i; + BaseType_t xTaskCreationResult; + + /* Create configNUMBER_OF_CORES low priority tasks. */ + for( i = 0; i < configNUMBER_OF_CORES; i++ ) + { + xTaskCreationResult = xTaskCreate( prvCheckRunningTask, + "CheckRunning", + configMINIMAL_STACK_SIZE * 2, + &xTaskIndexes[ i ], + configMAX_PRIORITIES - 2 - i, + &xTaskHandles[ i ] ); + + TEST_ASSERT_EQUAL_MESSAGE( pdPASS, xTaskCreationResult, "Task creation failed." ); + } + + /* Waiting for all the test tasks. */ + vTaskDelay( pdMS_TO_TICKS( TEST_TIMEOUT_MS ) ); + + /* Verify test results for all the tasks. */ + for( i = 0; i < configNUMBER_OF_CORES; i++ ) + { + TEST_ASSERT_EQUAL_MESSAGE( pdPASS, xTestResults[ i ], "Task test result is pdFAIL" ); + } +} +/*-----------------------------------------------------------*/ + +/* Runs before every test, put init calls here. */ +void setUp( void ) +{ + uint32_t i; + + /* Initialize variables. */ + for( i = 0; i < configNUMBER_OF_CORES; i++ ) + { + xTaskHandles[ i ] = NULL; + xTaskIndexes[ i ] = i; + } +} +/*-----------------------------------------------------------*/ + +/* Runs after every test, put clean-up calls here. */ +void tearDown( void ) +{ + uint32_t i; + + /* Delete all the tasks. */ + for( i = 0; i < configNUMBER_OF_CORES; i++ ) + { + if( xTaskHandles[ i ] != NULL ) + { + vTaskDelete( xTaskHandles[ i ] ); + xTaskHandles[ i ] = NULL; + } + } +} +/*-----------------------------------------------------------*/ + +/** + * @brief Entry point for test runner to run disable multiple priorities test. + */ +void vRunDisableMultiplePrioritiesTest( void ) +{ + UNITY_BEGIN(); + + RUN_TEST( Test_DisableMultiplePriorities ); + + UNITY_END(); +} +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Test/Target/tests/smp/disable_multiple_priorities/test_config.h b/FreeRTOS/Test/Target/tests/smp/disable_multiple_priorities/test_config.h new file mode 100644 index 0000000000..63b8de0d72 --- /dev/null +++ b/FreeRTOS/Test/Target/tests/smp/disable_multiple_priorities/test_config.h @@ -0,0 +1,73 @@ +/* + * FreeRTOS V202212.00 + * Copyright (C) 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * + */ + +#ifndef TEST_CONFIG_H +#define TEST_CONFIG_H + +/* This file must be included at the end of the FreeRTOSConfig.h. It contains + * any FreeRTOS specific configurations that the test requires. */ + +#ifdef configRUN_MULTIPLE_PRIORITIES + #undef configRUN_MULTIPLE_PRIORITIES +#endif /* ifdef configRUN_MULTIPLE_PRIORITIES */ + +#ifdef configUSE_CORE_AFFINITY + #undef configUSE_CORE_AFFINITY +#endif /* ifdef configUSE_CORE_AFFINITY */ + +#ifdef configUSE_MINIMAL_IDLE_HOOK + #undef configUSE_MINIMAL_IDLE_HOOK +#endif /* ifdef configUSE_MINIMAL_IDLE_HOOK */ + +#ifdef configUSE_TASK_PREEMPTION_DISABLE + #undef configUSE_TASK_PREEMPTION_DISABLE +#endif /* ifdef configUSE_TASK_PREEMPTION_DISABLE */ + +#ifdef configUSE_TIME_SLICING + #undef configUSE_TIME_SLICING +#endif /* ifdef configUSE_TIME_SLICING */ + +#ifdef configUSE_PREEMPTION + #undef configUSE_PREEMPTION +#endif /* ifdef configUSE_PREEMPTION */ + +#define configRUN_MULTIPLE_PRIORITIES 0 +#define configUSE_CORE_AFFINITY 0 +#define configUSE_MINIMAL_IDLE_HOOK 0 +#define configUSE_TASK_PREEMPTION_DISABLE 0 +#define configUSE_TIME_SLICING 1 +#define configUSE_PREEMPTION 1 + +/*-----------------------------------------------------------*/ + +/** + * @brief Entry point for test runner to run disable multiple priorities test. + */ +void vRunDisableMultiplePrioritiesTest( void ); + +/*-----------------------------------------------------------*/ + +#endif /* ifndef TEST_CONFIG_H */ From d9ced6e8ac15d2945a175452c9b2603fd07b5baf Mon Sep 17 00:00:00 2001 From: chinglee-iot <61685396+chinglee-iot@users.noreply.github.com> Date: Tue, 27 Feb 2024 12:01:25 +0800 Subject: [PATCH 07/15] Add SMP schedule affinity on target test (#1172) * Add SMP schedule affinity on target test --------- Signed-off-by: Gaurav Aggarwal Co-authored-by: Gaurav Aggarwal Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com> --- .../smp/schedule_affinity/CMakeLists.txt | 33 +++ .../schedule_affinity_test_runner.c | 73 ++++++ .../smp/schedule_affinity/schedule_affinity.c | 231 ++++++++++++++++++ .../tests/smp/schedule_affinity/test_config.h | 63 +++++ 4 files changed, 400 insertions(+) create mode 100644 FreeRTOS/Test/Target/boards/pico/tests/smp/schedule_affinity/CMakeLists.txt create mode 100644 FreeRTOS/Test/Target/boards/pico/tests/smp/schedule_affinity/schedule_affinity_test_runner.c create mode 100644 FreeRTOS/Test/Target/tests/smp/schedule_affinity/schedule_affinity.c create mode 100644 FreeRTOS/Test/Target/tests/smp/schedule_affinity/test_config.h diff --git a/FreeRTOS/Test/Target/boards/pico/tests/smp/schedule_affinity/CMakeLists.txt b/FreeRTOS/Test/Target/boards/pico/tests/smp/schedule_affinity/CMakeLists.txt new file mode 100644 index 0000000000..d4844bbe0e --- /dev/null +++ b/FreeRTOS/Test/Target/boards/pico/tests/smp/schedule_affinity/CMakeLists.txt @@ -0,0 +1,33 @@ +cmake_minimum_required(VERSION 3.13) + +project(example C CXX ASM) +set(CMAKE_C_STANDARD 11) +set(CMAKE_CXX_STANDARD 17) + +set(TEST_INCLUDE_PATHS ${CMAKE_CURRENT_LIST_DIR}/../../../../../tests/smp/schedule_affinity) +set(TEST_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../../../../../tests/smp/schedule_affinity) + +add_library(schedule_affinity INTERFACE) +target_sources(schedule_affinity INTERFACE + ${BOARD_LIBRARY_DIR}/main.c + ${CMAKE_CURRENT_LIST_DIR}/schedule_affinity_test_runner.c + ${TEST_SOURCE_DIR}/schedule_affinity.c) + +target_include_directories(schedule_affinity INTERFACE + ${CMAKE_CURRENT_LIST_DIR}/../../.. + ${TEST_INCLUDE_PATHS} + ) + +target_link_libraries(schedule_affinity INTERFACE + FreeRTOS-Kernel + FreeRTOS-Kernel-Heap4 + ${BOARD_LINK_LIBRARIES}) + +add_executable(test_schedule_affinity) +enable_board_functions(test_schedule_affinity) +target_link_libraries(test_schedule_affinity schedule_affinity) +target_include_directories(test_schedule_affinity PUBLIC + ${BOARD_INCLUDE_PATHS}) +target_compile_definitions(test_schedule_affinity PRIVATE + ${BOARD_DEFINES} +) diff --git a/FreeRTOS/Test/Target/boards/pico/tests/smp/schedule_affinity/schedule_affinity_test_runner.c b/FreeRTOS/Test/Target/boards/pico/tests/smp/schedule_affinity/schedule_affinity_test_runner.c new file mode 100644 index 0000000000..2230f6ac37 --- /dev/null +++ b/FreeRTOS/Test/Target/boards/pico/tests/smp/schedule_affinity/schedule_affinity_test_runner.c @@ -0,0 +1,73 @@ +/* + * FreeRTOS V202212.00 + * Copyright (C) 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * + */ + +/** + * @file schedule_affinity_test_runner.c + * @brief The implementation of main function to start test runner task. + * + * Procedure: + * - Initialize environment. + * - Run the test case. + */ + +/* Kernel includes. */ +#include "FreeRTOS.h" +#include "task.h" + +/* Unit testing support functions. */ +#include "unity.h" + +/* Pico includes. */ +#include "pico/multicore.h" +#include "pico/stdlib.h" + +/*-----------------------------------------------------------*/ + +static void prvTestRunnerTask( void * pvParameters ); + +/*-----------------------------------------------------------*/ + +static void prvTestRunnerTask( void * pvParameters ) +{ + ( void ) pvParameters; + + /* Run test case. */ + vRunScheduleAffinityTest(); + + vTaskDelete( NULL ); +} +/*-----------------------------------------------------------*/ + +void vRunTest( void ) +{ + xTaskCreate( prvTestRunnerTask, + "testRunner", + configMINIMAL_STACK_SIZE, + NULL, + configMAX_PRIORITIES - 1, + NULL ); +} +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Test/Target/tests/smp/schedule_affinity/schedule_affinity.c b/FreeRTOS/Test/Target/tests/smp/schedule_affinity/schedule_affinity.c new file mode 100644 index 0000000000..8de01c5967 --- /dev/null +++ b/FreeRTOS/Test/Target/tests/smp/schedule_affinity/schedule_affinity.c @@ -0,0 +1,231 @@ +/* + * FreeRTOS V202212.00 + * Copyright (C) 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * + */ + +/** + * @file schedule_affinity.c + * @brief The scheduler shall not schedule a task that is pinned to a specific core on any other core. + * + * Procedure: + * - Create 2 * ( num of cores ) tasks ( T0, ..., Tn-1, Tn, ..., T2n-1 ). + * - Pin T0 to core 0, T1 to core 1, and so on. + * - Pin Tn to core 0, Tn+1 to core 1, and so on. Note that this way Tx and + * Tn+x are pinned to the same core. + * - Verify the following conditions: + * - Tx+n is not running when Tx is running. + * - Tx is not running when Tx+n is running. + * - Both Tx and Tx+n can only run on core x. + * Expected: + * - All tasks will only run on the cores that they were pinned to. + */ + +/* Standard includes. */ +#include + +/* Kernel includes. */ +#include "FreeRTOS.h" +#include "task.h" + +/* Unit testing support functions. */ +#include "unity.h" +/*-----------------------------------------------------------*/ + +/** + * @brief Timeout value to stop test. + */ +#define TEST_TIMEOUT_MS ( 1000 ) +/*-----------------------------------------------------------*/ + +#if ( configNUMBER_OF_CORES < 2 ) + #error This test is for FreeRTOS SMP and therefore, requires at least 2 cores. +#endif /* if configNUMBER_OF_CORES != 2 */ + +#if ( configMAX_PRIORITIES <= ( configNUMBER_OF_CORES + 2 ) ) + #error configMAX_PRIORITIES must be larger than ( configNUMBER_OF_CORES + 2 ) to avoid scheduling idle tasks unexpectedly. +#endif /* if ( configMAX_PRIORITIES <= ( configNUMBER_OF_CORES + 2 ) ) */ +/*-----------------------------------------------------------*/ + +/** + * @brief Test case "Schedule Affinity". + */ +void Test_ScheduleAffinity( void ); + +/** + * @brief The task function that verifies that tasks are pinned to correct core. + */ +static void prvTaskCheckPinCore( void * pvParameters ); +/*-----------------------------------------------------------*/ + +/** + * @brief Handles of the tasks created in this test. + */ +static TaskHandle_t xTaskHandles[ configNUMBER_OF_CORES * 2 ]; + +/** + * @brief Indexes of the tasks created in this test. + */ +static uint32_t xTaskIndexes[ configNUMBER_OF_CORES * 2 ]; + +/** + * @brief Test results for tasks T0~T2n-1. + */ +static BaseType_t xTestResults[ configNUMBER_OF_CORES * 2 ] = { pdFAIL }; + +/** + * @brief Flag to indicate that all tasks in this test are created. + */ +static volatile BaseType_t xAllTasksCreated = pdFALSE; +/*-----------------------------------------------------------*/ + +static void prvTaskCheckPinCore( void * pvParameters ) +{ + uint32_t currentTaskIdx = *( ( uint32_t * ) pvParameters ); + uint32_t pinToSameCoreTaskIdx; + eTaskState taskState; + BaseType_t testResult = pdPASS; + BaseType_t xCore; + + /* Busy looping here to wait for test runner to create all the test tasks. + * Test runner has timeout to prevent infinite blocking here. */ + while( xAllTasksCreated == pdFALSE ) + { + } + + /* Find out the task index which is pinned to the same core. */ + if( currentTaskIdx >= configNUMBER_OF_CORES ) + { + pinToSameCoreTaskIdx = currentTaskIdx - configNUMBER_OF_CORES; + xCore = pinToSameCoreTaskIdx; + } + else + { + pinToSameCoreTaskIdx = currentTaskIdx + configNUMBER_OF_CORES; + xCore = currentTaskIdx; + } + + /* Verify that the task is running on the core it is pinned to. */ + taskState = eTaskGetState( xTaskHandles[ currentTaskIdx ] ); + + if( taskState != eRunning ) + { + testResult = pdFAIL; + } + + if( xCore != portGET_CORE_ID() ) + { + testResult = pdFAIL; + } + + /* Verify that the other task pinned to the same core is not running. */ + taskState = eTaskGetState( xTaskHandles[ pinToSameCoreTaskIdx ] ); + + if( taskState == eRunning ) + { + testResult = pdFAIL; + } + + xTestResults[ currentTaskIdx ] = testResult; + + /* Suspend the test task. */ + vTaskSuspend( NULL ); +} +/*-----------------------------------------------------------*/ + +void Test_ScheduleAffinity( void ) +{ + uint32_t i; + BaseType_t xTaskCreationResult; + + /* Create ( configNUMBER_OF_CORES * 2 ) low priority tasks. */ + for( i = 0; i < ( configNUMBER_OF_CORES * 2 ); i++ ) + { + xTaskCreationResult = xTaskCreateAffinitySet( prvTaskCheckPinCore, + "CheckPinCore", + configMINIMAL_STACK_SIZE, + &( xTaskIndexes[ i ] ), + configMAX_PRIORITIES - 2 - ( i % configNUMBER_OF_CORES ), + ( 1U << ( i % configNUMBER_OF_CORES ) ), + &( xTaskHandles[ i ] ) ); + + TEST_ASSERT_EQUAL_MESSAGE( pdPASS, xTaskCreationResult, "Task creation failed." ); + } + + /* Wait for test tasks finish test. */ + xAllTasksCreated = pdTRUE; + vTaskDelay( pdMS_TO_TICKS( TEST_TIMEOUT_MS ) ); + + /* Verify the test result. */ + for( i = 0; i < ( configNUMBER_OF_CORES * 2 ); i++ ) + { + TEST_ASSERT_TRUE( xTestResults[ i ] == pdPASS ); + } +} +/*-----------------------------------------------------------*/ + +/* Runs before every test, put init calls here. */ +void setUp( void ) +{ + uint32_t i; + + xAllTasksCreated = pdFALSE; + + for( i = 0; i < ( configNUMBER_OF_CORES * 2 ); i++ ) + { + xTaskIndexes[ i ] = i; + xTaskHandles[ i ] = NULL; + xTestResults[ i ] = pdFAIL; + } +} +/*-----------------------------------------------------------*/ + +/* Runs after every test, put clean-up calls here. */ +void tearDown( void ) +{ + uint32_t i; + + /* Delete all the tasks created in the test. */ + for( i = 0; i < ( configNUMBER_OF_CORES * 2 ); i++ ) + { + if( xTaskHandles[ i ] != NULL ) + { + vTaskDelete( xTaskHandles[ i ] ); + xTaskHandles[ i ] = NULL; + } + } +} +/*-----------------------------------------------------------*/ + +/** + * @brief Entry point for test runner to run schedule affinity test. + */ +void vRunScheduleAffinityTest( void ) +{ + UNITY_BEGIN(); + + RUN_TEST( Test_ScheduleAffinity ); + + UNITY_END(); +} +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Test/Target/tests/smp/schedule_affinity/test_config.h b/FreeRTOS/Test/Target/tests/smp/schedule_affinity/test_config.h new file mode 100644 index 0000000000..2d9cdabe3a --- /dev/null +++ b/FreeRTOS/Test/Target/tests/smp/schedule_affinity/test_config.h @@ -0,0 +1,63 @@ +/* + * FreeRTOS V202212.00 + * Copyright (C) 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * + */ + +#ifndef TEST_CONFIG_H +#define TEST_CONFIG_H + +/* This file must be included at the end of the FreeRTOSConfig.h. It contains + * any FreeRTOS specific configurations that the test requires. */ + +#ifdef configRUN_MULTIPLE_PRIORITIES + #undef configRUN_MULTIPLE_PRIORITIES +#endif /* ifdef configRUN_MULTIPLE_PRIORITIES */ + +#ifdef configUSE_CORE_AFFINITY + #undef configUSE_CORE_AFFINITY +#endif /* ifdef configUSE_CORE_AFFINITY */ + +#ifdef configUSE_TIME_SLICING + #undef configUSE_TIME_SLICING +#endif /* ifdef configUSE_TIME_SLICING */ + +#ifdef configUSE_PREEMPTION + #undef configUSE_PREEMPTION +#endif /* ifdef configUSE_PREEMPTION */ + +#define configRUN_MULTIPLE_PRIORITIES 1 +#define configUSE_CORE_AFFINITY 1 +#define configUSE_TIME_SLICING 1 +#define configUSE_PREEMPTION 1 + +/*-----------------------------------------------------------*/ + +/** + * @brief Entry point for test runner to run schedule affinity test. + */ +void vRunScheduleAffinityTest( void ); + +/*-----------------------------------------------------------*/ + +#endif /* ifndef TEST_CONFIG_H */ From 2adaf8471f41c4ff7923d1b09b4ceebc7f71f8ac Mon Sep 17 00:00:00 2001 From: chinglee-iot <61685396+chinglee-iot@users.noreply.github.com> Date: Tue, 27 Feb 2024 12:13:27 +0800 Subject: [PATCH 08/15] Add SMP disable preemption on target test (#1175) * Add SMP disable preemption on target test --------- Signed-off-by: Gaurav Aggarwal Co-authored-by: Gaurav Aggarwal Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com> --- .../smp/disable_preemption/CMakeLists.txt | 33 +++ .../disable_preemption_test_runner.c | 75 ++++++ .../disable_preemption/disable_preemption.c | 250 ++++++++++++++++++ .../smp/disable_preemption/test_config.h | 63 +++++ 4 files changed, 421 insertions(+) create mode 100644 FreeRTOS/Test/Target/boards/pico/tests/smp/disable_preemption/CMakeLists.txt create mode 100644 FreeRTOS/Test/Target/boards/pico/tests/smp/disable_preemption/disable_preemption_test_runner.c create mode 100644 FreeRTOS/Test/Target/tests/smp/disable_preemption/disable_preemption.c create mode 100644 FreeRTOS/Test/Target/tests/smp/disable_preemption/test_config.h diff --git a/FreeRTOS/Test/Target/boards/pico/tests/smp/disable_preemption/CMakeLists.txt b/FreeRTOS/Test/Target/boards/pico/tests/smp/disable_preemption/CMakeLists.txt new file mode 100644 index 0000000000..bc5d63330c --- /dev/null +++ b/FreeRTOS/Test/Target/boards/pico/tests/smp/disable_preemption/CMakeLists.txt @@ -0,0 +1,33 @@ +cmake_minimum_required(VERSION 3.13) + +project(example C CXX ASM) +set(CMAKE_C_STANDARD 11) +set(CMAKE_CXX_STANDARD 17) + +set(TEST_INCLUDE_PATHS ${CMAKE_CURRENT_LIST_DIR}/../../../../../tests/smp/disable_preemption) +set(TEST_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../../../../../tests/smp/disable_preemption) + +add_library(disable_preemption INTERFACE) +target_sources(disable_preemption INTERFACE + ${BOARD_LIBRARY_DIR}/main.c + ${CMAKE_CURRENT_LIST_DIR}/disable_preemption_test_runner.c + ${TEST_SOURCE_DIR}/disable_preemption.c) + +target_include_directories(disable_preemption INTERFACE + ${CMAKE_CURRENT_LIST_DIR}/../../.. + ${TEST_INCLUDE_PATHS} + ) + +target_link_libraries(disable_preemption INTERFACE + FreeRTOS-Kernel + FreeRTOS-Kernel-Heap4 + ${BOARD_LINK_LIBRARIES}) + +add_executable(test_disable_preemption) +enable_board_functions(test_disable_preemption) +target_link_libraries(test_disable_preemption disable_preemption) +target_include_directories(test_disable_preemption PUBLIC + ${BOARD_INCLUDE_PATHS}) +target_compile_definitions(test_disable_preemption PRIVATE + ${BOARD_DEFINES} +) diff --git a/FreeRTOS/Test/Target/boards/pico/tests/smp/disable_preemption/disable_preemption_test_runner.c b/FreeRTOS/Test/Target/boards/pico/tests/smp/disable_preemption/disable_preemption_test_runner.c new file mode 100644 index 0000000000..18118b0d8c --- /dev/null +++ b/FreeRTOS/Test/Target/boards/pico/tests/smp/disable_preemption/disable_preemption_test_runner.c @@ -0,0 +1,75 @@ +/* + * FreeRTOS V202212.00 + * Copyright (C) 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * + */ + +/** + * @file disable_preemption_test_runner.c + * @brief The implementation of main function to start test runner task. + * + * Procedure: + * - Initialize environment + * - Run the test case + */ + +/* Kernel includes. */ +#include "FreeRTOS.h" +#include "task.h" + +/* Unit testing support functions. */ +#include "unity.h" + +/* Pico includes. */ +#include "pico/multicore.h" +#include "pico/stdlib.h" + +/*-----------------------------------------------------------*/ + +static void prvTestRunnerTask( void * pvParameters ); + +/*-----------------------------------------------------------*/ + +static void prvTestRunnerTask( void * pvParameters ) +{ + ( void ) pvParameters; + + /* Run test case. */ + vRunDisablePreemptionTest(); + + vTaskDelete( NULL ); +} + +/*-----------------------------------------------------------*/ + +void vRunTest( void ) +{ + xTaskCreate( prvTestRunnerTask, + "testRunner", + configMINIMAL_STACK_SIZE, + NULL, + configMAX_PRIORITIES - 1, + NULL ); +} + +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Test/Target/tests/smp/disable_preemption/disable_preemption.c b/FreeRTOS/Test/Target/tests/smp/disable_preemption/disable_preemption.c new file mode 100644 index 0000000000..9587cb13ae --- /dev/null +++ b/FreeRTOS/Test/Target/tests/smp/disable_preemption/disable_preemption.c @@ -0,0 +1,250 @@ +/* + * FreeRTOS V202212.00 + * Copyright (C) 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * + */ + +/** + * @file disable_preemption.c + * @brief The scheduler shall not preempt a task for which preemption is disabled. + * + * Procedure: + * - Create ( num of cores + 1 ) tasks ( T0~Tn ) with priorities T0 > T1 > ... Tn. + * T0 has the highest priority and Tn has the lowest priority. + * - T0~Tn-1 suspend themselves. + * - Tn disables preemption for itself and then resumes ( T0~Tn-1 ). Test + * runner validates that Tn is still running. + * - Test runner enables preemption of Tn. Test runner validates that Tn is + * no longer running. + * Expected: + * - Tn will not be switched out when it has disabled preemption for itself. + * - Tn will be preempted when the test runner enables preemption for it. + */ + +/* Standard includes. */ +#include + +/* Kernel includes. */ +#include "FreeRTOS.h" +#include "task.h" + +/* Unit testing support functions. */ +#include "unity.h" +/*-----------------------------------------------------------*/ + +/** + * @brief Timeout value to stop test. + */ +#define TEST_TIMEOUT_MS ( 1000 ) + +/** + * @brief Nop operation for busy looping. + */ +#ifndef portNOP + #define TEST_NOP() __asm volatile ( "nop" ) +#else + #define TEST_NOP portNOP +#endif +/*-----------------------------------------------------------*/ + +#if ( configNUMBER_OF_CORES < 2 ) + #error This test is for FreeRTOS SMP and therefore, requires at least 2 cores. +#endif /* if configNUMBER_OF_CORES != 2 */ + +#if ( configUSE_TASK_PREEMPTION_DISABLE != 1 ) + #error configUSE_TASK_PREEMPTION_DISABLE must be enabled by including test_config.h in FreeRTOSConfig.h. +#endif /* if configUSE_TASK_PREEMPTION_DISABLE != 1 */ + +#if ( configMAX_PRIORITIES <= ( configNUMBER_OF_CORES + 2 ) ) + #error configMAX_PRIORITIES must be larger than ( configNUMBER_OF_CORES + 2 ) to avoid scheduling idle tasks unexpectedly. +#endif /* if ( configMAX_PRIORITIES <= ( configNUMBER_OF_CORES + 2 ) ) */ +/*-----------------------------------------------------------*/ + +/** + * @brief Test case "Disable Preemption". + */ +void Test_DisablePreemption( void ); + +/** + * @brief Disable preemption test task. + */ +static void prvTestPreemptionDisableTask( void * pvParameters ); +/*-----------------------------------------------------------*/ + +/** + * @brief Handles of the tasks created in this test. + */ +static TaskHandle_t xTaskHandles[ configNUMBER_OF_CORES + 1 ]; + +/** + * @brief Indexes of the tasks created in this test. + */ +static uint32_t xTaskIndexes[ configNUMBER_OF_CORES + 1 ]; + +/** + * @brief Flags to indicate the test result. + */ +static BaseType_t xTestResult = pdFAIL; +/*-----------------------------------------------------------*/ + +static void prvTestPreemptionDisableTask( void * pvParameters ) +{ + uint32_t currentTaskIdx = *( ( uint32_t * ) pvParameters ); + uint32_t taskIndex; + eTaskState taskState; + BaseType_t xAllHighPriorityTasksSuspended = pdFALSE; + + if( currentTaskIdx < configNUMBER_OF_CORES ) + { + /* Tasks with smaller index have higher priority. Higher priority tasks + * suspend themselves and are resumed later by the lowest priority task + * after the lower priority task disables preemption for itself. */ + vTaskSuspend( NULL ); + } + else + { + /* Wait for all the other higher priority tasks to suspend themselves. */ + while( xAllHighPriorityTasksSuspended == pdFALSE ) + { + for( taskIndex = 0; taskIndex < configNUMBER_OF_CORES; taskIndex++ ) + { + taskState = eTaskGetState( xTaskHandles[ taskIndex ] ); + + if( taskState != eSuspended ) + { + break; + } + } + + if( taskIndex == configNUMBER_OF_CORES ) + { + xAllHighPriorityTasksSuspended = pdTRUE; + } + } + + /* Disable preemption and resume all the other higher priority tasks. + * At this point, the number of higher priority ready tasks is equal + * to the number of cores. Still this lower priority must not be + * switched out because it has disabled preemption for itself. */ + vTaskPreemptionDisable( NULL ); + + for( taskIndex = 0; taskIndex < configNUMBER_OF_CORES; taskIndex++ ) + { + vTaskResume( xTaskHandles[ taskIndex ] ); + } + + /* This task must not be switched out for any other higher priority + * ready task because it has disabled preemption for itself. The + * execution of the next line ensures that this task is not switched out + * even though a higher priority ready task is available. This variable + * is checked in the test runner. */ + xTestResult = pdPASS; + } + + /* Busy looping here to occupy this core. */ + for( ; ; ) + { + /* Always running, put nop operation here to avoid optimization by compiler. */ + TEST_NOP(); + } +} +/*-----------------------------------------------------------*/ + +void Test_DisablePreemption( void ) +{ + eTaskState taskState; + + uint32_t i; + BaseType_t xTaskCreationResult; + + /* Create ( configNUMBER_OF_CORES + 1 ) tasks with desending priorities. */ + for( i = 0; i < ( configNUMBER_OF_CORES + 1 ); i++ ) + { + xTaskCreationResult = xTaskCreate( prvTestPreemptionDisableTask, + "TestPreemptionDisable", + configMINIMAL_STACK_SIZE * 2, + &( xTaskIndexes[ i ] ), + configMAX_PRIORITIES - 2 - i, + &( xTaskHandles[ i ] ) ); + + TEST_ASSERT_EQUAL_MESSAGE( pdPASS, xTaskCreationResult, "Task creation failed." ); + } + + /* TEST_TIMEOUT_MS is long enough to run this test. */ + vTaskDelay( pdMS_TO_TICKS( TEST_TIMEOUT_MS ) ); + + /* Verify the lowest priority task runs after resuming all test tasks. */ + TEST_ASSERT_EQUAL( pdPASS, xTestResult ); + + /* Enable preemption of the lowest priority task. The scheduler must switch + * out this task now as there is a higher priority ready task available. */ + vTaskPreemptionEnable( xTaskHandles[ configNUMBER_OF_CORES ] ); + + /* Verify that the lowest priority task is not running anymore. */ + taskState = eTaskGetState( xTaskHandles[ configNUMBER_OF_CORES ] ); + TEST_ASSERT_EQUAL( eReady, taskState ); +} +/*-----------------------------------------------------------*/ + +/* Runs before every test, put init calls here. */ +void setUp( void ) +{ + uint32_t i; + + for( i = 0; i < ( configNUMBER_OF_CORES + 1 ); i++ ) + { + xTaskIndexes[ i ] = i; + xTaskHandles[ i ] = NULL; + } +} +/*-----------------------------------------------------------*/ + +/* Runs after every test, put clean-up calls here. */ +void tearDown( void ) +{ + uint32_t i; + + /* Delete all the tasks. */ + for( i = 0; i < ( configNUMBER_OF_CORES + 1 ); i++ ) + { + if( xTaskHandles[ i ] != NULL ) + { + vTaskDelete( xTaskHandles[ i ] ); + xTaskHandles[ i ] = NULL; + } + } +} +/*-----------------------------------------------------------*/ + +/** + * @brief Entry point for test runner to run disable preemption test. + */ +void vRunDisablePreemptionTest( void ) +{ + UNITY_BEGIN(); + + RUN_TEST( Test_DisablePreemption ); + + UNITY_END(); +} +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Test/Target/tests/smp/disable_preemption/test_config.h b/FreeRTOS/Test/Target/tests/smp/disable_preemption/test_config.h new file mode 100644 index 0000000000..8e63c466c0 --- /dev/null +++ b/FreeRTOS/Test/Target/tests/smp/disable_preemption/test_config.h @@ -0,0 +1,63 @@ +/* + * FreeRTOS V202212.00 + * Copyright (C) 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * + */ + +#ifndef TEST_CONFIG_H +#define TEST_CONFIG_H + +/* This file must be included at the end of the FreeRTOSConfig.h. It contains + * any FreeRTOS specific configurations that the test requires. */ + +#ifdef configRUN_MULTIPLE_PRIORITIES + #undef configRUN_MULTIPLE_PRIORITIES +#endif /* ifdef configRUN_MULTIPLE_PRIORITIES */ + +#ifdef configUSE_TASK_PREEMPTION_DISABLE + #undef configUSE_TASK_PREEMPTION_DISABLE +#endif /* ifdef configUSE_TASK_PREEMPTION_DISABLE */ + +#ifdef configUSE_TIME_SLICING + #undef configUSE_TIME_SLICING +#endif /* ifdef configUSE_TIME_SLICING */ + +#ifdef configUSE_PREEMPTION + #undef configUSE_PREEMPTION +#endif /* ifdef configUSE_PREEMPTION */ + +#define configRUN_MULTIPLE_PRIORITIES 1 +#define configUSE_TASK_PREEMPTION_DISABLE 1 +#define configUSE_TIME_SLICING 1 +#define configUSE_PREEMPTION 1 + +/*-----------------------------------------------------------*/ + +/** + * @brief Entry point for test runner to run disable preemption test. + */ +void vRunDisablePreemptionTest( void ); + +/*-----------------------------------------------------------*/ + +#endif /* ifndef TEST_CONFIG_H */ From 77cc06d6925ef4ef3dcbbcd18e0c4105ce059cac Mon Sep 17 00:00:00 2001 From: Rahul Kar <118818625+kar-rahul-aws@users.noreply.github.com> Date: Mon, 4 Mar 2024 14:48:17 +0530 Subject: [PATCH 09/15] Fix demo build issue , when configUSE_TRACE_FACILITY is disabled (#1189) This PR enables the FreeRTOS Posix Blinky GCC Demo to be used without the configUSE_TRACE_FACILITY enabled. It is achieved by using `-DNO_TRACING=1` CMake option to disable tracing. By default, -DNO_TRACING is set to 0, and the tracing is enabled. --- FreeRTOS/Demo/Posix_GCC/CMakeLists.txt | 2 +- .../Demo/Posix_GCC/code_coverage_additions.c | 372 +++++++++--------- FreeRTOS/Demo/Posix_GCC/main_full.c | 32 +- 3 files changed, 214 insertions(+), 192 deletions(-) diff --git a/FreeRTOS/Demo/Posix_GCC/CMakeLists.txt b/FreeRTOS/Demo/Posix_GCC/CMakeLists.txt index 8abeb4ef87..4917ed3f21 100644 --- a/FreeRTOS/Demo/Posix_GCC/CMakeLists.txt +++ b/FreeRTOS/Demo/Posix_GCC/CMakeLists.txt @@ -10,7 +10,7 @@ else() add_compile_options( -DTRACE_ON_ENTER=0 ) endif() -if( COVERAGE_TEST ) +if( ( COVERAGE_TEST ) OR ( NO_TRACING ) ) set( COVERAGE_TEST 1 ) add_compile_options( -DprojCOVERAGE_TEST=1 ) else() diff --git a/FreeRTOS/Demo/Posix_GCC/code_coverage_additions.c b/FreeRTOS/Demo/Posix_GCC/code_coverage_additions.c index f0336bc29d..00af569dff 100644 --- a/FreeRTOS/Demo/Posix_GCC/code_coverage_additions.c +++ b/FreeRTOS/Demo/Posix_GCC/code_coverage_additions.c @@ -143,129 +143,133 @@ static BaseType_t prvStaticAllocationsWithNullBuffers( void ) } /*-----------------------------------------------------------*/ -static BaseType_t prvTraceUtils( void ) -{ - EventGroupHandle_t xEventGroup; - QueueHandle_t xQueue; - BaseType_t xReturn = pdPASS; - const UBaseType_t xNumber = ( UBaseType_t ) 100, xQueueLength = ( UBaseType_t ) 1; - UBaseType_t uxValue; - TaskHandle_t xTaskHandle; - StreamBufferHandle_t xStreamBuffer; - MessageBufferHandle_t xMessageBuffer; - - /* Exercise the event group trace utilities. */ - xEventGroup = xEventGroupCreate(); +#if( configUSE_TRACE_FACILITY == 1 ) - if( xEventGroup != NULL ) + static BaseType_t prvTraceUtils( void ) { - vEventGroupSetNumber( xEventGroup, xNumber ); + EventGroupHandle_t xEventGroup; + QueueHandle_t xQueue; + BaseType_t xReturn = pdPASS; + const UBaseType_t xNumber = ( UBaseType_t ) 100, xQueueLength = ( UBaseType_t ) 1; + UBaseType_t uxValue; + TaskHandle_t xTaskHandle; + StreamBufferHandle_t xStreamBuffer; + MessageBufferHandle_t xMessageBuffer; - if( uxEventGroupGetNumber( NULL ) != 0 ) + /* Exercise the event group trace utilities. */ + xEventGroup = xEventGroupCreate(); + + if( xEventGroup != NULL ) { - xReturn = pdFAIL; - } + vEventGroupSetNumber( xEventGroup, xNumber ); + + if( uxEventGroupGetNumber( NULL ) != 0 ) + { + xReturn = pdFAIL; + } - if( uxEventGroupGetNumber( xEventGroup ) != xNumber ) + if( uxEventGroupGetNumber( xEventGroup ) != xNumber ) + { + xReturn = pdFAIL; + } + + vEventGroupDelete( xEventGroup ); + } + else { xReturn = pdFAIL; } - vEventGroupDelete( xEventGroup ); - } - else - { - xReturn = pdFAIL; - } + /* Exercise the queue trace utilities. */ + xQueue = xQueueCreate( xQueueLength, ( UBaseType_t ) sizeof( uxValue ) ); - /* Exercise the queue trace utilities. */ - xQueue = xQueueCreate( xQueueLength, ( UBaseType_t ) sizeof( uxValue ) ); + if( xQueue != NULL ) + { + vQueueSetQueueNumber( xQueue, xNumber ); - if( xQueue != NULL ) - { - vQueueSetQueueNumber( xQueue, xNumber ); + if( uxQueueGetQueueNumber( xQueue ) != xNumber ) + { + xReturn = pdFAIL; + } + + if( ucQueueGetQueueType( xQueue ) != queueQUEUE_TYPE_BASE ) + { + xReturn = pdFAIL; + } - if( uxQueueGetQueueNumber( xQueue ) != xNumber ) + vQueueDelete( xQueue ); + } + else { xReturn = pdFAIL; } - if( ucQueueGetQueueType( xQueue ) != queueQUEUE_TYPE_BASE ) + /* Exercise the task trace utilities. Value of 100 is arbitrary, just + * want to check the value that is set is also read back. */ + uxValue = 100; + xTaskHandle = xTaskGetCurrentTaskHandle(); + vTaskSetTaskNumber( xTaskHandle, uxValue ); + + if( uxTaskGetTaskNumber( xTaskHandle ) != uxValue ) { xReturn = pdFAIL; } - vQueueDelete( xQueue ); - } - else - { - xReturn = pdFAIL; - } - - /* Exercise the task trace utilities. Value of 100 is arbitrary, just want - * to check the value that is set is also read back. */ - uxValue = 100; - xTaskHandle = xTaskGetCurrentTaskHandle(); - vTaskSetTaskNumber( xTaskHandle, uxValue ); + if( uxTaskGetTaskNumber( NULL ) != 0 ) + { + xReturn = pdFAIL; + } - if( uxTaskGetTaskNumber( xTaskHandle ) != uxValue ) - { - xReturn = pdFAIL; - } + /* Timer trace util functions are exercised in prvTimerQuery(). */ - if( uxTaskGetTaskNumber( NULL ) != 0 ) - { - xReturn = pdFAIL; - } - /* Timer trace util functions are exercised in prvTimerQuery(). */ + /* Exercise the stream buffer utilities. Try creating with a trigger + * level of 0, it should then get capped to 1. */ + xStreamBuffer = xStreamBufferCreate( sizeof( uint32_t ), 0 ); + if( xStreamBuffer != NULL ) + { + vStreamBufferSetStreamBufferNumber( xStreamBuffer, uxValue ); - /* Exercise the stream buffer utilities. Try creating with a trigger level - * of 0, it should then get capped to 1. */ - xStreamBuffer = xStreamBufferCreate( sizeof( uint32_t ), 0 ); + if( uxStreamBufferGetStreamBufferNumber( xStreamBuffer ) != uxValue ) + { + xReturn = pdFALSE; + } - if( xStreamBuffer != NULL ) - { - vStreamBufferSetStreamBufferNumber( xStreamBuffer, uxValue ); + if( ucStreamBufferGetStreamBufferType( xStreamBuffer ) != 0 ) + { + /* "Is Message Buffer" flag should have been 0. */ + xReturn = pdFALSE; + } - if( uxStreamBufferGetStreamBufferNumber( xStreamBuffer ) != uxValue ) - { - xReturn = pdFALSE; + vStreamBufferDelete( xStreamBuffer ); } - - if( ucStreamBufferGetStreamBufferType( xStreamBuffer ) != 0 ) + else { - /* "Is Message Buffer" flag should have been 0. */ xReturn = pdFALSE; } - vStreamBufferDelete( xStreamBuffer ); - } - else - { - xReturn = pdFALSE; - } + xMessageBuffer = xMessageBufferCreate( sizeof( uint32_t ) ); - xMessageBuffer = xMessageBufferCreate( sizeof( uint32_t ) ); + if( xMessageBuffer != NULL ) + { + if( ucStreamBufferGetStreamBufferType( xMessageBuffer ) == 0 ) + { + /* "Is Message Buffer" flag should have been 1. */ + xReturn = pdFALSE; + } - if( xMessageBuffer != NULL ) - { - if( ucStreamBufferGetStreamBufferType( xMessageBuffer ) == 0 ) + vMessageBufferDelete( xMessageBuffer ); + } + else { - /* "Is Message Buffer" flag should have been 1. */ xReturn = pdFALSE; } - vMessageBufferDelete( xMessageBuffer ); - } - else - { - xReturn = pdFALSE; + return xReturn; } - return xReturn; -} +#endif /* #if( configUSE_TRACE_FACILITY == 1 ) */ /*-----------------------------------------------------------*/ static BaseType_t prvPeekTimeout( void ) @@ -370,128 +374,132 @@ static BaseType_t prvQueueQueryFromISR( void ) } /*-----------------------------------------------------------*/ -static BaseType_t prvTaskQueryFunctions( void ) -{ - static TaskStatus_t xStatus, * pxStatusArray; - TaskHandle_t xTimerTask, xIdleTask; - BaseType_t xReturn = pdPASS; - UBaseType_t uxNumberOfTasks, uxReturned, ux; - uint32_t ulTotalRunTime1, ulTotalRunTime2; - const uint32_t ulRunTimeTollerance = ( uint32_t ) 0xfff; +#if( configUSE_TRACE_FACILITY == 1) - /* Obtain task status with the stack high water mark and without the - * state. */ - vTaskGetInfo( NULL, &xStatus, pdTRUE, eRunning ); - - if( uxTaskGetStackHighWaterMark( NULL ) != xStatus.usStackHighWaterMark ) + static BaseType_t prvTaskQueryFunctions( void ) { - xReturn = pdFAIL; - } + static TaskStatus_t xStatus, * pxStatusArray; + TaskHandle_t xTimerTask, xIdleTask; + BaseType_t xReturn = pdPASS; + UBaseType_t uxNumberOfTasks, uxReturned, ux; + uint32_t ulTotalRunTime1, ulTotalRunTime2; + const uint32_t ulRunTimeTollerance = ( uint32_t ) 0xfff; - if( uxTaskGetStackHighWaterMark2( NULL ) != ( configSTACK_DEPTH_TYPE ) xStatus.usStackHighWaterMark ) - { - xReturn = pdFAIL; - } - - /* Now obtain a task status without the high water mark but with the state, - * which in the case of the idle task should be Read. */ - xTimerTask = xTimerGetTimerDaemonTaskHandle(); - vTaskSuspend( xTimerTask ); /* Should never suspend Timer task normally!. */ - vTaskGetInfo( xTimerTask, &xStatus, pdFALSE, eInvalid ); - - if( xStatus.eCurrentState != eSuspended ) - { - xReturn = pdFAIL; - } + /* Obtain task status with the stack high water mark and without the + * state. */ + vTaskGetInfo( NULL, &xStatus, pdTRUE, eRunning ); - if( xStatus.uxBasePriority != uxTaskPriorityGetFromISR( xTimerTask ) ) - { - xReturn = pdFAIL; - } - - if( xStatus.uxBasePriority != ( configMAX_PRIORITIES - 1 ) ) - { - xReturn = pdFAIL; - } + if( uxTaskGetStackHighWaterMark( NULL ) != xStatus.usStackHighWaterMark ) + { + xReturn = pdFAIL; + } - xTaskResumeFromISR( xTimerTask ); - vTaskGetInfo( xTimerTask, &xStatus, pdTRUE, eInvalid ); + if( uxTaskGetStackHighWaterMark2( NULL ) != ( configSTACK_DEPTH_TYPE ) xStatus.usStackHighWaterMark ) + { + xReturn = pdFAIL; + } - if( ( xStatus.eCurrentState != eReady ) && ( xStatus.eCurrentState != eBlocked ) ) - { - xReturn = pdFAIL; - } + /* Now obtain a task status without the high water mark but with the state, + * which in the case of the idle task should be Read. */ + xTimerTask = xTimerGetTimerDaemonTaskHandle(); + vTaskSuspend( xTimerTask ); /* Should never suspend Timer task normally!. */ + vTaskGetInfo( xTimerTask, &xStatus, pdFALSE, eInvalid ); - if( uxTaskGetStackHighWaterMark( xTimerTask ) != xStatus.usStackHighWaterMark ) - { - xReturn = pdFAIL; - } + if( xStatus.eCurrentState != eSuspended ) + { + xReturn = pdFAIL; + } - if( uxTaskGetStackHighWaterMark2( xTimerTask ) != ( configSTACK_DEPTH_TYPE ) xStatus.usStackHighWaterMark ) - { - xReturn = pdFAIL; - } + if( xStatus.uxBasePriority != uxTaskPriorityGetFromISR( xTimerTask ) ) + { + xReturn = pdFAIL; + } - /* Attempting to abort a delay in the idle task should be guaranteed to - * fail as the idle task should never block. */ - xIdleTask = xTaskGetIdleTaskHandle(); + if( xStatus.uxBasePriority != ( configMAX_PRIORITIES - 1 ) ) + { + xReturn = pdFAIL; + } - if( xTaskAbortDelay( xIdleTask ) != pdFAIL ) - { - xReturn = pdFAIL; - } + xTaskResumeFromISR( xTimerTask ); + vTaskGetInfo( xTimerTask, &xStatus, pdTRUE, eInvalid ); - /* Create an array of task status objects large enough to hold information - * on the number of tasks at this time - note this may change at any time if - * higher priority tasks are executing and creating tasks. */ - uxNumberOfTasks = uxTaskGetNumberOfTasks(); - pxStatusArray = ( TaskStatus_t * ) pvPortMalloc( uxNumberOfTasks * sizeof( TaskStatus_t ) ); + if( ( xStatus.eCurrentState != eReady ) && ( xStatus.eCurrentState != eBlocked ) ) + { + xReturn = pdFAIL; + } - if( pxStatusArray != NULL ) - { - /* Pass part of the array into uxTaskGetSystemState() to ensure it doesn't - * try using more space than there is available. */ - uxReturned = uxTaskGetSystemState( pxStatusArray, uxNumberOfTasks / ( UBaseType_t ) 2, NULL ); + if( uxTaskGetStackHighWaterMark( xTimerTask ) != xStatus.usStackHighWaterMark ) + { + xReturn = pdFAIL; + } - if( uxReturned != ( UBaseType_t ) 0 ) + if( uxTaskGetStackHighWaterMark2( xTimerTask ) != ( configSTACK_DEPTH_TYPE ) xStatus.usStackHighWaterMark ) { xReturn = pdFAIL; } - /* Now do the same but passing in the complete array size, this is done - * twice to check for a difference in the total run time. */ - uxTaskGetSystemState( pxStatusArray, uxNumberOfTasks, &ulTotalRunTime1 ); - memset( ( void * ) pxStatusArray, 0xaa, uxNumberOfTasks * sizeof( TaskStatus_t ) ); - uxReturned = uxTaskGetSystemState( pxStatusArray, uxNumberOfTasks, &ulTotalRunTime2 ); + /* Attempting to abort a delay in the idle task should be guaranteed to + * fail as the idle task should never block. */ + xIdleTask = xTaskGetIdleTaskHandle(); - if( ( ulTotalRunTime2 - ulTotalRunTime1 ) > ulRunTimeTollerance ) + if( xTaskAbortDelay( xIdleTask ) != pdFAIL ) { xReturn = pdFAIL; } - /* Basic santity check of array contents. */ - for( ux = 0; ux < uxReturned; ux++ ) + /* Create an array of task status objects large enough to hold information + * on the number of tasks at this time - note this may change at any time if + * higher priority tasks are executing and creating tasks. */ + uxNumberOfTasks = uxTaskGetNumberOfTasks(); + pxStatusArray = ( TaskStatus_t * ) pvPortMalloc( uxNumberOfTasks * sizeof( TaskStatus_t ) ); + + if( pxStatusArray != NULL ) { - if( pxStatusArray[ ux ].eCurrentState >= ( UBaseType_t ) eInvalid ) + /* Pass part of the array into uxTaskGetSystemState() to ensure it doesn't + * try using more space than there is available. */ + uxReturned = uxTaskGetSystemState( pxStatusArray, uxNumberOfTasks / ( UBaseType_t ) 2, NULL ); + + if( uxReturned != ( UBaseType_t ) 0 ) { xReturn = pdFAIL; } - if( pxStatusArray[ ux ].uxCurrentPriority >= ( UBaseType_t ) configMAX_PRIORITIES ) + /* Now do the same but passing in the complete array size, this is done + * twice to check for a difference in the total run time. */ + uxTaskGetSystemState( pxStatusArray, uxNumberOfTasks, &ulTotalRunTime1 ); + memset( ( void * ) pxStatusArray, 0xaa, uxNumberOfTasks * sizeof( TaskStatus_t ) ); + uxReturned = uxTaskGetSystemState( pxStatusArray, uxNumberOfTasks, &ulTotalRunTime2 ); + + if( ( ulTotalRunTime2 - ulTotalRunTime1 ) > ulRunTimeTollerance ) { xReturn = pdFAIL; } + + /* Basic sanity check of array contents. */ + for( ux = 0; ux < uxReturned; ux++ ) + { + if( pxStatusArray[ ux ].eCurrentState >= ( UBaseType_t ) eInvalid ) + { + xReturn = pdFAIL; + } + + if( pxStatusArray[ ux ].uxCurrentPriority >= ( UBaseType_t ) configMAX_PRIORITIES ) + { + xReturn = pdFAIL; + } + } + + vPortFree( pxStatusArray ); + } + else + { + xReturn = pdFAIL; } - vPortFree( pxStatusArray ); - } - else - { - xReturn = pdFAIL; + return xReturn; } - return xReturn; -} +#endif /* #if( configUSE_TRACE_FACILITY == 1) */ /*-----------------------------------------------------------*/ static BaseType_t prvDummyTagFunction( void * pvParameter ) @@ -609,12 +617,16 @@ static BaseType_t prvTimerQuery( void ) xReturn = pdFAIL; } - vTimerSetTimerNumber( xTimer, uxTimerNumber ); - - if( uxTimerGetTimerNumber( xTimer ) != uxTimerNumber ) + #if( configUSE_TRACE_FACILITY == 1 ) { - xReturn = pdFAIL; + vTimerSetTimerNumber( xTimer, uxTimerNumber ); + + if( uxTimerGetTimerNumber( xTimer ) != uxTimerNumber ) + { + xReturn = pdFAIL; + } } + #endif /* #if( configUSE_TRACE_FACILITY == 1 ) */ xTimerDelete( xTimer, portMAX_DELAY ); } @@ -632,10 +644,16 @@ BaseType_t xRunCodeCoverageTestAdditions( void ) BaseType_t xReturn = pdPASS; xReturn &= prvStaticAllocationsWithNullBuffers(); - xReturn &= prvTraceUtils(); + + #if( configUSE_TRACE_FACILITY == 1 ) + { + xReturn &= prvTraceUtils(); + xReturn &= prvTaskQueryFunctions(); + } + #endif + xReturn &= prvPeekTimeout(); xReturn &= prvQueueQueryFromISR(); - xReturn &= prvTaskQueryFunctions(); xReturn &= prvTaskTags(); xReturn &= prvTimerQuery(); diff --git a/FreeRTOS/Demo/Posix_GCC/main_full.c b/FreeRTOS/Demo/Posix_GCC/main_full.c index 0e966f6a2f..fe395b2b84 100644 --- a/FreeRTOS/Demo/Posix_GCC/main_full.c +++ b/FreeRTOS/Demo/Posix_GCC/main_full.c @@ -737,22 +737,26 @@ static void prvDemonstrateTaskStateAndHandleGetFunctions( void ) xErrorCount++; } - /* Also with the vTaskGetInfo() function. */ - vTaskGetInfo( xTimerTaskHandle, /* The task being queried. */ - &xTaskInfo, /* The structure into which information on the task will be written. */ - pdTRUE, /* Include the task's high watermark in the structure. */ - eInvalid ); /* Include the task state in the structure. */ - - /* Check the information returned by vTaskGetInfo() is as expected. */ - if( ( xTaskInfo.eCurrentState != eBlocked ) || - ( strcmp( xTaskInfo.pcTaskName, "Tmr Svc" ) != 0 ) || - ( xTaskInfo.uxCurrentPriority != configTIMER_TASK_PRIORITY ) || - ( xTaskInfo.pxStackBase != uxTimerTaskStack ) || - ( xTaskInfo.xHandle != xTimerTaskHandle ) ) + #if( configUSE_TRACE_FACILITY == 1 ) { - pcStatusMessage = "Error: vTaskGetInfo() returned incorrect information about the timer task"; - xErrorCount++; + /* Also with the vTaskGetInfo() function. */ + vTaskGetInfo( xTimerTaskHandle, /* The task being queried. */ + &xTaskInfo, /* The structure into which information on the task will be written. */ + pdTRUE, /* Include the task's high watermark in the structure. */ + eInvalid ); /* Include the task state in the structure. */ + + /* Check the information returned by vTaskGetInfo() is as expected. */ + if( ( xTaskInfo.eCurrentState != eBlocked ) || + ( strcmp( xTaskInfo.pcTaskName, "Tmr Svc" ) != 0 ) || + ( xTaskInfo.uxCurrentPriority != configTIMER_TASK_PRIORITY ) || + ( xTaskInfo.pxStackBase != uxTimerTaskStack ) || + ( xTaskInfo.xHandle != xTimerTaskHandle ) ) + { + pcStatusMessage = "Error: vTaskGetInfo() returned incorrect information about the timer task"; + xErrorCount++; + } } + #endif /* #if( configUSE_TRACE_FACILITY == 1 ) */ /* Other tests that should only be performed once follow. The test task * is not created on each iteration because to do so would cause the death From e9593edb3973133778669766768f4df0c3e5d473 Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Wed, 6 Mar 2024 14:56:42 +0800 Subject: [PATCH 10/15] Select correct startup project. (#1190) --- .../fleet_provisioning_demo.sln | 4 ++-- .../Ota_Over_Mqtt_Demo/ota_over_mqtt_demo.sln | 4 ++-- .../FreeRTOS_Plus_TCP_Minimal.sln | 4 ++-- .../HTTP_Mutual_Auth/http_mutual_auth_demo.sln | 4 ++-- .../HTTP_Plaintext/http_plain_text_demo.sln | 4 ++-- .../HTTP_S3_Download/http_s3_download_demo.sln | 4 ++-- .../http_s3_download_multithreaded_demo.sln | 4 ++-- .../HTTP_S3_Upload/http_s3_upload_demo.sln | 4 ++-- .../corePKCS11_MQTT_Mutual_Auth.sln | 4 ++-- .../Demo/corePKCS11_Windows_Simulator/CorePKCS11_Demos.sln | 4 ++-- .../Demo/coreSNTP_Windows_Simulator/core_sntp_demo.sln | 4 ++-- 11 files changed, 22 insertions(+), 22 deletions(-) diff --git a/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo/fleet_provisioning_demo.sln b/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo/fleet_provisioning_demo.sln index 88c8096a7e..1398ad922b 100644 --- a/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo/fleet_provisioning_demo.sln +++ b/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo/fleet_provisioning_demo.sln @@ -2,12 +2,12 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.33027.164 MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Fleet Provisioning Demo", "fleet_provisioning_demo.vcxproj", "{382DC80F-E278-4BC9-9DB6-59014486DA0F}" +EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FreeRTOS-Kernel", "..\..\..\..\VisualStudio_StaticProjects\FreeRTOS-Kernel\FreeRTOS-Kernel.vcxproj", "{72C209C4-49A4-4942-A201-44706C9D77EC}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FreeRTOS+TCP", "..\..\..\..\VisualStudio_StaticProjects\FreeRTOS+TCP\FreeRTOS+TCP.vcxproj", "{C90E6CC5-818B-4C97-8876-0986D989387C}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Fleet Provisioning Demo", "fleet_provisioning_demo.vcxproj", "{382DC80F-E278-4BC9-9DB6-59014486DA0F}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Logging", "..\..\..\..\VisualStudio_StaticProjects\Logging\Logging.vcxproj", "{BE362AC0-B10B-4276-B84E-6304652BA228}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MbedTLS", "..\..\..\..\VisualStudio_StaticProjects\MbedTLS\MbedTLS.vcxproj", "{E1016F3E-94E9-4864-9FD8-1D7C1FEFBFD7}" diff --git a/FreeRTOS-Plus/Demo/AWS/Ota_Windows_Simulator/Ota_Over_Mqtt_Demo/ota_over_mqtt_demo.sln b/FreeRTOS-Plus/Demo/AWS/Ota_Windows_Simulator/Ota_Over_Mqtt_Demo/ota_over_mqtt_demo.sln index 4167cf4884..2089fce8c1 100644 --- a/FreeRTOS-Plus/Demo/AWS/Ota_Windows_Simulator/Ota_Over_Mqtt_Demo/ota_over_mqtt_demo.sln +++ b/FreeRTOS-Plus/Demo/AWS/Ota_Windows_Simulator/Ota_Over_Mqtt_Demo/ota_over_mqtt_demo.sln @@ -2,6 +2,8 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.31205.134 MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Ota_Over_Mqtt_Demo", "Ota_Over_Mqtt_Demo.vcxproj", "{4BE4E103-5BF4-4A85-9656-EC20852A2B8E}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Statically Linked Libraries", "Statically Linked Libraries", "{9799AFF4-25E2-43CD-8829-C066177E3748}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FreeRTOS+TCP", "..\..\..\..\VisualStudio_StaticProjects\FreeRTOS+TCP\FreeRTOS+TCP.vcxproj", "{C90E6CC5-818B-4C97-8876-0986D989387C}" @@ -12,8 +14,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Logging", "..\..\..\..\Visu EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MbedTLS", "..\..\..\..\VisualStudio_StaticProjects\MbedTLS\MbedTLS.vcxproj", "{E1016F3E-94E9-4864-9FD8-1D7C1FEFBFD7}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Ota_Over_Mqtt_Demo", "Ota_Over_Mqtt_Demo.vcxproj", "{4BE4E103-5BF4-4A85-9656-EC20852A2B8E}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Minimal_Windows_Simulator/FreeRTOS_Plus_TCP_Minimal.sln b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Minimal_Windows_Simulator/FreeRTOS_Plus_TCP_Minimal.sln index 01c369e11d..e01e8554a5 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Minimal_Windows_Simulator/FreeRTOS_Plus_TCP_Minimal.sln +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Minimal_Windows_Simulator/FreeRTOS_Plus_TCP_Minimal.sln @@ -2,12 +2,12 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.33027.164 MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FreeRTOS_Plus_TCP_Minimal", "FreeRTOS_Plus_TCP_Minimal.vcxproj", "{382DC80F-E278-4BC9-9DB6-59014486DA0F}" +EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FreeRTOS-Kernel", "..\..\VisualStudio_StaticProjects\FreeRTOS-Kernel\FreeRTOS-Kernel.vcxproj", "{72C209C4-49A4-4942-A201-44706C9D77EC}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FreeRTOS+TCP", "..\..\VisualStudio_StaticProjects\FreeRTOS+TCP\FreeRTOS+TCP.vcxproj", "{C90E6CC5-818B-4C97-8876-0986D989387C}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FreeRTOS_Plus_TCP_Minimal", "FreeRTOS_Plus_TCP_Minimal.vcxproj", "{382DC80F-E278-4BC9-9DB6-59014486DA0F}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Logging", "..\..\VisualStudio_StaticProjects\Logging\Logging.vcxproj", "{BE362AC0-B10B-4276-B84E-6304652BA228}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Statically Linked Libraries", "Statically Linked Libraries", "{190A6643-3DE4-49DC-96AA-7867C5E0A835}" diff --git a/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/HTTP_Mutual_Auth/http_mutual_auth_demo.sln b/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/HTTP_Mutual_Auth/http_mutual_auth_demo.sln index b08d576528..9f504014cf 100644 --- a/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/HTTP_Mutual_Auth/http_mutual_auth_demo.sln +++ b/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/HTTP_Mutual_Auth/http_mutual_auth_demo.sln @@ -2,12 +2,12 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.33027.164 MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CoreHTTP_Mutual_Auth", "CoreHTTP_Mutual_Auth.vcxproj", "{382DC80F-E278-4BC9-9DB6-59014486DA0F}" +EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FreeRTOS-Kernel", "..\..\..\VisualStudio_StaticProjects\FreeRTOS-Kernel\FreeRTOS-Kernel.vcxproj", "{72C209C4-49A4-4942-A201-44706C9D77EC}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FreeRTOS+TCP", "..\..\..\VisualStudio_StaticProjects\FreeRTOS+TCP\FreeRTOS+TCP.vcxproj", "{C90E6CC5-818B-4C97-8876-0986D989387C}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CoreHTTP_Mutual_Auth", "CoreHTTP_Mutual_Auth.vcxproj", "{382DC80F-E278-4BC9-9DB6-59014486DA0F}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "coreHTTP", "..\..\..\VisualStudio_StaticProjects\coreHTTP\coreHTTP.vcxproj", "{EE39FA0F-CEFB-4C29-A571-05A28FDD47FD}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Logging", "..\..\..\VisualStudio_StaticProjects\Logging\Logging.vcxproj", "{BE362AC0-B10B-4276-B84E-6304652BA228}" diff --git a/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/HTTP_Plaintext/http_plain_text_demo.sln b/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/HTTP_Plaintext/http_plain_text_demo.sln index 29c901be07..1eebb7726b 100644 --- a/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/HTTP_Plaintext/http_plain_text_demo.sln +++ b/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/HTTP_Plaintext/http_plain_text_demo.sln @@ -2,12 +2,12 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.33027.164 MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CoreHTTP_Plaintext", "CoreHTTP_Plaintext.vcxproj", "{382DC80F-E278-4BC9-9DB6-59014486DA0F}" +EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FreeRTOS-Kernel", "..\..\..\VisualStudio_StaticProjects\FreeRTOS-Kernel\FreeRTOS-Kernel.vcxproj", "{72C209C4-49A4-4942-A201-44706C9D77EC}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FreeRTOS+TCP", "..\..\..\VisualStudio_StaticProjects\FreeRTOS+TCP\FreeRTOS+TCP.vcxproj", "{C90E6CC5-818B-4C97-8876-0986D989387C}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CoreHTTP_Plaintext", "CoreHTTP_Plaintext.vcxproj", "{382DC80F-E278-4BC9-9DB6-59014486DA0F}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "coreHTTP", "..\..\..\VisualStudio_StaticProjects\coreHTTP\coreHTTP.vcxproj", "{EE39FA0F-CEFB-4C29-A571-05A28FDD47FD}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Logging", "..\..\..\VisualStudio_StaticProjects\Logging\Logging.vcxproj", "{BE362AC0-B10B-4276-B84E-6304652BA228}" diff --git a/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/HTTP_S3_Download/http_s3_download_demo.sln b/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/HTTP_S3_Download/http_s3_download_demo.sln index 252f6bf8b7..1322c1212e 100644 --- a/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/HTTP_S3_Download/http_s3_download_demo.sln +++ b/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/HTTP_S3_Download/http_s3_download_demo.sln @@ -2,12 +2,12 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.33027.164 MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CoreHTTP_S3_Download", "CoreHTTP_S3_Download.vcxproj", "{382DC80F-E278-4BC9-9DB6-59014486DA0F}" +EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FreeRTOS-Kernel", "..\..\..\VisualStudio_StaticProjects\FreeRTOS-Kernel\FreeRTOS-Kernel.vcxproj", "{72C209C4-49A4-4942-A201-44706C9D77EC}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FreeRTOS+TCP", "..\..\..\VisualStudio_StaticProjects\FreeRTOS+TCP\FreeRTOS+TCP.vcxproj", "{C90E6CC5-818B-4C97-8876-0986D989387C}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CoreHTTP_S3_Download", "CoreHTTP_S3_Download.vcxproj", "{382DC80F-E278-4BC9-9DB6-59014486DA0F}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "coreHTTP", "..\..\..\VisualStudio_StaticProjects\coreHTTP\coreHTTP.vcxproj", "{EE39FA0F-CEFB-4C29-A571-05A28FDD47FD}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Logging", "..\..\..\VisualStudio_StaticProjects\Logging\Logging.vcxproj", "{BE362AC0-B10B-4276-B84E-6304652BA228}" diff --git a/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/HTTP_S3_Download_Multithreaded/http_s3_download_multithreaded_demo.sln b/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/HTTP_S3_Download_Multithreaded/http_s3_download_multithreaded_demo.sln index 007b512710..35900706b0 100644 --- a/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/HTTP_S3_Download_Multithreaded/http_s3_download_multithreaded_demo.sln +++ b/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/HTTP_S3_Download_Multithreaded/http_s3_download_multithreaded_demo.sln @@ -2,12 +2,12 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.33027.164 MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CoreHTTP_S3_Download_Multithreaded", "CoreHTTP_S3_Download_Multithreaded.vcxproj", "{382DC80F-E278-4BC9-9DB6-59014486DA0F}" +EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FreeRTOS-Kernel", "..\..\..\VisualStudio_StaticProjects\FreeRTOS-Kernel\FreeRTOS-Kernel.vcxproj", "{72C209C4-49A4-4942-A201-44706C9D77EC}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FreeRTOS+TCP", "..\..\..\VisualStudio_StaticProjects\FreeRTOS+TCP\FreeRTOS+TCP.vcxproj", "{C90E6CC5-818B-4C97-8876-0986D989387C}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CoreHTTP_S3_Download_Multithreaded", "CoreHTTP_S3_Download_Multithreaded.vcxproj", "{382DC80F-E278-4BC9-9DB6-59014486DA0F}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "coreHTTP", "..\..\..\VisualStudio_StaticProjects\coreHTTP\coreHTTP.vcxproj", "{EE39FA0F-CEFB-4C29-A571-05A28FDD47FD}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Logging", "..\..\..\VisualStudio_StaticProjects\Logging\Logging.vcxproj", "{BE362AC0-B10B-4276-B84E-6304652BA228}" diff --git a/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/HTTP_S3_Upload/http_s3_upload_demo.sln b/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/HTTP_S3_Upload/http_s3_upload_demo.sln index a6835acc82..adb6d8aec6 100644 --- a/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/HTTP_S3_Upload/http_s3_upload_demo.sln +++ b/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/HTTP_S3_Upload/http_s3_upload_demo.sln @@ -2,12 +2,12 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.33027.164 MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CoreHTTP_S3_Upload", "CoreHTTP_S3_Upload.vcxproj", "{382DC80F-E278-4BC9-9DB6-59014486DA0F}" +EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FreeRTOS-Kernel", "..\..\..\VisualStudio_StaticProjects\FreeRTOS-Kernel\FreeRTOS-Kernel.vcxproj", "{72C209C4-49A4-4942-A201-44706C9D77EC}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FreeRTOS+TCP", "..\..\..\VisualStudio_StaticProjects\FreeRTOS+TCP\FreeRTOS+TCP.vcxproj", "{C90E6CC5-818B-4C97-8876-0986D989387C}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CoreHTTP_S3_Upload", "CoreHTTP_S3_Upload.vcxproj", "{382DC80F-E278-4BC9-9DB6-59014486DA0F}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "coreHTTP", "..\..\..\VisualStudio_StaticProjects\coreHTTP\coreHTTP.vcxproj", "{EE39FA0F-CEFB-4C29-A571-05A28FDD47FD}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Logging", "..\..\..\VisualStudio_StaticProjects\Logging\Logging.vcxproj", "{BE362AC0-B10B-4276-B84E-6304652BA228}" diff --git a/FreeRTOS-Plus/Demo/corePKCS11_MQTT_Mutual_Auth_Windows_Simulator/corePKCS11_MQTT_Mutual_Auth.sln b/FreeRTOS-Plus/Demo/corePKCS11_MQTT_Mutual_Auth_Windows_Simulator/corePKCS11_MQTT_Mutual_Auth.sln index a468f18935..46e454a458 100644 --- a/FreeRTOS-Plus/Demo/corePKCS11_MQTT_Mutual_Auth_Windows_Simulator/corePKCS11_MQTT_Mutual_Auth.sln +++ b/FreeRTOS-Plus/Demo/corePKCS11_MQTT_Mutual_Auth_Windows_Simulator/corePKCS11_MQTT_Mutual_Auth.sln @@ -2,12 +2,12 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.33027.164 MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "corePKCS11_MQTT_Mutual_Auth", "corePKCS11_MQTT_Mutual_Auth.vcxproj", "{382DC80F-E278-4BC9-9DB6-59014486DA0F}" +EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FreeRTOS-Kernel", "..\..\VisualStudio_StaticProjects\FreeRTOS-Kernel\FreeRTOS-Kernel.vcxproj", "{72C209C4-49A4-4942-A201-44706C9D77EC}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FreeRTOS+TCP", "..\..\VisualStudio_StaticProjects\FreeRTOS+TCP\FreeRTOS+TCP.vcxproj", "{C90E6CC5-818B-4C97-8876-0986D989387C}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "corePKCS11_MQTT_Mutual_Auth", "corePKCS11_MQTT_Mutual_Auth.vcxproj", "{382DC80F-E278-4BC9-9DB6-59014486DA0F}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Logging", "..\..\VisualStudio_StaticProjects\Logging\Logging.vcxproj", "{BE362AC0-B10B-4276-B84E-6304652BA228}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MbedTLS", "..\..\VisualStudio_StaticProjects\MbedTLS\MbedTLS.vcxproj", "{E1016F3E-94E9-4864-9FD8-1D7C1FEFBFD7}" diff --git a/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/CorePKCS11_Demos.sln b/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/CorePKCS11_Demos.sln index 9429b162b2..a1dee347c0 100644 --- a/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/CorePKCS11_Demos.sln +++ b/FreeRTOS-Plus/Demo/corePKCS11_Windows_Simulator/CorePKCS11_Demos.sln @@ -2,12 +2,12 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.33027.164 MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CorePKCS11_Demos", "CorePKCS11_Demos.vcxproj", "{382DC80F-E278-4BC9-9DB6-59014486DA0F}" +EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FreeRTOS-Kernel", "..\..\VisualStudio_StaticProjects\FreeRTOS-Kernel\FreeRTOS-Kernel.vcxproj", "{72C209C4-49A4-4942-A201-44706C9D77EC}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FreeRTOS+TCP", "..\..\VisualStudio_StaticProjects\FreeRTOS+TCP\FreeRTOS+TCP.vcxproj", "{C90E6CC5-818B-4C97-8876-0986D989387C}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CorePKCS11_Demos", "CorePKCS11_Demos.vcxproj", "{382DC80F-E278-4BC9-9DB6-59014486DA0F}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Logging", "..\..\VisualStudio_StaticProjects\Logging\Logging.vcxproj", "{BE362AC0-B10B-4276-B84E-6304652BA228}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MbedTLS", "..\..\VisualStudio_StaticProjects\MbedTLS\MbedTLS.vcxproj", "{E1016F3E-94E9-4864-9FD8-1D7C1FEFBFD7}" diff --git a/FreeRTOS-Plus/Demo/coreSNTP_Windows_Simulator/core_sntp_demo.sln b/FreeRTOS-Plus/Demo/coreSNTP_Windows_Simulator/core_sntp_demo.sln index 1f7ca05c44..9e3a1323de 100644 --- a/FreeRTOS-Plus/Demo/coreSNTP_Windows_Simulator/core_sntp_demo.sln +++ b/FreeRTOS-Plus/Demo/coreSNTP_Windows_Simulator/core_sntp_demo.sln @@ -2,12 +2,12 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.33027.164 MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "coreSNTP_Demo", "coreSNTP_Demo.vcxproj", "{382DC80F-E278-4BC9-9DB6-59014486DA0F}" +EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FreeRTOS-Kernel", "..\..\VisualStudio_StaticProjects\FreeRTOS-Kernel\FreeRTOS-Kernel.vcxproj", "{72C209C4-49A4-4942-A201-44706C9D77EC}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FreeRTOS+TCP", "..\..\VisualStudio_StaticProjects\FreeRTOS+TCP\FreeRTOS+TCP.vcxproj", "{C90E6CC5-818B-4C97-8876-0986D989387C}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "coreSNTP_Demo", "coreSNTP_Demo.vcxproj", "{382DC80F-E278-4BC9-9DB6-59014486DA0F}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Logging", "..\..\VisualStudio_StaticProjects\Logging\Logging.vcxproj", "{BE362AC0-B10B-4276-B84E-6304652BA228}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MbedTLS", "..\..\VisualStudio_StaticProjects\MbedTLS\MbedTLS.vcxproj", "{E1016F3E-94E9-4864-9FD8-1D7C1FEFBFD7}" From 3f24270b4af87aaa5cb6ff5f35219701449e433d Mon Sep 17 00:00:00 2001 From: chinglee-iot <61685396+chinglee-iot@users.noreply.github.com> Date: Wed, 6 Mar 2024 15:24:49 +0800 Subject: [PATCH 11/15] Update kernel xtaskGetHandle unit test (#1186) --- FreeRTOS/Test/CMock/tasks/tasks_1_utest.c | 27 ++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/FreeRTOS/Test/CMock/tasks/tasks_1_utest.c b/FreeRTOS/Test/CMock/tasks/tasks_1_utest.c index b931400b33..ded460d23f 100644 --- a/FreeRTOS/Test/CMock/tasks/tasks_1_utest.c +++ b/FreeRTOS/Test/CMock/tasks/tasks_1_utest.c @@ -2949,6 +2949,9 @@ void test_xtaskGetHandle_success( void ) /* prvSearchForNameWithinSingleList */ listCURRENT_LIST_LENGTH_ExpectAndReturn( &pxReadyTasksLists[ configMAX_PRIORITIES - 1 ], 1 ); + + listGET_LIST_ITEM_OWNER_ExpectAndReturn( &list_item, ptcb ); + /* vTaskResumeAll */ listLIST_IS_EMPTY_ExpectAndReturn( &xPendingReadyList, pdTRUE ); @@ -2965,19 +2968,26 @@ void test_xtaskGetHandle_success_2elements( void ) task_handle = create_task(); task_handle2 = create_task(); + strcpy( task_handle2->pcTaskName, "task2" ); ptcb = task_handle; INITIALIZE_LIST_2E( pxReadyTasksLists[ configMAX_PRIORITIES - 1 ], list_item, list_item2, ptcb, task_handle2 ); + /* Expectations */ /* prvSearchForNameWithinSingleList */ listCURRENT_LIST_LENGTH_ExpectAndReturn( &pxReadyTasksLists[ configMAX_PRIORITIES - 1 ], - 1 ); + 2 ); + + listGET_LIST_ITEM_OWNER_ExpectAndReturn( &list_item, task_handle ); + listGET_LIST_ITEM_OWNER_ExpectAndReturn( &list_item2, task_handle2 ); + /* vTaskResumeAll */ listLIST_IS_EMPTY_ExpectAndReturn( &xPendingReadyList, pdTRUE ); /* API Call */ - ret_task_handle = xTaskGetHandle( "create_task" ); + ret_task_handle = xTaskGetHandle( "task2" ); + /* Validations */ TEST_ASSERT_EQUAL_PTR( task_handle2, ret_task_handle ); } @@ -2989,6 +2999,7 @@ void test_xtaskGetHandle_success_2elements_set_index( void ) task_handle = create_task(); task_handle2 = create_task(); + strcpy( task_handle2->pcTaskName, "task2" ); ptcb = task_handle; INITIALIZE_LIST_2E( pxReadyTasksLists[ configMAX_PRIORITIES - 1 ], list_item, list_item2, @@ -2999,15 +3010,20 @@ void test_xtaskGetHandle_success_2elements_set_index( void ) /* advance index */ pxReadyTasksLists[ configMAX_PRIORITIES - 1 ].pxIndex = pxReadyTasksLists[ configMAX_PRIORITIES - 1 ].pxIndex->pxNext; + /* Expectations */ /* prvSearchForNameWithinSingleList */ listCURRENT_LIST_LENGTH_ExpectAndReturn( &pxReadyTasksLists[ configMAX_PRIORITIES - 1 ], 1 ); + + listGET_LIST_ITEM_OWNER_ExpectAndReturn( &list_item, task_handle ); + listGET_LIST_ITEM_OWNER_ExpectAndReturn( &list_item2, task_handle2 ); + /* vTaskResumeAll */ listLIST_IS_EMPTY_ExpectAndReturn( &xPendingReadyList, pdTRUE ); /* API Call */ - ret_task_handle = xTaskGetHandle( "create_task" ); + ret_task_handle = xTaskGetHandle( "task2" ); /* Validations */ TEST_ASSERT_EQUAL_PTR( task_handle2, ret_task_handle ); } @@ -3028,6 +3044,10 @@ void test_xtaskGetHandle_fail_no_task_found( void ) listCURRENT_LIST_LENGTH_ExpectAndReturn( &pxReadyTasksLists[ configMAX_PRIORITIES - 1 ], 2 ); + + listGET_LIST_ITEM_OWNER_ExpectAndReturn( &list_item, task_handle ); + listGET_LIST_ITEM_OWNER_ExpectAndReturn( &list_item2, task_handle2 ); + int i = configMAX_PRIORITIES - 1; do @@ -3041,6 +3061,7 @@ void test_xtaskGetHandle_fail_no_task_found( void ) listCURRENT_LIST_LENGTH_ExpectAndReturn( pxOverflowDelayedTaskList, 0 ); listCURRENT_LIST_LENGTH_ExpectAndReturn( &xSuspendedTaskList, 0 ); listCURRENT_LIST_LENGTH_ExpectAndReturn( &xTasksWaitingTermination, 0 ); + /* vTaskResumeAll */ listLIST_IS_EMPTY_ExpectAndReturn( &xPendingReadyList, pdTRUE ); From 2bb9bca68b87702022971a43ee185515fdc6f694 Mon Sep 17 00:00:00 2001 From: chinglee-iot <61685396+chinglee-iot@users.noreply.github.com> Date: Wed, 6 Mar 2024 16:11:46 +0800 Subject: [PATCH 12/15] Update kernel submodule pointer for xTaskGetHandle unit test (#1191) --- FreeRTOS/Source | 2 +- manifest.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/FreeRTOS/Source b/FreeRTOS/Source index 7284d84dc8..30f6061f48 160000 --- a/FreeRTOS/Source +++ b/FreeRTOS/Source @@ -1 +1 @@ -Subproject commit 7284d84dc88c5aaf2dc8337044177728b8bdae2d +Subproject commit 30f6061f48e2d54625d31e72ada6f5c474fba99f diff --git a/manifest.yml b/manifest.yml index 42150fba4d..3cb6055af3 100644 --- a/manifest.yml +++ b/manifest.yml @@ -5,7 +5,7 @@ license: "MIT" dependencies: - name: "FreeRTOS-Kernel" - version: "7284d84dc" + version: "30f6061f4" repository: type: "git" url: "https://github.com/FreeRTOS/FreeRTOS-Kernel.git" From 000c005ceed37605a3c146459acdf605ec90919e Mon Sep 17 00:00:00 2001 From: Tony Josi Date: Thu, 14 Mar 2024 14:51:54 +0530 Subject: [PATCH 13/15] Update +TCP to latest version (#1192) --- .../Demo/FreeRTOS_Plus_TCP_Echo_Posix/FreeRTOSIPConfig.h | 4 +++- FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP | 2 +- .../FreeRTOS+TCP/FreeRTOSIPConfig.h | 3 ++- manifest.yml | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Posix/FreeRTOSIPConfig.h b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Posix/FreeRTOSIPConfig.h index 24bd5d70ce..6c98ef994a 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Posix/FreeRTOSIPConfig.h +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Posix/FreeRTOSIPConfig.h @@ -312,7 +312,9 @@ extern void vLoggingPrintf( const char * pcFormatString, /* Set ipconfigBUFFER_PADDING on 64-bit platforms */ #if INTPTR_MAX == INT64_MAX - #define ipconfigBUFFER_PADDING ( 14U ) + #define ipconfigBUFFER_PADDING ( 14U ) #endif /* INTPTR_MAX == INT64_MAX */ +#define ipconfigETHERNET_DRIVER_FILTERS_PACKETS ( 1 ) + #endif /* FREERTOS_IP_CONFIG_H */ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP index b41e57e7b2..f940d75a13 160000 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP @@ -1 +1 @@ -Subproject commit b41e57e7b28d714a494cc470f16a8f5fea2b9e18 +Subproject commit f940d75a1393ba976edfcce118d4d97dc234322d diff --git a/FreeRTOS-Plus/VisualStudio_StaticProjects/FreeRTOS+TCP/FreeRTOSIPConfig.h b/FreeRTOS-Plus/VisualStudio_StaticProjects/FreeRTOS+TCP/FreeRTOSIPConfig.h index c49e2e2b60..d0b547748b 100644 --- a/FreeRTOS-Plus/VisualStudio_StaticProjects/FreeRTOS+TCP/FreeRTOSIPConfig.h +++ b/FreeRTOS-Plus/VisualStudio_StaticProjects/FreeRTOS+TCP/FreeRTOSIPConfig.h @@ -306,9 +306,10 @@ extern void vLoggingPrintf( const char * pcFormatString, /* Set ipconfigBUFFER_PADDING on 64-bit platforms */ #if INTPTR_MAX == INT64_MAX - #define ipconfigBUFFER_PADDING ( 14U ) + #define ipconfigBUFFER_PADDING ( 14U ) #endif /* INTPTR_MAX == INT64_MAX */ +#define ipconfigETHERNET_DRIVER_FILTERS_PACKETS ( 1 ) #define configMAC diff --git a/manifest.yml b/manifest.yml index 3cb6055af3..2e08c1c8c6 100644 --- a/manifest.yml +++ b/manifest.yml @@ -12,7 +12,7 @@ dependencies: path: "FreeRTOS/Source" - name: "FreeRTOS-Plus-TCP" - version: "V4.0.0" + version: "V4.1.0" repository: type: "git" url: "https://github.com/FreeRTOS/FreeRTOS-Plus-TCP.git" From 7de1b5098d80e3d6ea2f92ffd3b0c26776c9b904 Mon Sep 17 00:00:00 2001 From: Rahul Kar <118818625+kar-rahul-aws@users.noreply.github.com> Date: Thu, 21 Mar 2024 14:57:49 +0530 Subject: [PATCH 14/15] Add separate compile option for tracing functionality in Posix demo (#1194) * Add compile option for enabling tracing in cmake file * --- FreeRTOS/Demo/Posix_GCC/CMakeLists.txt | 15 +++++++++--- FreeRTOS/Demo/Posix_GCC/FreeRTOSConfig.h | 8 +++++- FreeRTOS/Demo/Posix_GCC/Makefile | 6 +++++ FreeRTOS/Demo/Posix_GCC/main.c | 31 +++++++++--------------- 4 files changed, 36 insertions(+), 24 deletions(-) diff --git a/FreeRTOS/Demo/Posix_GCC/CMakeLists.txt b/FreeRTOS/Demo/Posix_GCC/CMakeLists.txt index 4917ed3f21..199de7508b 100644 --- a/FreeRTOS/Demo/Posix_GCC/CMakeLists.txt +++ b/FreeRTOS/Demo/Posix_GCC/CMakeLists.txt @@ -10,10 +10,19 @@ else() add_compile_options( -DTRACE_ON_ENTER=0 ) endif() -if( ( COVERAGE_TEST ) OR ( NO_TRACING ) ) +if( COVERAGE_TEST ) set( COVERAGE_TEST 1 ) + set( NO_TRACING 1 ) add_compile_options( -DprojCOVERAGE_TEST=1 ) + add_compile_options( -DprojENABLE_TRACING=0 ) else() + if( NO_TRACING ) + set( NO_TRACING 1 ) + add_compile_options( -DprojENABLE_TRACING=0 ) + else() + set( NO_TRACING 0 ) + add_compile_options( -DprojENABLE_TRACING=1 ) + endif() set( COVERAGE_TEST 0 ) add_compile_options( -DprojCOVERAGE_TEST=0 ) endif() @@ -58,7 +67,7 @@ add_subdirectory( ${FREERTOS_KERNEL_PATH} ${CMAKE_CURRENT_BINARY_DIR}/FreeRTOS-K target_compile_options( freertos_kernel PRIVATE # Trace macro cast pointer to int to store memory management event - $ + $ ) file( GLOB FREERTOS_PLUS_TRACE_SOURCES ${FREERTOS_PLUS_TRACE_PATH}/*.c ${FREERTOS_PLUS_TRACE_PATH}/kernelports/FreeRTOS/*.c ) @@ -70,7 +79,7 @@ add_executable( posix_demo main_blinky.c main_full.c run-time-stats-utils.c - $<$:${FREERTOS_PLUS_TRACE_SOURCES}> + $<$:${FREERTOS_PLUS_TRACE_SOURCES}> ${CMAKE_CURRENT_LIST_DIR}/../Common/Minimal/AbortDelay.c ${CMAKE_CURRENT_LIST_DIR}/../Common/Minimal/BlockQ.c ${CMAKE_CURRENT_LIST_DIR}/../Common/Minimal/blocktim.c diff --git a/FreeRTOS/Demo/Posix_GCC/FreeRTOSConfig.h b/FreeRTOS/Demo/Posix_GCC/FreeRTOSConfig.h index 346b9fe786..df561108f1 100644 --- a/FreeRTOS/Demo/Posix_GCC/FreeRTOSConfig.h +++ b/FreeRTOS/Demo/Posix_GCC/FreeRTOSConfig.h @@ -128,6 +128,10 @@ extern void vAssertCalled( const char * const pcFileName, #error projCOVERAGE_TEST should be defined to 1 or 0 on the command line. #endif +#ifndef projENABLE_TRACING + #error projENABLE_TRACING should be defined to 1 or 0 on the command line. +#endif + #if ( projCOVERAGE_TEST == 1 ) /* Insert NOPs in empty decision paths to ensure both true and false paths @@ -154,7 +158,9 @@ extern void vAssertCalled( const char * const pcFileName, #define configUSE_MALLOC_FAILED_HOOK 1 /* Include the FreeRTOS+Trace FreeRTOS trace macro definitions. */ - #include "trcRecorder.h" + #if( projENABLE_TRACING == 1 ) + #include "trcRecorder.h" + #endif /* if ( projENABLE_TRACING == 1 ) */ #endif /* if ( projCOVERAGE_TEST == 1 ) */ /* networking definitions */ diff --git a/FreeRTOS/Demo/Posix_GCC/Makefile b/FreeRTOS/Demo/Posix_GCC/Makefile index ec5023b3bd..a3f09b1f2f 100644 --- a/FreeRTOS/Demo/Posix_GCC/Makefile +++ b/FreeRTOS/Demo/Posix_GCC/Makefile @@ -75,8 +75,14 @@ endif ifeq ($(COVERAGE_TEST),1) CPPFLAGS += -DprojCOVERAGE_TEST=1 + CPPFLAGS += -DprojENABLE_TRACING=0 CFLAGS += -Werror else + ifeq ($(NO_TRACING),1) + CPPFLAGS += -DprojENABLE_TRACING=0 + else + CPPFLAGS += -DprojENABLE_TRACING=1 + endif CPPFLAGS += -DprojCOVERAGE_TEST=0 # Trace library. SOURCE_FILES += ${FREERTOS_PLUS_DIR}/Source/FreeRTOS-Plus-Trace/kernelports/FreeRTOS/trcKernelPort.c diff --git a/FreeRTOS/Demo/Posix_GCC/main.c b/FreeRTOS/Demo/Posix_GCC/main.c index a4ea05d951..52a9753c9b 100644 --- a/FreeRTOS/Demo/Posix_GCC/main.c +++ b/FreeRTOS/Demo/Posix_GCC/main.c @@ -68,7 +68,7 @@ /* Local includes. */ #include "console.h" -#if ( projCOVERAGE_TEST != 1 ) +#if ( projENABLE_TRACING == 1 ) #include #endif @@ -139,13 +139,6 @@ static void handle_sigint( int signal ); * in a different file. */ StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ]; -/* Notes if the trace is running or not. */ -#if ( projCOVERAGE_TEST == 1 ) - static BaseType_t xTraceRunning = pdFALSE; -#else - static BaseType_t xTraceRunning = pdTRUE; -#endif - static clockid_t cid = CLOCK_THREAD_CPUTIME_ID; /*-----------------------------------------------------------*/ @@ -155,8 +148,7 @@ int main( void ) /* SIGINT is not blocked by the posix port */ signal( SIGINT, handle_sigint ); - /* Do not include trace code when performing a code coverage analysis. */ - #if ( projCOVERAGE_TEST != 1 ) + #if ( projENABLE_TRACING == 1 ) { /* Initialise the trace recorder. Use of the trace recorder is optional. * See http://www.FreeRTOS.org/trace for more information. */ @@ -168,9 +160,9 @@ int main( void ) #if ( TRACE_ON_ENTER == 1 ) printf( "\r\nThe trace will be dumped to disk if Enter is hit.\r\n" ); - #endif + #endif /* if ( TRACE_ON_ENTER == 1 ) */ } - #endif /* if ( projCOVERAGE_TEST != 1 ) */ + #endif /* if ( projENABLE_TRACING == 1 ) */ console_init(); #if ( mainSELECTED_APPLICATION == BLINKY_DEMO ) @@ -281,10 +273,11 @@ void traceOnEnter() if( xReturn > 0 ) { - if( xTraceRunning == pdTRUE ) + #if ( projENABLE_TRACING == 1 ) { prvSaveTraceFile(); } + #endif /* if ( projENABLE_TRACING == 1 ) */ /* clear the buffer */ char buffer[ 1 ]; @@ -334,10 +327,11 @@ void vAssertCalled( const char * const pcFileName, { xPrinted = pdTRUE; - if( xTraceRunning == pdTRUE ) + #if ( projENABLE_TRACING == 1 ) { prvSaveTraceFile(); } + #endif /* if ( projENABLE_TRACING == 0 ) */ } /* You can step out of this function to debug the assertion by using @@ -353,10 +347,8 @@ void vAssertCalled( const char * const pcFileName, } /*-----------------------------------------------------------*/ -static void prvSaveTraceFile( void ) -{ - /* Tracing is not used when code coverage analysis is being performed. */ - #if ( projCOVERAGE_TEST != 1 ) +#if ( projENABLE_TRACING == 1 ) + static void prvSaveTraceFile( void ) { FILE * pxOutputFile; @@ -375,8 +367,7 @@ static void prvSaveTraceFile( void ) printf( "\r\nFailed to create trace dump file\r\n" ); } } - #endif /* if ( projCOVERAGE_TEST != 1 ) */ -} +#endif /* if ( projENABLE_TRACING == 1 ) */ /*-----------------------------------------------------------*/ /* configUSE_STATIC_ALLOCATION is set to 1, so the application must provide an From c5c41ef3af679c77657431da528b8e7c33423d32 Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Fri, 22 Mar 2024 10:43:47 +0800 Subject: [PATCH 15/15] Update result section in README under CBMC folder. (#1196) * Update result section in README under CBMC folder * Code review suggestions Signed-off-by: Gaurav Aggarwal * Update proofs result path --------- Signed-off-by: Gaurav Aggarwal Co-authored-by: Gaurav Aggarwal Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com> --- FreeRTOS/Test/CBMC/README.md | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/FreeRTOS/Test/CBMC/README.md b/FreeRTOS/Test/CBMC/README.md index 8c0576f489..4b3e6de4a4 100644 --- a/FreeRTOS/Test/CBMC/README.md +++ b/FreeRTOS/Test/CBMC/README.md @@ -72,11 +72,19 @@ Each of the leaf directories under `proofs` is a proof of the memory safety of a single entry point in FreeRTOS. The scripts that you ran in the previous step will have left a Makefile in each of those directories. To run a proof, change into the directory for that proof and run `make`. -The proofs may take some time to run; they eventually write their output to -`cbmc.txt`, which should have the text `VERIFICATION SUCCESSFUL` at the end. +The proofs may take some time to run. -The make command will also generate a report in html and json format which makes -understanding the failures easier. +### Proof results + +The `make` command above generates a report in HTML and JSON format. Taking +[TaskCreate](./proofs/Task/TaskCreate) as an example: + +* HTML report is generated at `./proofs/Task/TaskCreate/html/html`. +* JSON report is generated at `./proofs/Task/TaskCreate/html/json`. + +You can open `./proofs/Task/TaskCreate/html/html/index.html` in any browser to view +the HTML report. You should see `None` under the `Errors` section in case of a +successful run. ### Proof directory structure