]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Demo/Common/Minimal/QueueSet.c
Increase test coverage for queue sets.
[freertos] / FreeRTOS / Demo / Common / Minimal / QueueSet.c
index da688d905273c3ffe563bb66c8f209c46d786e68..ad34a50e53d68d0695d5eb5bb853162d647269dc 100644 (file)
@@ -1,71 +1,29 @@
 /*\r
-    FreeRTOS V9.0.0rc2 - Copyright (C) 2016 Real Time Engineers Ltd.\r
-    All rights reserved\r
-\r
-    VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
-\r
-    This file is part of the FreeRTOS distribution.\r
-\r
-    FreeRTOS is free software; you can redistribute it and/or modify it under\r
-    the terms of the GNU General Public License (version 2) as published by the\r
-    Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.\r
-\r
-    ***************************************************************************\r
-    >>!   NOTE: The modification to the GPL is included to allow you to     !<<\r
-    >>!   distribute a combined work that includes FreeRTOS without being   !<<\r
-    >>!   obliged to provide the source code for proprietary components     !<<\r
-    >>!   outside of the FreeRTOS kernel.                                   !<<\r
-    ***************************************************************************\r
-\r
-    FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
-    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
-    FOR A PARTICULAR PURPOSE.  Full license text is available on the following\r
-    link: http://www.freertos.org/a00114.html\r
-\r
-    ***************************************************************************\r
-     *                                                                       *\r
-     *    FreeRTOS provides completely free yet professionally developed,    *\r
-     *    robust, strictly quality controlled, supported, and cross          *\r
-     *    platform software that is more than just the market leader, it     *\r
-     *    is the industry's de facto standard.                               *\r
-     *                                                                       *\r
-     *    Help yourself get started quickly while simultaneously helping     *\r
-     *    to support the FreeRTOS project by purchasing a FreeRTOS           *\r
-     *    tutorial book, reference manual, or both:                          *\r
-     *    http://www.FreeRTOS.org/Documentation                              *\r
-     *                                                                       *\r
-    ***************************************************************************\r
-\r
-    http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading\r
-    the FAQ page "My application does not run, what could be wrong?".  Have you\r
-    defined configASSERT()?\r
-\r
-    http://www.FreeRTOS.org/support - In return for receiving this top quality\r
-    embedded software for free we request you assist our global community by\r
-    participating in the support forum.\r
-\r
-    http://www.FreeRTOS.org/training - Investing in training allows your team to\r
-    be as productive as possible as early as possible.  Now you can receive\r
-    FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers\r
-    Ltd, and the world's leading authority on the world's leading RTOS.\r
-\r
-    http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
-    including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
-    compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
-\r
-    http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
-    Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
-\r
-    http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High\r
-    Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
-    licenses offer ticketed support, indemnification and commercial middleware.\r
-\r
-    http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
-    engineered and independently SIL3 certified version for use in safety and\r
-    mission critical applications that require provable dependability.\r
-\r
-    1 tab == 4 spaces!\r
-*/\r
+ * FreeRTOS Kernel V10.2.1\r
+ * Copyright (C) 2019 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of\r
+ * this software and associated documentation files (the "Software"), to deal in\r
+ * the Software without restriction, including without limitation the rights to\r
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\r
+ * the Software, and to permit persons to whom the Software is furnished to do so,\r
+ * subject to the following conditions:\r
+ *\r
+ * The above copyright notice and this permission notice shall be included in all\r
+ * copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+ *\r
+ * http://www.FreeRTOS.org\r
+ * http://aws.amazon.com/freertos\r
+ *\r
+ * 1 tab == 4 spaces!\r
+ */\r
 \r
 /*\r
  * Tests the use of queue sets.\r
 /* Demo includes. */\r
 #include "QueueSet.h"\r
 \r
+\r
+#if( configUSE_QUEUE_SETS == 1 ) /* Remove the tests if queue sets are not defined. */\r
+\r
+\r
 /* The number of queues that are created and added to the queue set. */\r
 #define queuesetNUM_QUEUES_IN_SET 3\r
 \r
@@ -180,9 +142,24 @@ static BaseType_t prvCheckReceivedValueWithinExpectedRange( uint32_t ulReceived,
 \r
 /*\r
  * Increase test coverage by occasionally change the priorities of the two tasks\r
- * relative to each other. */\r
+ * relative to each other.\r
+ */\r
 static void prvChangeRelativePriorities( void );\r
 \r
+/*\r
+ * Queue overwrites can only be performed on queues of length of one, requiring\r
+ * a special test function so a queue of length 1 can temporarily be added to a\r
+ * set.\r
+ */\r
+static void prvTestQueueOverwriteWithQueueSet( void );\r
+\r
+/*\r
+ * Test the case where two queues within a set are written to with\r
+ * xQueueOverwrite().\r
+ */\r
+static void prvTestQueueOverwriteOnTwoQueusInQueueSet( void );\r
+static void prvTestQueueOverwriteFromISROnTwoQueusInQueueSet( void );\r
+\r
 /*\r
  * Local pseudo random number seed and return functions.  Used to avoid calls\r
  * to the standard library.\r
@@ -619,8 +596,9 @@ uint32_t ulReceived;
 static void prvSendToQueueInSetFromISR( void )\r
 {\r
 static BaseType_t xQueueToWriteTo = 0;\r
+uint32_t ulTxValueSnapshot = ulISRTxValue;\r
 \r
-       if( xQueueSendFromISR( xQueues[ xQueueToWriteTo ], ( void * ) &ulISRTxValue, NULL ) == pdPASS )\r
+       if( xQueueSendFromISR( xQueues[ xQueueToWriteTo ], ( void * ) &ulTxValueSnapshot, NULL ) == pdPASS )\r
        {\r
                ulISRTxValue++;\r
 \r
@@ -640,6 +618,393 @@ static BaseType_t xQueueToWriteTo = 0;
 }\r
 /*-----------------------------------------------------------*/\r
 \r
+static void prvTestQueueOverwriteWithQueueSet( void )\r
+{\r
+uint32_t ulValueToSend = 0, ulValueReceived = 0;\r
+QueueHandle_t xQueueHandle = NULL, xReceivedHandle = NULL;\r
+const UBaseType_t xLengthOfOne = ( UBaseType_t ) 1;\r
+\r
+       /* Create a queue that has a length of one - a requirement in order to call\r
+       xQueueOverwrite.  This will get deleted again when this test completes. */\r
+       xQueueHandle = xQueueCreate( xLengthOfOne, sizeof( uint32_t ) );\r
+       configASSERT( xQueueHandle );\r
+\r
+       if( xQueueHandle != NULL )\r
+       {\r
+               xQueueAddToSet( xQueueHandle, xQueueSet );\r
+\r
+               /* Add an item to the queue then ensure the queue set correctly\r
+               indicates that one item is available, and that item is indeed the\r
+               queue written to. */\r
+               xQueueOverwrite( xQueueHandle, ( void * ) &ulValueToSend );\r
+               if( uxQueueMessagesWaiting( xQueueSet ) != ( UBaseType_t ) 1 )\r
+               {\r
+                       /* Expected one item in the queue set. */\r
+                       xQueueSetTasksStatus = pdFAIL;\r
+               }\r
+               xQueuePeek( xQueueSet, &xReceivedHandle, queuesetDONT_BLOCK );\r
+               if( xReceivedHandle != xQueueHandle )\r
+               {\r
+                       /* Wrote to xQueueHandle so expected xQueueHandle to be the handle\r
+                       held in the queue set. */\r
+                       xQueueSetTasksStatus = pdFAIL;\r
+               }\r
+\r
+               /* Now overwrite the value in the queue and ensure the queue set state\r
+               doesn't change as the number of items in the queues within the set have\r
+               not changed. */\r
+               ulValueToSend++;\r
+               xQueueOverwrite( xQueueHandle, ( void * ) &ulValueToSend );\r
+               if( uxQueueMessagesWaiting( xQueueSet ) != ( UBaseType_t ) 1 )\r
+               {\r
+                       /* Still expected one item in the queue set. */\r
+                       xQueueSetTasksStatus = pdFAIL;\r
+               }\r
+               xReceivedHandle = xQueueSelectFromSet( xQueueSet, queuesetDONT_BLOCK );\r
+               if( xReceivedHandle != xQueueHandle )\r
+               {\r
+                       /* Wrote to xQueueHandle so expected xQueueHandle to be the handle\r
+                       held in the queue set. */\r
+                       xQueueSetTasksStatus = pdFAIL;\r
+               }\r
+\r
+               /* Also ensure the value received from the queue is the overwritten\r
+               value, not the value originally written. */\r
+               xQueueReceive( xQueueHandle, &ulValueReceived, queuesetDONT_BLOCK );\r
+               if( ulValueReceived != ulValueToSend )\r
+               {\r
+                       /* Unexpected value received from the queue. */\r
+                       xQueueSetTasksStatus = pdFAIL;\r
+               }\r
+\r
+               /* Should be anything in the queue set now. */\r
+               if( uxQueueMessagesWaiting( xQueueSet ) != ( UBaseType_t ) 0 )\r
+               {\r
+                       xQueueSetTasksStatus = pdFAIL;\r
+               }\r
+               xReceivedHandle = xQueueSelectFromSet( xQueueSet, queuesetDONT_BLOCK );\r
+               if( xReceivedHandle != NULL )\r
+               {\r
+                       xQueueSetTasksStatus = pdFAIL;\r
+               }\r
+\r
+               /* Clean up. */\r
+               xQueueRemoveFromSet( xQueueHandle, xQueueSet );\r
+               vQueueDelete( xQueueHandle );\r
+       }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvTestQueueOverwriteOnTwoQueusInQueueSet( void )\r
+{\r
+uint32_t ulValueToSend1 = 1, ulValueToSend2 = 2UL, ulValueReceived = 0;\r
+QueueHandle_t xQueueHandle1 = NULL, xQueueHandle2 = NULL, xReceivedHandle = NULL;\r
+const UBaseType_t xLengthOfOne = ( UBaseType_t ) 1;\r
+\r
+       /* Create two queues that have a length of one - a requirement in order to call\r
+       xQueueOverwrite.  These will get deleted again when this test completes. */\r
+       xQueueHandle1 = xQueueCreate( xLengthOfOne, sizeof( uint32_t ) );\r
+       configASSERT( xQueueHandle1 );\r
+       xQueueHandle2 = xQueueCreate( xLengthOfOne, sizeof( uint32_t ) );\r
+       configASSERT( xQueueHandle2 );\r
+\r
+       if( ( xQueueHandle1 != NULL ) && ( xQueueHandle2 != NULL ) )\r
+       {\r
+               /* Add both queues to the queue set. */\r
+               xQueueAddToSet( xQueueHandle1, xQueueSet );\r
+               xQueueAddToSet( xQueueHandle2, xQueueSet );\r
+\r
+               /* Add an item using the first queue. */\r
+               xQueueOverwrite( xQueueHandle1, ( void * ) &ulValueToSend1 );\r
+               if( uxQueueMessagesWaiting( xQueueSet ) != ( UBaseType_t ) 1 )\r
+               {\r
+                       /* Expected one item in the queue set. */\r
+                       xQueueSetTasksStatus = pdFAIL;\r
+               }\r
+\r
+               xQueuePeek( xQueueSet, &xReceivedHandle, queuesetDONT_BLOCK );\r
+               if( xReceivedHandle != xQueueHandle1 )\r
+               {\r
+                       /* Wrote to xQueueHandle so expected xQueueHandle to be the handle\r
+                       held in the queue set. */\r
+                       xQueueSetTasksStatus = pdFAIL;\r
+               }\r
+\r
+\r
+               /* Next add an item to the second queue. */\r
+               xQueueOverwrite( xQueueHandle2, ( void * ) &ulValueToSend2 );\r
+               if( uxQueueMessagesWaiting( xQueueSet ) != ( UBaseType_t ) 2 )\r
+               {\r
+                       /* Expected two items in the queue set. */\r
+                       xQueueSetTasksStatus = pdFAIL;\r
+               }\r
+\r
+               /* The head of the queue set should not have changed though. */\r
+               xQueuePeek( xQueueSet, &xReceivedHandle, queuesetDONT_BLOCK );\r
+               if( xReceivedHandle != xQueueHandle1 )\r
+               {\r
+                       /* Wrote to xQueueHandle so expected xQueueHandle to be the handle\r
+                       held in the queue set. */\r
+                       xQueueSetTasksStatus = pdFAIL;\r
+               }\r
+\r
+\r
+\r
+\r
+               /* Now overwrite the value in the queue and ensure the queue set state\r
+               doesn't change as the number of items in the queues within the set have\r
+               not changed.  NOTE:  after this queue 1 should hold ulValueToSend2 and queue\r
+               2 should hold the value ulValueToSend1. */\r
+               xQueueOverwrite( xQueueHandle1, ( void * ) &ulValueToSend2 );\r
+               if( uxQueueMessagesWaiting( xQueueSet ) != ( UBaseType_t ) 2 )\r
+               {\r
+                       /* Still expected two items in the queue set. */\r
+                       xQueueSetTasksStatus = pdFAIL;\r
+               }\r
+               xQueueOverwrite( xQueueHandle2, ( void * ) &ulValueToSend1 );\r
+               if( uxQueueMessagesWaiting( xQueueSet ) != ( UBaseType_t ) 2 )\r
+               {\r
+                       /* Still expected two items in the queue set. */\r
+                       xQueueSetTasksStatus = pdFAIL;\r
+               }\r
+\r
+\r
+               /* Repeat the above to ensure the queue set state doesn't change. */\r
+               xQueueOverwrite( xQueueHandle1, ( void * ) &ulValueToSend2 );\r
+               if( uxQueueMessagesWaiting( xQueueSet ) != ( UBaseType_t ) 2 )\r
+               {\r
+                       /* Still expected two items in the queue set. */\r
+                       xQueueSetTasksStatus = pdFAIL;\r
+               }\r
+               xQueueOverwrite( xQueueHandle2, ( void * ) &ulValueToSend1 );\r
+               if( uxQueueMessagesWaiting( xQueueSet ) != ( UBaseType_t ) 2 )\r
+               {\r
+                       /* Still expected two items in the queue set. */\r
+                       xQueueSetTasksStatus = pdFAIL;\r
+               }\r
+\r
+\r
+               /* Now when reading from the queue set we expect the handle to the first\r
+               queue to be received first, and for that queue to hold ulValueToSend2 as the\r
+               originally written value was overwritten.  Likewise the second handle received\r
+               from the set should be that of the second queue, and that queue should hold\r
+               ulValueToSend1 as the originally written value was overwritten. */\r
+               xReceivedHandle = xQueueSelectFromSet( xQueueSet, queuesetDONT_BLOCK );\r
+               if( xReceivedHandle != xQueueHandle1 )\r
+               {\r
+                       /* Wrote to xQueueHandle1 first so expected that handle to be read from\r
+                       the set first. */\r
+                       xQueueSetTasksStatus = pdFAIL;\r
+               }\r
+               if( uxQueueMessagesWaiting( xQueueSet ) != ( UBaseType_t ) 1 )\r
+               {\r
+                       /* One value was read from the set, so now only expect a single value\r
+                       in the set. */\r
+                       xQueueSetTasksStatus = pdFAIL;\r
+               }\r
+               xQueueReceive( xReceivedHandle, &ulValueReceived, queuesetDONT_BLOCK );\r
+               if( ulValueReceived != ulValueToSend2 )\r
+               {\r
+                       /* Unexpected value received from the queue.  ulValueToSend1 was written\r
+                       first, but then overwritten with ulValueToSend2; */\r
+                       xQueueSetTasksStatus = pdFAIL;\r
+               }\r
+\r
+               xReceivedHandle = xQueueSelectFromSet( xQueueSet, queuesetDONT_BLOCK );\r
+               if( xReceivedHandle != xQueueHandle2 )\r
+               {\r
+                       /* xQueueHandle1 has already been removed from the set so expect only\r
+                       xQueueHandle2 to be left. */\r
+                       xQueueSetTasksStatus = pdFAIL;\r
+               }\r
+               if( uxQueueMessagesWaiting( xQueueSet ) != ( UBaseType_t ) 0 )\r
+               {\r
+                       /* The last value was read from the set so don't expect any more. */\r
+                       xQueueSetTasksStatus = pdFAIL;\r
+               }\r
+               xQueueReceive( xReceivedHandle, &ulValueReceived, queuesetDONT_BLOCK );\r
+               if( ulValueReceived != ulValueToSend1 )\r
+               {\r
+                       /* Unexpected value received from the queue.  ulValueToSend2 was written\r
+                       first, but then overwritten with ulValueToSend1. */\r
+                       xQueueSetTasksStatus = pdFAIL;\r
+               }\r
+\r
+\r
+\r
+\r
+               /* Should be anything in the queue set now. */\r
+               xReceivedHandle = xQueueSelectFromSet( xQueueSet, queuesetDONT_BLOCK );\r
+               if( xReceivedHandle != NULL )\r
+               {\r
+                       xQueueSetTasksStatus = pdFAIL;\r
+               }\r
+\r
+               /* Clean up. */\r
+               xQueueRemoveFromSet( xQueueHandle1, xQueueSet );\r
+               xQueueRemoveFromSet( xQueueHandle2, xQueueSet );\r
+               vQueueDelete( xQueueHandle1 );\r
+               vQueueDelete( xQueueHandle2 );\r
+       }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvTestQueueOverwriteFromISROnTwoQueusInQueueSet( void )\r
+{\r
+uint32_t ulValueToSend1 = 1, ulValueToSend2 = 2UL, ulValueReceived = 0;\r
+QueueHandle_t xQueueHandle1 = NULL, xQueueHandle2 = NULL, xReceivedHandle = NULL;\r
+const UBaseType_t xLengthOfOne = ( UBaseType_t ) 1;\r
+\r
+       /* Create two queues that have a length of one - a requirement in order to call\r
+       xQueueOverwrite.  These will get deleted again when this test completes. */\r
+       xQueueHandle1 = xQueueCreate( xLengthOfOne, sizeof( uint32_t ) );\r
+       configASSERT( xQueueHandle1 );\r
+       xQueueHandle2 = xQueueCreate( xLengthOfOne, sizeof( uint32_t ) );\r
+       configASSERT( xQueueHandle2 );\r
+\r
+       if( ( xQueueHandle1 != NULL ) && ( xQueueHandle2 != NULL ) )\r
+       {\r
+               /* Add both queues to the queue set. */\r
+               xQueueAddToSet( xQueueHandle1, xQueueSet );\r
+               xQueueAddToSet( xQueueHandle2, xQueueSet );\r
+\r
+               /* Add an item using the first queue using the 'FromISR' version of the\r
+               overwrite function. */\r
+               xQueueOverwriteFromISR( xQueueHandle1, ( void * ) &ulValueToSend1, NULL );\r
+               if( uxQueueMessagesWaiting( xQueueSet ) != ( UBaseType_t ) 1 )\r
+               {\r
+                       /* Expected one item in the queue set. */\r
+                       xQueueSetTasksStatus = pdFAIL;\r
+               }\r
+\r
+               xQueuePeek( xQueueSet, &xReceivedHandle, queuesetDONT_BLOCK );\r
+               if( xReceivedHandle != xQueueHandle1 )\r
+               {\r
+                       /* Wrote to xQueueHandle so expected xQueueHandle to be the handle\r
+                       held in the queue set. */\r
+                       xQueueSetTasksStatus = pdFAIL;\r
+               }\r
+\r
+\r
+               /* Next add an item to the second queue using the 'FromISR' version of the\r
+               overwrite function. */\r
+               xQueueOverwriteFromISR( xQueueHandle2, ( void * ) &ulValueToSend2, NULL );\r
+               if( uxQueueMessagesWaiting( xQueueSet ) != ( UBaseType_t ) 2 )\r
+               {\r
+                       /* Expected two items in the queue set. */\r
+                       xQueueSetTasksStatus = pdFAIL;\r
+               }\r
+\r
+               /* The head of the queue set should not have changed though. */\r
+               xQueuePeek( xQueueSet, &xReceivedHandle, queuesetDONT_BLOCK );\r
+               if( xReceivedHandle != xQueueHandle1 )\r
+               {\r
+                       /* Wrote to xQueueHandle so expected xQueueHandle to be the handle\r
+                       held in the queue set. */\r
+                       xQueueSetTasksStatus = pdFAIL;\r
+               }\r
+\r
+\r
+\r
+\r
+               /* Now overwrite the value in the queue and ensure the queue set state\r
+               doesn't change as the number of items in the queues within the set have\r
+               not changed.  NOTE:  after this queue 1 should hold ulValueToSend2 and queue\r
+               2 should hold the value ulValueToSend1. */\r
+               xQueueOverwriteFromISR( xQueueHandle1, ( void * ) &ulValueToSend2, NULL );\r
+               if( uxQueueMessagesWaiting( xQueueSet ) != ( UBaseType_t ) 2 )\r
+               {\r
+                       /* Still expected two items in the queue set. */\r
+                       xQueueSetTasksStatus = pdFAIL;\r
+               }\r
+               xQueueOverwriteFromISR( xQueueHandle2, ( void * ) &ulValueToSend1, NULL );\r
+               if( uxQueueMessagesWaiting( xQueueSet ) != ( UBaseType_t ) 2 )\r
+               {\r
+                       /* Still expected two items in the queue set. */\r
+                       xQueueSetTasksStatus = pdFAIL;\r
+               }\r
+\r
+\r
+               /* Repeat the above to ensure the queue set state doesn't change. */\r
+               xQueueOverwriteFromISR( xQueueHandle1, ( void * ) &ulValueToSend2, NULL );\r
+               if( uxQueueMessagesWaiting( xQueueSet ) != ( UBaseType_t ) 2 )\r
+               {\r
+                       /* Still expected two items in the queue set. */\r
+                       xQueueSetTasksStatus = pdFAIL;\r
+               }\r
+               xQueueOverwriteFromISR( xQueueHandle2, ( void * ) &ulValueToSend1, NULL );\r
+               if( uxQueueMessagesWaiting( xQueueSet ) != ( UBaseType_t ) 2 )\r
+               {\r
+                       /* Still expected two items in the queue set. */\r
+                       xQueueSetTasksStatus = pdFAIL;\r
+               }\r
+\r
+\r
+               /* Now when reading from the queue set we expect the handle to the first\r
+               queue to be received first, and for that queue to hold ulValueToSend2 as the\r
+               originally written value was overwritten.  Likewise the second handle received\r
+               from the set should be that of the second queue, and that queue should hold\r
+               ulValueToSend1 as the originally written value was overwritten. */\r
+               xReceivedHandle = xQueueSelectFromSet( xQueueSet, queuesetDONT_BLOCK );\r
+               if( xReceivedHandle != xQueueHandle1 )\r
+               {\r
+                       /* Wrote to xQueueHandle1 first so expected that handle to be read from\r
+                       the set first. */\r
+                       xQueueSetTasksStatus = pdFAIL;\r
+               }\r
+               if( uxQueueMessagesWaiting( xQueueSet ) != ( UBaseType_t ) 1 )\r
+               {\r
+                       /* One value was read from the set, so now only expect a single value\r
+                       in the set. */\r
+                       xQueueSetTasksStatus = pdFAIL;\r
+               }\r
+               xQueueReceive( xReceivedHandle, &ulValueReceived, queuesetDONT_BLOCK );\r
+               if( ulValueReceived != ulValueToSend2 )\r
+               {\r
+                       /* Unexpected value received from the queue.  ulValueToSend1 was written\r
+                       first, but then overwritten with ulValueToSend2; */\r
+                       xQueueSetTasksStatus = pdFAIL;\r
+               }\r
+\r
+               xReceivedHandle = xQueueSelectFromSet( xQueueSet, queuesetDONT_BLOCK );\r
+               if( xReceivedHandle != xQueueHandle2 )\r
+               {\r
+                       /* xQueueHandle1 has already been removed from the set so expect only\r
+                       xQueueHandle2 to be left. */\r
+                       xQueueSetTasksStatus = pdFAIL;\r
+               }\r
+               if( uxQueueMessagesWaiting( xQueueSet ) != ( UBaseType_t ) 0 )\r
+               {\r
+                       /* The last value was read from the set so don't expect any more. */\r
+                       xQueueSetTasksStatus = pdFAIL;\r
+               }\r
+               xQueueReceive( xReceivedHandle, &ulValueReceived, queuesetDONT_BLOCK );\r
+               if( ulValueReceived != ulValueToSend1 )\r
+               {\r
+                       /* Unexpected value received from the queue.  ulValueToSend2 was written\r
+                       first, but then overwritten with ulValueToSend1. */\r
+                       xQueueSetTasksStatus = pdFAIL;\r
+               }\r
+\r
+\r
+\r
+\r
+               /* Should be anything in the queue set now. */\r
+               xReceivedHandle = xQueueSelectFromSet( xQueueSet, queuesetDONT_BLOCK );\r
+               if( xReceivedHandle != NULL )\r
+               {\r
+                       xQueueSetTasksStatus = pdFAIL;\r
+               }\r
+\r
+               /* Clean up. */\r
+               xQueueRemoveFromSet( xQueueHandle1, xQueueSet );\r
+               xQueueRemoveFromSet( xQueueHandle2, xQueueSet );\r
+               vQueueDelete( xQueueHandle1 );\r
+               vQueueDelete( xQueueHandle2 );\r
+       }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
 static void prvSetupTest( void )\r
 {\r
 BaseType_t x;\r
@@ -716,6 +1081,19 @@ uint32_t ulValueToSend = 0;
                xQueueSetTasksStatus = pdFAIL;\r
        }\r
 \r
+       /* Testing the behaviour of queue sets when a queue overwrite operation is\r
+       performed on a set member requires a special test as overwrites can only\r
+       be performed on queues that have a length of 1. */\r
+       prvTestQueueOverwriteWithQueueSet();\r
+\r
+       /* Test the case where two queues within a set are written to with\r
+       xQueueOverwrite(). */\r
+       prvTestQueueOverwriteOnTwoQueusInQueueSet();\r
+       prvTestQueueOverwriteFromISROnTwoQueusInQueueSet();\r
+\r
+       /* In case any of the above have already indicated a failure. */\r
+       configASSERT( xQueueSetTasksStatus != pdFAIL );\r
+\r
        /* Resume the task that writes to the queues. */\r
        vTaskResume( xQueueSetSendingTask );\r
 \r
@@ -736,3 +1114,4 @@ static void prvSRand( size_t uxSeed )
        uxNextRand = uxSeed;\r
 }\r
 \r
+#endif /* ( configUSE_QUEUE_SETS == 1 ) */\r