mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-10-19 11:17:43 -04:00
Add unit test for xTaskGetIdleTaskHandleForCore (#1119)
* Add unit test for xTaskGetIdleTaskHandleForCore() --------- Co-authored-by: Rahul Kar <118818625+kar-rahul-aws@users.noreply.github.com>
This commit is contained in:
parent
f6d2b62ec6
commit
30fadd8d38
3 changed files with 118 additions and 0 deletions
|
@ -115,6 +115,7 @@ extern volatile UBaseType_t uxTopReadyPriority;
|
||||||
extern List_t pxReadyTasksLists[ configMAX_PRIORITIES ];
|
extern List_t pxReadyTasksLists[ configMAX_PRIORITIES ];
|
||||||
extern volatile TickType_t xTickCount;
|
extern volatile TickType_t xTickCount;
|
||||||
extern volatile TickType_t xNextTaskUnblockTime;
|
extern volatile TickType_t xNextTaskUnblockTime;
|
||||||
|
extern TaskHandle_t xIdleTaskHandles[ configNUMBER_OF_CORES ];
|
||||||
|
|
||||||
/* ========================== STATIC FUNCTIONS ========================== */
|
/* ========================== STATIC FUNCTIONS ========================== */
|
||||||
static void vFakeAssertStub( bool x,
|
static void vFakeAssertStub( bool x,
|
||||||
|
@ -669,3 +670,70 @@ void test_vTaskStepTick_assert_tick_to_jump_eq_0( void )
|
||||||
/* Test Verifications */
|
/* Test Verifications */
|
||||||
validate_and_clear_assertions();
|
validate_and_clear_assertions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief xTaskGetIdleTaskHandleForCore - assert if xCoreID is less than 0
|
||||||
|
*
|
||||||
|
* <b>Coverage</b>
|
||||||
|
* @code{c}
|
||||||
|
* configASSERT( taskVALID_CORE_ID( xCoreID ) == pdTRUE );
|
||||||
|
* @endcode
|
||||||
|
* taskVALID_CORE_ID( xCoreID ) is false with xCoreID less than 0.
|
||||||
|
*/
|
||||||
|
void test_xTaskGetIdleTaskHandleForCore_assert_invalid_core_id_lt( void )
|
||||||
|
{
|
||||||
|
/* API Call */
|
||||||
|
EXPECT_ASSERT_BREAK( xTaskGetIdleTaskHandleForCore( -1 ) );
|
||||||
|
|
||||||
|
/* Test Verifications */
|
||||||
|
validate_and_clear_assertions();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief xTaskGetIdleTaskHandleForCore - assert if xCoreID is greater or equal
|
||||||
|
* than configNUMBER_OF_CORES
|
||||||
|
*
|
||||||
|
* <b>Coverage</b>
|
||||||
|
* @code{c}
|
||||||
|
* configASSERT( taskVALID_CORE_ID( xCoreID ) == pdTRUE );
|
||||||
|
* @endcode
|
||||||
|
* taskVALID_CORE_ID( xCoreID ) is false with xCoreID greater or equal than configNUMBER_OF_CORES
|
||||||
|
*/
|
||||||
|
void test_xTaskGetIdleTaskHandleForCore_assert_invalid_core_id_ge( void )
|
||||||
|
{
|
||||||
|
/* API Call */
|
||||||
|
EXPECT_ASSERT_BREAK( xTaskGetIdleTaskHandleForCore( configNUMBER_OF_CORES ) );
|
||||||
|
|
||||||
|
/* Test Verifications */
|
||||||
|
validate_and_clear_assertions();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief xTaskGetIdleTaskHandleForCore - assert if idle task handle is NULL due to
|
||||||
|
* scheduler not started.
|
||||||
|
*
|
||||||
|
* <b>Coverage</b>
|
||||||
|
* @code{c}
|
||||||
|
* configASSERT( ( xIdleTaskHandles[ xCoreID ] != NULL ) );
|
||||||
|
* @endcode
|
||||||
|
* ( xIdleTaskHandles[ xCoreID ] != NULL ) is false.
|
||||||
|
*/
|
||||||
|
void test_xTaskGetIdleTaskHandleForCore_assert_null_idle_task_handle( void )
|
||||||
|
{
|
||||||
|
BaseType_t xCoreID;
|
||||||
|
|
||||||
|
/* Setup the variables and structure. */
|
||||||
|
for( xCoreID = 0; xCoreID < configNUMBER_OF_CORES; xCoreID++ )
|
||||||
|
{
|
||||||
|
xIdleTaskHandles[ xCoreID ] = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
for( xCoreID = 0; xCoreID < configNUMBER_OF_CORES; xCoreID++ )
|
||||||
|
{
|
||||||
|
/* API Call */
|
||||||
|
EXPECT_ASSERT_BREAK( xTaskGetIdleTaskHandleForCore( xCoreID ) );
|
||||||
|
|
||||||
|
/* Test Verifications */
|
||||||
|
validate_and_clear_assertions();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -4679,3 +4679,45 @@ void test_coverage_prvCreateIdleTasks_get_static_memory( void )
|
||||||
TEST_ASSERT_EQUAL( xIdleTaskHandles[ xCoreID ]->pxStack, &uxIdleTaskStacks[ xCoreID ][ 0 ] );
|
TEST_ASSERT_EQUAL( xIdleTaskHandles[ xCoreID ]->pxStack, &uxIdleTaskStacks[ xCoreID ][ 0 ] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief xTaskGetIdleTaskHandleForCore - get the idle task handle by core
|
||||||
|
*
|
||||||
|
* Verify idle task handle returned is correct.
|
||||||
|
*
|
||||||
|
* <b>Coverage</b>
|
||||||
|
* @code{c}
|
||||||
|
* TaskHandle_t xTaskGetIdleTaskHandleForCore( BaseType_t xCoreID )
|
||||||
|
* {
|
||||||
|
* ...
|
||||||
|
* return xIdleTaskHandles[ xCoreID ];
|
||||||
|
* }
|
||||||
|
* @endcode
|
||||||
|
* The happy path test to return the idle task handles.
|
||||||
|
*/
|
||||||
|
void test_coverage_xTaskGetIdleTaskHandleForCore_success( void )
|
||||||
|
{
|
||||||
|
TCB_t xTaskTCBs[ configNUMBER_OF_CORES ] = { NULL };
|
||||||
|
TaskHandle_t xReturnedIdleTaskHandle;
|
||||||
|
BaseType_t xCoreID;
|
||||||
|
|
||||||
|
/* Setup the variables and structure. */
|
||||||
|
/* Create coreNUMBER_OF_CORES idle tasks. */
|
||||||
|
for( xCoreID = 0; xCoreID < configNUMBER_OF_CORES; xCoreID++ )
|
||||||
|
{
|
||||||
|
vCreateStaticTestTask( &xTaskTCBs[ xCoreID ],
|
||||||
|
tskIDLE_PRIORITY,
|
||||||
|
xCoreID,
|
||||||
|
pdTRUE );
|
||||||
|
xIdleTaskHandles[ xCoreID ] = &xTaskTCBs[ xCoreID ];
|
||||||
|
}
|
||||||
|
|
||||||
|
for( xCoreID = 0; xCoreID < configNUMBER_OF_CORES; xCoreID++ )
|
||||||
|
{
|
||||||
|
/* API call. */
|
||||||
|
xReturnedIdleTaskHandle = xTaskGetIdleTaskHandleForCore( xCoreID );
|
||||||
|
|
||||||
|
/* Validation. */
|
||||||
|
TEST_ASSERT_EQUAL( xIdleTaskHandles[ xCoreID ], xReturnedIdleTaskHandle );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -242,6 +242,14 @@
|
||||||
#define INCLUDE_xTaskGetIdleTaskHandle 0
|
#define INCLUDE_xTaskGetIdleTaskHandle 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef traceENTER_xTaskGetIdleTaskHandleForCore
|
||||||
|
#define traceENTER_xTaskGetIdleTaskHandleForCore( xCoreID )
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef traceRETURN_xTaskGetIdleTaskHandleForCore
|
||||||
|
#define traceRETURN_xTaskGetIdleTaskHandleForCore( xIdleTaskHandle )
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef INCLUDE_xTaskAbortDelay
|
#ifndef INCLUDE_xTaskAbortDelay
|
||||||
#define INCLUDE_xTaskAbortDelay 0
|
#define INCLUDE_xTaskAbortDelay 0
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue