Skip to content

Commit

Permalink
Add unit tests for kernel PR FreeRTOS#679 (FreeRTOS#1015)
Browse files Browse the repository at this point in the history
Also, fix the broken tests by that PR.

Signed-off-by: Gaurav Aggarwal <[email protected]>
  • Loading branch information
aggarg authored May 25, 2023
1 parent 9e1c6e1 commit 2f5b186
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions FreeRTOS/Test/CMock/tasks/tasks_1_utest.c
Original file line number Diff line number Diff line change
Expand Up @@ -1721,6 +1721,29 @@ void test_eTaskGetState_success_current_tcb( void )
TEST_ASSERT_EQUAL( eRunning, ret_task_state );
}

void test_eTaskGetState_success_not_current_tcb_pending_ready( void )
{
TaskHandle_t task_handle;

create_task_priority = 3;
task_handle = create_task();
create_task_priority = 5;
create_task();
ptcb = ( TCB_t * ) task_handle;
TEST_ASSERT_NOT_EQUAL( pxCurrentTCB, ptcb );
eTaskState ret_task_state;
/* Expectations */
listLIST_ITEM_CONTAINER_ExpectAndReturn( &ptcb->xStateListItem,
NULL );
listLIST_ITEM_CONTAINER_ExpectAndReturn( &ptcb->xEventListItem,
&xPendingReadyList );

/* API Call */
ret_task_state = eTaskGetState( task_handle );
/* Validations */
TEST_ASSERT_EQUAL( eReady, ret_task_state );
}

void test_eTaskGetState_success_not_current_tcb_blocked_delayed( void )
{
TaskHandle_t task_handle;
Expand All @@ -1735,6 +1758,8 @@ void test_eTaskGetState_success_not_current_tcb_blocked_delayed( void )
/* Expectations */
listLIST_ITEM_CONTAINER_ExpectAndReturn( &ptcb->xStateListItem,
pxDelayedTaskList );
listLIST_ITEM_CONTAINER_ExpectAndReturn( &ptcb->xEventListItem,
NULL );

/* API Call */
ret_task_state = eTaskGetState( task_handle );
Expand All @@ -1756,6 +1781,8 @@ void test_eTaskGetState_success_not_current_tcb_blocked_overflow( void )
/* Expectations */
listLIST_ITEM_CONTAINER_ExpectAndReturn( &ptcb->xStateListItem,
pxOverflowDelayedTaskList );
listLIST_ITEM_CONTAINER_ExpectAndReturn( &ptcb->xEventListItem,
NULL );

/* API Call */
ret_task_state = eTaskGetState( task_handle );
Expand All @@ -1777,6 +1804,8 @@ void test_eTaskGetState_success_not_current_tcb_ready( void )
/* Expectations */
listLIST_ITEM_CONTAINER_ExpectAndReturn( &ptcb->xStateListItem,
&pxReadyTasksLists[ 0 ] );
listLIST_ITEM_CONTAINER_ExpectAndReturn( &ptcb->xEventListItem,
NULL );

/* API Call */
ret_task_state = eTaskGetState( task_handle );
Expand All @@ -1800,6 +1829,8 @@ void test_eTaskGetState_success_not_current_tcb_suspended( void )
&xSuspendedTaskList );
listLIST_ITEM_CONTAINER_ExpectAndReturn( &ptcb->xEventListItem,
NULL );
listLIST_ITEM_CONTAINER_ExpectAndReturn( &ptcb->xEventListItem,
NULL );

/* API Call */
ret_task_state = eTaskGetState( task_handle );
Expand All @@ -1821,6 +1852,8 @@ void test_eTaskGetState_success_not_current_tcb_deleted( void )
/* Expectations */
listLIST_ITEM_CONTAINER_ExpectAndReturn( &ptcb->xStateListItem,
&xTasksWaitingTermination );
listLIST_ITEM_CONTAINER_ExpectAndReturn( &ptcb->xEventListItem,
NULL );

/* API Call */
ret_task_state = eTaskGetState( task_handle );
Expand All @@ -1842,6 +1875,9 @@ void test_eTaskGetState_success_not_current_tcb_deleted_not_found( void )
/* Expectations */
listLIST_ITEM_CONTAINER_ExpectAndReturn( &ptcb->xStateListItem,
NULL );
listLIST_ITEM_CONTAINER_ExpectAndReturn( &ptcb->xEventListItem,
NULL );

/* API Call */
ret_task_state = eTaskGetState( task_handle );
/* Validations */
Expand Down Expand Up @@ -1870,6 +1906,8 @@ void test_eTaskGetState_success_not_current_tcb_wait_notif( void )
&xSuspendedTaskList );
listLIST_ITEM_CONTAINER_ExpectAndReturn( &ptcb->xEventListItem,
NULL );
listLIST_ITEM_CONTAINER_ExpectAndReturn( &ptcb->xEventListItem,
NULL );

/* API Call */
ret_task_state = eTaskGetState( task_handle );
Expand All @@ -1893,6 +1931,8 @@ void test_eTaskGetState_success_not_current_tcb_blocked( void )
&xSuspendedTaskList );
listLIST_ITEM_CONTAINER_ExpectAndReturn( &ptcb->xEventListItem,
&xSuspendedTaskList );
listLIST_ITEM_CONTAINER_ExpectAndReturn( &ptcb->xEventListItem,
&xSuspendedTaskList );
/* API Call */
ret_task_state = eTaskGetState( task_handle );
/* Validations */
Expand Down Expand Up @@ -3101,6 +3141,7 @@ void test_xTaskAbortDelay_success( void )
/* eTaskGetState */
listLIST_ITEM_CONTAINER_ExpectAndReturn( &ptcb->xStateListItem,
pxDelayedTaskList );
listLIST_ITEM_CONTAINER_ExpectAndReturn( &ptcb->xEventListItem, NULL );
/* back */
uxListRemove_ExpectAndReturn( &tcb->xStateListItem, pdTRUE );
listLIST_ITEM_CONTAINER_ExpectAndReturn( &ptcb->xEventListItem, NULL );
Expand Down Expand Up @@ -3147,6 +3188,8 @@ void test_xTaskAbortDelay_success_notdelayed( void )
/* eTaskGetState */
listLIST_ITEM_CONTAINER_ExpectAndReturn( &ptcb->xStateListItem,
pxDelayedTaskList );
listLIST_ITEM_CONTAINER_ExpectAndReturn( &ptcb->xEventListItem,
pxDelayedTaskList );
/* back */
uxListRemove_ExpectAndReturn( &tcb->xStateListItem, pdTRUE );
listLIST_ITEM_CONTAINER_ExpectAndReturn( &ptcb->xEventListItem,
Expand Down

0 comments on commit 2f5b186

Please sign in to comment.