Skip to content

Commit f430a10

Browse files
fix(freertos/tasks): Updated the xTaskGetIdleTaskHandle Test (FreeRTOS#1314)
This commit updates the xTaskGetIdleTaskHandle unit test as per the idle task naming logic. Signed-off-by: Sudeep Mohanty <sudeep.mohanty@espressif.com> Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
1 parent dfb7b28 commit f430a10

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

FreeRTOS/Test/CMock/tasks/tasks_1_utest.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3607,12 +3607,22 @@ void test_xTaskGetIdleTaskHandle_success( void )
36073607
{
36083608
TaskHandle_t ret_idle_handle;
36093609
int ret;
3610+
BaseType_t xIdleNameLen;
3611+
BaseType_t xCopyLen;
36103612

36113613
start_scheduler();
3614+
3615+
/* The length of the idle task name is limited to the minimum of the length
3616+
* of configIDLE_TASK_NAME and configMAX_TASK_NAME_LEN - 2, keeping space
3617+
* for the core ID suffix and the null-terminator. */
3618+
xIdleNameLen = sizeof( configIDLE_TASK_NAME ) - 1;
3619+
xCopyLen = ( xIdleNameLen < configMAX_TASK_NAME_LEN - 2 ) ? xIdleNameLen : configMAX_TASK_NAME_LEN - 2;
3620+
36123621
/* Api Call */
36133622
ret_idle_handle = xTaskGetIdleTaskHandle();
36143623
ptcb = ret_idle_handle;
3615-
ret = strncmp( ptcb->pcTaskName, configIDLE_TASK_NAME, configMAX_TASK_NAME_LEN - 1 );
3624+
/* Verify the base name of the idle task. */
3625+
ret = strncmp( ptcb->pcTaskName, configIDLE_TASK_NAME, xCopyLen );
36163626
TEST_ASSERT_EQUAL( 0, ret );
36173627
}
36183628

0 commit comments

Comments
 (0)