Merge branch 'main' into qemu_demo_m4_mpu
commit
5e92d2fff7
@ -1 +1 @@
|
||||
Subproject commit b41e57e7b28d714a494cc470f16a8f5fea2b9e18
|
||||
Subproject commit f940d75a1393ba976edfcce118d4d97dc234322d
|
@ -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 */
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
@ -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 <FreeRTOSConfig.h>
|
||||
|
||||
|
||||
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
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 7284d84dc88c5aaf2dc8337044177728b8bdae2d
|
||||
Subproject commit 30f6061f48e2d54625d31e72ada6f5c474fba99f
|
@ -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}
|
||||
)
|
@ -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 );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
@ -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}
|
||||
)
|
@ -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 );
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
@ -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}
|
||||
)
|
@ -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 );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
@ -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}
|
||||
)
|
@ -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 );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
@ -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 <stdint.h>
|
||||
|
||||
/* 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();
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
@ -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 */
|
@ -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 <stdint.h>
|
||||
|
||||
/* 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();
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
@ -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 */
|
@ -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 <stdint.h>
|
||||
|
||||
/* 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();
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
@ -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 */
|
@ -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 <stdint.h>
|
||||
|
||||
/* 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();
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
@ -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 */
|
Loading…
Reference in New Issue