Update unit tests due to task notification changes (#1177)

This commit updates the CMock unit tests according to the changes introduced
to https://github.com/FreeRTOS/FreeRTOS-Kernel/pull/982.

Co-authored-by: chinglee-iot <61685396+chinglee-iot@users.noreply.github.com>
Co-authored-by: Rahul Kar <118818625+kar-rahul-aws@users.noreply.github.com>
pull/1182/head
Darian 1 year ago committed by GitHub
parent b31b3d4eb3
commit ce28d94516
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -583,6 +583,7 @@ void test_prvGetExpectedIdleTime_assert_nextUnblock_lt_xTickCount( void )
/* vTaskSuspendAll */
vFakePortAssertIfISR_Expect();
vFakePortGetCoreID_ExpectAndReturn( 0 );
ulFakePortSetInterruptMask_ExpectAndReturn( 0 );
vFakePortGetTaskLock_Expect();
vFakePortGetISRLock_Expect();

@ -619,46 +619,6 @@ void test_coverage_vTaskPreemptionDisable_null_handle( void )
TEST_ASSERT_EQUAL( pdTRUE, pxCurrentTCBs[ 0 ]->xPreemptionDisable );
}
/**
* @brief This test ensures that when we call vTaskSuspendAll and we task of the
* current core has a critical nesting count of 1 only the scheduler is
* suspended
*
* <b>Coverage</b>
* @code{c}
* vTaskSuspendAll();
*
* if( portGET_CRITICAL_NESTING_COUNT() == 0U )
*
* @endcode
*
* configNUMBER_OF_CORES > 1
*/
void test_coverage_vTaskSuspendAll_critical_nesting_ne_zero( void )
{
TCB_t xTask = { 0 };
xTask.uxCriticalNesting = 1;
pxCurrentTCBs[ 0 ] = &xTask;
xSchedulerRunning = pdTRUE;
uxSchedulerSuspended = 0U;
/* Test Expectations */
vFakePortAssertIfISR_Expect();
ulFakePortSetInterruptMask_ExpectAndReturn( 0 );
vFakePortGetTaskLock_Expect();
vFakePortGetCoreID_ExpectAndReturn( 0 );
vFakePortGetISRLock_Expect();
vFakePortReleaseISRLock_Expect();
vFakePortClearInterruptMask_Expect( 0 );
/* API Call */
vTaskSuspendAll();
/* Test Verifications */
TEST_ASSERT_EQUAL( 1, uxSchedulerSuspended );
}
/**
* @brief This test ensures that when we call prvGetExpectedIdleTime and the top
* ready priority is greater than the idle task, we return zero,
@ -840,12 +800,17 @@ void test_coverage_prvGetExpectedIdleTime_ready_list_eq_1( void )
/* vTaskSuspendAll */
vFakePortAssertIfISR_Expect();
vFakePortGetCoreID_ExpectAndReturn( 0 );
ulFakePortSetInterruptMask_ExpectAndReturn( 0 );
vFakePortGetTaskLock_Expect();
/* prvCheckForRunStateChange */
vFakePortAssertIfISR_Expect();
vFakePortGetCoreID_ExpectAndReturn( 0 );
/* End of prvCheckForRunStateChange */
vFakePortGetISRLock_Expect();
vFakePortReleaseISRLock_Expect();
vFakePortClearInterruptMask_Expect( 0 );
/* End of vTaskSuspendAll */
ulFakePortSetInterruptMask_ExpectAndReturn( 0 );
vFakePortGetCoreID_ExpectAndReturn( 0 );
@ -941,11 +906,16 @@ void test_coverage_prvGetExpectedIdleTime_ready_list_eq_2( void )
/* vTaskSuspendAll */
vFakePortAssertIfISR_Stub( port_assert_if_isr_cb );
vFakePortGetCoreID_ExpectAndReturn( 0 );
ulFakePortSetInterruptMask_ExpectAndReturn( 0 );
vFakePortGetTaskLock_Expect();
/* prvCheckForRunStateChange */
vFakePortGetCoreID_ExpectAndReturn( 0 );
/* End of prvCheckForRunStateChange */
vFakePortGetISRLock_Expect();
vFakePortReleaseISRLock_Expect();
vFakePortClearInterruptMask_Expect( 0 );
/* End of vTaskSuspendAll */
ulFakePortSetInterruptMask_ExpectAndReturn( 0 );

@ -4928,6 +4928,8 @@ void test_ulTaskGenericNotifyTake_success( void )
task_handle = create_task();
task_handle->ulNotifiedValue[ uxIndexToWait ] = 0;
/* Expectations */
/* xTaskResumeAll */
listLIST_IS_EMPTY_ExpectAndReturn( &xPendingReadyList, pdTRUE );
/* API Call */
ret_gen_notify_take = ulTaskGenericNotifyTake( uxIndexToWait,
pdFALSE,
@ -4948,6 +4950,8 @@ void test_ulTaskGenericNotifyTake_success2( void )
task_handle = create_task();
task_handle->ulNotifiedValue[ uxIndexToWait ] = 2;
/* Expectations */
/* xTaskResumeAll */
listLIST_IS_EMPTY_ExpectAndReturn( &xPendingReadyList, pdTRUE );
/* API Call */
ret_gen_notify_take = ulTaskGenericNotifyTake( uxIndexToWait,
pdFALSE,
@ -4968,6 +4972,8 @@ void test_ulTaskGenericNotifyTake_success_clear_count( void )
task_handle = create_task();
task_handle->ulNotifiedValue[ uxIndexToWait ] = 5;
/* Expectations */
/* xTaskResumeAll */
listLIST_IS_EMPTY_ExpectAndReturn( &xPendingReadyList, pdTRUE );
/* API Call */
ret_gen_notify_take = ulTaskGenericNotifyTake( uxIndexToWait,
pdTRUE,
@ -4993,7 +4999,8 @@ void test_ulTaskGenericNotifyTake_success_yield( void )
uxListRemove_ExpectAndReturn( &ptcb->xStateListItem, 1 );
listSET_LIST_ITEM_VALUE_Expect( &ptcb->xStateListItem, xTickCount + 9 );
vListInsert_Expect( pxDelayedTaskList, &ptcb->xStateListItem );
listLIST_IS_EMPTY_ExpectAnyArgsAndReturn( pdTRUE );
/* xTaskResumeAll */
listLIST_IS_EMPTY_ExpectAndReturn( &xPendingReadyList, pdTRUE );
/* API Call */
ret_gen_notify_take = ulTaskGenericNotifyTake( uxIndexToWait,
pdFALSE,
@ -5607,16 +5614,21 @@ void test_xTaskGenericNotifyWait_success_notif_received( void )
TaskHandle_t task_handle;
/* Setup */
task_handle = create_task();
ptcb = task_handle;
ptcb->ucNotifyState[ uxIndexToWait ] = 2; /* taskNOTIFICATION_RECEIVED */
ptcb->ulNotifiedValue[ uxIndexToWait ] = 5;
/* Expectations */
/* xTaskResumeAll */
listLIST_IS_EMPTY_ExpectAndReturn( &xPendingReadyList, pdTRUE );
/* API Call */
ret = xTaskGenericNotifyWait( uxIndexToWait,
ulBitsToClearOnEntry,
ulBitsToClearOnExit,
&pullNotificationValue,
xTicksToWait );
/* Validations */
TEST_ASSERT_EQUAL( pdTRUE, ret );
TEST_ASSERT_EQUAL( 5, pullNotificationValue );
ASSERT_PORT_YIELD_WITHIN_API_NOT_CALLED();
@ -5667,12 +5679,14 @@ void test_xTaskGenericNotifyWait_success_notif_not_received_no_wait( void )
TaskHandle_t task_handle;
/* Setup */
task_handle = create_task();
ptcb = task_handle;
ptcb->ucNotifyState[ uxIndexToWait ] = 1; /* taskWAITING_NOTIFICATION */
ptcb->ulNotifiedValue[ uxIndexToWait ] = 5;
/* Expectations */
/* xTaskResumeAll */
listLIST_IS_EMPTY_ExpectAndReturn( &xPendingReadyList, pdTRUE );
/* API Call */
ret = xTaskGenericNotifyWait( uxIndexToWait,
ulBitsToClearOnEntry,
@ -5695,12 +5709,14 @@ void test_xTaskGenericNotifyWait_success_notif_not_received_pull_null( void )
TaskHandle_t task_handle;
/* Setup */
task_handle = create_task();
ptcb = task_handle;
ptcb->ucNotifyState[ uxIndexToWait ] = 1; /* taskWAITING_NOTIFICATION */
ptcb->ulNotifiedValue[ uxIndexToWait ] = 5;
/* Expectations */
/* xTaskResumeAll */
listLIST_IS_EMPTY_ExpectAndReturn( &xPendingReadyList, pdTRUE );
/* API Call */
ret = xTaskGenericNotifyWait( uxIndexToWait,
ulBitsToClearOnEntry,

Loading…
Cancel
Save