]> begriffs open source - cmsis-driver-validation/blob - Source/DV_Framework.c
Update LPCXpresso55S69.png
[cmsis-driver-validation] / Source / DV_Framework.c
1 /*-----------------------------------------------------------------------------
2  *      Name:         DV_Framework.c
3  *      Purpose:      Test framework
4  *----------------------------------------------------------------------------
5  *      Copyright(c) KEIL - An ARM Company
6  *----------------------------------------------------------------------------*/
7
8 #include "cmsis_dv.h" 
9 #include "DV_Framework.h"
10
11 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
12 /**
13 \defgroup framework_funcs Framework Functions
14 \brief Functions in the Framework software component
15 \details
16
17 @{
18 */
19
20 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
21 /**
22 \brief Close the debug session.
23 \details
24 Debug session dead end - debug script should close session here. This function is called by \ref cmsis_dv.
25 */
26 void closeDebug(void);
27 void __attribute__((noinline)) closeDebug(void){
28   __NOP();
29   // Test completed
30 }
31
32
33 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
34 /**
35 \brief This is the entry point of the test framework.
36 \details
37 Program flow:
38   -# Test report is initialized
39   -# For each test group following steps are executed:
40     -# Test group initialization is called (custom test group initialization)
41     -# Test group header is written to standard output 
42     -# All tests in a group are executed as follows:
43         - Test case statistics are initialized
44         - Test case report header is written to the standard output
45         - Test case is executed
46         - Test case results are written to the standard output
47         - Test case report footer is written to the standard output
48     -# Test group footer is written to standard output 
49     -# Test group uninitialization is called (custom test group uninitialization)
50   -# Debug session ends when closeDebug function is reached
51 */
52 void cmsis_dv (void __attribute__((unused)) *argument) {
53   const char *fn;
54   uint32_t    i, tc, no;
55
56   if (tg_cnt != 0) {                    /* If at least 1 test is enabled      */
57
58     ritf.tr_Init ();                    /* Init test report                   */
59
60     for (i = 0U; i < tg_cnt; i++) {
61
62       if (ts[i].Init) {
63         ts[i].Init();                   /* Init test group (group setup)      */
64       }
65                                         /* Init test group report             */
66       ritf.tg_Init(ts[i].ReportTitle,   /* Write test group title             */
67                    ts[i].Date,          /* Write test group compilation date  */
68                    ts[i].Time,          /* Write test group compilation time  */
69                    ts[i].FileName);     /* Write test group module file name  */
70
71       /* Execute all test cases in a group */
72       for (tc = 0; tc < ts[i].NumOfTC; tc++) {
73         no = ts[i].TCBaseNum+tc;        /* Test case number                   */
74         fn = ts[i].TC[tc].TFName;       /* Test function name string          */
75         ritf.tc_Init (no, fn);          /* Init test case report #(Base + TC) */
76         if (ts[i].TC[tc].en) {
77           ts[i].TC[tc].TestFunc();      /* Execute test case if enabled       */
78         }
79         ritf.tc_Uninit ();              /* Uninit test case report            */
80       }
81
82       ritf.tg_Uninit ();                /* Uninit test group report           */
83
84       if (ts[i].Uninit) {
85         ts[i].Uninit();                 /* Uninit test group (group teardown) */
86       }
87     }
88
89     ritf.tr_Uninit();                   /* Uninit test report                 */
90   }
91
92   closeDebug();                         /* Close debug session                */
93 }
94
95 /**
96 @}
97 */ 
98 // end of group framework_funcs