From d122d26d7da5a4aa0b43e1b1ae5f222205f76eee Mon Sep 17 00:00:00 2001 From: Archit Aggarwal Date: Tue, 27 Jul 2021 10:26:37 -0700 Subject: [PATCH] Re-add submodules to Community and Partner Contribution repos (#669) --- .gitmodules | 6 + .../Demo/ThirdParty/Community-Supported-Demos | 1 + .../Demo/ThirdParty/Partner-Supported-Demos | 1 + .../Demo/ThirdParty/Template/IntQueueTimer.c | 49 ++ .../Demo/ThirdParty/Template/IntQueueTimer.h | 42 ++ FreeRTOS/Demo/ThirdParty/Template/README.md | 177 ++++++ FreeRTOS/Demo/ThirdParty/Template/RegTests.c | 167 +++++ FreeRTOS/Demo/ThirdParty/Template/RegTests.h | 34 + .../Demo/ThirdParty/Template/TestRunner.c | 589 ++++++++++++++++++ .../Demo/ThirdParty/Template/TestRunner.h | 38 ++ manifest.yml | 14 + 11 files changed, 1118 insertions(+) create mode 160000 FreeRTOS/Demo/ThirdParty/Community-Supported-Demos create mode 160000 FreeRTOS/Demo/ThirdParty/Partner-Supported-Demos create mode 100644 FreeRTOS/Demo/ThirdParty/Template/IntQueueTimer.c create mode 100644 FreeRTOS/Demo/ThirdParty/Template/IntQueueTimer.h create mode 100644 FreeRTOS/Demo/ThirdParty/Template/README.md create mode 100644 FreeRTOS/Demo/ThirdParty/Template/RegTests.c create mode 100644 FreeRTOS/Demo/ThirdParty/Template/RegTests.h create mode 100644 FreeRTOS/Demo/ThirdParty/Template/TestRunner.c create mode 100644 FreeRTOS/Demo/ThirdParty/Template/TestRunner.h diff --git a/.gitmodules b/.gitmodules index 27be47e251..8142dd039c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -52,3 +52,9 @@ [submodule "FreeRTOS-Plus/Source/Application-Protocols/coreSNTP"] path = FreeRTOS-Plus/Source/Application-Protocols/coreSNTP url = https://github.com/FreeRTOS/coreSNTP.git +[submodule "FreeRTOS/Demo/ThirdParty/Community-Supported-Demos"] + path = FreeRTOS/Demo/ThirdParty/Community-Supported-Demos + url = https://github.com/FreeRTOS/FreeRTOS-Community-Supported-Demos +[submodule "FreeRTOS/Demo/ThirdParty/Partner-Supported-Demos"] + path = FreeRTOS/Demo/ThirdParty/Partner-Supported-Demos + url = https://github.com/FreeRTOS/FreeRTOS-Partner-Supported-Demos diff --git a/FreeRTOS/Demo/ThirdParty/Community-Supported-Demos b/FreeRTOS/Demo/ThirdParty/Community-Supported-Demos new file mode 160000 index 0000000000..e21b617e4c --- /dev/null +++ b/FreeRTOS/Demo/ThirdParty/Community-Supported-Demos @@ -0,0 +1 @@ +Subproject commit e21b617e4c0516fd64ac7cb1352a7cde81b571bc diff --git a/FreeRTOS/Demo/ThirdParty/Partner-Supported-Demos b/FreeRTOS/Demo/ThirdParty/Partner-Supported-Demos new file mode 160000 index 0000000000..109ef4d0f8 --- /dev/null +++ b/FreeRTOS/Demo/ThirdParty/Partner-Supported-Demos @@ -0,0 +1 @@ +Subproject commit 109ef4d0f8973aa4e624cc3a4048c88ea048e0a4 diff --git a/FreeRTOS/Demo/ThirdParty/Template/IntQueueTimer.c b/FreeRTOS/Demo/ThirdParty/Template/IntQueueTimer.c new file mode 100644 index 0000000000..8e51fbb188 --- /dev/null +++ b/FreeRTOS/Demo/ThirdParty/Template/IntQueueTimer.c @@ -0,0 +1,49 @@ +/* + * FreeRTOS V202104.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. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * 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. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/* Scheduler includes. */ +#include "FreeRTOS.h" +#include "task.h" + +/* Demo includes. */ +#include "IntQueueTimer.h" +#include "IntQueue.h" + +/*-----------------------------------------------------------*/ + +void vInitialiseTimerForIntQueueTest( void ) +{ + /* Initialize a hardware timer. */ +} +/*-----------------------------------------------------------*/ + +void IntQueueTestTimerHandler( void ) +{ + portYIELD_FROM_ISR( xSecondTimerHandler() ); +} +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Demo/ThirdParty/Template/IntQueueTimer.h b/FreeRTOS/Demo/ThirdParty/Template/IntQueueTimer.h new file mode 100644 index 0000000000..7508f6fc51 --- /dev/null +++ b/FreeRTOS/Demo/ThirdParty/Template/IntQueueTimer.h @@ -0,0 +1,42 @@ +/* + * FreeRTOS V202104.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. If you wish to use our Amazon + * FreeRTOS name, please do so in a fair use way that does not cause confusion. + * + * 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. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef INT_QUEUE_TIMER_H +#define INT_QUEUE_TIMER_H + +/** + * The function called from queue interrupt tests to initialise timer. + */ +void vInitialiseTimerForIntQueueTest( void ); + +/** + * The function to be called from a timer handler. + */ +void IntQueueTestTimerHandler( void ); + +#endif /* INT_QUEUE_TIMER_H */ diff --git a/FreeRTOS/Demo/ThirdParty/Template/README.md b/FreeRTOS/Demo/ThirdParty/Template/README.md new file mode 100644 index 0000000000..e5ddb80138 --- /dev/null +++ b/FreeRTOS/Demo/ThirdParty/Template/README.md @@ -0,0 +1,177 @@ +# Create a Test Project + +## Initial Setup + +1. Create a new directory in the [FreeRTOS Partner Supported Demos Repository](https://github.com/FreeRTOS/FreeRTOS-Partner-Supported-Demos/tree/main) + or [FreeRTOS Community Supported Demos Repository](https://github.com/FreeRTOS/FreeRTOS-Community-Supported-Demos/tree/main). + The suggested name for the directory is `_`. +2. Create a project for your hardware and tool-chain in this directory. +3. Copy all the files in the [FreeRTOS/Demo/ThirdParty/Template](https://github.com/FreeRTOS/FreeRTOS/tree/main/FreeRTOS/Demo/ThirdParty/Template) + directory to your project directory: + * `IntQueueTimer.h` + * `IntQueueTimer.c` + * `TestRunner.h` + * `TestRunner.c` + * `RegTests.h` + * `RegTests.c` + +## Project Configuration + +1. Compile the following additional files in your project: + * All files in the [FreeRTOS/Demo/Common/Minimal](https://github.com/FreeRTOS/FreeRTOS/tree/main/FreeRTOS/Demo/Common/Minimal) directory except + `comtest_strings.c`, `crhook.c` , `comtest.c` ,`crflash.c`,`flash.c`, `flash_timer.c` and `sp_flop.c`. +2. Add the following paths to your include search path: + * `FreeRTOS/Demo/Common/include`. +3. Call the `void vStartTests( void )` function from your `main` function after + doing all the hardware initialization. Note that this function starts the + scheduler and therefore, never returns. +```c +#include "TestRunner.h" + +void main( void ) +{ + /* Startup and Hardware initialization. */ + + /* Start tests. */ + vStartTests(); + + /* Should never reach here. */ + for( ; ; ); +} +``` + +## Set up FreeRTOSConfig.h + +1. Enable tick hook by adding the following line in your `FreeRTOSConfig.h`: +```c +#define configUSE_TICK_HOOK 1 +``` +2. Set the task notification array size to 3 by adding the following line in + your `FreeRTOSConfig.h`: +```c +#define configTASK_NOTIFICATION_ARRAY_ENTRIES 3 +``` +3. Enable printing by mapping `configPRINTF` to your print function. Note that + `configPRINTF` calls are wrapped in double parentheses to support C89. If you + have a thread-safe `printf` function, the following is what should be added + in your `FreeRTOSConfig.h`: +```c +#define configPRINTF( X ) printf X +``` +4. Add the following defines in your `FreeRTOSConfig.h`: +```c +#define configSTART_TASK_NOTIFY_TESTS 0 +#define configSTART_TASK_NOTIFY_ARRAY_TESTS 0 +#define configSTART_BLOCKING_QUEUE_TESTS 0 +#define configSTART_SEMAPHORE_TESTS 0 +#define configSTART_POLLED_QUEUE_TESTS 0 +#define configSTART_INTEGER_MATH_TESTS 0 +#define configSTART_GENERIC_QUEUE_TESTS 0 +#define configSTART_PEEK_QUEUE_TESTS 0 +#define configSTART_MATH_TESTS 0 +#define configSTART_RECURSIVE_MUTEX_TESTS 0 +#define configSTART_COUNTING_SEMAPHORE_TESTS 0 +#define configSTART_QUEUE_SET_TESTS 0 +#define configSTART_QUEUE_OVERWRITE_TESTS 0 +#define configSTART_EVENT_GROUP_TESTS 0 +#define configSTART_INTERRUPT_SEMAPHORE_TESTS 0 +#define configSTART_QUEUE_SET_POLLING_TESTS 0 +#define configSTART_BLOCK_TIME_TESTS 0 +#define configSTART_ABORT_DELAY_TESTS 0 +#define configSTART_MESSAGE_BUFFER_TESTS 0 +#define configSTART_STREAM_BUFFER_TESTS 0 +#define configSTART_STREAM_BUFFER_INTERRUPT_TESTS 0 +#define configSTART_TIMER_TESTS 0 +#define configSTART_INTERRUPT_QUEUE_TESTS 0 +#define configSTART_REGISTER_TESTS 0 +#define configSTART_DELETE_SELF_TESTS 0 +``` + +## Create and Run Register Tests + +1. Fill the definitions of the following functions in the `RegTests.c` file + copied in the [Initial Setup](#Initial-Setup) step: + * `prvRegisterTest1Task` + * `prvRegisterTest2Task` + * `prvRegisterTest3Task` + * `prvRegisterTest4Task` +2. Define `configSTART_REGISTER_TESTS` to `1` in your `FreeRTOSConfig.h`: +```c +#define configSTART_REGISTER_TESTS 1 +``` +3. Build and run the register tests. The output should look like the following: +``` +No errors +No errors +No errors +No errors +``` + +## Setup and Run Interrupt Nesting Tests + +1. If your hardware **does not** support interrupt nesting, skip this section. +2. Fill the `void vInitialiseTimerForIntQueueTest( void )` function in the + `IntQueueTimer.c` file copied in the [Initial Setup](#Initial-Setup) step to + initialize and start a hardware timer. Make sure that the timer interrupt + runs at a logical priority less than or equal to `configMAX_SYSCALL_INTERRUPT_PRIORITY`. + The following is an example for ARM MPS2 which starts TIM0 timer: +```c +void vInitialiseTimerForIntQueueTest( void ) +{ + /* Clear interrupt. */ + CMSDK_TIMER0->INTCLEAR = ( 1ul << 0 ); + + /* Reload value is slightly offset from the other timer. */ + CMSDK_TIMER0->RELOAD = ( configCPU_CLOCK_HZ / tmrTIMER_0_FREQUENCY ) + 1UL; + CMSDK_TIMER0->CTRL = ( ( 1ul << 3 ) | ( 1ul << 0 ) ); + + NVIC_SetPriority( TIMER0_IRQn, configMAX_SYSCALL_INTERRUPT_PRIORITY ); + NVIC_EnableIRQ( TIMER0_IRQn ); +} +``` +3. Either install `void IntQueueTestTimerHandler( void )` function as the timer + interrupt handler or call it from the timer interrupt handler of the above + timer. The following is an example for ARM MPS2 which calls + `IntQueueTestTimerHandler` from the TIM0 handler: +```c +void TIMER0_Handler( void ) +{ + /* Clear interrupt. */ + CMSDK_TIMER0->INTCLEAR = ( 1ul << 0 ); + + IntQueueTestTimerHandler(); +} +``` +4. Define `configSTART_INTERRUPT_QUEUE_TESTS` to `1` in your `FreeRTOSConfig.h`: +```c +#define configSTART_INTERRUPT_QUEUE_TESTS 1 +``` +5. Build and run the tests. The output should look like the following: +``` +No errors +No errors +No errors +No errors +``` + +## Running All Tests + +1. Define all the `configSTART__TESTS` macros to `1` in your +`FreeRTOSConfig.h`. +2. Build and run the tests. The output should look like the following: +``` +No errors +No errors +No errors +No errors +``` +3. If you cannot fit all the tests in one binary because of Flash or RAM space, +you can run tests one by one or in groups by defining +`configSTART__TESTS` macros to `0` or `1` as needed. + +## Add README +Add a `README.md` file in the project directory with the following information: +* Link to the hardware page. +* How to setup tool-chain. +* How to build and run the project. +* Any other relevant information. diff --git a/FreeRTOS/Demo/ThirdParty/Template/RegTests.c b/FreeRTOS/Demo/ThirdParty/Template/RegTests.c new file mode 100644 index 0000000000..3c95e1830a --- /dev/null +++ b/FreeRTOS/Demo/ThirdParty/Template/RegTests.c @@ -0,0 +1,167 @@ +/* + * FreeRTOS V202104.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. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/* Scheduler include files. */ +#include "FreeRTOS.h" +#include "task.h" + +/* Interface include files. */ +#include "RegTests.h" + +/* Tasks that implement register tests. */ +static void prvRegisterTest1Task( void *pvParameters ); +static void prvRegisterTest2Task( void *pvParameters ); +static void prvRegisterTest3Task( void *pvParameters ); +static void prvRegisterTest4Task( void *pvParameters ); + +/* Flag that will be latched to pdTRUE should any unexpected behaviour be +detected in any of the tasks. */ +static volatile BaseType_t xErrorDetected = pdFALSE; + +/* Counters that are incremented on each cycle of a test. This is used to +detect a stalled task - a test that is no longer running. */ +static volatile uint32_t ulRegisterTest1Counter = 0; +static volatile uint32_t ulRegisterTest2Counter = 0; +static volatile uint32_t ulRegisterTest3Counter = 0; +static volatile uint32_t ulRegisterTest4Counter = 0; +/*-----------------------------------------------------------*/ + +static void prvRegisterTest1Task( void *pvParameters ) +{ + ( void ) pvParameters; + + for( ; ; ) + { + /* 1. Fill the registers stored as part of task context with known values. + * 2. Force a context switch. + * 3. Verify that all the registers contain expected values. + * 4. If all the register contain expected values, increment ulRegisterTest1Counter. + */ + } +} +/*-----------------------------------------------------------*/ + +static void prvRegisterTest2Task( void *pvParameters ) +{ + ( void ) pvParameters; + + for( ; ; ) + { + /* 1. Fill the registers stored as part of task context with known values. + * 2. Force a context switch. + * 3. Verify that all the registers contain expected values. + * 4. If all the register contain expected values, increment ulRegisterTest2Counter. + */ + } +} +/*-----------------------------------------------------------*/ + +static void prvRegisterTest3Task( void *pvParameters ) +{ + ( void ) pvParameters; + + for( ; ; ) + { + /* 1. Fill the registers stored as part of task context with known values. + * 2. Force a context switch. + * 3. Verify that all the registers contain expected values. + * 4. If all the register contain expected values, increment ulRegisterTest3Counter. + */ + } +} +/*-----------------------------------------------------------*/ + +static void prvRegisterTest4Task( void *pvParameters ) +{ + ( void ) pvParameters; + + for( ; ; ) + { + /* 1. Fill the registers stored as part of task context with known values. + * 2. Force a context switch. + * 3. Verify that all the registers contain expected values. + * 4. If all the register contain expected values, increment ulRegisterTest4Counter. + */ + } +} +/*-----------------------------------------------------------*/ + +void vStartRegisterTasks( UBaseType_t uxPriority ) +{ + BaseType_t ret; + + ret = xTaskCreate( prvRegisterTest1Task, "RegTest1", configMINIMAL_STACK_SIZE, NULL, uxPriority, NULL ); + configASSERT( ret == pdPASS ); + + ret = xTaskCreate( prvRegisterTest2Task, "RegTest2", configMINIMAL_STACK_SIZE, NULL, uxPriority, NULL ); + configASSERT( ret == pdPASS ); + + ret = xTaskCreate( prvRegisterTest3Task, "RegTest3", configMINIMAL_STACK_SIZE, NULL, uxPriority, NULL ); + configASSERT( ret == pdPASS ); + + ret = xTaskCreate( prvRegisterTest4Task, "RegTest4", configMINIMAL_STACK_SIZE, NULL, uxPriority, NULL ); + configASSERT( ret == pdPASS ); +} +/*-----------------------------------------------------------*/ + +BaseType_t xAreRegisterTasksStillRunning( void ) +{ +static uint32_t ulLastRegisterTest1Counter = 0, ulLastRegisterTest2Counter = 0; +static uint32_t ulLastRegisterTest3Counter = 0, ulLastRegisterTest4Counter = 0; + + /* If the register test task is still running then we expect the loop + * counters to have incremented since this function was last called. */ + if( ulLastRegisterTest1Counter == ulRegisterTest1Counter ) + { + xErrorDetected = pdTRUE; + } + + if( ulLastRegisterTest2Counter == ulRegisterTest2Counter ) + { + xErrorDetected = pdTRUE; + } + + if( ulLastRegisterTest3Counter == ulRegisterTest3Counter ) + { + xErrorDetected = pdTRUE; + } + + if( ulLastRegisterTest4Counter == ulRegisterTest4Counter ) + { + xErrorDetected = pdTRUE; + } + + ulLastRegisterTest1Counter = ulRegisterTest1Counter; + ulLastRegisterTest2Counter = ulRegisterTest2Counter; + ulLastRegisterTest3Counter = ulRegisterTest3Counter; + ulLastRegisterTest4Counter = ulRegisterTest4Counter; + + /* Errors detected in the task itself will have latched xErrorDetected + * to true. */ + return ( BaseType_t ) !xErrorDetected; +} +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Demo/ThirdParty/Template/RegTests.h b/FreeRTOS/Demo/ThirdParty/Template/RegTests.h new file mode 100644 index 0000000000..6b64070b0e --- /dev/null +++ b/FreeRTOS/Demo/ThirdParty/Template/RegTests.h @@ -0,0 +1,34 @@ +/* + * FreeRTOS V202104.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. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef REG_TEST_H +#define REG_TEST_H + +void vStartRegisterTasks( UBaseType_t uxPriority ); +BaseType_t xAreRegisterTasksStillRunning( void ); + +#endif /* REG_TEST_H */ diff --git a/FreeRTOS/Demo/ThirdParty/Template/TestRunner.c b/FreeRTOS/Demo/ThirdParty/Template/TestRunner.c new file mode 100644 index 0000000000..c94ffbbb26 --- /dev/null +++ b/FreeRTOS/Demo/ThirdParty/Template/TestRunner.c @@ -0,0 +1,589 @@ +/* + * FreeRTOS V202104.00 + * Copyright (C) 2017 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. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/* Standard includes. */ +#include +#include + +/* Kernel includes. */ +#include "FreeRTOS.h" +#include "task.h" +#include "queue.h" +#include "timers.h" +#include "semphr.h" + +/* Various test includes. */ +#include "BlockQ.h" +#include "integer.h" +#include "semtest.h" +#include "PollQ.h" +#include "GenQTest.h" +#include "QPeek.h" +#include "recmutex.h" +#include "flop.h" +#include "TimerDemo.h" +#include "countsem.h" +#include "death.h" +#include "QueueSet.h" +#include "QueueOverwrite.h" +#include "EventGroupsDemo.h" +#include "IntSemTest.h" +#include "IntQueue.h" +#include "TaskNotify.h" +#include "TaskNotifyArray.h" +#include "QueueSetPolling.h" +#include "StaticAllocation.h" +#include "blocktim.h" +#include "AbortDelay.h" +#include "MessageBufferDemo.h" +#include "StreamBufferDemo.h" +#include "StreamBufferInterrupt.h" +#include "RegTests.h" + +/** + * Priorities at which the tasks are created. + */ +#define testrunnerCHECK_TASK_PRIORITY ( configMAX_PRIORITIES - 2 ) +#define testrunnerQUEUE_POLL_PRIORITY ( tskIDLE_PRIORITY + 1 ) +#define testrunnerSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1 ) +#define testrunnerBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2 ) +#define testrunnerCREATOR_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 ) +#define testrunnerFLASH_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 ) +#define testrunnerINTEGER_TASK_PRIORITY ( tskIDLE_PRIORITY ) +#define testrunnerGEN_QUEUE_TASK_PRIORITY ( tskIDLE_PRIORITY ) +#define testrunnerFLOP_TASK_PRIORITY ( tskIDLE_PRIORITY ) +#define testrunnerQUEUE_OVERWRITE_PRIORITY ( tskIDLE_PRIORITY ) +#define testrunnerREGISTER_TEST_PRIORITY ( tskIDLE_PRIORITY ) + +/** + * Period used in timer tests. + */ +#define testrunnerTIMER_TEST_PERIOD ( 50 ) +/*-----------------------------------------------------------*/ + +/** + * The variable into which error messages are latched. + */ +static char *pcStatusMessage = "No errors"; +/*-----------------------------------------------------------*/ + +/** + * The task that periodically checks that all the standard demo tasks are + * still executing and error free. + */ +static void prvCheckTask( void *pvParameters ); +/*-----------------------------------------------------------*/ + +void vStartTests( void ) +{ + BaseType_t xResult; + + xResult = xTaskCreate( prvCheckTask, + "Check", + configMINIMAL_STACK_SIZE, + NULL, + testrunnerCHECK_TASK_PRIORITY, + NULL ); + + if( xResult == pdPASS ) + { + #if( configSTART_TASK_NOTIFY_TESTS == 1 ) + { + vStartTaskNotifyTask(); + } + #endif /* configSTART_TASK_NOTIFY_TESTS */ + + #if( configSTART_TASK_NOTIFY_ARRAY_TESTS == 1 ) + { + vStartTaskNotifyArrayTask(); + } + #endif /* configSTART_TASK_NOTIFY_ARRAY_TESTS */ + + #if( configSTART_BLOCKING_QUEUE_TESTS == 1 ) + { + vStartBlockingQueueTasks( testrunnerBLOCK_Q_PRIORITY ); + } + #endif /* configSTART_BLOCKING_QUEUE_TESTS */ + + #if( configSTART_SEMAPHORE_TESTS == 1 ) + { + vStartSemaphoreTasks( testrunnerSEM_TEST_PRIORITY ); + } + #endif /* configSTART_SEMAPHORE_TESTS */ + + #if( configSTART_POLLED_QUEUE_TESTS == 1 ) + { + vStartPolledQueueTasks( testrunnerQUEUE_POLL_PRIORITY ); + } + #endif /* configSTART_POLLED_QUEUE_TESTS */ + + #if( configSTART_INTEGER_MATH_TESTS == 1 ) + { + vStartIntegerMathTasks( testrunnerINTEGER_TASK_PRIORITY ); + } + #endif /* configSTART_INTEGER_MATH_TESTS */ + + #if( configSTART_GENERIC_QUEUE_TESTS == 1 ) + { + vStartGenericQueueTasks( testrunnerGEN_QUEUE_TASK_PRIORITY ); + } + #endif /* configSTART_GENERIC_QUEUE_TESTS */ + + #if( configSTART_PEEK_QUEUE_TESTS == 1 ) + { + vStartQueuePeekTasks(); + } + #endif /* configSTART_PEEK_QUEUE_TESTS */ + + #if( configSTART_MATH_TESTS == 1 ) + { + vStartMathTasks( testrunnerFLOP_TASK_PRIORITY ); + } + #endif /* configSTART_MATH_TESTS */ + + #if( configSTART_RECURSIVE_MUTEX_TESTS == 1 ) + { + vStartRecursiveMutexTasks(); + } + #endif /* configSTART_RECURSIVE_MUTEX_TESTS */ + + #if( configSTART_COUNTING_SEMAPHORE_TESTS == 1 ) + { + vStartCountingSemaphoreTasks(); + } + #endif /* configSTART_COUNTING_SEMAPHORE_TESTS */ + + #if( configSTART_QUEUE_SET_TESTS == 1 ) + { + vStartQueueSetTasks(); + } + #endif /* configSTART_QUEUE_SET_TESTS */ + + #if( configSTART_QUEUE_OVERWRITE_TESTS == 1 ) + { + vStartQueueOverwriteTask( testrunnerQUEUE_OVERWRITE_PRIORITY ); + } + #endif /* configSTART_QUEUE_OVERWRITE_TESTS */ + + #if( configSTART_EVENT_GROUP_TESTS == 1 ) + { + vStartEventGroupTasks(); + } + #endif /* configSTART_EVENT_GROUP_TESTS */ + + #if( configSTART_INTERRUPT_SEMAPHORE_TESTS == 1 ) + { + vStartInterruptSemaphoreTasks(); + } + #endif /* configSTART_INTERRUPT_SEMAPHORE_TESTS */ + + #if( configSTART_QUEUE_SET_POLLING_TESTS == 1 ) + { + vStartQueueSetPollingTask(); + } + #endif /* configSTART_QUEUE_SET_POLLING_TESTS */ + + #if( configSTART_BLOCK_TIME_TESTS == 1 ) + { + vCreateBlockTimeTasks(); + } + #endif /* configSTART_BLOCK_TIME_TESTS */ + + #if( configSTART_ABORT_DELAY_TESTS == 1 ) + { + vCreateAbortDelayTasks(); + } + #endif /* configSTART_ABORT_DELAY_TESTS */ + + #if( configSTART_MESSAGE_BUFFER_TESTS == 1 ) + { + vStartMessageBufferTasks( configMINIMAL_STACK_SIZE ); + } + #endif /* configSTART_MESSAGE_BUFFER_TESTS */ + + #if(configSTART_STREAM_BUFFER_TESTS == 1 ) + { + vStartStreamBufferTasks(); + } + #endif /* configSTART_STREAM_BUFFER_TESTS */ + + #if( configSTART_STREAM_BUFFER_INTERRUPT_TESTS == 1 ) + { + vStartStreamBufferInterruptDemo(); + } + #endif /* configSTART_STREAM_BUFFER_INTERRUPT_TESTS */ + + #if( ( configSTART_TIMER_TESTS == 1 ) && ( configUSE_PREEMPTION != 0 ) ) + { + /* Don't expect these tasks to pass when preemption is not used. */ + vStartTimerDemoTask( testrunnerTIMER_TEST_PERIOD ); + } + #endif /* ( configSTART_TIMER_TESTS == 1 ) && ( configUSE_PREEMPTION != 0 ) */ + + #if( configSTART_INTERRUPT_QUEUE_TESTS == 1 ) + { + vStartInterruptQueueTasks(); + } + #endif /* configSTART_INTERRUPT_QUEUE_TESTS */ + + #if( configSTART_REGISTER_TESTS == 1 ) + { + vStartRegisterTasks( testrunnerREGISTER_TEST_PRIORITY ); + } + #endif /* configSTART_REGISTER_TESTS */ + + #if( configSTART_DELETE_SELF_TESTS == 1 ) + { + /* The suicide tasks must be created last as they need to know how many + * tasks were running prior to their creation. This then allows them to + * ascertain whether or not the correct/expected number of tasks are + * running at any given time. */ + vCreateSuicidalTasks( testrunnerCREATOR_TASK_PRIORITY ); + } + #endif /* configSTART_DELETE_SELF_TESTS */ + } + + vTaskStartScheduler(); +} +/*-----------------------------------------------------------*/ + +void vApplicationTickHook( void ) +{ + #if( configSTART_TASK_NOTIFY_TESTS == 1 ) + { + xNotifyTaskFromISR(); + } + #endif /* configSTART_TASK_NOTIFY_TESTS */ + + #if( configSTART_TASK_NOTIFY_ARRAY_TESTS == 1 ) + { + xNotifyArrayTaskFromISR(); + } + #endif /* configSTART_TASK_NOTIFY_ARRAY_TESTS */ + + #if( configSTART_QUEUE_SET_TESTS == 1 ) + { + vQueueSetAccessQueueSetFromISR(); + } + #endif /* configSTART_QUEUE_SET_TESTS */ + + #if( configSTART_QUEUE_OVERWRITE_TESTS == 1 ) + { + vQueueOverwritePeriodicISRDemo(); + } + #endif /* configSTART_QUEUE_OVERWRITE_TESTS */ + + #if( configSTART_EVENT_GROUP_TESTS == 1 ) + { + vPeriodicEventGroupsProcessing(); + } + #endif /* configSTART_EVENT_GROUP_TESTS */ + + #if( configSTART_INTERRUPT_SEMAPHORE_TESTS == 1 ) + { + vInterruptSemaphorePeriodicTest(); + } + #endif /* configSTART_INTERRUPT_SEMAPHORE_TESTS */ + + #if( configSTART_QUEUE_SET_POLLING_TESTS == 1 ) + { + vQueueSetPollingInterruptAccess(); + } + #endif /* configSTART_QUEUE_SET_POLLING_TESTS */ + + #if( configSTART_STREAM_BUFFER_TESTS == 1 ) + { + vPeriodicStreamBufferProcessing(); + } + #endif /* configSTART_STREAM_BUFFER_TESTS */ + + #if( configSTART_STREAM_BUFFER_INTERRUPT_TESTS == 1 ) + { + vBasicStreamBufferSendFromISR(); + } + #endif /* configSTART_STREAM_BUFFER_INTERRUPT_TESTS */ + + #if( ( configSTART_TIMER_TESTS == 1 ) && ( configUSE_PREEMPTION != 0 ) ) + { + /* Only created when preemption is used. */ + vTimerPeriodicISRTests(); + } + #endif /* ( configSTART_TIMER_TESTS == 1 ) && ( configUSE_PREEMPTION != 0 ) */ + + #if( configSTART_INTERRUPT_QUEUE_TESTS == 1 ) + { + portYIELD_FROM_ISR( xFirstTimerHandler() ); + } + #endif /* configSTART_INTERRUPT_QUEUE_TESTS */ +} +/*-----------------------------------------------------------*/ + +static void prvCheckTask( void *pvParameters ) +{ +TickType_t xNextWakeTime; +const TickType_t xCycleFrequency = pdMS_TO_TICKS( 5000UL ); + + /* Silence compiler warnings about unused variables. */ + ( void ) pvParameters; + + /* Initialise xNextWakeTime - this only needs to be done once. */ + xNextWakeTime = xTaskGetTickCount(); + + for( ;; ) + { + /* Place this task in the blocked state until it is time to run again. */ + vTaskDelayUntil( &xNextWakeTime, xCycleFrequency ); + + #if( configSTART_TASK_NOTIFY_TESTS == 1 ) + { + if( xAreTaskNotificationTasksStillRunning() != pdTRUE ) + { + pcStatusMessage = "Error: Notification"; + } + } + #endif /* configSTART_TASK_NOTIFY_TESTS */ + + #if( configSTART_TASK_NOTIFY_ARRAY_TESTS == 1 ) + { + if( xAreTaskNotificationArrayTasksStillRunning() != pdTRUE ) + { + pcStatusMessage = "Error: Notification Array"; + } + } + #endif /* configSTART_TASK_NOTIFY_ARRAY_TESTS */ + + #if( configSTART_BLOCKING_QUEUE_TESTS == 1 ) + { + if( xAreBlockingQueuesStillRunning() != pdTRUE ) + { + pcStatusMessage = "Error: BlockQueue"; + } + } + #endif /* configSTART_BLOCKING_QUEUE_TESTS */ + + #if( configSTART_SEMAPHORE_TESTS == 1 ) + { + if( xAreSemaphoreTasksStillRunning() != pdTRUE ) + { + pcStatusMessage = "Error: SemTest"; + } + } + #endif /* configSTART_SEMAPHORE_TESTS */ + + #if( configSTART_POLLED_QUEUE_TESTS == 1 ) + { + if( xArePollingQueuesStillRunning() != pdTRUE ) + { + pcStatusMessage = "Error: PollQueue"; + } + } + #endif /* configSTART_POLLED_QUEUE_TESTS */ + + #if( configSTART_INTEGER_MATH_TESTS == 1 ) + { + if( xAreIntegerMathsTaskStillRunning() != pdTRUE ) + { + pcStatusMessage = "Error: IntMath"; + } + } + #endif /* configSTART_INTEGER_MATH_TESTS */ + + #if( configSTART_GENERIC_QUEUE_TESTS == 1 ) + { + if( xAreGenericQueueTasksStillRunning() != pdTRUE ) + { + pcStatusMessage = "Error: GenQueue"; + } + } + #endif /* configSTART_GENERIC_QUEUE_TESTS */ + + #if( configSTART_PEEK_QUEUE_TESTS == 1 ) + { + if( xAreQueuePeekTasksStillRunning() != pdTRUE ) + { + pcStatusMessage = "Error: QueuePeek"; + } + } + #endif /* configSTART_PEEK_QUEUE_TESTS */ + + #if( configSTART_MATH_TESTS == 1 ) + { + if( xAreMathsTaskStillRunning() != pdPASS ) + { + pcStatusMessage = "Error: Flop"; + } + } + #endif /* configSTART_MATH_TESTS */ + + #if( configSTART_RECURSIVE_MUTEX_TESTS == 1 ) + { + if( xAreRecursiveMutexTasksStillRunning() != pdTRUE ) + { + pcStatusMessage = "Error: RecMutex"; + } + } + #endif /* configSTART_RECURSIVE_MUTEX_TESTS */ + + #if( configSTART_COUNTING_SEMAPHORE_TESTS == 1 ) + { + if( xAreCountingSemaphoreTasksStillRunning() != pdTRUE ) + { + pcStatusMessage = "Error: CountSem"; + } + } + #endif /* configSTART_COUNTING_SEMAPHORE_TESTS */ + + #if( configSTART_QUEUE_SET_TESTS == 1 ) + { + if( xAreQueueSetTasksStillRunning() != pdPASS ) + { + pcStatusMessage = "Error: Queue set"; + } + } + #endif /* configSTART_QUEUE_SET_TESTS */ + + #if( configSTART_QUEUE_OVERWRITE_TESTS == 1 ) + { + if( xIsQueueOverwriteTaskStillRunning() != pdPASS ) + { + pcStatusMessage = "Error: Queue overwrite"; + } + } + #endif /* configSTART_QUEUE_OVERWRITE_TESTS */ + + #if( configSTART_EVENT_GROUP_TESTS == 1 ) + { + if( xAreEventGroupTasksStillRunning() != pdTRUE ) + { + pcStatusMessage = "Error: EventGroup"; + } + } + #endif /* configSTART_EVENT_GROUP_TESTS */ + + #if( configSTART_INTERRUPT_SEMAPHORE_TESTS == 1 ) + { + if( xAreInterruptSemaphoreTasksStillRunning() != pdTRUE ) + { + pcStatusMessage = "Error: IntSem"; + } + } + #endif /* configSTART_INTERRUPT_SEMAPHORE_TESTS */ + + #if( configSTART_QUEUE_SET_POLLING_TESTS == 1 ) + { + if( xAreQueueSetPollTasksStillRunning() != pdPASS ) + { + pcStatusMessage = "Error: Queue set polling"; + } + } + #endif /* configSTART_QUEUE_SET_POLLING_TESTS */ + + #if( configSTART_BLOCK_TIME_TESTS == 1 ) + { + if( xAreBlockTimeTestTasksStillRunning() != pdPASS ) + { + pcStatusMessage = "Error: Block time"; + } + } + #endif /* configSTART_BLOCK_TIME_TESTS */ + + #if( configSTART_ABORT_DELAY_TESTS == 1 ) + { + if( xAreAbortDelayTestTasksStillRunning() != pdPASS ) + { + pcStatusMessage = "Error: Abort delay"; + } + } + #endif /* configSTART_ABORT_DELAY_TESTS */ + + #if( configSTART_MESSAGE_BUFFER_TESTS == 1 ) + { + if( xAreMessageBufferTasksStillRunning() != pdTRUE ) + { + pcStatusMessage = "Error: MessageBuffer"; + } + } + #endif /* configSTART_MESSAGE_BUFFER_TESTS */ + + #if( configSTART_STREAM_BUFFER_TESTS == 1 ) + { + if( xAreStreamBufferTasksStillRunning() != pdTRUE ) + { + pcStatusMessage = "Error: StreamBuffer"; + } + } + #endif /* configSTART_STREAM_BUFFER_TESTS */ + + #if( configSTART_STREAM_BUFFER_INTERRUPT_TESTS == 1 ) + { + if( xIsInterruptStreamBufferDemoStillRunning() != pdPASS ) + { + pcStatusMessage = "Error: Stream buffer interrupt"; + } + } + #endif /* configSTART_STREAM_BUFFER_INTERRUPT_TESTS */ + + #if( ( configSTART_TIMER_TESTS == 1 ) && ( configUSE_PREEMPTION != 0 ) ) + { + if( xAreTimerDemoTasksStillRunning( xCycleFrequency ) != pdTRUE ) + { + pcStatusMessage = "Error: TimerDemo"; + } + } + #endif /* ( configSTART_TIMER_TESTS == 1 ) && ( configUSE_PREEMPTION != 0 ) */ + + #if( configSTART_INTERRUPT_QUEUE_TESTS == 1 ) + { + if( xAreIntQueueTasksStillRunning() != pdTRUE ) + { + pcStatusMessage = "Error: IntQueue"; + } + } + #endif /* configSTART_INTERRUPT_QUEUE_TESTS */ + + #if( configSTART_REGISTER_TESTS == 1 ) + { + if( xAreRegisterTasksStillRunning() != pdTRUE ) + { + pcStatusMessage = "Error: RegTests"; + } + } + #endif /* configSTART_REGISTER_TESTS */ + + #if( configSTART_DELETE_SELF_TESTS == 1 ) + { + if( xIsCreateTaskStillRunning() != pdTRUE ) + { + pcStatusMessage = "Error: Death"; + } + } + #endif /* configSTART_DELETE_SELF_TESTS */ + + configPRINTF( ( "%s \r\n", pcStatusMessage ) ); + } +} +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Demo/ThirdParty/Template/TestRunner.h b/FreeRTOS/Demo/ThirdParty/Template/TestRunner.h new file mode 100644 index 0000000000..3e740b2e5e --- /dev/null +++ b/FreeRTOS/Demo/ThirdParty/Template/TestRunner.h @@ -0,0 +1,38 @@ +/* + * FreeRTOS V202104.00 + * Copyright (C) 2017 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. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +#ifndef TEST_RUNNER_H +#define TEST_RUNNER_H + +/** + * Start all the tests. + * + * Note that this function starts the scheduler and therefore, never returns. + */ +void vStartTests( void ); + +#endif /* TEST_RUNNER_H */ diff --git a/manifest.yml b/manifest.yml index 0d4940263a..099457a847 100644 --- a/manifest.yml +++ b/manifest.yml @@ -108,4 +108,18 @@ dependencies: url: "https://github.com/FreeRTOS/coreSNTP" path: "FreeRTOS-Plus/Source/Application-Protocols/coreSNTP" + - name: "FreeRTOS-Community-Supported-Demos" + version: "e21b617" + repository: + type: "git" + url: "https://github.com/FreeRTOS/FreeRTOS-Community-Supported-Demos" + path: "FreeRTOS/Demo/ThirdParty/Community-Supported-Demos" + + - name: "FreeRTOS-Partner-Supported-Demos" + version: "109ef4d" + repository: + type: "git" + url: "https://github.com/FreeRTOS/FreeRTOS-Partner-Supported-Demos" + path: "FreeRTOS/Demo/ThirdParty/Partner-Supported-Demos" + license: "MIT"