From 8b98d08bcc3030db5afee0ae4b756db63ad653c8 Mon Sep 17 00:00:00 2001
From: kar-rahul-aws <118818625+kar-rahul-aws@users.noreply.github.com>
Date: Tue, 18 Jul 2023 15:12:00 +0530
Subject: [PATCH] Update queue Unit Tests to add uxQueueItemSize (#1040)

Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
---
 .../generic/queue_create_dynamic_utest.c      | 29 ++++++++++++-------
 .../queue/generic/queue_create_static_utest.c | 16 ++++++----
 .../generic/queue_receive_nonblocking_utest.c |  6 ++--
 .../Test/CMock/queue/sets/queue_set_utest.c   |  4 +--
 4 files changed, 35 insertions(+), 20 deletions(-)

diff --git a/FreeRTOS/Test/CMock/queue/generic/queue_create_dynamic_utest.c b/FreeRTOS/Test/CMock/queue/generic/queue_create_dynamic_utest.c
index 2aece2140e..d7ab3ab9be 100644
--- a/FreeRTOS/Test/CMock/queue/generic/queue_create_dynamic_utest.c
+++ b/FreeRTOS/Test/CMock/queue/generic/queue_create_dynamic_utest.c
@@ -68,17 +68,17 @@ int suiteTearDown( int numFailures )
 static void test_long_queue( QueueHandle_t xQueue,
                              uint32_t maxItems )
 {
-    /* Veify that queue is empty */
+    /* Verify that queue is empty */
     TEST_ASSERT_EQUAL( 0, uxQueueMessagesWaiting( xQueue ) );
 
     queue_common_add_sequential_to_queue( xQueue, maxItems );
 
-    /* Veify that queue is full */
+    /* Verify that queue is full */
     TEST_ASSERT_EQUAL( 0, uxQueueSpacesAvailable( xQueue ) );
 
     queue_common_receive_sequential_from_queue( xQueue, maxItems, maxItems, 0 );
 
-    /* Veify that queue is empty */
+    /* Verify that queue is empty */
     TEST_ASSERT_EQUAL( 0, uxQueueMessagesWaiting( xQueue ) );
 }
 
@@ -154,7 +154,10 @@ void test_macro_xQueueCreate_oneItem_zeroLength( void )
 
     TEST_ASSERT_EQUAL( QUEUE_T_SIZE, getLastMallocSize() );
 
-    /* Veify that new queue is empty */
+    /* Verify that Queue ItemSize is zero */
+    TEST_ASSERT_EQUAL( 0, uxQueueGetQueueItemSize( xQueue ) );
+
+    /* Verify that new queue is empty */
     TEST_ASSERT_EQUAL( 0, uxQueueMessagesWaiting( xQueue ) );
 
     /* Valdiate that the queue has 1 space remaining */
@@ -177,14 +180,17 @@ void test_macro_xQueueCreate_oneItem_oneLength( void )
 
     TEST_ASSERT_EQUAL( QUEUE_T_SIZE + 1, getLastMallocSize() );
 
-    /* Veify that new queue is empty */
+    /* Verify that Queue ItemSize is one */
+    TEST_ASSERT_EQUAL( 1, uxQueueGetQueueItemSize( xQueue ) );
+
+    /* Verify that new queue is empty */
     TEST_ASSERT_EQUAL( 0, uxQueueMessagesWaiting( xQueue ) );
 
     uint8_t testval = ( uint8_t ) getNextMonotonicTestValue();
 
     TEST_ASSERT_EQUAL( pdTRUE, xQueueSend( xQueue, &testval, 0 ) );
 
-    /* Veify that queue is full */
+    /* Verify that queue is full */
     TEST_ASSERT_EQUAL( 1, uxQueueMessagesWaiting( xQueue ) );
     TEST_ASSERT_EQUAL( 0, uxQueueSpacesAvailable( xQueue ) );
 
@@ -194,7 +200,7 @@ void test_macro_xQueueCreate_oneItem_oneLength( void )
     TEST_ASSERT_EQUAL( pdTRUE, xQueueReceive( xQueue, &testVal2, 0 ) );
     TEST_ASSERT_EQUAL( testval, testVal2 );
 
-    /* Veify that queue is empty */
+    /* Verify that queue is empty */
     TEST_ASSERT_EQUAL( 0, uxQueueMessagesWaiting( xQueue ) );
     TEST_ASSERT_EQUAL( 1, uxQueueSpacesAvailable( xQueue ) );
 
@@ -222,7 +228,10 @@ void test_macro_xQueueCreate_oneItem_multiLength( void )
 
         TEST_ASSERT_EQUAL( QUEUE_T_SIZE + i, getLastMallocSize() );
 
-        /* Veify that queue is empty */
+        /* Verify that Queue ItemSize is equal to the mailbox size */
+        TEST_ASSERT_EQUAL( i, uxQueueGetQueueItemSize( xQueue ) );
+
+        /* Verify that queue is empty */
         TEST_ASSERT_EQUAL( 0, uxQueueMessagesWaiting( xQueue ) );
 
         /* Mask off the bytes we won't use */
@@ -242,7 +251,7 @@ void test_macro_xQueueCreate_oneItem_multiLength( void )
 
         TEST_ASSERT_EQUAL( pdTRUE, xQueueSend( xQueue, &testVal, 0 ) );
 
-        /* Veify that queue is also full */
+        /* Verify that queue is also full */
         TEST_ASSERT_EQUAL( 0, uxQueueSpacesAvailable( xQueue ) );
 
         uint8_t testValCheck[ MAX_MULTI_LEN ];
@@ -252,7 +261,7 @@ void test_macro_xQueueCreate_oneItem_multiLength( void )
         TEST_ASSERT_EQUAL( pdTRUE, xQueueReceive( xQueue, &testValCheck, 0 ) );
         TEST_ASSERT_EQUAL_MEMORY( testValCompare, testValCheck, MAX_MULTI_LEN );
 
-        /* Veify that queue is empty */
+        /* Verify that queue is empty */
         TEST_ASSERT_EQUAL( 0, uxQueueMessagesWaiting( xQueue ) );
 
         vQueueDelete( xQueue );
diff --git a/FreeRTOS/Test/CMock/queue/generic/queue_create_static_utest.c b/FreeRTOS/Test/CMock/queue/generic/queue_create_static_utest.c
index 8c28b104ba..9664689a44 100644
--- a/FreeRTOS/Test/CMock/queue/generic/queue_create_static_utest.c
+++ b/FreeRTOS/Test/CMock/queue/generic/queue_create_static_utest.c
@@ -69,17 +69,17 @@ int suiteTearDown( int numFailures )
 static void test_long_queue( QueueHandle_t xQueue,
                              uint32_t maxItems )
 {
-    /* Veify that queue is empty */
+    /* Verify that queue is empty */
     TEST_ASSERT_EQUAL( 0, uxQueueMessagesWaiting( xQueue ) );
 
     queue_common_add_sequential_to_queue( xQueue, maxItems );
 
-    /* Veify that queue is full */
+    /* Verify that queue is full */
     TEST_ASSERT_EQUAL( 0, uxQueueSpacesAvailable( xQueue ) );
 
     queue_common_receive_sequential_from_queue( xQueue, maxItems, maxItems, 0 );
 
-    /* Veify that queue is empty */
+    /* Verify that queue is empty */
     TEST_ASSERT_EQUAL( 0, uxQueueMessagesWaiting( xQueue ) );
 }
 
@@ -138,7 +138,10 @@ void test_macro_xQueueCreateStatic_nullQueueStorage_oneItem_zeroLength( void )
     /* validate returned queue handle */
     TEST_ASSERT_NOT_EQUAL( NULL, xQueue );
 
-    /* Veify that new queue is empty */
+    /* Verify that Queue ItemSize is zero */
+    TEST_ASSERT_EQUAL( 0, uxQueueGetQueueItemSize( xQueue ) );
+
+    /* Verify that new queue is empty */
     TEST_ASSERT_EQUAL( 0, uxQueueMessagesWaiting( xQueue ) );
 
     /* Valdiate that the queue has 1 space remaining */
@@ -184,7 +187,7 @@ void test_macro_xQueueCreateStatic_validQueueStorage_oneItem_zeroLength( void )
     uint32_t queueData;
 
     /* Expect that xQueueCreateStatic will assert because data storage is
-     *   prohibited for a zero itemLength queue */
+     * prohibited for a zero itemLength queue */
     fakeAssertExpectFail();
     QueueHandle_t xQueue = xQueueCreateStatic( 1, 0, ( void * ) &queueData, &queueBuffer );
 
@@ -205,6 +208,9 @@ void test_macro_xQueueCreateStatic_large( void )
     StaticQueue_t queueBuffer;
     QueueHandle_t xQueue = xQueueCreateStatic( MAX_QUEUE_ITEMS, sizeof( uint32_t ), ( void * ) queueStorage, &queueBuffer );
 
+    /* Verify that Queue ItemSize is 4 */
+    TEST_ASSERT_EQUAL( 4, uxQueueGetQueueItemSize( xQueue ) );
+
     test_long_queue( xQueue, MAX_QUEUE_ITEMS );
     vQueueDelete( xQueue );
 }
diff --git a/FreeRTOS/Test/CMock/queue/generic/queue_receive_nonblocking_utest.c b/FreeRTOS/Test/CMock/queue/generic/queue_receive_nonblocking_utest.c
index 0812fbe059..2c81471428 100644
--- a/FreeRTOS/Test/CMock/queue/generic/queue_receive_nonblocking_utest.c
+++ b/FreeRTOS/Test/CMock/queue/generic/queue_receive_nonblocking_utest.c
@@ -294,7 +294,7 @@ void test_xQueuePeek_noop_waiting_higher_priority( void )
 
     TEST_ASSERT_EQUAL( 1, uxQueueMessagesWaiting( xQueue ) );
 
-    /* Veify that the task Yielded */
+    /* Verify that the task Yielded */
     TEST_ASSERT_EQUAL( 1, td_task_getYieldCount() );
 
     /* Check that vTaskMissedYield was called */
@@ -338,7 +338,7 @@ void test_xQueuePeek_xQueuePeek_waiting_higher_priority( void )
 
     TEST_ASSERT_EQUAL( 1, uxQueueMessagesWaiting( xQueue ) );
 
-    /* Veify that the task Yielded */
+    /* Verify that the task Yielded */
     TEST_ASSERT_EQUAL( 1, td_task_getYieldCount() );
 
     /* Check that vTaskMissedYield was called */
@@ -382,7 +382,7 @@ void test_xQueuePeek_xQueueReceive_waiting_higher_priority( void )
 
     TEST_ASSERT_EQUAL( 0, uxQueueMessagesWaiting( xQueue ) );
 
-    /* Veify that the task Yielded */
+    /* Verify that the task Yielded */
     TEST_ASSERT_EQUAL( 1, td_task_getYieldCount() );
 
     /* Check that vTaskMissedYield was called */
diff --git a/FreeRTOS/Test/CMock/queue/sets/queue_set_utest.c b/FreeRTOS/Test/CMock/queue/sets/queue_set_utest.c
index 7da646dabb..98281a3ea7 100644
--- a/FreeRTOS/Test/CMock/queue/sets/queue_set_utest.c
+++ b/FreeRTOS/Test/CMock/queue/sets/queue_set_utest.c
@@ -115,10 +115,10 @@ void test_xQueueCreateSet_oneLength( void )
 
     TEST_ASSERT_EQUAL( QUEUE_T_SIZE + sizeof( void * ), getLastMallocSize() );
 
-    /* Veify that QueueSet is not full */
+    /* Verify that QueueSet is not full */
     TEST_ASSERT_EQUAL( 1, uxQueueSpacesAvailable( xQueueSet ) );
 
-    /* Veify that QueueSet is empty */
+    /* Verify that QueueSet is empty */
     TEST_ASSERT_EQUAL( 0, uxQueueMessagesWaiting( xQueueSet ) );
 
     vQueueDelete( xQueueSet );