mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-12-20 10:35:14 -05:00
Add kernel base priority get unit test (#1099)
* Add uxTaskBasePriorityGet and uxTaskBasePriorityGetFromISR unit test
This commit is contained in:
parent
03926888d8
commit
1114e8f39b
3 changed files with 92 additions and 2 deletions
|
|
@ -1604,6 +1604,96 @@ void test_uxTaskPriorityGetFromISR_success_null_handle( void )
|
|||
ASSERT_INVALID_INTERRUPT_PRIORITY_CALLED();
|
||||
}
|
||||
|
||||
/* ----------------------- testing uxTaskBasePriorityGet API --------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Test uxTaskBasePriorityGet with a task.
|
||||
* @details Test uxTaskBasePriorityGet returns the base priority of the task.
|
||||
*/
|
||||
void test_uxTaskBasePriorityGet_success( void )
|
||||
{
|
||||
TaskHandle_t taskHandle;
|
||||
UBaseType_t ret_priority;
|
||||
|
||||
create_task_priority = 3;
|
||||
taskHandle = create_task();
|
||||
ptcb = ( TCB_t * ) taskHandle;
|
||||
TEST_ASSERT_EQUAL_PTR( pxCurrentTCB, ptcb );
|
||||
/* expectations */
|
||||
|
||||
/* API call */
|
||||
ret_priority = uxTaskBasePriorityGet( taskHandle );
|
||||
|
||||
/* Validations */
|
||||
TEST_ASSERT_EQUAL( 3, ret_priority );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Test uxTaskBasePriorityGet with current task.
|
||||
* @details Test uxTaskBasePriorityGet returns the base priority of current task.
|
||||
*/
|
||||
void test_uxTaskBasePriorityGet_success_null_handle( void )
|
||||
{
|
||||
TaskHandle_t taskHandle;
|
||||
UBaseType_t ret_priority;
|
||||
|
||||
create_task_priority = 3;
|
||||
taskHandle = create_task();
|
||||
ptcb = ( TCB_t * ) taskHandle;
|
||||
TEST_ASSERT_EQUAL_PTR( pxCurrentTCB, ptcb );
|
||||
/* expectations */
|
||||
|
||||
/* API call */
|
||||
ret_priority = uxTaskBasePriorityGet( NULL );
|
||||
|
||||
/* Validations */
|
||||
TEST_ASSERT_EQUAL( 3, ret_priority );
|
||||
}
|
||||
|
||||
/* ----------------------- testing uxTaskBasePriorityGetFromISR API --------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Test uxTaskBasePriorityGetFromISR with a task.
|
||||
* @details Test uxTaskBasePriorityGetFromISR returns the base priority of the task.
|
||||
*/
|
||||
void test_uxTaskBasePriorityGetFromISR_success( void )
|
||||
{
|
||||
TaskHandle_t taskHandle;
|
||||
UBaseType_t ret_priority;
|
||||
|
||||
create_task_priority = 3;
|
||||
taskHandle = create_task();
|
||||
ptcb = ( TCB_t * ) taskHandle;
|
||||
TEST_ASSERT_EQUAL_PTR( pxCurrentTCB, ptcb );
|
||||
ret_priority = uxTaskBasePriorityGetFromISR( taskHandle );
|
||||
|
||||
TEST_ASSERT_EQUAL( 3, ret_priority );
|
||||
ASSERT_PORT_CLEAR_INTERRUPT_FROM_ISR_CALLED();
|
||||
ASSERT_PORT_SET_INTERRUPT_FROM_ISR_CALLED();
|
||||
ASSERT_INVALID_INTERRUPT_PRIORITY_CALLED();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Test uxTaskBasePriorityGetFromISR with current task.
|
||||
* @details Test uxTaskBasePriorityGetFromISR returns the base priority of current task.
|
||||
*/
|
||||
void test_uxTaskBasePriorityGetFromISR_success_null_handle( void )
|
||||
{
|
||||
TaskHandle_t taskHandle;
|
||||
UBaseType_t ret_priority;
|
||||
|
||||
create_task_priority = 3;
|
||||
taskHandle = create_task();
|
||||
ptcb = ( TCB_t * ) taskHandle;
|
||||
TEST_ASSERT_EQUAL_PTR( pxCurrentTCB, ptcb );
|
||||
ret_priority = uxTaskBasePriorityGetFromISR( NULL );
|
||||
|
||||
TEST_ASSERT_EQUAL( 3, ret_priority );
|
||||
ASSERT_PORT_CLEAR_INTERRUPT_FROM_ISR_CALLED();
|
||||
ASSERT_PORT_SET_INTERRUPT_FROM_ISR_CALLED();
|
||||
ASSERT_INVALID_INTERRUPT_PRIORITY_CALLED();
|
||||
}
|
||||
|
||||
/* ----------------------- testing vTaskDelay API --------------------------- */
|
||||
void test_vTaskDelay_success_gt_0_yield_called( void )
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue