diff --git a/FreeRTOS/Test/CMock/smp/config_assert/config_assert_utest.c b/FreeRTOS/Test/CMock/smp/config_assert/config_assert_utest.c index 53421af20c..4fb1aa4032 100644 --- a/FreeRTOS/Test/CMock/smp/config_assert/config_assert_utest.c +++ b/FreeRTOS/Test/CMock/smp/config_assert/config_assert_utest.c @@ -115,6 +115,7 @@ extern volatile UBaseType_t uxTopReadyPriority; extern List_t pxReadyTasksLists[ configMAX_PRIORITIES ]; extern volatile TickType_t xTickCount; extern volatile TickType_t xNextTaskUnblockTime; +extern TaskHandle_t xIdleTaskHandles[ configNUMBER_OF_CORES ]; /* ========================== STATIC FUNCTIONS ========================== */ static void vFakeAssertStub( bool x, @@ -669,3 +670,70 @@ void test_vTaskStepTick_assert_tick_to_jump_eq_0( void ) /* Test Verifications */ validate_and_clear_assertions(); } + +/** + * @brief xTaskGetIdleTaskHandleForCore - assert if xCoreID is less than 0 + * + * Coverage + * @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 + * + * Coverage + * @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. + * + * Coverage + * @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(); + } +} diff --git a/FreeRTOS/Test/CMock/smp/multiple_priorities_no_timeslice/covg_multiple_priorities_no_timeslice_utest.c b/FreeRTOS/Test/CMock/smp/multiple_priorities_no_timeslice/covg_multiple_priorities_no_timeslice_utest.c index 50f615c9f1..0647a66dc0 100644 --- a/FreeRTOS/Test/CMock/smp/multiple_priorities_no_timeslice/covg_multiple_priorities_no_timeslice_utest.c +++ b/FreeRTOS/Test/CMock/smp/multiple_priorities_no_timeslice/covg_multiple_priorities_no_timeslice_utest.c @@ -4679,3 +4679,45 @@ void test_coverage_prvCreateIdleTasks_get_static_memory( void ) 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. + * + * Coverage + * @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 ); + } +} diff --git a/FreeRTOS/Test/CMock/tasks/tasks_freertos/FreeRTOS.h b/FreeRTOS/Test/CMock/tasks/tasks_freertos/FreeRTOS.h index 62477578ab..92648a8cbf 100644 --- a/FreeRTOS/Test/CMock/tasks/tasks_freertos/FreeRTOS.h +++ b/FreeRTOS/Test/CMock/tasks/tasks_freertos/FreeRTOS.h @@ -242,6 +242,14 @@ #define INCLUDE_xTaskGetIdleTaskHandle 0 #endif +#ifndef traceENTER_xTaskGetIdleTaskHandleForCore + #define traceENTER_xTaskGetIdleTaskHandleForCore( xCoreID ) +#endif + +#ifndef traceRETURN_xTaskGetIdleTaskHandleForCore + #define traceRETURN_xTaskGetIdleTaskHandleForCore( xIdleTaskHandle ) +#endif + #ifndef INCLUDE_xTaskAbortDelay #define INCLUDE_xTaskAbortDelay 0 #endif