]> begriffs open source - cmsis-driver-validation/blob - Source/DV_Framework.c
Update ETH driver validation and related examples
[cmsis-driver-validation] / Source / DV_Framework.c
1 /*
2  * Copyright (c) 2015-2020 Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Licensed under the Apache License, Version 2.0 (the License); you may
7  * not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an AS IS BASIS, WITHOUT
14  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  * -----------------------------------------------------------------------------
19  *
20  * Project:     CMSIS-Driver Validation
21  * Title:       Test framework
22  *
23  * -----------------------------------------------------------------------------
24  */
25
26
27 #include "cmsis_dv.h" 
28 #include "DV_Framework.h"
29
30 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
31 /**
32 \defgroup dv_framework Framework
33 \brief Framework configuration and functions
34 \details
35
36 \defgroup framework_funcs Functions
37 \ingroup dv_framework
38
39 @{
40 */
41
42 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
43 /**
44 \brief Close the debug session.
45 \details
46 Debug session dead end - debug script should close session here. This function is called by \ref cmsis_dv.
47 */
48 void closeDebug(void);
49
50 #ifndef __DOXYGEN__                     // Exclude form the documentation
51 void __attribute__((noinline)) closeDebug(void){
52   __NOP();
53   // Test completed
54 }
55 #endif
56
57
58 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
59 /**
60 \brief This is the entry point of the test framework.
61 \details
62 Program flow:
63   -# Test report is initialized
64   -# For each test group following steps are executed:
65     -# Test group initialization is called (custom test group initialization)
66     -# Test group header is written to standard output 
67     -# All tests in a group are executed as follows:
68         - Test statistics are initialized
69         - Test report header is written to the standard output
70         - Test function is executed
71         - Test results are written to the standard output
72         - Test report footer is written to the standard output
73     -# Test group footer is written to standard output 
74     -# Test group uninitialization is called (custom test group uninitialization)
75   -# Debug session ends when closeDebug function is reached
76 */
77 void cmsis_dv (void *argument) {
78   const char *fn;
79   uint32_t    i, tc, no;
80
81   (void)argument;
82
83   if (tg_cnt != 0U) {                   /* If at least 1 test is enabled      */
84
85     ritf.tr_Init ();                    /* Init test report                   */
86
87     for (i = 0U; i < tg_cnt; i++) {
88
89                                         /* Init test group report             */
90       ritf.tg_Init(ts[i].ReportTitle,   /* Write test group title             */
91                    ts[i].Date,          /* Write test group compilation date  */
92                    ts[i].Time,          /* Write test group compilation time  */
93                    ts[i].FileName);     /* Write test group module file name  */
94
95       if (ts[i].Init != NULL) {
96         ts[i].Init();                   /* Init test group (group setup)      */
97       }
98
99       ritf.tg_InfoDone();               /* Test group info done               */
100
101       /* Execute all tests in a group */
102       for (tc = 0U; tc < ts[i].NumOfTC; tc++) {
103         no = tc + 1U;                   /* Test number                        */
104         fn = ts[i].TC[tc].TFName;       /* Test function name string          */
105         ritf.tc_Init (no, fn);          /* Init test report #(Base + TC)      */
106         if (ts[i].TC[tc].TestFunc != NULL) {
107           ts[i].TC[tc].TestFunc();      /* Execute test func if enabled       */
108         }
109         ritf.tc_Uninit ();              /* Uninit test report                 */
110       }
111
112       ritf.tg_Uninit ();                /* Uninit test group report           */
113
114       if (ts[i].Uninit != NULL) {
115         ts[i].Uninit();                 /* Uninit test group (group teardown) */
116       }
117     }
118
119     ritf.tr_Uninit();                   /* Uninit test report                 */
120   }
121
122   closeDebug();                         /* Close debug session                */
123 }
124
125 /**
126 @}
127 */ 
128 // end of group framework_funcs