mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-10-27 07:46:20 -04:00
Add eTaskConfirmSleepModeStatus unit test for SMP (#1118)
* Add eTaskConfirmSleepModeStatus unit test for SMP
This commit is contained in:
parent
660166b734
commit
31d6ace7e0
1 changed files with 51 additions and 0 deletions
|
|
@ -116,6 +116,9 @@ extern List_t pxReadyTasksLists[ configMAX_PRIORITIES ];
|
||||||
extern UBaseType_t uxTaskNumber;
|
extern UBaseType_t uxTaskNumber;
|
||||||
extern volatile TickType_t xTickCount;
|
extern volatile TickType_t xTickCount;
|
||||||
extern volatile TickType_t xNextTaskUnblockTime;
|
extern volatile TickType_t xNextTaskUnblockTime;
|
||||||
|
extern List_t xSuspendedTaskList;
|
||||||
|
extern List_t xPendingReadyList;
|
||||||
|
extern volatile TickType_t xPendedTicks;
|
||||||
|
|
||||||
/* =========================== EXTERN FUNCTIONS =========================== */
|
/* =========================== EXTERN FUNCTIONS =========================== */
|
||||||
|
|
||||||
|
|
@ -1257,3 +1260,51 @@ void test_coverage_xTaskGetSchedulerState_scheduler_not_running_and_suspended( v
|
||||||
|
|
||||||
TEST_ASSERT_EQUAL( taskSCHEDULER_SUSPENDED, xRet );
|
TEST_ASSERT_EQUAL( taskSCHEDULER_SUSPENDED, xRet );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief eTaskConfirmSleepModeStatus - confirm no task is waiting for timeout.
|
||||||
|
*
|
||||||
|
* All the tasks except idle tasks are in suspended list. The system can stay in
|
||||||
|
* a low power state. This is a regression test for SMP to ensure uxNonApplicationTasks
|
||||||
|
* is set to configNUMBER_OF_CORES in the implementation.
|
||||||
|
*
|
||||||
|
* <b>Coverage</b>
|
||||||
|
* @code{c}
|
||||||
|
* #if ( INCLUDE_vTaskSuspend == 1 )
|
||||||
|
* else if( listCURRENT_LIST_LENGTH( &xSuspendedTaskList ) == ( uxCurrentNumberOfTasks - uxNonApplicationTasks ) )
|
||||||
|
* {
|
||||||
|
* ...
|
||||||
|
* eReturn = eNoTasksWaitingTimeout;
|
||||||
|
* }
|
||||||
|
* #endif
|
||||||
|
* @endcode
|
||||||
|
* ( listCURRENT_LIST_LENGTH( &xSuspendedTaskList ) == ( uxCurrentNumberOfTasks - uxNonApplicationTasks ) ) is true.
|
||||||
|
*/
|
||||||
|
void test_coverage_eTaskConfirmSleepModeStatus_no_tasks_waiting_timeout( void )
|
||||||
|
{
|
||||||
|
eSleepModeStatus eRetStatus;
|
||||||
|
UBaseType_t uxSuspendedTask;
|
||||||
|
|
||||||
|
/* Setup */
|
||||||
|
xPendedTicks = 0;
|
||||||
|
uxSuspendedTask = 3U; /* Assume system has 3 suspended task. */
|
||||||
|
xYieldPendings[ 0 ] = 0;
|
||||||
|
|
||||||
|
/* System has uxSuspendedTask number of suspended task and configNUMBER_OF_CORES
|
||||||
|
* idle tasks. */
|
||||||
|
uxCurrentNumberOfTasks = uxSuspendedTask + configNUMBER_OF_CORES;
|
||||||
|
|
||||||
|
/* Expectations */
|
||||||
|
listCURRENT_LIST_LENGTH_ExpectAndReturn( &xPendingReadyList, 0 );
|
||||||
|
vFakePortGetCoreID_ExpectAndReturn( 0 );
|
||||||
|
listCURRENT_LIST_LENGTH_ExpectAndReturn( &xSuspendedTaskList, uxSuspendedTask );
|
||||||
|
|
||||||
|
/* API Call */
|
||||||
|
eRetStatus = eTaskConfirmSleepModeStatus();
|
||||||
|
|
||||||
|
/* Validations */
|
||||||
|
|
||||||
|
/* If the implementation sets uxNonApplicationTasks to a fixed number 1 instead of
|
||||||
|
* configNUMBER_OF_CORES, the following assertion will be violated. */
|
||||||
|
TEST_ASSERT_EQUAL( eNoTasksWaitingTimeout, eRetStatus );
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue