mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-10-14 16:57:41 -04:00
Add tests to cover https://github.com/FreeRTOS/FreeRTOS-Kernel/pull/435 (#768)
Add tests to cover https://github.com/FreeRTOS/FreeRTOS-Kernel/pull/435 This ensures that the coverage does not go down with the PR https://github.com/FreeRTOS/FreeRTOS-Kernel/pull/435. Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
This commit is contained in:
parent
26dcb22052
commit
89938537bc
3 changed files with 47 additions and 7 deletions
|
@ -994,11 +994,12 @@ void test_xQueueReceiveFromISR_success( void )
|
|||
void test_xQueueReceiveFromISR_locked( void )
|
||||
{
|
||||
/* Create a new queue */
|
||||
QueueHandle_t xQueue = xQueueCreate( 1, sizeof( uint32_t ) );
|
||||
QueueHandle_t xQueue = xQueueCreate( 2, sizeof( uint32_t ) );
|
||||
|
||||
/* Send a test value so the queue is not empty */
|
||||
uint32_t testVal = getNextMonotonicTestValue();
|
||||
|
||||
( void ) xQueueSend( xQueue, &testVal, 0 );
|
||||
( void ) xQueueSend( xQueue, &testVal, 0 );
|
||||
|
||||
uxTaskGetNumberOfTasks_IgnoreAndReturn( 1 );
|
||||
|
@ -1007,16 +1008,19 @@ void test_xQueueReceiveFromISR_locked( void )
|
|||
vSetQueueRxLock( xQueue, queueLOCKED_UNMODIFIED );
|
||||
vSetQueueTxLock( xQueue, queueLOCKED_UNMODIFIED );
|
||||
|
||||
TEST_ASSERT_EQUAL( 1, uxQueueMessagesWaiting( xQueue ) );
|
||||
TEST_ASSERT_EQUAL( 2, uxQueueMessagesWaiting( xQueue ) );
|
||||
|
||||
uint32_t checkVal = INVALID_UINT32;
|
||||
|
||||
/* Run xQueueReceiveFromISR with the queue locked */
|
||||
TEST_ASSERT_EQUAL( pdTRUE, xQueueReceiveFromISR( xQueue, &checkVal, NULL ) );
|
||||
TEST_ASSERT_EQUAL( pdTRUE, xQueueReceiveFromISR( xQueue, &checkVal, NULL ) );
|
||||
|
||||
TEST_ASSERT_EQUAL( 0, uxQueueMessagesWaiting( xQueue ) );
|
||||
|
||||
/* Verify that the cRxLock counter has been incremented */
|
||||
/* Verify that the cRxLock counter has only been incremented by one
|
||||
* even after 2 calls to xQueueReceiveFromISR because there is only
|
||||
* one task in the system as returned from uxTaskGetNumberOfTasks. */
|
||||
TEST_ASSERT_EQUAL( queueLOCKED_UNMODIFIED + 1, cGetQueueRxLock( xQueue ) );
|
||||
|
||||
/* Verify that the cTxLock counter has not changed */
|
||||
|
|
|
@ -597,12 +597,13 @@ void test_macro_xQueueSendFromISR_task_waiting_lower_priority_success( void )
|
|||
*/
|
||||
void test_macro_xQueueSendFromISR_locked( void )
|
||||
{
|
||||
QueueHandle_t xQueue = xQueueCreate( 1, sizeof( uint32_t ) );
|
||||
QueueHandle_t xQueue = xQueueCreate( 2, sizeof( uint32_t ) );
|
||||
|
||||
/* Set private lock counters */
|
||||
vSetQueueRxLock( xQueue, queueLOCKED_UNMODIFIED );
|
||||
vSetQueueTxLock( xQueue, queueLOCKED_UNMODIFIED );
|
||||
|
||||
vFakePortAssertIfInterruptPriorityInvalid_Expect();
|
||||
vFakePortAssertIfInterruptPriorityInvalid_Expect();
|
||||
uxTaskGetNumberOfTasks_IgnoreAndReturn( 1 );
|
||||
|
||||
|
@ -610,21 +611,27 @@ void test_macro_xQueueSendFromISR_locked( void )
|
|||
|
||||
TEST_ASSERT_EQUAL( 0, uxQueueMessagesWaiting( xQueue ) );
|
||||
|
||||
TEST_ASSERT_EQUAL( pdTRUE, xQueueSendFromISR( xQueue, &testval, NULL ) );
|
||||
TEST_ASSERT_EQUAL( pdTRUE, xQueueSendFromISR( xQueue, &testval, NULL ) );
|
||||
|
||||
TEST_ASSERT_EQUAL( 1, uxQueueMessagesWaiting( xQueue ) );
|
||||
TEST_ASSERT_EQUAL( 2, uxQueueMessagesWaiting( xQueue ) );
|
||||
|
||||
/* Verify that the cRxLock counter has not changed */
|
||||
TEST_ASSERT_EQUAL( queueLOCKED_UNMODIFIED, cGetQueueRxLock( xQueue ) );
|
||||
|
||||
/* Verify that the cTxLock counter has been incremented */
|
||||
/* Verify that the cTxLock counter has only been incremented by one
|
||||
* even after 2 calls to xQueueSendFromISR because there is only
|
||||
* one task in the system as returned from uxTaskGetNumberOfTasks. */
|
||||
TEST_ASSERT_EQUAL( queueLOCKED_UNMODIFIED + 1, cGetQueueTxLock( xQueue ) );
|
||||
|
||||
uint32_t checkVal = INVALID_UINT32;
|
||||
|
||||
( void ) xQueueReceive( xQueue, &checkVal, 0 );
|
||||
|
||||
TEST_ASSERT_EQUAL( testval, checkVal );
|
||||
|
||||
( void ) xQueueReceive( xQueue, &checkVal, 0 );
|
||||
TEST_ASSERT_EQUAL( testval, checkVal );
|
||||
|
||||
vQueueDelete( xQueue );
|
||||
}
|
||||
|
||||
|
|
|
@ -673,3 +673,32 @@ void test_xSemaphoreTake_blocking_success_locked_low_prio_pending( void )
|
|||
|
||||
vQueueDelete( xSemaphore );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Test xSemaphoreGiveFromISR on a semaphore that is locked
|
||||
* @coverage xQueueGiveFromISR
|
||||
*/
|
||||
void test_macro_xSemaphoreGiveFromISR_locked( void )
|
||||
{
|
||||
SemaphoreHandle_t xSemaphore = xSemaphoreCreateCounting( 2, 0 );
|
||||
|
||||
/* Set private lock counters */
|
||||
vSetQueueRxLock( xSemaphore, queueLOCKED_UNMODIFIED );
|
||||
vSetQueueTxLock( xSemaphore, queueLOCKED_UNMODIFIED );
|
||||
|
||||
vFakePortAssertIfInterruptPriorityInvalid_Ignore();
|
||||
uxTaskGetNumberOfTasks_IgnoreAndReturn( 1 );
|
||||
|
||||
TEST_ASSERT_EQUAL( pdTRUE, xSemaphoreGiveFromISR( xSemaphore, NULL ) );
|
||||
TEST_ASSERT_EQUAL( pdTRUE, xSemaphoreGiveFromISR( xSemaphore, NULL ) );
|
||||
|
||||
/* Verify that the cRxLock counter has not changed */
|
||||
TEST_ASSERT_EQUAL( queueLOCKED_UNMODIFIED, cGetQueueRxLock( xSemaphore ) );
|
||||
|
||||
/* Verify that the cTxLock counter has only been incremented by one
|
||||
* even after 2 calls to xQueueSendFromISR because there is only
|
||||
* one task in the system as returned from uxTaskGetNumberOfTasks. */
|
||||
TEST_ASSERT_EQUAL( queueLOCKED_UNMODIFIED + 1, cGetQueueTxLock( xSemaphore ) );
|
||||
|
||||
vSemaphoreDelete( xSemaphore );
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue