From f430a10431e98494145d55b03aa96650aa2dc71c Mon Sep 17 00:00:00 2001 From: Sudeep Mohanty <91244425+sudeep-mohanty@users.noreply.github.com> Date: Thu, 19 Dec 2024 22:32:48 +0530 Subject: [PATCH] fix(freertos/tasks): Updated the xTaskGetIdleTaskHandle Test (#1314) This commit updates the xTaskGetIdleTaskHandle unit test as per the idle task naming logic. Signed-off-by: Sudeep Mohanty Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com> --- FreeRTOS/Test/CMock/tasks/tasks_1_utest.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/FreeRTOS/Test/CMock/tasks/tasks_1_utest.c b/FreeRTOS/Test/CMock/tasks/tasks_1_utest.c index dbbd77b5fc..247fba5b86 100644 --- a/FreeRTOS/Test/CMock/tasks/tasks_1_utest.c +++ b/FreeRTOS/Test/CMock/tasks/tasks_1_utest.c @@ -3607,12 +3607,22 @@ void test_xTaskGetIdleTaskHandle_success( void ) { TaskHandle_t ret_idle_handle; int ret; + BaseType_t xIdleNameLen; + BaseType_t xCopyLen; start_scheduler(); + + /* The length of the idle task name is limited to the minimum of the length + * of configIDLE_TASK_NAME and configMAX_TASK_NAME_LEN - 2, keeping space + * for the core ID suffix and the null-terminator. */ + xIdleNameLen = sizeof( configIDLE_TASK_NAME ) - 1; + xCopyLen = ( xIdleNameLen < configMAX_TASK_NAME_LEN - 2 ) ? xIdleNameLen : configMAX_TASK_NAME_LEN - 2; + /* Api Call */ ret_idle_handle = xTaskGetIdleTaskHandle(); ptcb = ret_idle_handle; - ret = strncmp( ptcb->pcTaskName, configIDLE_TASK_NAME, configMAX_TASK_NAME_LEN - 1 ); + /* Verify the base name of the idle task. */ + ret = strncmp( ptcb->pcTaskName, configIDLE_TASK_NAME, xCopyLen ); TEST_ASSERT_EQUAL( 0, ret ); }