mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2026-01-22 01:30:31 -05:00
Add tests to increase queue code coverage (#770)
These tests cover the following portion in the queue code:
static void prvUnlockQueue( Queue_t * const pxQueue )
{
...
if( prvNotifyQueueSetContainer( pxQueue ) != pdFALSE )
{
/* The queue is a member of a queue set, and posting to
* the queue set caused a higher priority task to unblock.
* A context switch is required. */
vTaskMissedYield();
}
else
{
mtCOVERAGE_TEST_MARKER();
}
...
}
Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
This commit is contained in:
parent
89938537bc
commit
2f5a633383
1 changed files with 91 additions and 0 deletions
|
|
@ -370,6 +370,97 @@ void test_macro_xQueueSendFromISR_in_set_high_priority_pending( void )
|
|||
vQueueDelete( xQueueSet );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Test xQueueSendFromISR with a higher priority task waiting on a locked queue in Queue Set.
|
||||
* @details Test xQueueSendFromISR with a higher priority task waiting on a locked queue and
|
||||
* verifies that xTaskResumeAll resumes the high priority task.
|
||||
* @coverage xQueueGenericSendFromISR
|
||||
*/
|
||||
void test_macro_xQueueSendFromISR_in_set_locked_and_high_priority_pending( void )
|
||||
{
|
||||
QueueHandle_t xQueue = xQueueCreate( 1, sizeof( uint32_t ) );
|
||||
QueueSetHandle_t xQueueSet = xQueueCreateSet( 1 );
|
||||
|
||||
xQueueAddToSet( xQueue, xQueueSet );
|
||||
|
||||
vFakePortAssertIfInterruptPriorityInvalid_Expect();
|
||||
|
||||
/* Insert an item into the event list. */
|
||||
td_task_setFakeTaskPriority( DEFAULT_PRIORITY + 1 );
|
||||
td_task_addFakeTaskWaitingToReceiveFromQueue( xQueueSet );
|
||||
|
||||
/* Lock the queue. */
|
||||
vSetQueueTxLock( xQueue, queueLOCKED_UNMODIFIED );
|
||||
uxTaskGetNumberOfTasks_IgnoreAndReturn( 1 );
|
||||
|
||||
uint32_t testVal = getNextMonotonicTestValue();
|
||||
|
||||
/* Add item to queue. */
|
||||
TEST_ASSERT_EQUAL( pdTRUE, xQueueSendFromISR( xQueue, &testVal, NULL ) );
|
||||
/* This call will trigger unlocking of the queue which eventually calls xTaskResumeAll. */
|
||||
TEST_ASSERT_EQUAL( errQUEUE_FULL, xQueueSend( xQueue, &testVal, 1 ) );
|
||||
|
||||
/* Ensure that the xTaskResumeAll resumes high priority task. */
|
||||
TEST_ASSERT_EQUAL( 1, td_task_getYieldCount() );
|
||||
TEST_ASSERT_EQUAL( 1, td_task_getCount_YieldFromTaskResumeAll() );
|
||||
TEST_ASSERT_EQUAL( 1, td_task_getCount_vTaskMissedYield() );
|
||||
|
||||
QueueHandle_t xQueueTemp = xQueueSelectFromSet( xQueueSet, 0 );
|
||||
uint32_t checkVal = INVALID_UINT32;
|
||||
|
||||
xQueueReceive( xQueueTemp, &checkVal, 0 );
|
||||
TEST_ASSERT_EQUAL( testVal, checkVal );
|
||||
|
||||
vQueueDelete( xQueue );
|
||||
vQueueDelete( xQueueSet );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Test xQueueSendFromISR with a low priority task waiting on a locked queue in Queue Set.
|
||||
* @details Test xQueueSendFromISR with a low priority task waiting on a locked queue and
|
||||
* verifies that xTaskResumeAll does not resume the low priority task.
|
||||
* @coverage xQueueGenericSendFromISR
|
||||
*/
|
||||
void test_macro_xQueueSendFromISR_in_set_locked_and_low_priority_pending( void )
|
||||
{
|
||||
QueueHandle_t xQueue = xQueueCreate( 1, sizeof( uint32_t ) );
|
||||
QueueSetHandle_t xQueueSet = xQueueCreateSet( 1 );
|
||||
|
||||
xQueueAddToSet( xQueue, xQueueSet );
|
||||
|
||||
vFakePortAssertIfInterruptPriorityInvalid_Expect();
|
||||
|
||||
/* Insert an item into the event list. */
|
||||
td_task_setFakeTaskPriority( DEFAULT_PRIORITY - 1 );
|
||||
td_task_addFakeTaskWaitingToReceiveFromQueue( xQueueSet );
|
||||
|
||||
/* Lock the queue. */
|
||||
vSetQueueTxLock( xQueue, queueLOCKED_UNMODIFIED );
|
||||
uxTaskGetNumberOfTasks_IgnoreAndReturn( 1 );
|
||||
|
||||
uint32_t testVal = getNextMonotonicTestValue();
|
||||
|
||||
/* Add item to queue. */
|
||||
TEST_ASSERT_EQUAL( pdTRUE, xQueueSendFromISR( xQueue, &testVal, NULL ) );
|
||||
/* This call will trigger unlocking of the queue which eventually calls xTaskResumeAll. */
|
||||
TEST_ASSERT_EQUAL( errQUEUE_FULL, xQueueSend( xQueue, &testVal, 1 ) );
|
||||
|
||||
/* Ensure that the xTaskResumeAll does not resume low priority task. */
|
||||
TEST_ASSERT_EQUAL( 0, td_task_getCount_YieldFromTaskResumeAll() );
|
||||
TEST_ASSERT_EQUAL( 0, td_task_getCount_vTaskMissedYield() );
|
||||
TEST_ASSERT_EQUAL( 1, td_task_getYieldCount() );
|
||||
TEST_ASSERT_EQUAL( 1, td_task_getCount_vPortYieldWithinAPI() );
|
||||
|
||||
QueueHandle_t xQueueTemp = xQueueSelectFromSet( xQueueSet, 0 );
|
||||
uint32_t checkVal = INVALID_UINT32;
|
||||
|
||||
xQueueReceive( xQueueTemp, &checkVal, 0 );
|
||||
TEST_ASSERT_EQUAL( testVal, checkVal );
|
||||
|
||||
vQueueDelete( xQueue );
|
||||
vQueueDelete( xQueueSet );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Test xQueueSendFromISR with a lower priority task waiting on a queue in a Queue Set
|
||||
* @details Test xQueueSendFromISR on a Queeu in a Queue Set with a lower priority task waiting and
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue