Update unit tests to match changes in queue.c (#614)

pull/617/head
Dan Good 4 years ago committed by GitHub
parent ea798d0612
commit f37753da06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1 +1 @@
Subproject commit a1b918c1aa784bec96681141601546e0becceb79
Subproject commit 8e2f723996e7ae1851310caad26e359a23da6ff0

@ -113,19 +113,11 @@ void test_macro_xQueueCreate_zeroQueueLength_zeroItemSize()
QueueHandle_t xQueue = xQueueCreate( 0, 0 );
/* validate returned queue handle */
TEST_ASSERT_NOT_EQUAL( NULL, xQueue );
TEST_ASSERT_EQUAL( NULL, xQueue );
/* verify that configASSERT was called */
TEST_ASSERT_EQUAL( true, fakeAssertGetFlagAndClear() );
TEST_ASSERT_EQUAL( QUEUE_T_SIZE, getLastMallocSize() );
/* Veify that queue is empty */
TEST_ASSERT_EQUAL( 0, uxQueueMessagesWaiting( xQueue ) );
/* Veify that queue is also full */
TEST_ASSERT_EQUAL( 0, uxQueueSpacesAvailable( xQueue ) );
vQueueDelete( xQueue );
TEST_ASSERT_EQUAL( 0, getNumberMallocCalls() );
}
/**
@ -141,19 +133,11 @@ void test_macro_xQueueCreate_zeroQueueLength_oneItemSize( void )
QueueHandle_t xQueue = xQueueCreate( 0, 1 );
/* validate returned queue handle */
TEST_ASSERT_NOT_EQUAL( NULL, xQueue );
TEST_ASSERT_EQUAL( NULL, xQueue );
/* verify that configASSERT was called */
TEST_ASSERT_EQUAL( true, fakeAssertGetFlagAndClear() );
TEST_ASSERT_EQUAL( QUEUE_T_SIZE, getLastMallocSize() );
/* Veify that new queue is empty */
TEST_ASSERT_EQUAL( 0, uxQueueMessagesWaiting( xQueue ) );
/* Valdiate that the queue is full */
TEST_ASSERT_EQUAL( 0, uxQueueSpacesAvailable( xQueue ) );
vQueueDelete( xQueue );
TEST_ASSERT_EQUAL( 0, getNumberMallocCalls() );
}
/**

@ -99,7 +99,7 @@ void test_macro_xQueueCreateStatic_null_QueueStorage_fail( void )
QueueHandle_t xQueue = xQueueCreateStatic( MAX_QUEUE_ITEMS, sizeof( uint32_t ), NULL, &queueBuffer );
/* Validate the queue handle */
TEST_ASSERT_EQUAL( &queueBuffer, xQueue );
TEST_ASSERT_EQUAL( NULL, xQueue );
TEST_ASSERT_EQUAL( true, fakeAssertGetFlagAndClear() );
}
@ -121,8 +121,8 @@ void test_macro_xQueueCreateStatic_null_queueBuffer_fail( void )
/* Validate that the queue handle is NULL */
TEST_ASSERT_EQUAL( NULL, xQueue );
/* Check that configASSERT was called */
TEST_ASSERT_EQUAL( true, fakeAssertGetFlagAndClear() );
/* Check that configASSERT was called twice */
fakeAssertVerifyNumAssertsAndClear( 2 );
}
/**
@ -170,20 +170,12 @@ void test_macro_xQueueCreateStatic_validQueueStorage_zeroItem_zeroLength( void )
TEST_ASSERT_EQUAL( true, fakeAssertGetFlagAndClear() );
/* validate returned queue handle */
TEST_ASSERT_NOT_EQUAL( NULL, xQueue );
/* Veify that new queue is empty */
TEST_ASSERT_EQUAL( 0, uxQueueMessagesWaiting( xQueue ) );
/* Valdiate that the queue has 0 space remaining */
TEST_ASSERT_EQUAL( 0, uxQueueSpacesAvailable( xQueue ) );
vQueueDelete( xQueue );
TEST_ASSERT_EQUAL( NULL, xQueue );
}
/**
* @brief Test xQueueCreateStatic with a valid buffer, uxQueueLength=1, uxItemSize=0
* @details This configuration is equivalent to a binary semaphore.
* @details This configuration is invalid and causes a configASSERT.
* @coverage xQueueGenericCreateStatic
*/
void test_macro_xQueueCreateStatic_validQueueStorage_oneItem_zeroLength( void )
@ -191,8 +183,8 @@ void test_macro_xQueueCreateStatic_validQueueStorage_oneItem_zeroLength( void )
StaticQueue_t queueBuffer;
uint32_t queueData;
/* Expect that xQueueCreateStatic will assert because data storage is not
* necessary for a zero itemLength queue */
/* Expect that xQueueCreateStatic will assert because data storage is
* prohibited for a zero itemLength queue */
fakeAssertExpectFail();
QueueHandle_t xQueue = xQueueCreateStatic( 1, 0, ( void * ) &queueData, &queueBuffer );
@ -200,21 +192,7 @@ void test_macro_xQueueCreateStatic_validQueueStorage_oneItem_zeroLength( void )
TEST_ASSERT_EQUAL( true, fakeAssertGetFlagAndClear() );
/* validate returned queue handle */
TEST_ASSERT_NOT_EQUAL( NULL, xQueue );
/* Veify that new queue is empty */
TEST_ASSERT_EQUAL( 0, uxQueueMessagesWaiting( xQueue ) );
/* Valdiate that the queue has 1 space remaining */
TEST_ASSERT_EQUAL( 1, uxQueueSpacesAvailable( xQueue ) );
/* Send a test value */
TEST_ASSERT_EQUAL( pdTRUE, xQueueSend( xQueue, NULL, 0 ) );
/* Test receive */
TEST_ASSERT_EQUAL( pdTRUE, xQueueReceive( xQueue, NULL, 0 ) );
vQueueDelete( xQueue );
TEST_ASSERT_EQUAL( NULL, xQueue );
}
/**

@ -133,70 +133,6 @@ void test_macro_xQueueSend_fail_full( void )
vQueueDelete( xQueue );
}
/**
* @brief Test xQueueSend with a queue of uxQueueLength=0, uxItemSize=0
* @details This is an invalid queue configuration and causes a failed configASSERT.
* @coverage xQueueGenericSend
*/
void test_macro_xQueueSend_fail_zeroQueueLength_zeroItemSize()
{
/* Expect that xQueueCreate will assert because a length of 0 is invalid */
fakeAssertExpectFail();
QueueHandle_t xQueue = xQueueCreate( 0, 0 );
/* Clear the assert flag*/
fakeAssertGetFlagAndClear();
uint32_t testVal = getNextMonotonicTestValue();
TEST_ASSERT_EQUAL( pdFALSE, xQueueSend( xQueue, &testVal, 0 ) );
vQueueDelete( xQueue );
}
/**
* @brief Test xQueueSend with a queue of uxQueueLength=0, uxItemSize=0 and NULL item.
* @details This is an invalid queue configuration and causes a failed configASSERT.
* @coverage xQueueGenericSend
*/
void test_macro_xQueueSend_fail_zeroQueueLength_zeroItemSize_null()
{
/* Expect that xQueueCreate will assert because a length of 0 is invalid */
fakeAssertExpectFail();
QueueHandle_t xQueue = xQueueCreate( 0, 0 );
/* Clear the assert flag*/
fakeAssertGetFlagAndClear();
TEST_ASSERT_EQUAL( pdFALSE, xQueueSend( xQueue, NULL, 0 ) );
vQueueDelete( xQueue );
}
/**
* @brief Test xQueueSend with uxQueueLength=0, uxItemSize=1
* @details xQueueSend should return pdFALSE because the queue is full.
* @coverage xQueueGenericSend
*/
void test_macro_xQueueSend_zeroQueueLength_oneItemSize( void )
{
/* Expect that xQueueCreate will assert because a length of 0 is invalid */
fakeAssertExpectFail();
QueueHandle_t xQueue = xQueueCreate( 0, 1 );
/* Clear the assert flag*/
fakeAssertGetFlagAndClear();
uint8_t testVal = getNextMonotonicTestValue();
TEST_ASSERT_EQUAL( pdFALSE, xQueueSend( xQueue, &testVal, 0 ) );
vQueueDelete( xQueue );
}
/**
* @brief Test xQueueSend with uxQueueLength=1, uxItemSize=0
* @details xQueueSend should return pdTRUE because the queue is empty.
@ -464,88 +400,6 @@ void test_macro_xQueueSendFromISR_fail( void )
vQueueDelete( xQueue );
}
/**
* @brief Test xQueueSendFromISR with a queue of uxQueueLength=0, uxItemSize=0
* @details This is an invalid queue configuration and causes a failed configASSERT.
* @coverage xQueueGenericSendFromISR
*/
void test_macro_xQueueSendFromISR_fail_zeroQueueLength_zeroItemSize()
{
/* Expect that xQueueCreate will assert because a length of 0 is invalid */
fakeAssertExpectFail();
QueueHandle_t xQueue = xQueueCreate( 0, 0 );
/* Clear the assert flag*/
fakeAssertGetFlagAndClear();
vFakePortAssertIfInterruptPriorityInvalid_Expect();
uint32_t testVal = getNextMonotonicTestValue();
TEST_ASSERT_EQUAL( 0, uxQueueMessagesWaiting( xQueue ) );
TEST_ASSERT_EQUAL( pdFALSE, xQueueSendFromISR( xQueue, &testVal, 0 ) );
TEST_ASSERT_EQUAL( 0, uxQueueMessagesWaiting( xQueue ) );
vQueueDelete( xQueue );
}
/**
* @brief Test xQueueSendFromISR with a queue of uxQueueLength=0, uxItemSize=0 and NULL item.
* @details This is an invalid queue configuration and causes a failed configASSERT.
* @coverage xQueueGenericSendFromISR
*/
void test_macro_xQueueSendFromISR_fail_zeroQueueLength_zeroItemSize_null()
{
/* Expect that xQueueCreate will assert because a length of 0 is invalid */
fakeAssertExpectFail();
QueueHandle_t xQueue = xQueueCreate( 0, 0 );
vFakePortAssertIfInterruptPriorityInvalid_Expect();
/* Clear the assert flag*/
fakeAssertGetFlagAndClear();
TEST_ASSERT_EQUAL( 0, uxQueueMessagesWaiting( xQueue ) );
TEST_ASSERT_EQUAL( pdFALSE, xQueueSendFromISR( xQueue, NULL, 0 ) );
TEST_ASSERT_EQUAL( 0, uxQueueMessagesWaiting( xQueue ) );
vQueueDelete( xQueue );
}
/**
* @brief Test xQueueSendFromISR with uxQueueLength=0, uxItemSize=1
* @details xQueueSendFromISR should return pdFALSE because the queue is full.
* @coverage xQueueGenericSendFromISR
*/
void test_macro_xQueueSendFromISR_zeroQueueLength_oneItemSize( void )
{
/* Expect that xQueueCreate will assert because a length of 0 is invalid */
fakeAssertExpectFail();
QueueHandle_t xQueue = xQueueCreate( 0, 1 );
/* Clear the assert flag*/
fakeAssertGetFlagAndClear();
uint8_t testVal = getNextMonotonicTestValue();
vFakePortAssertIfInterruptPriorityInvalid_Expect();
TEST_ASSERT_EQUAL( 0, uxQueueMessagesWaiting( xQueue ) );
TEST_ASSERT_EQUAL( pdFALSE, xQueueSendFromISR( xQueue, &testVal, 0 ) );
TEST_ASSERT_EQUAL( 0, uxQueueMessagesWaiting( xQueue ) );
vQueueDelete( xQueue );
}
/**
* @brief Test xQueueSendFromISR with uxQueueLength=1, uxItemSize=0
* @details xQueueSendFromISR should return pdTRUE because the queue is empty.

@ -69,145 +69,6 @@ int suiteTearDown( int numFailures )
/**
* @brief Test xSemaphoreTake with an invalid counting semaphore
* @details Verify that a call to xSemaphoreTake fails on a counting
* semaphore created with uxMaxCount=0 and uxInitialCount=0
* @coverage xQueueSemaphoreTake
*/
void test_macro_xSemaphoreTake_CountingSemaphore_zero_zero_fail( void )
{
/* Expect that xSemaphoreCreateCounting will assert because uxMaxCount=0 is invalid */
fakeAssertExpectFail();
SemaphoreHandle_t xSemaphore = xSemaphoreCreateCounting( 0, 0 );
fakeAssertGetNumAssertsAndClear();
/* validate returned semaphore handle */
TEST_ASSERT_NOT_EQUAL( NULL, xSemaphore );
TEST_ASSERT_EQUAL( QUEUE_T_SIZE, getLastMallocSize() );
/* Verify that an xSemaphoreTake fails */
TEST_ASSERT_EQUAL( pdFALSE, xSemaphoreTake( xSemaphore, 0 ) );
vSemaphoreDelete( xSemaphore );
}
/**
* @brief Test xSemaphoreGive with an invalid counting semaphore
* @details Verify that a call to xSemaphoreGive fails on a counting
* semaphore created with uxMaxCount=0 and uxInitialCount=0
* @coverage xQueueGenericSend
*/
void test_macro_xSemaphoreGive_CountingSemaphore_zero_zero_fail( void )
{
/* Expect that xSemaphoreCreateCounting will assert because uxMaxCount=0 is invalid */
fakeAssertExpectFail();
SemaphoreHandle_t xSemaphore = xSemaphoreCreateCounting( 0, 0 );
fakeAssertGetNumAssertsAndClear();
/* validate returned semaphore handle */
TEST_ASSERT_NOT_EQUAL( NULL, xSemaphore );
TEST_ASSERT_EQUAL( QUEUE_T_SIZE, getLastMallocSize() );
/* Verify that an xSemaphoreGive fails */
TEST_ASSERT_EQUAL( pdFALSE, xSemaphoreGive( xSemaphore ) );
vSemaphoreDelete( xSemaphore );
}
/**
* @brief Test xSemaphoreGive with xSemaphoreCreateCounting( 1, 2 )
* @details Test xSemaphoreGive with an invalid counting semaphore where
* uxInitialCount > xMaxCount
* @coverage xQueueGenericSend
*/
void test_macro_xSemaphoreGive_with_CountingSemaphore_one_two_fail( void )
{
/* Expect that xSemaphoreCreateCounting will assert because
* uxInitialCount > xMaxCount is invalid */
fakeAssertExpectFail();
SemaphoreHandle_t xSemaphore = xSemaphoreCreateCounting( 1, 2 );
fakeAssertGetFlagAndClear();
/* validate returned semaphore handle */
TEST_ASSERT_NOT_EQUAL( NULL, xSemaphore );
TEST_ASSERT_EQUAL( QUEUE_T_SIZE, getLastMallocSize() );
/* Verify that an xSemaphoreGive fails */
TEST_ASSERT_EQUAL( pdFALSE, xSemaphoreGive( xSemaphore ) );
vSemaphoreDelete( xSemaphore );
}
/**
* @brief Test xSemaphoreTake with xSemaphoreCreateCounting( 1, 2 )
* @details Test xSemaphoreTake with an invalid counting semaphore where
* uxInitialCount > xMaxCount
* @coverage xQueueSemaphoreTake
*/
void test_macro_xSemaphoreTake_with_CountingSemaphore_one_two_success( void )
{
/* Expect that xSemaphoreCreateCounting will assert because
* uxInitialCount > xMaxCount is invalid */
fakeAssertExpectFail();
SemaphoreHandle_t xSemaphore = xSemaphoreCreateCounting( 1, 2 );
fakeAssertGetFlagAndClear();
/* validate returned semaphore handle */
TEST_ASSERT_NOT_EQUAL( NULL, xSemaphore );
TEST_ASSERT_EQUAL( QUEUE_T_SIZE, getLastMallocSize() );
/* Verify that an xSemaphoreTake succeeds */
TEST_ASSERT_EQUAL( pdTRUE, xSemaphoreTake( xSemaphore, 0 ) );
vSemaphoreDelete( xSemaphore );
}
/**
* @brief Test xSemaphoreTake and xSemaphoreGive with xSemaphoreCreateCounting( 1, 2 )
* @details Test xSemaphoreTake and xSemaphoreGive with an invalid counting
* semaphore where uxInitialCount > xMaxCount.
* @coverage xQueueSemaphoreTake xQueueGenericSend
*/
void test_macro_xSemaphoreTake_xSemaphoreGive_with_CountingSemaphore_one_two_success( void )
{
/* Expect that xSemaphoreCreateCounting will assert because
* uxInitialCount > xMaxCount is invalid */
fakeAssertExpectFail();
SemaphoreHandle_t xSemaphore = xSemaphoreCreateCounting( 1, 2 );
fakeAssertGetFlagAndClear();
/* validate returned semaphore handle */
TEST_ASSERT_NOT_EQUAL( NULL, xSemaphore );
TEST_ASSERT_EQUAL( QUEUE_T_SIZE, getLastMallocSize() );
/* Verify that an xSemaphoreTake succeeds */
TEST_ASSERT_EQUAL( pdTRUE, xSemaphoreTake( xSemaphore, 0 ) );
/* Verify that a second xSemaphoreTake succeeds */
TEST_ASSERT_EQUAL( pdTRUE, xSemaphoreTake( xSemaphore, 0 ) );
/* Verify that an xSemaphoreGive succeeds */
TEST_ASSERT_EQUAL( pdTRUE, xSemaphoreGive( xSemaphore ) );
vSemaphoreDelete( xSemaphore );
}
/**
* @brief Test xSemaphoreTake with xSemaphoreCreateCounting( 1, 0 )
* @details Test xSemaphoreTake with a binary semaphore constructed with
@ -475,91 +336,6 @@ void test_macro_xSemaphoreGive_CountingSemaphore_lower_bound( void )
vSemaphoreDelete( xSemaphore );
}
/**
* @brief Test xSemaphoreGive with xSemaphoreCreateCounting( UINT64_MAX - 1, UINT64_MAX )
* @details Test xSemaphoreGive with a counting semaphore with uxMaxCount=UINT64_MAX-1 and
* uxInitialCount=UINT64_MAX
* @coverage xQueueGenericSend
*/
void test_macro_xSemaphoreGive_CountingSemaphore_over_upper_bound( void )
{
/* Expect that xSemaphoreCreateCounting will configASSERT because
* uxInitialCount > xMaxCount is invalid */
fakeAssertExpectFail();
SemaphoreHandle_t xSemaphore = xSemaphoreCreateCounting( UINT64_MAX - 1, UINT64_MAX );
/* verify that configASSERT was called */
TEST_ASSERT_EQUAL( true, fakeAssertGetFlagAndClear() );
/* validate returned semaphore handle */
TEST_ASSERT_NOT_EQUAL( NULL, xSemaphore );
TEST_ASSERT_EQUAL( QUEUE_T_SIZE, getLastMallocSize() );
/* Check the count */
TEST_ASSERT_EQUAL( UINT64_MAX, uxSemaphoreGetCount( xSemaphore ) );
/* Verify that an xSemaphoreGive operation fails */
TEST_ASSERT_EQUAL( pdFALSE, xSemaphoreGive( xSemaphore ) );
/* Check that the count has not changed */
TEST_ASSERT_EQUAL( UINT64_MAX, uxSemaphoreGetCount( xSemaphore ) );
vSemaphoreDelete( xSemaphore );
}
/**
* @brief Test xSemaphoreGive with a counting semaphore where uxInitialCount > uxMaxCount
* @details Test xSemaphoreGive with a counting semaphore with uxMaxCount=1 and
* uxInitialCount=2
* @coverage xQueueGenericSend
*/
void test_macro_xSemaphoreGive_count_higher_than_max( void )
{
/* Expect that xSemaphoreCreateCounting will assert because
* uxInitialCount > xMaxCount is invalid */
fakeAssertExpectFail();
SemaphoreHandle_t xSemaphore = xSemaphoreCreateCounting( 1, 2 );
fakeAssertGetFlagAndClear();
/* validate returned semaphore handle */
TEST_ASSERT_NOT_EQUAL( NULL, xSemaphore );
TEST_ASSERT_EQUAL( QUEUE_T_SIZE, getLastMallocSize() );
/* Check that the count was initialized correctly */
TEST_ASSERT_EQUAL( 2, uxSemaphoreGetCount( xSemaphore ) );
/* Verify that an xSemaphoreGive fails (would cause the count to increase) */
TEST_ASSERT_EQUAL( pdFALSE, xSemaphoreGive( xSemaphore ) );
/* Verify that an xSemaphoreTake succeeds */
TEST_ASSERT_EQUAL( pdTRUE, xSemaphoreTake( xSemaphore, 0 ) );
/* Check that the count has decreased */
TEST_ASSERT_EQUAL( 1, uxSemaphoreGetCount( xSemaphore ) );
/* Verify that an xSemaphoreGive fails (would cause the count to increase beyond 2) */
TEST_ASSERT_EQUAL( pdFALSE, xSemaphoreGive( xSemaphore ) );
/* Verify that an xSemaphoreTake succeds */
TEST_ASSERT_EQUAL( pdTRUE, xSemaphoreTake( xSemaphore, 0 ) );
/* Check that the count has decreased */
TEST_ASSERT_EQUAL( 0, uxSemaphoreGetCount( xSemaphore ) );
/* Verify that an xSemaphoreGive succeeds */
TEST_ASSERT_EQUAL( pdTRUE, xSemaphoreGive( xSemaphore ) );
/* Check that the count is now 1 */
TEST_ASSERT_EQUAL( 1, uxSemaphoreGetCount( xSemaphore ) );
vSemaphoreDelete( xSemaphore );
}
/**
* @brief Test xSemaphoreTake with taskSCHEDULER_SUSPENDED and timeout=10
* @details This should cause xSemaphoreTake to configASSERT because it would

@ -114,8 +114,8 @@ void test_macro_xSemaphoreCreateMutexStatic_nullptr( void )
xSemaphore = xSemaphoreCreateMutexStatic( NULL );
/* verify that configASSERT was called */
TEST_ASSERT_EQUAL( true, fakeAssertGetFlagAndClear() );
/* Check that configASSERT was called twice */
fakeAssertVerifyNumAssertsAndClear( 2 );
TEST_ASSERT_EQUAL( NULL, xSemaphore );
TEST_ASSERT_EQUAL( 0, getLastMallocSize() );

@ -112,8 +112,8 @@ void test_macro_xSemaphoreCreateRecursiveMutexStatic_nullptr( void )
xSemaphore = xSemaphoreCreateRecursiveMutexStatic( NULL );
/* verify that configASSERT was called */
TEST_ASSERT_EQUAL( true, fakeAssertGetFlagAndClear() );
/* Check that configASSERT was called twice */
fakeAssertVerifyNumAssertsAndClear( 2 );
TEST_ASSERT_EQUAL( NULL, xSemaphore );
TEST_ASSERT_EQUAL( 0, getLastMallocSize() );

@ -115,8 +115,8 @@ void test_macro_xSemaphoreCreateBinaryStatic_fail( void )
xSemaphore = xSemaphoreCreateBinaryStatic( NULL );
/* verify that configASSERT was called */
TEST_ASSERT_EQUAL( true, fakeAssertGetFlagAndClear() );
/* verify that configASSERT was called twice */
fakeAssertVerifyNumAssertsAndClear( 2 );
TEST_ASSERT_EQUAL( NULL, xSemaphore );
TEST_ASSERT_EQUAL( 0, getLastMallocSize() );
@ -216,14 +216,34 @@ void test_macro_xSemaphoreCreateCounting_one_two( void )
fakeAssertGetFlagAndClear();
/* validate returned semaphore handle */
TEST_ASSERT_NOT_EQUAL( NULL, xSemaphore );
TEST_ASSERT_EQUAL( NULL, xSemaphore );
TEST_ASSERT_EQUAL( QUEUE_T_SIZE, getLastMallocSize() );
/* Check that no call to malloc occurred */
TEST_ASSERT_EQUAL( 0, getLastMallocSize() );
}
/**
* @brief Test xSemaphoreCreateCounting with uxMaxCount=UINT64_MAX - 1 and uxInitialCount=UINT64_MAX
* @details This is an invalid initial condition for a counting semaphore since
* uxMaxCount >= uxInitialCount.
* @coverage xQueueCreateCountingSemaphore
*/
void test_macro_xSemaphoreCreateCounting_over_upper_bound( void )
{
/* Expect that xSemaphoreCreateCounting will configASSERT because
* uxInitialCount > xMaxCount is invalid */
fakeAssertExpectFail();
/* Check that the count was initialized correctly */
TEST_ASSERT_EQUAL( 2, uxSemaphoreGetCount( xSemaphore ) );
SemaphoreHandle_t xSemaphore = xSemaphoreCreateCounting( UINT64_MAX - 1, UINT64_MAX );
vSemaphoreDelete( xSemaphore );
/* verify that configASSERT was called */
TEST_ASSERT_EQUAL( true, fakeAssertGetFlagAndClear() );
/* validate returned semaphore handle */
TEST_ASSERT_EQUAL( NULL, xSemaphore );
/* Check that no call to malloc occurred */
TEST_ASSERT_EQUAL( 0, getLastMallocSize() );
}
/**
@ -259,16 +279,14 @@ void test_macro_xSemaphoreCreateCounting_zero_zero( void )
SemaphoreHandle_t xSemaphore = xSemaphoreCreateCounting( 0, 0 );
fakeAssertVerifyNumAssertsAndClear( 2 );
/* verify that configASSERT was called */
TEST_ASSERT_EQUAL( true, fakeAssertGetFlagAndClear() );
/* validate returned semaphore handle */
TEST_ASSERT_NOT_EQUAL( NULL, xSemaphore );
TEST_ASSERT_EQUAL( QUEUE_T_SIZE, getLastMallocSize() );
TEST_ASSERT_EQUAL( 0, uxSemaphoreGetCount( xSemaphore ) );
TEST_ASSERT_EQUAL( NULL, xSemaphore );
vSemaphoreDelete( xSemaphore );
/* Check that no call to malloc occurred */
TEST_ASSERT_EQUAL( 0, getLastMallocSize() );
}
/**
@ -342,8 +360,8 @@ void test_macro_xSemaphoreCreateCountingStatic_null_fail( void )
xSemaphore = xSemaphoreCreateCountingStatic( 2, 1, NULL );
/* Verify that configASSERT was called due to the null buffer */
TEST_ASSERT_EQUAL( true, fakeAssertGetFlagAndClear() );
/* verify that configASSERT was called twice */
fakeAssertVerifyNumAssertsAndClear( 2 );
/* Verify that the returned handle is NULL */
TEST_ASSERT_EQUAL( NULL, xSemaphore );
@ -367,18 +385,14 @@ void test_macro_xSemaphoreCreateCountingStatic_zero_zero_fail( void )
xSemaphore = xSemaphoreCreateCountingStatic( 0, 0, &xSemaphoreBuffer );
fakeAssertVerifyNumAssertsAndClear( 2 );
/* verify that configASSERT was called */
TEST_ASSERT_EQUAL( true, fakeAssertGetFlagAndClear() );
/* validate returned semaphore handle */
TEST_ASSERT_NOT_EQUAL( NULL, xSemaphore );
TEST_ASSERT_EQUAL( NULL, xSemaphore );
/* Check that no malloc occurred */
TEST_ASSERT_EQUAL( 0, getLastMallocSize() );
/* Check that the returned count is zero */
TEST_ASSERT_EQUAL( 0, uxSemaphoreGetCount( xSemaphore ) );
vSemaphoreDelete( xSemaphore );
}
/**
@ -401,15 +415,10 @@ void test_macro_xSemaphoreCreateCountingStatic_one_two( void )
fakeAssertGetFlagAndClear();
/* validate returned semaphore handle */
TEST_ASSERT_NOT_EQUAL( NULL, xSemaphore );
TEST_ASSERT_EQUAL( NULL, xSemaphore );
/* verify that no heap memory allocation occurred */
TEST_ASSERT_EQUAL( 0, getLastMallocSize() );
/* Check that the count was initialized correctly */
TEST_ASSERT_EQUAL( 2, uxSemaphoreGetCount( xSemaphore ) );
vSemaphoreDelete( xSemaphore );
}
/**

@ -75,47 +75,6 @@ int suiteTearDown( int numFailures )
/* ============================== Test Cases =============================== */
/**
* @brief Test xQueueSend on a member Queue (size 1) of a QueueSet (size 0)
* @details: In this case, sending to the queue causes a configASSERT, but returns pdTRUE.
* @coverage xQueueGenericSend
*/
void test_macro_xQueueSend_QueueSet_Fail( void )
{
/* Expect that xQueueCreateSet will assert because a length of 0 is invalid */
fakeAssertExpectFail();
QueueSetHandle_t xQueueSet = xQueueCreateSet( 0 );
fakeAssertGetFlagAndClear();
QueueHandle_t xQueue = xQueueCreate( 1, sizeof( uint32_t ) );
TEST_ASSERT_EQUAL( pdTRUE, xQueueAddToSet( xQueue, xQueueSet ) );
/* Expect that xQueueSend / prvNotifyQueueSetContainer will assert because
* a QueueSet length of 0 is invalid */
fakeAssertExpectFail();
uint32_t testValue = getNextMonotonicTestValue();
TEST_ASSERT_EQUAL( pdTRUE, xQueueSend( xQueue, &testValue, 0 ) );
TEST_ASSERT_EQUAL( pdTRUE, fakeAssertGetFlagAndClear() );
QueueHandle_t xQueue2 = xQueueSelectFromSet( xQueueSet, 0 );
TEST_ASSERT_EQUAL( NULL, xQueue2 );
uint32_t checkValue = INVALID_UINT32;
TEST_ASSERT_EQUAL( pdTRUE, xQueueReceive( xQueue, &checkValue, 0 ) );
TEST_ASSERT_EQUAL( testValue, checkValue );
vQueueDelete( xQueueSet );
vQueueDelete( xQueue );
}
/**
* @brief Test xQueueSend on a member Queue (size 1) of a QueueSet (size 1)
* @details: Send an item to a queue that is part of a QueueSet.

@ -95,19 +95,11 @@ void test_xQueueCreateSet_zeroLength( void )
QueueSetHandle_t xQueueSet = xQueueCreateSet( 0 );
/* validate returned QueueSet handle */
TEST_ASSERT_NOT_EQUAL( NULL, xQueueSet );
TEST_ASSERT_EQUAL( NULL, xQueueSet );
/* verify that configASSERT was called */
TEST_ASSERT_EQUAL( true, fakeAssertGetFlagAndClear() );
TEST_ASSERT_EQUAL( QUEUE_T_SIZE, getLastMallocSize() );
/* Veify that QueueSet is full */
TEST_ASSERT_EQUAL( 0, uxQueueSpacesAvailable( xQueueSet ) );
/* Veify that QueueSet is also empty */
TEST_ASSERT_EQUAL( 0, uxQueueMessagesWaiting( xQueueSet ) );
vQueueDelete( xQueueSet );
TEST_ASSERT_EQUAL( 0, getLastMallocSize() );
}
/**
@ -132,36 +124,6 @@ void test_xQueueCreateSet_oneLength( void )
vQueueDelete( xQueueSet );
}
/**
* @brief Test xQueueAddToSet with a QueueSet of uxEventQueueLength=0
* @details: Adds two queues of size 1,0 to a QueueSet of size 0.
* @coverage xQueueAddToSet
*/
void test_xQueueAddToSet_ZeroLength( void )
{
/* Expect that xQueueCreateSet will assert because a length of 0 is invalid */
fakeAssertExpectFail();
QueueSetHandle_t xQueueSet = xQueueCreateSet( 0 );
fakeAssertGetFlagAndClear();
QueueHandle_t xQueue1 = xQueueCreate( 1, 0 );
TEST_ASSERT_EQUAL( pdTRUE, xQueueAddToSet( xQueue1, xQueueSet ) );
QueueHandle_t xQueue2 = xQueueCreate( 1, 0 );
TEST_ASSERT_EQUAL( pdTRUE, xQueueAddToSet( xQueue2, xQueueSet ) );
( void ) xQueueRemoveFromSet( xQueue1, xQueueSet );
( void ) xQueueRemoveFromSet( xQueue2, xQueueSet );
vQueueDelete( xQueueSet );
vQueueDelete( xQueue1 );
vQueueDelete( xQueue2 );
}
/**
* @brief Test xQueueAddToSet with the same queue twice
* @coverage xQueueAddToSet

Loading…
Cancel
Save