1 : /*
2 : * This file is part of MIN Test Framework. Copyright © 2008 Nokia Corporation
3 : * and/or its subsidiary(-ies).
4 : * Contact: Sampo Saaristo
5 : * Contact e-mail: DG.MIN-Support@nokia.com
6 : *
7 : * This program is free software: you can redistribute it and/or modify it
8 : * under the terms of the GNU General Public License as published by the Free
9 : * Software Foundation, version 2 of the License.
10 : *
11 : * This program is distributed in the hope that it will be useful, but WITHOUT
12 : * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 : * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 : * more details. You should have received a copy of the GNU General Public
15 : * License along with this program. If not, see
16 : * <http://www.gnu.org/licenses/>.
17 : */
18 :
19 : /**
20 : * @file minunit.c
21 : * @version 0.1
22 : * @brief MINUnit testmodule api implementation.
23 : */
24 :
25 : /* ------------------------------------------------------------------------- */
26 : /* INCLUDE FILES */
27 : #include <test_module_api.h>
28 : #include <min_logger.h>
29 : #include <min_parser.h>
30 : #include <min_test_event_if.h>
31 : #include <min_unit_macros.h>
32 :
33 : /* ------------------------------------------------------------------------- */
34 : /* EXTERNAL DATA STRUCTURES */
35 : /* None */
36 :
37 : /* ------------------------------------------------------------------------- */
38 : /* EXTERNAL GLOBAL VARIABLES */
39 : char *module_date = __DATE__;
40 : char *module_time = __TIME__;
41 : /* ------------------------------------------------------------------------- */
42 : /* EXTERNAL FUNCTION PROTOTYPES */
43 : /* None */
44 :
45 : /* ------------------------------------------------------------------------- */
46 : /* GLOBAL VARIABLES */
47 : TTestModuleType module_type = ESUnit;
48 : unsigned int module_version = 200842;
49 : /* ------------------------------------------------------------------------- */
50 : /* CONSTANTS */
51 : /* None */
52 :
53 : /* ------------------------------------------------------------------------- */
54 : /* MACROS */
55 : #define GET_CASES 0
56 : #define RUN_SETUP 1
57 : #define RUN_CASE 2
58 : #define RUN_TEARDOWN 3
59 :
60 : #ifndef CASES_FILE
61 : #error "CASES_FILE undefined, define with -D"
62 : #else
63 :
64 : /* ------------------------------------------------------------------------- */
65 : /* LOCAL GLOBAL VARIABLES */
66 : /* None */
67 :
68 : /* ------------------------------------------------------------------------- */
69 : /* LOCAL CONSTANTS AND MACROS */
70 : /* None */
71 :
72 : /* ------------------------------------------------------------------------- */
73 : /* MODULE DATA STRUCTURES */
74 : /* None */
75 :
76 : /* ------------------------------------------------------------------------- */
77 : /* LOCAL FUNCTION PROTOTYPES */
78 : LOCAL int min_unit_wrapper (int __action__, const char *__cfg_file__,
79 : DLList ** __cases__, unsigned int __id__,
80 : TestCaseResult * __result__);
81 :
82 : /* ------------------------------------------------------------------------- */
83 : /* FORWARD DECLARATIONS */
84 : /* None */
85 :
86 : /* ==================== LOCAL FUNCTIONS ==================================== */
87 : /* ------------------------------------------------------------------------- */
88 : LOCAL int min_unit_wrapper (int __action__, const char *__cfg_file__,
89 : DLList ** __cases__, unsigned int __id__,
90 : TestCaseResult * __result__)
91 74 : {
92 : /*
93 : * Needed variables, please do not edit this section
94 : */
95 : int __test_case_index__;
96 : #define TEST_VAR_DECLARATIONS
97 : #include CASES_FILE
98 : #undef TEST_VAR_DECLARATIONS
99 74 : if (__action__ == RUN_CASE)
100 36 : __action__ = RUN_SETUP;
101 138 : min_unit_again:
102 138 : __test_case_index__ = 0;
103 : #define TEST_CASES
104 : #include CASES_FILE
105 : #undef TEST_CASES
106 130 : if (__action__ == RUN_SETUP) {
107 36 : __action__ = RUN_CASE;
108 36 : goto min_unit_again;
109 94 : } else if (__action__ == RUN_CASE) {
110 28 : __action__ = RUN_TEARDOWN;
111 28 : goto min_unit_again;
112 : }
113 :
114 66 : if (__action__ != GET_CASES)
115 28 : RESULT (__result__, TP_PASSED, "PASSED");
116 :
117 38 : return ENOERR;
118 : }
119 :
120 : /* ------------------------------------------------------------------------- */
121 : /* ======================== FUNCTIONS ====================================== */
122 : /* ------------------------------------------------------------------------- */
123 : int tm_get_test_cases (const char *cfg_file, DLList ** cases)
124 38 : {
125 :
126 38 : min_unit_wrapper (GET_CASES, cfg_file, cases, 0, NULL);
127 :
128 38 : return 0;
129 : }
130 :
131 : /* ------------------------------------------------------------------------- */
132 : int tm_run_test_case (unsigned int id, const char *cfg_file,
133 : TestCaseResult * result)
134 36 : {
135 36 : int retval = 0;
136 :
137 36 : min_unit_wrapper (RUN_CASE, cfg_file, NULL, id, result);
138 :
139 36 : return retval;
140 : }
141 : /* ------------------------------------------------------------------------- */
142 : unsigned int get_module_type()
143 38 : { return module_type; }
144 : /* ------------------------------------------------------------------------- */
145 : unsigned int get_module_version()
146 38 : { return module_version; }
147 : /* ------------------------------------------------------------------------- */
148 : char* get_module_date()
149 76 : { return module_date; }
150 : /* ------------------------------------------------------------------------- */
151 : char* get_module_time()
152 76 : { return module_time; }
153 : /* ------------------------------------------------------------------------- */
154 : /* ================= OTHER EXPORTED FUNCTIONS ============================== */
155 : /* None */
156 :
157 : /* ------------------------------------------------------------------------- */
158 : #endif /* CASES_FILE */
159 : /* End of file */
|