summaryrefslogtreecommitdiff
path: root/FreeRTOS/Test/CMock/queue
diff options
context:
space:
mode:
Diffstat (limited to 'FreeRTOS/Test/CMock/queue')
-rw-r--r--FreeRTOS/Test/CMock/queue/generic/Makefile1
-rw-r--r--FreeRTOS/Test/CMock/queue/generic/queue_get_static_buffers_utest.c159
-rw-r--r--FreeRTOS/Test/CMock/queue/semaphore/Makefile1
-rw-r--r--FreeRTOS/Test/CMock/queue/semaphore/semaphore_get_static_buffer_utest.c130
-rw-r--r--FreeRTOS/Test/CMock/queue/static/Makefile1
l---------FreeRTOS/Test/CMock/queue/static/queue_get_static_buffers_utest.c1
6 files changed, 293 insertions, 0 deletions
diff --git a/FreeRTOS/Test/CMock/queue/generic/Makefile b/FreeRTOS/Test/CMock/queue/generic/Makefile
index a46ad250d..91d3b8b61 100644
--- a/FreeRTOS/Test/CMock/queue/generic/Makefile
+++ b/FreeRTOS/Test/CMock/queue/generic/Makefile
@@ -26,6 +26,7 @@ SUITE_UT_SRC += queue_receive_blocking_utest.c
SUITE_UT_SRC += queue_send_nonblocking_utest.c
SUITE_UT_SRC += queue_send_blocking_utest.c
SUITE_UT_SRC += queue_status_utest.c
+SUITE_UT_SRC += queue_get_static_buffers_utest.c
# SUITE_SUPPORT_SRC: .c files used for testing that do not contain test cases.
# Paths are relative to PROJECT_DIR
diff --git a/FreeRTOS/Test/CMock/queue/generic/queue_get_static_buffers_utest.c b/FreeRTOS/Test/CMock/queue/generic/queue_get_static_buffers_utest.c
new file mode 100644
index 000000000..52c40b8e0
--- /dev/null
+++ b/FreeRTOS/Test/CMock/queue/generic/queue_get_static_buffers_utest.c
@@ -0,0 +1,159 @@
+/*
+ * FreeRTOS V202212.00
+ * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+ * the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * https://www.FreeRTOS.org
+ * https://github.com/FreeRTOS
+ *
+ */
+/*! @file queue_status_utest.c */
+
+/* C runtime includes. */
+#include <stdlib.h>
+#include <stdbool.h>
+#include <string.h>
+
+#include "../queue_utest_common.h"
+
+/* Queue includes */
+#include "FreeRTOS.h"
+#include "FreeRTOSConfig.h"
+#include "queue.h"
+
+/* ============================ GLOBAL VARIABLES =========================== */
+
+/* ========================== CALLBACK FUNCTIONS =========================== */
+
+/* ============================= Unity Fixtures ============================= */
+
+void setUp( void )
+{
+ commonSetUp();
+}
+
+void tearDown( void )
+{
+ commonTearDown();
+}
+
+void suiteSetUp()
+{
+ commonSuiteSetUp();
+}
+
+int suiteTearDown( int numFailures )
+{
+ return commonSuiteTearDown( numFailures );
+}
+
+/* ========================== Helper functions =========================== */
+
+/* ============================= Test Cases ============================== */
+
+/**
+ * @brief Test xQueueGetStaticBuffers with an invalid QueueHandle
+ * @coverage xQueueGetStaticBuffers xQueueGenericGetStaticBuffers
+ */
+void test_macro_xQueueGetStaticBuffers_invalid_handle( void )
+{
+ uint8_t * pucQueueStorageRet = NULL;
+ StaticQueue_t * pxStaticQueueRet = NULL;
+
+ EXPECT_ASSERT_BREAK( xQueueGetStaticBuffers( NULL, &pucQueueStorageRet, &pxStaticQueueRet ) );
+ TEST_ASSERT_EQUAL( NULL, pucQueueStorageRet );
+ TEST_ASSERT_EQUAL( NULL, pxStaticQueueRet );
+}
+
+/**
+ * @brief Test xQueueGetStaticBuffers with a null ppxStaticQueue argument
+ * @coverage xQueueGetStaticBuffers xQueueGenericGetStaticBuffers
+ */
+void test_macro_xQueueGetStaticBuffers_null_ppxStaticQueue( void )
+{
+ uint32_t queueStorage[ 5 ];
+ StaticQueue_t queueBuffer;
+ uint8_t * pucQueueStorageRet = NULL;
+ StaticQueue_t * pxStaticQueueRet = NULL;
+
+ QueueHandle_t xQueue = xQueueCreateStatic( 5, sizeof( uint32_t ), ( void * ) queueStorage, &queueBuffer );
+
+ EXPECT_ASSERT_BREAK( xQueueGetStaticBuffers( xQueue, &pucQueueStorageRet, NULL ) );
+
+ TEST_ASSERT_EQUAL( NULL, pucQueueStorageRet );
+ TEST_ASSERT_EQUAL( NULL, pxStaticQueueRet );
+}
+
+/**
+ * @brief Test xQueueGetStaticBuffers with a null ppucQueueStorage argument
+ * @coverage xQueueGetStaticBuffers xQueueGenericGetStaticBuffers
+ */
+void test_macro_xQueueGetStaticBuffers_null_ppucQueueStorage( void )
+{
+ uint32_t queueStorage[ 5 ];
+ StaticQueue_t queueBuffer;
+ StaticQueue_t * pxStaticQueueRet = NULL;
+
+ QueueHandle_t xQueue = xQueueCreateStatic( 5, sizeof( uint32_t ), ( void * ) queueStorage, &queueBuffer );
+
+ TEST_ASSERT_EQUAL( pdTRUE, xQueueGetStaticBuffers( xQueue, NULL, &pxStaticQueueRet ) );
+ TEST_ASSERT_EQUAL( &queueBuffer, pxStaticQueueRet );
+}
+
+/**
+ * @brief xQueueGetStaticBuffers with a statically allocated queue.
+ * @details Test xQueueGetStaticBuffers returns the buffers of a statically allocated queue
+ * @coverage xQueueGetStaticBuffers xQueueGenericGetStaticBuffers
+ */
+void test_macro_xQueueGetStaticBuffers_static( void )
+{
+ uint32_t queueStorage[ 5 ];
+ StaticQueue_t queueBuffer;
+ uint8_t * pucQueueStorageRet = NULL;
+ StaticQueue_t * pxStaticQueueRet = NULL;
+
+ QueueHandle_t xQueue = xQueueCreateStatic( 5, sizeof( uint32_t ), ( void * ) queueStorage, &queueBuffer );
+
+ TEST_ASSERT_EQUAL( pdTRUE, xQueueGetStaticBuffers( xQueue, &pucQueueStorageRet, &pxStaticQueueRet ) );
+ TEST_ASSERT_EQUAL( queueStorage, ( uint32_t * ) pucQueueStorageRet );
+ TEST_ASSERT_EQUAL( &queueBuffer, pxStaticQueueRet );
+
+ vQueueDelete( xQueue );
+}
+
+/**
+ * @brief xQueueGetStaticBuffers with a dynamically allocated queue.
+ * @details Test xQueueGetStaticBuffers returns an error when called on a dynamically allocated queue.
+ * @coverage xQueueGetStaticBuffers xQueueGenericGetStaticBuffers
+ */
+void test_macro_xQueueGetStaticBuffers_dynamic( void )
+{
+ #if configSUPPORT_DYNAMIC_ALLOCATION == 1
+ uint8_t * pucQueueStorageRet = NULL;
+ StaticQueue_t * pxStaticQueueRet = NULL;
+
+ QueueHandle_t xQueue = xQueueCreate( 5, sizeof( uint32_t ) );
+
+ TEST_ASSERT_EQUAL( pdFALSE, xQueueGetStaticBuffers( xQueue, &pucQueueStorageRet, &pxStaticQueueRet ) );
+ TEST_ASSERT_EQUAL( NULL, pucQueueStorageRet );
+ TEST_ASSERT_EQUAL( NULL, pxStaticQueueRet );
+
+ vQueueDelete( xQueue );
+ #endif /* configSUPPORT_DYNAMIC_ALLOCATION == 1 */
+}
diff --git a/FreeRTOS/Test/CMock/queue/semaphore/Makefile b/FreeRTOS/Test/CMock/queue/semaphore/Makefile
index 56fb180ad..cf635ba24 100644
--- a/FreeRTOS/Test/CMock/queue/semaphore/Makefile
+++ b/FreeRTOS/Test/CMock/queue/semaphore/Makefile
@@ -22,6 +22,7 @@ SUITE_UT_SRC += counting_semaphore_utest.c
SUITE_UT_SRC += semaphore_common_utest.c
SUITE_UT_SRC += mutex_utest.c
SUITE_UT_SRC += recursive_mutex_utest.c
+SUITE_UT_SRC += semaphore_get_static_buffer_utest.c
# SUITE_SUPPORT_SRC: .c files used for testing that do not contain test cases.
# Paths are relative to PROJECT_DIR
diff --git a/FreeRTOS/Test/CMock/queue/semaphore/semaphore_get_static_buffer_utest.c b/FreeRTOS/Test/CMock/queue/semaphore/semaphore_get_static_buffer_utest.c
new file mode 100644
index 000000000..04b1509a2
--- /dev/null
+++ b/FreeRTOS/Test/CMock/queue/semaphore/semaphore_get_static_buffer_utest.c
@@ -0,0 +1,130 @@
+/*
+ * FreeRTOS V202212.00
+ * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+ * the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * https://www.FreeRTOS.org
+ * https://github.com/FreeRTOS
+ *
+ */
+/*! @file semaphore_common_utest.c */
+
+#include "../queue_utest_common.h"
+
+/* Queue includes */
+#include "FreeRTOS.h"
+#include "FreeRTOSConfig.h"
+#include "semphr.h"
+
+
+/* ============================ GLOBAL VARIABLES =========================== */
+
+/* ========================== CALLBACK FUNCTIONS =========================== */
+
+/* ============================= Unity Fixtures ============================= */
+
+void setUp( void )
+{
+ commonSetUp();
+}
+
+void tearDown( void )
+{
+ commonTearDown();
+}
+
+void suiteSetUp()
+{
+ commonSuiteSetUp();
+}
+
+int suiteTearDown( int numFailures )
+{
+ return commonSuiteTearDown( numFailures );
+}
+
+/* =========================== Helper functions ============================ */
+
+/* ============================== Test Cases =============================== */
+
+/**
+ * @brief Test xSemaphoreGetStaticBuffer with an invalid SemaphoreHandle
+ * @coverage xSemaphoreGetStaticBuffer xQueueGenericGetStaticBuffers
+ */
+void test_macro_xSemaphoreGetStaticBuffer_null_handle( void )
+{
+ StaticSemaphore_t * pxSemaphoreBufferRet = NULL;
+
+ EXPECT_ASSERT_BREAK( xSemaphoreGetStaticBuffer( NULL, &pxSemaphoreBufferRet ) );
+
+ TEST_ASSERT_EQUAL( NULL, pxSemaphoreBufferRet );
+}
+
+/**
+ * @brief Test xSemaphoreGetStaticBuffer with a null ppxSemaphoreBuffer argument
+ * @coverage xSemaphoreGetStaticBuffer xQueueGenericGetStaticBuffers
+ */
+void test_macro_xSemaphoreGetStaticBuffer_null_ppxSemaphoreBuffer( void )
+{
+ SemaphoreHandle_t xSemaphore = NULL;
+ StaticSemaphore_t xSemaphoreBuffer;
+
+ xSemaphore = xSemaphoreCreateBinaryStatic( &xSemaphoreBuffer );
+
+ EXPECT_ASSERT_BREAK( xSemaphoreGetStaticBuffer( xSemaphore, NULL ) );
+
+ vSemaphoreDelete( xSemaphore );
+}
+
+/**
+ * @brief Test xSemaphoreGetStaticBuffer with a static Semaphore
+ * @details Test that xSemaphoreGetStaticBuffer returns the buffer of a statically allocated Semaphore
+ * @coverage xSemaphoreGetStaticBuffer xQueueGenericGetStaticBuffers
+ */
+void test_macro_xSemaphoreGetStaticBuffer_static( void )
+{
+ SemaphoreHandle_t xSemaphore = NULL;
+ StaticSemaphore_t xSemaphoreBuffer;
+ StaticSemaphore_t * pxSemaphoreBufferRet = NULL;
+
+ xSemaphore = xSemaphoreCreateBinaryStatic( &xSemaphoreBuffer );
+
+ TEST_ASSERT_EQUAL( pdTRUE, xSemaphoreGetStaticBuffer( xSemaphore, &pxSemaphoreBufferRet ) );
+ TEST_ASSERT_EQUAL( &xSemaphoreBuffer, pxSemaphoreBufferRet );
+
+ vSemaphoreDelete( xSemaphore );
+}
+
+/**
+ * @brief Test xSemaphoreGetStaticBuffer with a dynamic Semaphore
+ * @details Test that xSemaphoreGetStaticBuffer returns an error when called on a dynamically allocated Semaphore
+ * @coverage xSemaphoreGetStaticBuffer xQueueGenericGetStaticBuffers
+ */
+void test_macro_xSemaphoreGetStaticBuffer_dynamic( void )
+{
+ #if configSUPPORT_DYNAMIC_ALLOCATION == 1
+ StaticSemaphore_t * pxSemaphoreBufferRet = NULL;
+ SemaphoreHandle_t xSemaphore = xSemaphoreCreateBinary();
+
+ TEST_ASSERT_EQUAL( pdFALSE, xSemaphoreGetStaticBuffer( xSemaphore, &pxSemaphoreBufferRet ) );
+ TEST_ASSERT_EQUAL( NULL, pxSemaphoreBufferRet );
+
+ vSemaphoreDelete( xSemaphore );
+ #endif /* configSUPPORT_DYNAMIC_ALLOCATION == 1 */
+}
diff --git a/FreeRTOS/Test/CMock/queue/static/Makefile b/FreeRTOS/Test/CMock/queue/static/Makefile
index b6ad9c42f..df490d0c2 100644
--- a/FreeRTOS/Test/CMock/queue/static/Makefile
+++ b/FreeRTOS/Test/CMock/queue/static/Makefile
@@ -18,6 +18,7 @@ PROJECT_HEADER_DEPS += FreeRTOS.h
# SUITE_UT_SRC: .c files that contain test cases (must end in _utest.c)
SUITE_UT_SRC += queue_create_static_utest.c
SUITE_UT_SRC += queue_delete_static_utest.c
+SUITE_UT_SRC += queue_get_static_buffers_utest.c
# SUITE_SUPPORT_SRC: .c files used for testing that do not contain test cases.
# Paths are relative to PROJECT_DIR
diff --git a/FreeRTOS/Test/CMock/queue/static/queue_get_static_buffers_utest.c b/FreeRTOS/Test/CMock/queue/static/queue_get_static_buffers_utest.c
new file mode 120000
index 000000000..2a8297832
--- /dev/null
+++ b/FreeRTOS/Test/CMock/queue/static/queue_get_static_buffers_utest.c
@@ -0,0 +1 @@
+../generic/queue_get_static_buffers_utest.c \ No newline at end of file