]> begriffs open source - cmsis-freertos/blob - Test/CMock/queue/generic/queue_send_nonblocking_utest.c
Update README.md - branch main is now the base branch
[cmsis-freertos] / Test / CMock / queue / generic / queue_send_nonblocking_utest.c
1 /*
2  * FreeRTOS V202111.00
3  * Copyright (C) 2020 Amazon.com, Inc. or its affiliates.  All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of
6  * this software and associated documentation files (the "Software"), to deal in
7  * the Software without restriction, including without limitation the rights to
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9  * the Software, and to permit persons to whom the Software is furnished to do so,
10  * subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in all
13  * copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  *
22  * https://www.FreeRTOS.org
23  * https://github.com/FreeRTOS
24  *
25  */
26 /*! @file queue_send_nonblocking_utest.c */
27
28 /* C runtime includes. */
29 #include <stdlib.h>
30 #include <stdbool.h>
31 #include <string.h>
32
33 #include "../queue_utest_common.h"
34
35 /* Queue includes */
36 #include "FreeRTOS.h"
37 #include "FreeRTOSConfig.h"
38 #include "queue.h"
39 #include "mock_fake_port.h"
40
41 /* ===============================  CONSTANTS =============================== */
42
43 /* ============================  GLOBAL VARIABLES =========================== */
44
45 /* ==========================  CALLBACK FUNCTIONS =========================== */
46
47 /* ============================= Unity Fixtures ============================= */
48
49 void setUp( void )
50 {
51     commonSetUp();
52 }
53
54 void tearDown( void )
55 {
56     commonTearDown();
57 }
58
59 void suiteSetUp()
60 {
61     commonSuiteSetUp();
62 }
63
64 int suiteTearDown( int numFailures )
65 {
66     return commonSuiteTearDown( numFailures );
67 }
68
69 /* ==========================  Helper functions =========================== */
70
71 /* =============================  Test Cases ============================== */
72
73 /**
74  * @brief Test xQueueSend with an invalid QueueHandle
75  * @coverage xQueueGenericSend
76  */
77 void test_macro_xQueueSend_invalid_handle( void )
78 {
79     EXPECT_ASSERT_BREAK( xQueueSend( NULL, NULL, 0 ) );
80 }
81
82 /**
83  * @brief xQueueSend with an empty queue
84  * @coverage xQueueGenericSend
85  */
86 void test_macro_xQueueSend_success( void )
87 {
88     QueueHandle_t xQueue = xQueueCreate( 1, sizeof( uint32_t ) );
89
90     uint32_t testval = getNextMonotonicTestValue();
91
92     TEST_ASSERT_EQUAL( 0, uxQueueMessagesWaiting( xQueue ) );
93
94     TEST_ASSERT_EQUAL( pdTRUE, xQueueSend( xQueue, &testval, 0 ) );
95
96     TEST_ASSERT_EQUAL( 1, uxQueueMessagesWaiting( xQueue ) );
97
98     uint32_t checkVal = INVALID_UINT32;
99
100     TEST_ASSERT_EQUAL( pdTRUE, xQueueReceive( xQueue, &checkVal, 0 ) );
101
102     TEST_ASSERT_EQUAL( testval, checkVal );
103
104     vQueueDelete( xQueue );
105 }
106
107 /*!
108  * @brief xQueueSend with a full queue
109  * @details verify that the correct value is returned after a failed send operation.
110  * @coverage xQueueGenericSend
111  */
112 void test_macro_xQueueSend_fail_full( void )
113 {
114     QueueHandle_t xQueue = xQueueCreate( 1, sizeof( uint32_t ) );
115
116     uint32_t testVal1 = getNextMonotonicTestValue();
117
118     TEST_ASSERT_EQUAL( 0, uxQueueMessagesWaiting( xQueue ) );
119
120     TEST_ASSERT_EQUAL( pdTRUE, xQueueSend( xQueue, &testVal1, 0 ) );
121
122     TEST_ASSERT_EQUAL( 1, uxQueueMessagesWaiting( xQueue ) );
123
124     uint32_t testVal2 = getNextMonotonicTestValue();
125
126     TEST_ASSERT_EQUAL( errQUEUE_FULL, xQueueSend( xQueue, &testVal2, 0 ) );
127
128     uint32_t checkVal = INVALID_UINT32;
129
130     TEST_ASSERT_EQUAL( pdTRUE, xQueueReceive( xQueue, &checkVal, 0 ) );
131     TEST_ASSERT_EQUAL( testVal1, checkVal );
132
133     vQueueDelete( xQueue );
134 }
135
136 /**
137  * @brief Test xQueueSend with uxQueueLength=1, uxItemSize=0
138  * @details xQueueSend should return pdTRUE because the queue is empty.
139  *  This queue is eqivalent to a binary semaphore.
140  * @coverage xQueueGenericSend
141  */
142 void test_macro_xQueueSend_oneQueueLength_zeroItemSize( void )
143 {
144     QueueHandle_t xQueue = xQueueCreate( 1, 0 );
145
146     uint8_t testVal = getNextMonotonicTestValue();
147
148     TEST_ASSERT_EQUAL( 0, uxQueueMessagesWaiting( xQueue ) );
149
150     TEST_ASSERT_EQUAL( pdTRUE, xQueueSend( xQueue, &testVal, 0 ) );
151
152     TEST_ASSERT_EQUAL( 1, uxQueueMessagesWaiting( xQueue ) );
153
154     vQueueDelete( xQueue );
155 }
156
157 /**
158  * @brief Test xQueueSend with uxQueueLength=1, uxItemSize=0 and null item.
159  * @details xQueueSend should return pdTRUE because the queue is empty.
160  *  This queue is eqivalent to a binary semaphore.
161  * @coverage xQueueGenericSend
162  */
163 void test_macro_xQueueSend_oneQueueLength_zeroItemSize_null( void )
164 {
165     QueueHandle_t xQueue = xQueueCreate( 1, 0 );
166
167     TEST_ASSERT_EQUAL( 0, uxQueueMessagesWaiting( xQueue ) );
168
169     TEST_ASSERT_EQUAL( pdTRUE, xQueueSend( xQueue, NULL, 0 ) );
170
171     TEST_ASSERT_EQUAL( 1, uxQueueMessagesWaiting( xQueue ) );
172
173     vQueueDelete( xQueue );
174 }
175
176 /**
177  * @brief Test xQueueSend with uxQueueLength=1, uxItemSize=1
178  * @details xQueueSend should return pdTRUE because the queue is empty.
179  * @coverage xQueueGenericSend
180  */
181 void test_macro_xQueueSend_oneQueueLength_oneItemSize( void )
182 {
183     QueueHandle_t xQueue = xQueueCreate( 1, 1 );
184
185     uint8_t testVal = getNextMonotonicTestValue();
186
187     TEST_ASSERT_EQUAL( 0, uxQueueMessagesWaiting( xQueue ) );
188
189     TEST_ASSERT_EQUAL( pdTRUE, xQueueSend( xQueue, &testVal, 0 ) );
190
191     TEST_ASSERT_EQUAL( 1, uxQueueMessagesWaiting( xQueue ) );
192
193     vQueueDelete( xQueue );
194 }
195
196 /**
197  * @brief Test xQueueSend with uxQueueLength=1, uxItemSize=1 and null item.
198  * @details xQueueSend should configASSERT because of the null item pointer.
199  * @coverage xQueueGenericSend
200  */
201 void test_macro_xQueueSend_oneQueueLength_oneItemSize_null( void )
202 {
203     QueueHandle_t xQueue = xQueueCreate( 1, 1 );
204
205     EXPECT_ASSERT_BREAK( xQueueSend( xQueue, NULL, 0 ) );
206
207     vQueueDelete( xQueue );
208 }
209
210 /**
211  * @brief Test xQueueSend with an equal priority task waiting.
212  * @coverage xQueueGenericSend
213  */
214 void test_macro_xQueueSend_task_waiting_equal_priority_success( void )
215 {
216     QueueHandle_t xQueue = xQueueCreate( 1, sizeof( uint32_t ) );
217
218     /* Insert an item into the event list. */
219     td_task_setFakeTaskPriority( DEFAULT_PRIORITY );
220     td_task_addFakeTaskWaitingToReceiveFromQueue( xQueue );
221
222     uint32_t testVal = getNextMonotonicTestValue();
223
224     TEST_ASSERT_EQUAL( 0, uxQueueMessagesWaiting( xQueue ) );
225
226     /* Add item to queue*/
227     TEST_ASSERT_EQUAL( pdTRUE, xQueueSend( xQueue, &testVal, 0 ) );
228
229     TEST_ASSERT_EQUAL( 1, uxQueueMessagesWaiting( xQueue ) );
230
231     TEST_ASSERT_EQUAL( 0, td_task_getYieldCount() );
232
233     uint32_t checkVal = INVALID_UINT32;
234
235     ( void ) xQueueReceive( xQueue, &checkVal, 0 );
236     TEST_ASSERT_EQUAL( testVal, checkVal );
237
238     vQueueDelete( xQueue );
239 }
240
241 /**
242  * @brief Test xQueueSend with a higher priority task waiting.
243  * @coverage xQueueGenericSend
244  */
245 void test_macro_xQueueSend_task_waiting_higher_priority_success( void )
246 {
247     QueueHandle_t xQueue = xQueueCreate( 1, sizeof( uint32_t ) );
248
249     /* Insert an item into the event list */
250     td_task_setFakeTaskPriority( DEFAULT_PRIORITY + 1 );
251     td_task_addFakeTaskWaitingToReceiveFromQueue( xQueue );
252
253     uint32_t testVal = getNextMonotonicTestValue();
254
255     TEST_ASSERT_EQUAL( 0, uxQueueMessagesWaiting( xQueue ) );
256
257     /* Add item to queue*/
258     TEST_ASSERT_EQUAL( pdTRUE, xQueueSend( xQueue, &testVal, 0 ) );
259
260     TEST_ASSERT_EQUAL( 1, uxQueueMessagesWaiting( xQueue ) );
261
262     TEST_ASSERT_EQUAL( 1, td_task_getYieldCount() );
263
264     TEST_ASSERT_EQUAL( 1, td_task_getCount_vPortYieldWithinAPI() );
265
266     /* Check that vTaskMissedYield was not called */
267     TEST_ASSERT_EQUAL( 0, td_task_getCount_vTaskMissedYield() );
268
269     uint32_t checkVal = INVALID_UINT32;
270
271     ( void ) xQueueReceive( xQueue, &checkVal, 0 );
272     TEST_ASSERT_EQUAL( testVal, checkVal );
273
274     vQueueDelete( xQueue );
275 }
276
277 /**
278  * @brief Test xQueueSend with a lower priority task waiting.
279  * @coverage xQueueGenericSend
280  */
281 void test_macro_xQueueSend_task_waiting_lower_priority_success( void )
282 {
283     QueueHandle_t xQueue = xQueueCreate( 1, sizeof( uint32_t ) );
284
285     /* Insert an item into the event list. */
286     td_task_setFakeTaskPriority( DEFAULT_PRIORITY - 1 );
287     td_task_addFakeTaskWaitingToReceiveFromQueue( xQueue );
288
289     uint32_t testVal = getNextMonotonicTestValue();
290
291     TEST_ASSERT_EQUAL( 0, uxQueueMessagesWaiting( xQueue ) );
292
293     /* Add item to queue*/
294     TEST_ASSERT_EQUAL( pdTRUE, xQueueSend( xQueue, &testVal, 0 ) );
295
296     TEST_ASSERT_EQUAL( 1, uxQueueMessagesWaiting( xQueue ) );
297
298     TEST_ASSERT_EQUAL( 0, td_task_getYieldCount() );
299
300     uint32_t checkVal = INVALID_UINT32;
301
302     ( void ) xQueueReceive( xQueue, &checkVal, 0 );
303     TEST_ASSERT_EQUAL( testVal, checkVal );
304
305     vQueueDelete( xQueue );
306 }
307
308 /**
309  *  @brief Test xQueueSend with taskSCHEDULER_SUSPENDED and timeout=0
310  *  @details This should not cause xQueueSend to configASSERT because
311  *  xQueueSend is non-blocking when timeout=0.
312  *  @coverage xQueueGenericSend
313  */
314 void test_macro_xQueueSend_nonblocking_suspended_noassert( void )
315 {
316     QueueHandle_t xQueue = xQueueCreate( 1, sizeof( uint32_t ) );
317
318     uint32_t testVal = getNextMonotonicTestValue();
319
320     td_task_setSchedulerState( taskSCHEDULER_SUSPENDED );
321
322     TEST_ASSERT_EQUAL( 0, uxQueueMessagesWaiting( xQueue ) );
323
324     TEST_ASSERT_EQUAL( pdTRUE, xQueueSend( xQueue, &testVal, 0 ) );
325
326     TEST_ASSERT_EQUAL( 1, uxQueueMessagesWaiting( xQueue ) );
327
328     td_task_setSchedulerState( taskSCHEDULER_RUNNING );
329
330     vQueueDelete( xQueue );
331 }
332
333 /**
334  * @brief Test xQueueSendFromISR with an invalid (null) QueueHandle
335  * @coverage xQueueGenericSendFromISR
336  */
337 void test_macro_xQueueSendFromISR_invalid_handle( void )
338 {
339     uint32_t testVal = INVALID_UINT32;
340
341     EXPECT_ASSERT_BREAK( xQueueSendFromISR( NULL, &testVal, NULL ) );
342 }
343
344 /**
345  * @brief xQueueSendFromISR with an empty queue
346  * @coverage xQueueGenericSendFromISR
347  */
348 void test_macro_xQueueSendFromISR_success( void )
349 {
350     QueueHandle_t xQueue = xQueueCreate( 1, sizeof( uint32_t ) );
351
352     uint32_t testval = getNextMonotonicTestValue();
353
354     vFakePortAssertIfInterruptPriorityInvalid_Expect();
355
356     TEST_ASSERT_EQUAL( 0, uxQueueMessagesWaiting( xQueue ) );
357
358     TEST_ASSERT_EQUAL( pdTRUE, xQueueSendFromISR( xQueue, &testval, NULL ) );
359
360     TEST_ASSERT_EQUAL( 1, uxQueueMessagesWaiting( xQueue ) );
361
362     uint32_t checkVal = INVALID_UINT32;
363
364     TEST_ASSERT_EQUAL( pdTRUE, xQueueReceive( xQueue, &checkVal, 0 ) );
365
366     TEST_ASSERT_EQUAL( testval, checkVal );
367     vQueueDelete( xQueue );
368 }
369
370 /*!
371  * @brief xQueueSendFromISR with a full queue
372  * @details verify that the correct value is returned after a failed send operation.
373  * @coverage xQueueGenericSendFromISR
374  */
375 void test_macro_xQueueSendFromISR_fail( void )
376 {
377     QueueHandle_t xQueue = xQueueCreate( 1, sizeof( uint32_t ) );
378
379     uint32_t testVal1 = getNextMonotonicTestValue();
380
381     vFakePortAssertIfInterruptPriorityInvalid_Expect();
382
383     TEST_ASSERT_EQUAL( 0, uxQueueMessagesWaiting( xQueue ) );
384
385     TEST_ASSERT_EQUAL( pdTRUE, xQueueSendFromISR( xQueue, &testVal1, NULL ) );
386
387     TEST_ASSERT_EQUAL( 1, uxQueueMessagesWaiting( xQueue ) );
388
389     uint32_t testVal2 = getNextMonotonicTestValue();
390
391     vFakePortAssertIfInterruptPriorityInvalid_Expect();
392     TEST_ASSERT_EQUAL( errQUEUE_FULL, xQueueSendFromISR( xQueue, &testVal2, NULL ) );
393
394     TEST_ASSERT_EQUAL( 1, uxQueueMessagesWaiting( xQueue ) );
395
396     uint32_t checkVal = INVALID_UINT32;
397
398     ( void ) xQueueReceive( xQueue, &checkVal, 0 );
399     TEST_ASSERT_EQUAL( testVal1, checkVal );
400     vQueueDelete( xQueue );
401 }
402
403 /**
404  * @brief Test xQueueSendFromISR with uxQueueLength=1, uxItemSize=0
405  * @details xQueueSendFromISR should return pdTRUE because the queue is empty.
406  *  This queue is eqivalent to a binary semaphore.
407  * @coverage xQueueGenericSendFromISR
408  */
409 void test_macro_xQueueSendFromISR_oneQueueLength_zeroItemSize( void )
410 {
411     QueueHandle_t xQueue = xQueueCreate( 1, 0 );
412
413     uint8_t testVal = getNextMonotonicTestValue();
414
415     vFakePortAssertIfInterruptPriorityInvalid_Expect();
416
417     TEST_ASSERT_EQUAL( 0, uxQueueMessagesWaiting( xQueue ) );
418
419     TEST_ASSERT_EQUAL( pdTRUE, xQueueSendFromISR( xQueue, &testVal, 0 ) );
420
421     TEST_ASSERT_EQUAL( 1, uxQueueMessagesWaiting( xQueue ) );
422
423     vQueueDelete( xQueue );
424 }
425
426 /**
427  * @brief Test xQueueSendFromISR with uxQueueLength=1, uxItemSize=0 and null item.
428  * @details xQueueSendFromISR should return pdTRUE because the queue is empty.
429  *  This queue is eqivalent to a binary semaphore.
430  * @coverage xQueueGenericSendFromISR
431  */
432 void test_macro_xQueueSendFromISR_oneQueueLength_zeroItemSize_null( void )
433 {
434     QueueHandle_t xQueue = xQueueCreate( 1, 0 );
435
436     vFakePortAssertIfInterruptPriorityInvalid_Expect();
437
438     TEST_ASSERT_EQUAL( 0, uxQueueMessagesWaiting( xQueue ) );
439
440     TEST_ASSERT_EQUAL( pdTRUE, xQueueSendFromISR( xQueue, NULL, 0 ) );
441
442     TEST_ASSERT_EQUAL( 1, uxQueueMessagesWaiting( xQueue ) );
443
444     vQueueDelete( xQueue );
445 }
446
447 /**
448  * @brief Test xQueueSendFromISR with uxQueueLength=1, uxItemSize=1
449  * @details xQueueSendFromISR should return pdTRUE because the queue is empty.
450  * @coverage xQueueGenericSendFromISR
451  */
452 void test_macro_xQueueSendFromISR_oneQueueLength_oneItemSize( void )
453 {
454     QueueHandle_t xQueue = xQueueCreate( 1, 1 );
455
456     uint8_t testVal = getNextMonotonicTestValue();
457
458     vFakePortAssertIfInterruptPriorityInvalid_Expect();
459
460     TEST_ASSERT_EQUAL( 0, uxQueueMessagesWaiting( xQueue ) );
461
462     TEST_ASSERT_EQUAL( pdTRUE, xQueueSendFromISR( xQueue, &testVal, 0 ) );
463
464     TEST_ASSERT_EQUAL( 1, uxQueueMessagesWaiting( xQueue ) );
465
466     vQueueDelete( xQueue );
467 }
468
469 /**
470  * @brief Test xQueueSendFromISR with uxQueueLength=1, uxItemSize=1 and null item.
471  * @details xQueueSendFromISR should configASSERT because of the null item pointer.
472  * @coverage xQueueGenericSendFromISR
473  */
474 void test_macro_xQueueSendFromISR_oneQueueLength_oneItemSize_null( void )
475 {
476     QueueHandle_t xQueue = xQueueCreate( 1, 1 );
477
478     EXPECT_ASSERT_BREAK( xQueueSendFromISR( xQueue, NULL, 0 ) );
479
480     vQueueDelete( xQueue );
481 }
482
483 /**
484  * @brief Test xQueueSendFromISR with a null pxHigherPriorityTaskWoken.
485  * @details Test xQueueSendFromISR with a NULL pxHigherPriorityTaskWoken
486  * in a case where xHigherPriorityTaskWoken would otherwise be written to
487  * and cause a null pointer dereference.
488  * @coverage xQueueGenericSendFromISR
489  */
490 void test_macro_xQueueSendFromISR_task_waiting_higher_priority_null_pxHigherPriorityTaskWoken( void )
491 {
492     QueueHandle_t xQueue = xQueueCreate( 1, sizeof( uint32_t ) );
493
494     vFakePortAssertIfInterruptPriorityInvalid_Expect();
495
496     /* Insert an item into the event list. */
497     td_task_setFakeTaskPriority( DEFAULT_PRIORITY + 1 );
498     td_task_addFakeTaskWaitingToReceiveFromQueue( xQueue );
499
500     uint32_t testVal = getNextMonotonicTestValue();
501
502     TEST_ASSERT_EQUAL( 0, uxQueueMessagesWaiting( xQueue ) );
503
504     /* Add item to queue*/
505     TEST_ASSERT_EQUAL( pdTRUE, xQueueSendFromISR( xQueue, &testVal, NULL ) );
506
507     TEST_ASSERT_EQUAL( 1, uxQueueMessagesWaiting( xQueue ) );
508
509     TEST_ASSERT_EQUAL( pdTRUE, td_task_getYieldPending() );
510
511     uint32_t checkVal = INVALID_UINT32;
512
513     ( void ) xQueueReceive( xQueue, &checkVal, 0 );
514     TEST_ASSERT_EQUAL( testVal, checkVal );
515
516     vQueueDelete( xQueue );
517 }
518
519 /**
520  * @brief Test xQueueSendFromISR with a higher priority task waiting
521  * @details Test xQueueSendFromISR with a higher priority task waiting and
522  *  verifies that xHigherPriorityTaskWoken is set accordingly.
523  * @coverage xQueueGenericSendFromISR
524  */
525 void test_macro_xQueueSendFromISR_task_waiting_higher_priority_success( void )
526 {
527     QueueHandle_t xQueue = xQueueCreate( 1, sizeof( uint32_t ) );
528
529     vFakePortAssertIfInterruptPriorityInvalid_Expect();
530
531     /* Insert an item into the event list. */
532     td_task_setFakeTaskPriority( DEFAULT_PRIORITY + 1 );
533     td_task_addFakeTaskWaitingToReceiveFromQueue( xQueue );
534
535     uint32_t testVal = getNextMonotonicTestValue();
536
537     BaseType_t xHigherPriorityTaskWoken = pdFALSE;
538
539     TEST_ASSERT_EQUAL( 0, uxQueueMessagesWaiting( xQueue ) );
540
541     /* Add item to queue*/
542     TEST_ASSERT_EQUAL( pdTRUE, xQueueSendFromISR( xQueue, &testVal, &xHigherPriorityTaskWoken ) );
543
544     TEST_ASSERT_EQUAL( 1, uxQueueMessagesWaiting( xQueue ) );
545
546     TEST_ASSERT_EQUAL( pdTRUE, xHigherPriorityTaskWoken );
547
548     TEST_ASSERT_EQUAL( pdTRUE, td_task_getYieldPending() );
549
550     uint32_t checkVal = INVALID_UINT32;
551
552     ( void ) xQueueReceive( xQueue, &checkVal, 0 );
553     TEST_ASSERT_EQUAL( testVal, checkVal );
554
555     vQueueDelete( xQueue );
556 }
557
558 /**
559  * @brief Test xQueueSendFromISR with a lower priority task waiting
560  * @details Test xQueueSendFromISR with a lower priority task waiting and
561  *  verify that xHigherPriorityTaskWoken is not modified.
562  * @coverage xQueueGenericSendFromISR
563  */
564 void test_macro_xQueueSendFromISR_task_waiting_lower_priority_success( void )
565 {
566     QueueHandle_t xQueue = xQueueCreate( 1, sizeof( uint32_t ) );
567
568     vFakePortAssertIfInterruptPriorityInvalid_Expect();
569
570     /* Insert an item into the event list. */
571     td_task_setFakeTaskPriority( DEFAULT_PRIORITY - 1 );
572     td_task_addFakeTaskWaitingToReceiveFromQueue( xQueue );
573
574     uint32_t testVal = getNextMonotonicTestValue();
575
576     BaseType_t xHigherPriorityTaskWoken = pdFALSE;
577
578     TEST_ASSERT_EQUAL( 0, uxQueueMessagesWaiting( xQueue ) );
579
580     /* Add item to queue*/
581     TEST_ASSERT_EQUAL( pdTRUE, xQueueSendFromISR( xQueue, &testVal, &xHigherPriorityTaskWoken ) );
582     TEST_ASSERT_EQUAL( pdFALSE, xHigherPriorityTaskWoken );
583
584     TEST_ASSERT_EQUAL( 1, uxQueueMessagesWaiting( xQueue ) );
585
586     uint32_t checkVal = INVALID_UINT32;
587
588     ( void ) xQueueReceive( xQueue, &checkVal, 0 );
589     TEST_ASSERT_EQUAL( testVal, checkVal );
590
591     vQueueDelete( xQueue );
592 }
593
594 /**
595  * @brief Test xQueueSendFromISR on a queue that is locked
596  * @coverage xQueueGenericSendFromISR
597  */
598 void test_macro_xQueueSendFromISR_locked( void )
599 {
600     QueueHandle_t xQueue = xQueueCreate( 1, sizeof( uint32_t ) );
601
602     /* Set private lock counters */
603     vSetQueueRxLock( xQueue, queueLOCKED_UNMODIFIED );
604     vSetQueueTxLock( xQueue, queueLOCKED_UNMODIFIED );
605
606     vFakePortAssertIfInterruptPriorityInvalid_Expect();
607
608     uint32_t testval = getNextMonotonicTestValue();
609
610     TEST_ASSERT_EQUAL( 0, uxQueueMessagesWaiting( xQueue ) );
611
612     TEST_ASSERT_EQUAL( pdTRUE, xQueueSendFromISR( xQueue, &testval, NULL ) );
613
614     TEST_ASSERT_EQUAL( 1, uxQueueMessagesWaiting( xQueue ) );
615
616     /* Verify that the cRxLock counter has not changed */
617     TEST_ASSERT_EQUAL( queueLOCKED_UNMODIFIED, cGetQueueRxLock( xQueue ) );
618
619     /* Verify that the cTxLock counter has been incremented */
620     TEST_ASSERT_EQUAL( queueLOCKED_UNMODIFIED + 1, cGetQueueTxLock( xQueue ) );
621
622     uint32_t checkVal = INVALID_UINT32;
623
624     ( void ) xQueueReceive( xQueue, &checkVal, 0 );
625
626     TEST_ASSERT_EQUAL( testval, checkVal );
627     vQueueDelete( xQueue );
628 }
629
630 /**
631  * @brief Test xQueueSendFromISR on a queue that is locked and cRxLock overflows.
632  * @coverage xQueueGenericSendFromISR
633  */
634 void test_macro_xQueueSendFromISR_locked_overflow( void )
635 {
636     QueueHandle_t xQueue = xQueueCreate( 1, sizeof( uint32_t ) );
637
638     /* Set private lock counters */
639     vSetQueueRxLock( xQueue, INT8_MAX );
640     vSetQueueTxLock( xQueue, INT8_MAX );
641
642     vFakePortAssertIfInterruptPriorityInvalid_Expect();
643
644     /* Expect an assertion since the cTxLock value has overflowed */
645     fakeAssertExpectFail();
646
647     uint32_t testval = getNextMonotonicTestValue();
648
649     TEST_ASSERT_EQUAL( 0, uxQueueMessagesWaiting( xQueue ) );
650
651     TEST_ASSERT_EQUAL( pdTRUE, xQueueSendFromISR( xQueue, &testval, NULL ) );
652
653     TEST_ASSERT_EQUAL( 1, uxQueueMessagesWaiting( xQueue ) );
654
655     /* Verify that the cRxLock counter has not changed */
656     TEST_ASSERT_EQUAL( INT8_MAX, cGetQueueRxLock( xQueue ) );
657
658     /* Verify that the cTxLock counter has been incremented */
659     TEST_ASSERT_EQUAL( INT8_MIN, cGetQueueTxLock( xQueue ) );
660
661     TEST_ASSERT_EQUAL( true, fakeAssertGetFlagAndClear() );
662
663     uint32_t checkVal = INVALID_UINT32;
664
665     ( void ) xQueueReceive( xQueue, &checkVal, 0 );
666
667     TEST_ASSERT_EQUAL( testval, checkVal );
668     vQueueDelete( xQueue );
669 }
670
671 /**
672  * @brief Test xQueueSendToFront with an invalid (NULL) handle
673  * @coverage xQueueGenericSend
674  */
675 void test_macro_xQueueSendToFront_invalid_handle( void )
676 {
677     uint32_t testVal = INVALID_UINT32;
678
679     EXPECT_ASSERT_BREAK( xQueueSendToFront( NULL, &testVal, 0 ) );
680 }
681
682 /**
683  * @brief Test xQueueSendToFront with a queue of length 6
684  * @coverage xQueueGenericSend
685  */
686 void test_macro_xQueueSendToFront( void )
687 {
688     QueueHandle_t xQueue = xQueueCreate( 6, sizeof( uint32_t ) );
689
690     /* Add 5 sequential items to the queue */
691     for( int i = 1; i <= 5; i++ )
692     {
693         TEST_ASSERT_EQUAL( pdTRUE, xQueueSend( xQueue, &i, 0 ) );
694     }
695
696     TEST_ASSERT_EQUAL( 5, uxQueueMessagesWaiting( xQueue ) );
697
698     /* Add "random-ish" value to front of queue */
699     uint32_t testVal = getNextMonotonicTestValue();
700
701     TEST_ASSERT_EQUAL( pdTRUE, xQueueSendToFront( xQueue, &testVal, 0 ) );
702
703     TEST_ASSERT_EQUAL( 6, uxQueueMessagesWaiting( xQueue ) );
704
705     /* receive the value added to the front */
706     uint32_t testValCompare = 0;
707
708     TEST_ASSERT_EQUAL( pdTRUE, xQueueReceive( xQueue, &testValCompare, 0 ) );
709     TEST_ASSERT_EQUAL( testVal, testValCompare );
710
711     /* verify the remaining items and remove from the queue */
712     for( uint32_t i = 1; i <= 5; i++ )
713     {
714         uint32_t testVal = INVALID_UINT32;
715         TEST_ASSERT_EQUAL( pdTRUE, xQueueReceive( xQueue, &testVal, 0 ) );
716         TEST_ASSERT_EQUAL( i, testVal );
717     }
718
719     vQueueDelete( xQueue );
720 }
721
722 /**
723  * @brief Test xQueueSendToFrontFromISR with a queue of length 6
724  * @coverage xQueueGenericSendFromISR
725  */
726 void test_macro_xQueueSendToFrontFromISR_invalid_handle( void )
727 {
728     uint32_t testVal = INVALID_UINT32;
729
730     EXPECT_ASSERT_BREAK( xQueueSendToFrontFromISR( NULL, &testVal, 0 ) );
731 }
732
733 /**
734  * @brief Test xQueueSendToFrontFromISR with a queue of length 6
735  * @coverage xQueueGenericSendFromISR
736  */
737 void test_macro_xQueueSendToFrontFromISR( void )
738 {
739     QueueHandle_t xQueue = xQueueCreate( 6, sizeof( uint32_t ) );
740
741     /* Add 5 sequential items to the queue */
742     for( int i = 1; i <= 5; i++ )
743     {
744         TEST_ASSERT_EQUAL( pdTRUE, xQueueSend( xQueue, &i, 0 ) );
745     }
746
747     vFakePortAssertIfInterruptPriorityInvalid_Expect();
748
749     /* Add "random-ish" value to front of queue */
750     uint32_t testVal = getNextMonotonicTestValue();
751
752     TEST_ASSERT_EQUAL( 5, uxQueueMessagesWaiting( xQueue ) );
753
754     TEST_ASSERT_EQUAL( pdTRUE, xQueueSendToFrontFromISR( xQueue, &testVal, 0 ) );
755
756     TEST_ASSERT_EQUAL( 6, uxQueueMessagesWaiting( xQueue ) );
757
758     /* receive the value added to the front */
759     uint32_t testValCompare = 0;
760
761     TEST_ASSERT_EQUAL( pdTRUE, xQueueReceive( xQueue, &testValCompare, 0 ) );
762     TEST_ASSERT_EQUAL( testVal, testValCompare );
763
764     /* verify the remaining items and remove from the queue */
765     for( uint32_t i = 1; i <= 5; i++ )
766     {
767         uint32_t testVal = INVALID_UINT32;
768         TEST_ASSERT_EQUAL( pdTRUE, xQueueReceive( xQueue, &testVal, 0 ) );
769         TEST_ASSERT_EQUAL( i, testVal );
770     }
771
772     vQueueDelete( xQueue );
773 }
774
775 /**
776  * @brief Test xQueueSendToBack with an invalid (NULL) handle
777  * @coverage xQueueGenericSend
778  */
779 void test_macro_xQueueSendToBack_invalid_handle( void )
780 {
781     uint32_t testVal = INVALID_UINT32;
782
783     EXPECT_ASSERT_BREAK( xQueueSendToBack( NULL, &testVal, 0 ) );
784 }
785
786 /**
787  * @brief Test xQueueSendToBack with a queue of length 6
788  * @coverage xQueueGenericSend
789  */
790 void test_macro_xQueueSendToBack( void )
791 {
792     QueueHandle_t xQueue = xQueueCreate( 6, sizeof( uint32_t ) );
793
794     /* Add 5 sequential items to the queue */
795     for( int i = 1; i <= 5; i++ )
796     {
797         TEST_ASSERT_EQUAL( pdTRUE, xQueueSend( xQueue, &i, 0 ) );
798     }
799
800     TEST_ASSERT_EQUAL( 5, uxQueueMessagesWaiting( xQueue ) );
801
802     /* Add "random-ish" value to end of queue */
803     uint32_t testVal = getNextMonotonicTestValue();
804
805     TEST_ASSERT_EQUAL( pdTRUE, xQueueSendToBack( xQueue, &testVal, 0 ) );
806
807     TEST_ASSERT_EQUAL( 6, uxQueueMessagesWaiting( xQueue ) );
808
809     /* verify the first 5 items and remove from the queue */
810     for( uint32_t i = 1; i <= 5; i++ )
811     {
812         uint32_t testVal = INVALID_UINT32;
813         TEST_ASSERT_EQUAL( pdTRUE, xQueueReceive( xQueue, &testVal, 0 ) );
814         TEST_ASSERT_EQUAL( i, testVal );
815     }
816
817     /* receive the value added to the front */
818     uint32_t testValCompare = 0;
819
820     TEST_ASSERT_EQUAL( pdTRUE, xQueueReceive( xQueue, &testValCompare, 0 ) );
821     TEST_ASSERT_EQUAL( getLastMonotonicTestValue(), testValCompare );
822
823     vQueueDelete( xQueue );
824 }
825
826 /**
827  * @brief Test xQueueSendToBackFromISR with an invalid (NULL) handle.
828  * @coverage xQueueGenericSendFromISR
829  */
830 void test_macro_xQueueSendToBackFromISR_invalid_handle( void )
831 {
832     uint32_t testVal = INVALID_UINT32;
833
834     EXPECT_ASSERT_BREAK( xQueueSendToBackFromISR( NULL, &testVal, 0 ) );
835 }
836
837 /**
838  * @brief Test xQueueSendToBackFromISR with a queue of length 6
839  * @coverage xQueueGenericSendFromISR
840  */
841 void test_macro_xQueueSendToBackFromISR( void )
842 {
843     QueueHandle_t xQueue = xQueueCreate( 6, sizeof( uint32_t ) );
844
845     /* Add 5 sequential items to the queue */
846     for( int i = 1; i <= 5; i++ )
847     {
848         TEST_ASSERT_EQUAL( pdTRUE, xQueueSend( xQueue, &i, 0 ) );
849     }
850
851     /* Add "random-ish" value to end of queue */
852     uint32_t testVal = getNextMonotonicTestValue();
853
854     TEST_ASSERT_EQUAL( 5, uxQueueMessagesWaiting( xQueue ) );
855
856     vFakePortAssertIfInterruptPriorityInvalid_Expect();
857     TEST_ASSERT_EQUAL( pdTRUE, xQueueSendToBackFromISR( xQueue, &testVal, 0 ) );
858
859     TEST_ASSERT_EQUAL( 6, uxQueueMessagesWaiting( xQueue ) );
860
861     /* verify the first 5 items and remove from the queue */
862     for( uint32_t i = 1; i <= 5; i++ )
863     {
864         uint32_t testVal = INVALID_UINT32;
865         TEST_ASSERT_EQUAL( pdTRUE, xQueueReceive( xQueue, &testVal, 0 ) );
866         TEST_ASSERT_EQUAL( i, testVal );
867     }
868
869     /* receive the value added to the front */
870     uint32_t testValCompare = 0;
871
872     TEST_ASSERT_EQUAL( pdTRUE, xQueueReceive( xQueue, &testValCompare, 0 ) );
873     TEST_ASSERT_EQUAL( testVal, testValCompare );
874
875     vQueueDelete( xQueue );
876 }
877
878 /**
879  * @brief Test xQueueOverwrite with an invalid (NULL) queue handle.
880  * @coverage xQueueGenericSend
881  */
882 void test_macro_xQueueOverwrite_invalid_handle( void )
883 {
884     uint32_t testVal = INVALID_UINT32;
885
886     EXPECT_ASSERT_BREAK( xQueueOverwrite( NULL, &testVal ) );
887 }
888
889 /**
890  * @brief Test xQueueOverwrite on an empty queue of length 1
891  * @details Test xQueueOverwrite with an empty queue, equivalent to xQueueSend.
892  * @coverage xQueueGenericSend
893  */
894 void test_macro_xQueueOverwrite_empty_queue_1_add_success( void )
895 {
896     QueueHandle_t xQueue = xQueueCreate( 1, sizeof( uint32_t ) );
897
898     /* Send a new value to the queue using xQueueOverwrite */
899     uint32_t testVal1 = getNextMonotonicTestValue();
900
901     TEST_ASSERT_EQUAL( 0, uxQueueMessagesWaiting( xQueue ) );
902
903     TEST_ASSERT_EQUAL( pdTRUE, xQueueOverwrite( xQueue, &testVal1 ) );
904
905     /* Check that the queue is now full */
906     TEST_ASSERT_EQUAL( 1, uxQueueMessagesWaiting( xQueue ) );
907
908     /* Receive from the queue and verify the received value */
909     uint32_t checkVal1 = INVALID_UINT32;
910
911     TEST_ASSERT_EQUAL( pdTRUE, xQueueReceive( xQueue, &checkVal1, 0 ) );
912     TEST_ASSERT_EQUAL( testVal1, checkVal1 );
913
914     vQueueDelete( xQueue );
915 }
916
917 /**
918  * @brief Test xQueueOverwrite on a full queue of size (1,4)
919  * @details Test xQueueOverwrite with a full queue containing one item.
920  * @coverage xQueueGenericSend
921  */
922 void test_macro_xQueueOverwrite_overwrite_success( void )
923 {
924     QueueHandle_t xQueue = xQueueCreate( 1, sizeof( uint32_t ) );
925
926     uint32_t testVal1 = getNextMonotonicTestValue();
927
928     TEST_ASSERT_EQUAL( 0, uxQueueMessagesWaiting( xQueue ) );
929
930     /* send a random value to the queue */
931     TEST_ASSERT_EQUAL( pdTRUE, xQueueSend( xQueue, &testVal1, 0 ) );
932
933     /* Check that the queue now has a single message waiting */
934     TEST_ASSERT_EQUAL( 1, uxQueueMessagesWaiting( xQueue ) );
935
936     /* Peek from the queue and verify that the returned value matches testVal1 */
937     uint32_t checkVal1 = 0;
938
939     TEST_ASSERT_EQUAL( pdTRUE, xQueuePeek( xQueue, &checkVal1, 0 ) );
940     TEST_ASSERT_EQUAL( testVal1, checkVal1 );
941     TEST_ASSERT_NOT_EQUAL( 0, checkVal1 );
942
943     /* Overwrite testVal1 with testVal2 in the queue */
944     uint32_t testVal2 = getNextMonotonicTestValue();
945
946     TEST_ASSERT_EQUAL( pdTRUE, xQueueOverwrite( xQueue, &testVal2 ) );
947
948     /* Receive from the queue */
949     uint32_t checkVal2 = 0;
950
951     TEST_ASSERT_EQUAL( pdTRUE, xQueueReceive( xQueue, &checkVal2, 0 ) );
952
953     /* Validate that checkVal2 was received from the queue */
954     TEST_ASSERT_EQUAL( testVal2, checkVal2 );
955     TEST_ASSERT_NOT_EQUAL( 0, checkVal2 );
956     TEST_ASSERT_NOT_EQUAL( testVal1, checkVal2 );
957
958     vQueueDelete( xQueue );
959 }
960
961 /**
962  * @brief Test xQueueOverwrite on a full queue of size (2,4)
963  * @details Test xQueueOverwrite with a full queue containing one item.
964  * @note Operation of xQueueOverwrite on queues larger than 1 in length is undefined.
965  * The behavior in this test is undefined.
966  * @coverage xQueueGenericSend
967  */
968 void test_macro_xQueueOverwrite_full_assert_undefined( void )
969 {
970     QueueHandle_t xQueue = xQueueCreate( 2, sizeof( uint32_t ) );
971
972     uint32_t testVal1 = getNextMonotonicTestValue();
973
974     TEST_ASSERT_EQUAL( 0, uxQueueMessagesWaiting( xQueue ) );
975
976     /* Expect that xQueueOverwrite will assert due to uxQueueLength > 1 */
977     fakeAssertExpectFail();
978     TEST_ASSERT_EQUAL( pdTRUE, xQueueOverwrite( xQueue, &testVal1 ) );
979
980     /* Check that xQueueOverwrite called configASSERT */
981     TEST_ASSERT_EQUAL( true, fakeAssertGetFlagAndClear() );
982
983     /* Check that the queue now has a single message waiting */
984     TEST_ASSERT_EQUAL( 1, uxQueueMessagesWaiting( xQueue ) );
985
986     /* Overwrite testVal1 with testVal2 in the queue */
987     uint32_t testVal2 = getNextMonotonicTestValue();
988
989     /* Expect that xQueueOverwrite will assert due to uxQueueLength > 1 */
990     fakeAssertExpectFail();
991     TEST_ASSERT_EQUAL( pdTRUE, xQueueOverwrite( xQueue, &testVal2 ) );
992     /* Check that xQueueOverwrite called configASSERT */
993     TEST_ASSERT_EQUAL( true, fakeAssertGetFlagAndClear() );
994
995     TEST_ASSERT_EQUAL( 1, uxQueueMessagesWaiting( xQueue ) );
996
997     /* Receive from the queue */
998     uint32_t checkVal2 = 0;
999
1000     TEST_ASSERT_EQUAL( pdTRUE, xQueueReceive( xQueue, &checkVal2, 0 ) );
1001
1002     /* Validate that checkVal2 was received from the queue */
1003     TEST_ASSERT_EQUAL( testVal2, checkVal2 );
1004     TEST_ASSERT_NOT_EQUAL( 0, checkVal2 );
1005
1006     vQueueDelete( xQueue );
1007 }
1008
1009 /**
1010  * @brief Test xQueueOverwriteFromISR with an invalid (NULL) queue handle.
1011  * @coverage xQueueGenericSendFromISR
1012  */
1013 void test_macro_xQueueOverwriteFromISR_invalid_handle( void )
1014 {
1015     uint32_t testVal = INVALID_UINT32;
1016
1017     EXPECT_ASSERT_BREAK( xQueueOverwriteFromISR( NULL, &testVal, NULL ) );
1018 }
1019
1020 /**
1021  * @brief Test xQueueOverwriteFromISR on an empty queue of length 1
1022  * @details Test xQueueOverwriteFromISR with an empty queue, equivalent to xQueueSend.
1023  * @coverage xQueueGenericSendFromISR
1024  */
1025 void test_macro_xQueueOverwriteFromISR_empty_queue_1_add_success( void )
1026 {
1027     QueueHandle_t xQueue = xQueueCreate( 1, sizeof( uint32_t ) );
1028
1029     vFakePortAssertIfInterruptPriorityInvalid_Expect();
1030
1031     TEST_ASSERT_EQUAL( 0, uxQueueMessagesWaiting( xQueue ) );
1032
1033     /* Send a new value to the queue using xQueueOverwriteFromISR */
1034     uint32_t testVal1 = getNextMonotonicTestValue();
1035
1036     TEST_ASSERT_EQUAL( pdTRUE, xQueueOverwriteFromISR( xQueue, &testVal1, NULL ) );
1037
1038     /* Check that the queue is now full */
1039     TEST_ASSERT_EQUAL( 1, uxQueueMessagesWaiting( xQueue ) );
1040
1041     /* Receive from the queue and verify the received value */
1042     uint32_t checkVal1 = INVALID_UINT32;
1043
1044     TEST_ASSERT_EQUAL( pdTRUE, xQueueReceive( xQueue, &checkVal1, 0 ) );
1045     TEST_ASSERT_EQUAL( testVal1, checkVal1 );
1046
1047     vQueueDelete( xQueue );
1048 }
1049
1050 /**
1051  * @brief Test xQueueOverwriteFromISR on a full queue of size (1,4)
1052  * @details Test xQueueOverwriteFromISR with a full queue containing one item.
1053  * @coverage xQueueGenericSendFromISR
1054  */
1055 void test_macro_xQueueOverwriteFromISR_overwrite_success( void )
1056 {
1057     QueueHandle_t xQueue = xQueueCreate( 1, sizeof( uint32_t ) );
1058
1059     uint32_t testVal1 = getNextMonotonicTestValue();
1060
1061     /* send a random value to the queue */
1062     TEST_ASSERT_EQUAL( pdTRUE, xQueueSend( xQueue, &testVal1, 0 ) );
1063
1064     /* Check that the queue now has a single message waiting */
1065     TEST_ASSERT_EQUAL( 1, uxQueueMessagesWaiting( xQueue ) );
1066
1067     /* Peek from the queue and verify that the returned value matches testVal1 */
1068     uint32_t checkVal1 = 0;
1069
1070     TEST_ASSERT_EQUAL( pdTRUE, xQueuePeek( xQueue, &checkVal1, 0 ) );
1071     TEST_ASSERT_EQUAL( testVal1, checkVal1 );
1072     TEST_ASSERT_NOT_EQUAL( 0, checkVal1 );
1073
1074     vFakePortAssertIfInterruptPriorityInvalid_Expect();
1075
1076     /* Overwrite testVal1 with testVal2 in the queue */
1077     uint32_t testVal2 = getNextMonotonicTestValue();
1078
1079     TEST_ASSERT_EQUAL( pdTRUE, xQueueOverwriteFromISR( xQueue, &testVal2, NULL ) );
1080
1081     TEST_ASSERT_EQUAL( 1, uxQueueMessagesWaiting( xQueue ) );
1082
1083     /* Receive from the queue */
1084     uint32_t checkVal2 = 0;
1085
1086     TEST_ASSERT_EQUAL( pdTRUE, xQueueReceive( xQueue, &checkVal2, 0 ) );
1087
1088     /* Validate that checkVal2 was received from the queue */
1089     TEST_ASSERT_EQUAL( testVal2, checkVal2 );
1090     TEST_ASSERT_NOT_EQUAL( 0, checkVal2 );
1091     TEST_ASSERT_NOT_EQUAL( testVal1, checkVal2 );
1092
1093     /* Verify that the queue is empty */
1094     TEST_ASSERT_EQUAL( 0, uxQueueMessagesWaiting( xQueue ) );
1095
1096     vQueueDelete( xQueue );
1097 }
1098
1099 /**
1100  * @brief Test xQueueOverwriteFromISR on a full queue of size (2,4)
1101  * @details Test xQueueOverwriteFromISR with a full queue containing one item.
1102  * @note Operation of xQueueOverwriteFromISR on queues larger than 1 in length is undefined.
1103  * The behavior in this test is undefined.
1104  * @coverage xQueueGenericSendFromISR
1105  */
1106 void test_macro_xQueueOverwriteFromISR_full_assert_undefined( void )
1107 {
1108     QueueHandle_t xQueue = xQueueCreate( 2, sizeof( uint32_t ) );
1109
1110     vFakePortAssertIfInterruptPriorityInvalid_Expect();
1111
1112     uint32_t testVal1 = getNextMonotonicTestValue();
1113
1114     TEST_ASSERT_EQUAL( 0, uxQueueMessagesWaiting( xQueue ) );
1115
1116     /* Expect that xQueueOverwriteFromISR will assert due to uxQueueLength > 1 */
1117     fakeAssertExpectFail();
1118     TEST_ASSERT_EQUAL( pdTRUE, xQueueOverwriteFromISR( xQueue, &testVal1, NULL ) );
1119
1120     /* Check that xQueueOverwriteFromISR called configASSERT */
1121     TEST_ASSERT_EQUAL( true, fakeAssertGetFlagAndClear() );
1122
1123     /* Check that the queue now has a single message waiting */
1124     TEST_ASSERT_EQUAL( 1, uxQueueMessagesWaiting( xQueue ) );
1125
1126     vFakePortAssertIfInterruptPriorityInvalid_Expect();
1127
1128     /* Overwrite testVal1 with testVal2 in the queue */
1129     uint32_t testVal2 = getNextMonotonicTestValue();
1130
1131     /* Expect that xQueueOverwriteFromISR will assert due to uxQueueLength > 1 */
1132     fakeAssertExpectFail();
1133     TEST_ASSERT_EQUAL( pdTRUE, xQueueOverwriteFromISR( xQueue, &testVal2, NULL ) );
1134     /* Check that xQueueOverwriteFromISR called configASSERT */
1135     TEST_ASSERT_EQUAL( true, fakeAssertGetFlagAndClear() );
1136
1137     TEST_ASSERT_EQUAL( 1, uxQueueMessagesWaiting( xQueue ) );
1138
1139     /* Receive from the queue */
1140     uint32_t checkVal2 = 0;
1141
1142     TEST_ASSERT_EQUAL( pdTRUE, xQueueReceive( xQueue, &checkVal2, 0 ) );
1143
1144     /* Validate that checkVal2 was received from the queue */
1145     TEST_ASSERT_EQUAL( testVal2, checkVal2 );
1146     TEST_ASSERT_NOT_EQUAL( 0, checkVal2 );
1147
1148     vQueueDelete( xQueue );
1149 }