1 /*
2  * FreeRTOS V202212.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 
27 /**
28  * @file aws_test_runner.c
29  * @brief The function to be called to run all the tests.
30  */
31 
32 /* Test runner interface includes. */
33 #include "test_runner.h"
34 
35 /* FreeRTOS includes. */
36 #include "FreeRTOS.h"
37 #include "task.h"
38 
39 /* Unity framework includes. */
40 #include "unity_fixture.h"
41 #include "unity_internals.h"
42 
43 char cBuffer[ testrunnerBUFFER_SIZE ];
44 
45 /* Heap leak variables. */
46 unsigned int xHeapBefore;
47 unsigned int xHeapAfter;
48 /*-----------------------------------------------------------*/
49 
50 /* This function will be generated by the test automation framework,
51  * do not change the signature of it. You could, however, add or remove
52  * RUN_TEST_GROUP statements.
53  */
RunTests(void)54 static void RunTests( void )
55 {
56     RUN_TEST_GROUP( Full_FREERTOS_TCP );
57 }
58 /*-----------------------------------------------------------*/
59 
TEST_RUNNER_RunTests_task(void * pvParameters)60 void TEST_RUNNER_RunTests_task( void * pvParameters )
61 {
62     /* Disable unused parameter warning. */
63     ( void ) pvParameters;
64 
65     /* Initialize unity. */
66     UnityFixture.Verbose = 1;
67     UnityFixture.GroupFilter = 0;
68     UnityFixture.NameFilter = testrunnerTEST_FILTER;
69     UnityFixture.RepeatCount = 1;
70 
71     UNITY_BEGIN();
72 
73     /* Give the print buffer time to empty */
74     vTaskDelay( pdMS_TO_TICKS( 500 ) );
75     /* Measure the heap size before any tests are run. */
76     #if ( testrunnerFULL_MEMORYLEAK_ENABLED == 1 )
77         xHeapBefore = xPortGetFreeHeapSize();
78     #endif
79 
80     RunTests();
81 
82     #if ( testrunnerFULL_MEMORYLEAK_ENABLED == 1 )
83 
84         /* Measure the heap size after tests are done running.
85          * This test must run last. */
86 
87         /* Perform any global resource cleanup necessary to avoid memory leaks. */
88         #ifdef testrunnerMEMORYLEAK_CLEANUP
89             testrunnerMEMORYLEAK_CLEANUP();
90         #endif
91 
92         /* Give the print buffer time to empty */
93         vTaskDelay( pdMS_TO_TICKS( 500 ) );
94         xHeapAfter = xPortGetFreeHeapSize();
95         RUN_TEST_GROUP( Full_MemoryLeak );
96     #endif /* if ( testrunnerFULL_MEMORYLEAK_ENABLED == 1 ) */
97 
98     /* Currently disabled. Will be enabled after cleanup. */
99     UNITY_END();
100 
101     #ifdef CODE_COVERAGE
102         exit( 0 );
103     #endif
104 
105     /* This task has finished.  FreeRTOS does not allow a task to run off the
106      * end of its implementing function, so the task must be deleted. */
107     vTaskDelete( NULL );
108 }
109 /*-----------------------------------------------------------*/
110