Update kernel xtaskGetHandle unit test (#1186)

pull/1191/head^2
chinglee-iot 11 months ago committed by GitHub
parent e9593edb39
commit 3f24270b4a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -2949,6 +2949,9 @@ void test_xtaskGetHandle_success( void )
/* prvSearchForNameWithinSingleList */ /* prvSearchForNameWithinSingleList */
listCURRENT_LIST_LENGTH_ExpectAndReturn( &pxReadyTasksLists[ configMAX_PRIORITIES - 1 ], listCURRENT_LIST_LENGTH_ExpectAndReturn( &pxReadyTasksLists[ configMAX_PRIORITIES - 1 ],
1 ); 1 );
listGET_LIST_ITEM_OWNER_ExpectAndReturn( &list_item, ptcb );
/* vTaskResumeAll */ /* vTaskResumeAll */
listLIST_IS_EMPTY_ExpectAndReturn( &xPendingReadyList, pdTRUE ); listLIST_IS_EMPTY_ExpectAndReturn( &xPendingReadyList, pdTRUE );
@ -2965,19 +2968,26 @@ void test_xtaskGetHandle_success_2elements( void )
task_handle = create_task(); task_handle = create_task();
task_handle2 = create_task(); task_handle2 = create_task();
strcpy( task_handle2->pcTaskName, "task2" );
ptcb = task_handle; ptcb = task_handle;
INITIALIZE_LIST_2E( pxReadyTasksLists[ configMAX_PRIORITIES - 1 ], INITIALIZE_LIST_2E( pxReadyTasksLists[ configMAX_PRIORITIES - 1 ],
list_item, list_item2, list_item, list_item2,
ptcb, task_handle2 ); ptcb, task_handle2 );
/* Expectations */ /* Expectations */
/* prvSearchForNameWithinSingleList */ /* prvSearchForNameWithinSingleList */
listCURRENT_LIST_LENGTH_ExpectAndReturn( &pxReadyTasksLists[ configMAX_PRIORITIES - 1 ], listCURRENT_LIST_LENGTH_ExpectAndReturn( &pxReadyTasksLists[ configMAX_PRIORITIES - 1 ],
1 ); 2 );
listGET_LIST_ITEM_OWNER_ExpectAndReturn( &list_item, task_handle );
listGET_LIST_ITEM_OWNER_ExpectAndReturn( &list_item2, task_handle2 );
/* vTaskResumeAll */ /* vTaskResumeAll */
listLIST_IS_EMPTY_ExpectAndReturn( &xPendingReadyList, pdTRUE ); listLIST_IS_EMPTY_ExpectAndReturn( &xPendingReadyList, pdTRUE );
/* API Call */ /* API Call */
ret_task_handle = xTaskGetHandle( "create_task" ); ret_task_handle = xTaskGetHandle( "task2" );
/* Validations */ /* Validations */
TEST_ASSERT_EQUAL_PTR( task_handle2, ret_task_handle ); TEST_ASSERT_EQUAL_PTR( task_handle2, ret_task_handle );
} }
@ -2989,6 +2999,7 @@ void test_xtaskGetHandle_success_2elements_set_index( void )
task_handle = create_task(); task_handle = create_task();
task_handle2 = create_task(); task_handle2 = create_task();
strcpy( task_handle2->pcTaskName, "task2" );
ptcb = task_handle; ptcb = task_handle;
INITIALIZE_LIST_2E( pxReadyTasksLists[ configMAX_PRIORITIES - 1 ], INITIALIZE_LIST_2E( pxReadyTasksLists[ configMAX_PRIORITIES - 1 ],
list_item, list_item2, list_item, list_item2,
@ -2999,15 +3010,20 @@ void test_xtaskGetHandle_success_2elements_set_index( void )
/* advance index */ /* advance index */
pxReadyTasksLists[ configMAX_PRIORITIES - 1 ].pxIndex = pxReadyTasksLists[ configMAX_PRIORITIES - 1 ].pxIndex =
pxReadyTasksLists[ configMAX_PRIORITIES - 1 ].pxIndex->pxNext; pxReadyTasksLists[ configMAX_PRIORITIES - 1 ].pxIndex->pxNext;
/* Expectations */ /* Expectations */
/* prvSearchForNameWithinSingleList */ /* prvSearchForNameWithinSingleList */
listCURRENT_LIST_LENGTH_ExpectAndReturn( &pxReadyTasksLists[ configMAX_PRIORITIES - 1 ], listCURRENT_LIST_LENGTH_ExpectAndReturn( &pxReadyTasksLists[ configMAX_PRIORITIES - 1 ],
1 ); 1 );
listGET_LIST_ITEM_OWNER_ExpectAndReturn( &list_item, task_handle );
listGET_LIST_ITEM_OWNER_ExpectAndReturn( &list_item2, task_handle2 );
/* vTaskResumeAll */ /* vTaskResumeAll */
listLIST_IS_EMPTY_ExpectAndReturn( &xPendingReadyList, pdTRUE ); listLIST_IS_EMPTY_ExpectAndReturn( &xPendingReadyList, pdTRUE );
/* API Call */ /* API Call */
ret_task_handle = xTaskGetHandle( "create_task" ); ret_task_handle = xTaskGetHandle( "task2" );
/* Validations */ /* Validations */
TEST_ASSERT_EQUAL_PTR( task_handle2, ret_task_handle ); TEST_ASSERT_EQUAL_PTR( task_handle2, ret_task_handle );
} }
@ -3028,6 +3044,10 @@ void test_xtaskGetHandle_fail_no_task_found( void )
listCURRENT_LIST_LENGTH_ExpectAndReturn( listCURRENT_LIST_LENGTH_ExpectAndReturn(
&pxReadyTasksLists[ configMAX_PRIORITIES - 1 ], &pxReadyTasksLists[ configMAX_PRIORITIES - 1 ],
2 ); 2 );
listGET_LIST_ITEM_OWNER_ExpectAndReturn( &list_item, task_handle );
listGET_LIST_ITEM_OWNER_ExpectAndReturn( &list_item2, task_handle2 );
int i = configMAX_PRIORITIES - 1; int i = configMAX_PRIORITIES - 1;
do do
@ -3041,6 +3061,7 @@ void test_xtaskGetHandle_fail_no_task_found( void )
listCURRENT_LIST_LENGTH_ExpectAndReturn( pxOverflowDelayedTaskList, 0 ); listCURRENT_LIST_LENGTH_ExpectAndReturn( pxOverflowDelayedTaskList, 0 );
listCURRENT_LIST_LENGTH_ExpectAndReturn( &xSuspendedTaskList, 0 ); listCURRENT_LIST_LENGTH_ExpectAndReturn( &xSuspendedTaskList, 0 );
listCURRENT_LIST_LENGTH_ExpectAndReturn( &xTasksWaitingTermination, 0 ); listCURRENT_LIST_LENGTH_ExpectAndReturn( &xTasksWaitingTermination, 0 );
/* vTaskResumeAll */ /* vTaskResumeAll */
listLIST_IS_EMPTY_ExpectAndReturn( &xPendingReadyList, pdTRUE ); listLIST_IS_EMPTY_ExpectAndReturn( &xPendingReadyList, pdTRUE );

Loading…
Cancel
Save