components/freertos/test_apps/freertos/kernel/README.md
The FreeRTOS tests are currently being refactored/reorganized with the goal of being upstreamed. This document describes the set of guidelines to which the tests are refactored/reorganized according to.
These test cases assume that the FreeRTOS port has also ported the Unity Test Framework. Because each FreeRTOS test case will require the scheduler to be started, the way that each test case is invoked will differ form regular Unity ports.
Regular Unity ports will assume that the main() function invokes each test using the RUN_TEST() macro. However, these test cases assume the following about the Unity port:
UnityTask instead of main(). Thus each test case is run from the context of the UnityTask.
UnityTask is created using xTaskCreate...() (and pinned to core 0 if SMP) from the port's startup (i.e., main())main()) should also start the scheduler using vTaskStartScheduler()TEST_CASE(name, ...) macro. The VA_ARGS of the macro allows each port to specify a set of extra arguments (such as test case labels/tags) to be used into their CI pipelines.portTestMacro.h must be provided by each port. This header will contain
configTEST_DEFAULT_STACK_SIZE)portTEST_GET_TIME()).#if (config... == 1) to wrap the affected areas#if (config... == 1).Each test case should have the following:
config... macrosTEST_ASSERT_...() macros provided by unity// In test_priority_scheduling.c
/*
Test Priority Scheduling (Single Core)
Purpose:
- Test that the single-core scheduler always schedules the highest priority ready task
Procedure:
- Raise the unityTask priority to (configMAX_PRIORITIES - 1)
- unityTask creates the following lower priority tasks
- task_A (configMAX_PRIORITIES - 2)
- task_B (configMAX_PRIORITIES - 3)
- UnityTask blocks for a short period of time to allow task_A to run
- Clean up and restore unityTask's original priority
Expected:
- task_A should run after unityTask blocks
- task_B should never have run
*/
#if ( configNUM_CORES == 1 )
static BaseType_t test_static_var = 0;
static void test_static_func(void)
{
...
}
TEST_CASE("Tasks: Priority scheduling single core", "[freertos]")
{
...
}
#endif /* configNUM_CORES == 1 */