mirror of
https://github.com/FreeRTOS/FreeRTOS.git
synced 2026-08-17 17:12:57 +08:00
Add unit test coverage for vTaskPriorityDisinheritAfterTimeout (#1382)
CI Checks / git-secrets (push) Has been cancelled
CI Checks / formatting (push) Has been cancelled
CI Checks / spell-check (push) Has been cancelled
CI Checks / doxygen (push) Has been cancelled
CI Checks / verify-manifest (push) Has been cancelled
CI Checks / memory-statistics (push) Has been cancelled
CI Checks / proof_ci (push) Has been cancelled
FreeRTOS Demos / WIN32 MSVC (push) Has been cancelled
FreeRTOS Demos / WIN32 MingW (push) Has been cancelled
FreeRTOS Demos / Posix GCC (push) Has been cancelled
FreeRTOS Demos / GNU MSP430 Toolchain (push) Has been cancelled
FreeRTOS Demos / GNU ARM Toolchain (push) Has been cancelled
FreeRTOS MPU Demo / TI-Hercules RM46 and RM57 MPU Demos (push) Has been cancelled
Build FreeRTOS+ Demos / Windows Simulator Cellular Demos (push) Has been cancelled
Build FreeRTOS+ Demos / coreHTTP WinSim Demos (push) Has been cancelled
Build FreeRTOS+ Demos / corePKCS11 WinSim Demos (push) Has been cancelled
Build FreeRTOS+ Demos / core Library Windows Simulator Demos (push) Has been cancelled
Build FreeRTOS+ Demos / AWS IoT Windows Simulator Demos (push) Has been cancelled
Build FreeRTOS+ Demos / FreeRTOS+TCP Posix Simulator Demo (push) Has been cancelled
Build FreeRTOS+ Demos / FreeRTOS+TCP QEMU ARM MPS2 AN385 (push) Has been cancelled
Build FreeRTOS+ Demos / FreeRTOS+TCP Windows Simulator Demos (push) Has been cancelled
Build FreeRTOS+ Demos / FreeRTOS+CLI Windows Simulator Demos (push) Has been cancelled
Kernel Unit Tests / FreeRTOS/Source Submodule Revision (push) Has been cancelled
Kernel Unit Tests / FreeRTOS-Kernel Main Branch (push) Has been cancelled
CI Checks / git-secrets (push) Has been cancelled
CI Checks / formatting (push) Has been cancelled
CI Checks / spell-check (push) Has been cancelled
CI Checks / doxygen (push) Has been cancelled
CI Checks / verify-manifest (push) Has been cancelled
CI Checks / memory-statistics (push) Has been cancelled
CI Checks / proof_ci (push) Has been cancelled
FreeRTOS Demos / WIN32 MSVC (push) Has been cancelled
FreeRTOS Demos / WIN32 MingW (push) Has been cancelled
FreeRTOS Demos / Posix GCC (push) Has been cancelled
FreeRTOS Demos / GNU MSP430 Toolchain (push) Has been cancelled
FreeRTOS Demos / GNU ARM Toolchain (push) Has been cancelled
FreeRTOS MPU Demo / TI-Hercules RM46 and RM57 MPU Demos (push) Has been cancelled
Build FreeRTOS+ Demos / Windows Simulator Cellular Demos (push) Has been cancelled
Build FreeRTOS+ Demos / coreHTTP WinSim Demos (push) Has been cancelled
Build FreeRTOS+ Demos / corePKCS11 WinSim Demos (push) Has been cancelled
Build FreeRTOS+ Demos / core Library Windows Simulator Demos (push) Has been cancelled
Build FreeRTOS+ Demos / AWS IoT Windows Simulator Demos (push) Has been cancelled
Build FreeRTOS+ Demos / FreeRTOS+TCP Posix Simulator Demo (push) Has been cancelled
Build FreeRTOS+ Demos / FreeRTOS+TCP QEMU ARM MPS2 AN385 (push) Has been cancelled
Build FreeRTOS+ Demos / FreeRTOS+TCP Windows Simulator Demos (push) Has been cancelled
Build FreeRTOS+ Demos / FreeRTOS+CLI Windows Simulator Demos (push) Has been cancelled
Kernel Unit Tests / FreeRTOS/Source Submodule Revision (push) Has been cancelled
Kernel Unit Tests / FreeRTOS-Kernel Main Branch (push) Has been cancelled
vTaskPriorityDisinheritAfterTimeout has been tweaked to reset the original priority upon entry. This change modifies unit tests to verify this
This commit is contained in:
+1
-1
Submodule FreeRTOS/Source updated: 0030d609a4...1dbc77697f
@@ -50,7 +50,6 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
/* =========================== EXTERN VARIABLES =========================== */
|
||||
extern TCB_t * volatile pxCurrentTCB;
|
||||
extern List_t pxReadyTasksLists[ configMAX_PRIORITIES ];
|
||||
@@ -115,15 +114,16 @@ extern volatile UBaseType_t uxSchedulerSuspended;
|
||||
( list_item2 ).pxContainer = &( list ); \
|
||||
} while( 0 )
|
||||
|
||||
#define taskNOT_WAITING_NOTIFICATION ( ( uint8_t ) 0 )
|
||||
#define taskWAITING_NOTIFICATION ( ( uint8_t ) 1 )
|
||||
#define taskNOTIFICATION_RECEIVED ( ( uint8_t ) 2 )
|
||||
#define TCB_ARRAY 10 /* simulate up to 10 tasks: add more if needed */
|
||||
#define taskNOT_WAITING_NOTIFICATION ( ( uint8_t ) 0 )
|
||||
#define taskWAITING_NOTIFICATION ( ( uint8_t ) 1 )
|
||||
#define taskNOTIFICATION_RECEIVED ( ( uint8_t ) 2 )
|
||||
#define TCB_ARRAY 10 /* simulate up to 10 tasks: add more if needed */
|
||||
#define taskEVENT_LIST_ITEM_VALUE_IN_USE ( ( uint32_t ) 0x80000000U )
|
||||
|
||||
/**
|
||||
* @brief CException code for when a configASSERT should be intercepted.
|
||||
*/
|
||||
#define configASSERT_E 0xAA101
|
||||
#define configASSERT_E 0xAA101
|
||||
|
||||
/* =========================== GLOBAL VARIABLES =========================== */
|
||||
static StaticTask_t xIdleTaskTCB;
|
||||
@@ -1503,7 +1503,7 @@ void test_vTaskPrioritySet_success_gt_max_prio( void )
|
||||
ptcb = ( TCB_t * ) taskHandle;
|
||||
|
||||
/* expectations */
|
||||
listGET_LIST_ITEM_VALUE_ExpectAnyArgsAndReturn( 0x80000000UL );
|
||||
listGET_LIST_ITEM_VALUE_ExpectAnyArgsAndReturn( taskEVENT_LIST_ITEM_VALUE_IN_USE );
|
||||
listIS_CONTAINED_WITHIN_ExpectAndReturn( &pxReadyTasksLists[ 3 ],
|
||||
&( ptcb->xStateListItem ),
|
||||
pdTRUE );
|
||||
@@ -1528,7 +1528,7 @@ void test_vTaskPrioritySet_success_call_current_null( void )
|
||||
ptcb = ( TCB_t * ) taskHandle;
|
||||
|
||||
/* expectations */
|
||||
listGET_LIST_ITEM_VALUE_ExpectAnyArgsAndReturn( 0x80000000UL );
|
||||
listGET_LIST_ITEM_VALUE_ExpectAnyArgsAndReturn( taskEVENT_LIST_ITEM_VALUE_IN_USE );
|
||||
listIS_CONTAINED_WITHIN_ExpectAndReturn( &pxReadyTasksLists[ 3 ],
|
||||
&( ptcb->xStateListItem ),
|
||||
pdTRUE );
|
||||
@@ -1638,7 +1638,7 @@ void test_vTaskPrioritySet_success_gt_curr_prio_diff_base( void )
|
||||
ptcb = ( TCB_t * ) taskHandle;
|
||||
TEST_ASSERT_EQUAL_PTR( pxCurrentTCB, taskHandle2 );
|
||||
/* task handle will inherit the priorit of taskHandle2 */
|
||||
listGET_LIST_ITEM_VALUE_ExpectAnyArgsAndReturn( 0x80000000UL );
|
||||
listGET_LIST_ITEM_VALUE_ExpectAnyArgsAndReturn( taskEVENT_LIST_ITEM_VALUE_IN_USE );
|
||||
listIS_CONTAINED_WITHIN_ExpectAndReturn( &pxReadyTasksLists[ 3 ],
|
||||
&( taskHandle->xStateListItem ),
|
||||
pdFALSE );
|
||||
@@ -1677,7 +1677,7 @@ void test_vTaskPrioritySet_success_lt_curr_prio_diff_base( void )
|
||||
ptcb = ( TCB_t * ) taskHandle;
|
||||
TEST_ASSERT_EQUAL_PTR( pxCurrentTCB, taskHandle2 );
|
||||
/* task handle will inherit the priorit of taskHandle2 */
|
||||
listGET_LIST_ITEM_VALUE_ExpectAnyArgsAndReturn( 0x80000000UL );
|
||||
listGET_LIST_ITEM_VALUE_ExpectAnyArgsAndReturn( taskEVENT_LIST_ITEM_VALUE_IN_USE );
|
||||
listIS_CONTAINED_WITHIN_ExpectAndReturn( &pxReadyTasksLists[ 3 ],
|
||||
&( taskHandle->xStateListItem ),
|
||||
pdFALSE );
|
||||
@@ -3884,7 +3884,7 @@ void test_vTaskPlaceOnUnorderedEventList( void )
|
||||
uxSchedulerSuspended = pdTRUE;
|
||||
|
||||
/* Expectations */
|
||||
listSET_LIST_ITEM_VALUE_Expect( &ptcb->xEventListItem, 32 | 0x80000000UL );
|
||||
listSET_LIST_ITEM_VALUE_Expect( &ptcb->xEventListItem, 32 | taskEVENT_LIST_ITEM_VALUE_IN_USE );
|
||||
listINSERT_END_Expect( &eventList, &ptcb->xEventListItem );
|
||||
/* prvAddCurrentTaskToDelayedList */
|
||||
uxListRemove_ExpectAndReturn( &ptcb->xStateListItem, 1 );
|
||||
@@ -4031,7 +4031,7 @@ void test_vTaskRemoveFromUnorderedEventList( void )
|
||||
ptcb = task_handle;
|
||||
|
||||
/* Expectations */
|
||||
listSET_LIST_ITEM_VALUE_Expect( &list_item, xItemValue | 0x80000000UL );
|
||||
listSET_LIST_ITEM_VALUE_Expect( &list_item, xItemValue | taskEVENT_LIST_ITEM_VALUE_IN_USE );
|
||||
listGET_LIST_ITEM_OWNER_ExpectAndReturn( &list_item, tcb );
|
||||
listREMOVE_ITEM_Expect( &list_item );
|
||||
/* prvResetNextTaskUnblockTime */
|
||||
@@ -4069,7 +4069,7 @@ void test_vTaskRemoveFromUnorderedEventList_yielding( void )
|
||||
TEST_ASSERT_EQUAL( task_handle2, pxCurrentTCB );
|
||||
|
||||
/* Expectations */
|
||||
listSET_LIST_ITEM_VALUE_Expect( &list_item, xItemValue | 0x80000000UL );
|
||||
listSET_LIST_ITEM_VALUE_Expect( &list_item, xItemValue | taskEVENT_LIST_ITEM_VALUE_IN_USE );
|
||||
listGET_LIST_ITEM_OWNER_ExpectAndReturn( &list_item, tcb );
|
||||
/*uxListRemove_ExpectAndReturn( &list_item, pdTRUE ); */
|
||||
listREMOVE_ITEM_Expect( &( list_item ) );
|
||||
@@ -4813,35 +4813,67 @@ void test_vTaskPriorityDisinheritAfterTimeout_fail_null_handle()
|
||||
void test_vTaskPriorityDisinheritAfterTimeout_success()
|
||||
{
|
||||
TaskHandle_t mutex_holder;
|
||||
UBaseType_t inheritedPriority = 5U;
|
||||
/* Tasks at priority 1-3 are ready */
|
||||
UBaseType_t lowPriorityTasksReady = ( UBaseType_t ) ( ( 1 << 1 ) | ( 1 << 2 ) | ( 1 << 3 ) );
|
||||
|
||||
/* Setup */
|
||||
create_task_priority = 4;
|
||||
mutex_holder = create_task();
|
||||
mutex_holder->uxMutexesHeld = 1;
|
||||
mutex_holder->uxPriority = inheritedPriority;
|
||||
/* Now mark task priority 5 as ready */
|
||||
uxTopReadyPriority = ( UBaseType_t ) ( ( 1 << inheritedPriority ) | lowPriorityTasksReady );
|
||||
/* Expectations */
|
||||
listGET_LIST_ITEM_VALUE_ExpectAndReturn( &mutex_holder->xEventListItem, taskEVENT_LIST_ITEM_VALUE_IN_USE );
|
||||
listIS_CONTAINED_WITHIN_ExpectAndReturn( &pxReadyTasksLists[ inheritedPriority ],
|
||||
&mutex_holder->xStateListItem,
|
||||
pdTRUE );
|
||||
uxListRemove_ExpectAndReturn( &mutex_holder->xStateListItem, 0 );
|
||||
/* prvAddTaskToReadyList */
|
||||
listINSERT_END_Expect( &pxReadyTasksLists[ mutex_holder->uxBasePriority ],
|
||||
&mutex_holder->xStateListItem );
|
||||
/* API Call */
|
||||
vTaskPriorityDisinheritAfterTimeout( mutex_holder,
|
||||
create_task_priority - 1 );
|
||||
/* Validations */
|
||||
TEST_ASSERT_EQUAL( create_task_priority, mutex_holder->uxPriority );
|
||||
TEST_ASSERT_EQUAL( create_task_priority, mutex_holder->uxBasePriority );
|
||||
/* Priority is reset back to 4, we should expect tasks 4-1 to be ready */
|
||||
TEST_ASSERT_EQUAL( uxTopReadyPriority, ( UBaseType_t ) ( ( 1 << create_task_priority ) | lowPriorityTasksReady ) );
|
||||
}
|
||||
|
||||
void test_vTaskPriorityDisinheritAfterTimeout_success2()
|
||||
{
|
||||
TaskHandle_t mutex_holder;
|
||||
UBaseType_t inheritedPriority = 6U;
|
||||
/* Task at priority 5 is ready */
|
||||
UBaseType_t priorityFiveTaskReady = ( UBaseType_t ) ( 1 << 5 );
|
||||
|
||||
/* Setup */
|
||||
create_task_priority = 4;
|
||||
mutex_holder = create_task();
|
||||
mutex_holder->uxMutexesHeld = 1;
|
||||
mutex_holder->uxPriority = inheritedPriority;
|
||||
/* Now mark task priority 6 as ready */
|
||||
uxTopReadyPriority = ( UBaseType_t ) ( ( 1 << inheritedPriority ) | priorityFiveTaskReady );
|
||||
/* Expectations */
|
||||
listGET_LIST_ITEM_VALUE_ExpectAndReturn( &mutex_holder->xEventListItem, taskEVENT_LIST_ITEM_VALUE_IN_USE );
|
||||
listIS_CONTAINED_WITHIN_ExpectAndReturn( &pxReadyTasksLists[ inheritedPriority ],
|
||||
&mutex_holder->xStateListItem,
|
||||
pdTRUE );
|
||||
uxListRemove_ExpectAndReturn( &mutex_holder->xStateListItem, 0 );
|
||||
/* prvAddTaskToReadyList */
|
||||
listINSERT_END_Expect( &pxReadyTasksLists[ mutex_holder->uxBasePriority ],
|
||||
&mutex_holder->xStateListItem );
|
||||
/* API Call */
|
||||
vTaskPriorityDisinheritAfterTimeout( mutex_holder,
|
||||
create_task_priority );
|
||||
/* Validations */
|
||||
TEST_ASSERT_EQUAL( create_task_priority, mutex_holder->uxPriority );
|
||||
TEST_ASSERT_EQUAL( create_task_priority, mutex_holder->uxBasePriority );
|
||||
/* Priority is reset back to 4, we should expect tasks 5-4 to be ready */
|
||||
TEST_ASSERT_EQUAL( uxTopReadyPriority, ( UBaseType_t ) ( ( 1 << create_task_priority ) | priorityFiveTaskReady ) );
|
||||
}
|
||||
|
||||
void test_vTaskPriorityDisinheritAfterTimeout_success3()
|
||||
@@ -4870,7 +4902,7 @@ void test_vTaskPriorityDisinheritAfterTimeout_success4()
|
||||
mutex_holder = create_task();
|
||||
mutex_holder->uxMutexesHeld = 1;
|
||||
/* Expectations */
|
||||
listGET_LIST_ITEM_VALUE_ExpectAndReturn( &mutex_holder->xEventListItem, 0x80000000UL );
|
||||
listGET_LIST_ITEM_VALUE_ExpectAndReturn( &mutex_holder->xEventListItem, taskEVENT_LIST_ITEM_VALUE_IN_USE );
|
||||
listIS_CONTAINED_WITHIN_ExpectAndReturn( &pxReadyTasksLists[ mutex_holder->uxPriority ],
|
||||
&mutex_holder->xStateListItem,
|
||||
pdFALSE );
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ license: "MIT"
|
||||
|
||||
dependencies:
|
||||
- name: "FreeRTOS-Kernel"
|
||||
version: "0030d609a"
|
||||
version: "1dbc776"
|
||||
repository:
|
||||
type: "git"
|
||||
url: "https://github.com/FreeRTOS/FreeRTOS-Kernel.git"
|
||||
|
||||
Reference in New Issue
Block a user