Changeset 9b20126 in mainline for uspace/lib/pcut/src/main.c
- Timestamp:
- 2014-09-19T08:23:01Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c85a57f
- Parents:
- 15d0046
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/pcut/src/main.c
r15d0046 r9b20126 41 41 int pcut_run_mode = PCUT_RUN_MODE_FORKING; 42 42 43 /** Empty list to bypass special handling for NULL. */ 44 static pcut_main_extra_t empty_main_extra[] = { 45 PCUT_MAIN_EXTRA_SET_LAST 46 }; 47 48 /** Helper for iteration over main extras. */ 49 #define FOR_EACH_MAIN_EXTRA(extras, it) \ 50 for (it = extras; it->type != PCUT_MAIN_EXTRA_LAST; it++) 43 51 44 52 /** Checks whether the argument is an option followed by a number. … … 54 62 return 0; 55 63 } 56 int val = pcut_str_to_int(arg + opt_len); 57 *value = val; 64 *value = pcut_str_to_int(arg + opt_len); 58 65 return 1; 59 66 } … … 85 92 */ 86 93 static void run_suite(pcut_item_t *suite, pcut_item_t **last, const char *prog_path) { 94 int is_first_test = 1; 95 int total_count = 0; 96 87 97 pcut_item_t *it = pcut_get_real_next(suite); 88 98 if ((it == NULL) || (it->kind == PCUT_KIND_TESTSUITE)) { … … 90 100 } 91 101 92 int is_first_test = 1;93 int total_count = 0;94 95 102 for (; it != NULL; it = pcut_get_real_next(it)) { 96 103 if (it->kind == PCUT_KIND_TESTSUITE) { … … 135 142 static void set_setup_teardown_callbacks(pcut_item_t *first) { 136 143 pcut_item_t *active_suite = NULL; 137 for (pcut_item_t *it = first; it != NULL; it = pcut_get_real_next(it)) { 144 pcut_item_t *it; 145 for (it = first; it != NULL; it = pcut_get_real_next(it)) { 138 146 if (it->kind == PCUT_KIND_TESTSUITE) { 139 147 active_suite = it; 140 148 } else if (it->kind == PCUT_KIND_SETUP) { 141 149 if (active_suite != NULL) { 142 active_suite->s uite.setup = it->setup.func;150 active_suite->setup_func = it->setup_func; 143 151 } 144 152 it->kind = PCUT_KIND_SKIP; 145 153 } else if (it->kind == PCUT_KIND_TEARDOWN) { 146 154 if (active_suite != NULL) { 147 active_suite-> suite.teardown = it->setup.func;155 active_suite->teardown_func = it->teardown_func; 148 156 } 149 157 it->kind = PCUT_KIND_SKIP; … … 166 174 int pcut_main(pcut_item_t *last, int argc, char *argv[]) { 167 175 pcut_item_t *items = pcut_fix_list_get_real_head(last); 176 pcut_item_t *it; 177 pcut_main_extra_t *main_extras = last->main_extras; 178 pcut_main_extra_t *main_extras_it; 168 179 169 180 int run_only_suite = -1; 170 181 int run_only_test = -1; 171 182 183 if (main_extras == NULL) { 184 main_extras = empty_main_extra; 185 } 186 172 187 pcut_report_register_handler(&pcut_report_tap); 188 189 FOR_EACH_MAIN_EXTRA(main_extras, main_extras_it) { 190 if (main_extras_it->type == PCUT_MAIN_EXTRA_REPORT_XML) { 191 pcut_report_register_handler(&pcut_report_xml); 192 } 193 if (main_extras_it->type == PCUT_MAIN_EXTRA_PREINIT_HOOK) { 194 main_extras_it->preinit_hook(&argc, &argv); 195 } 196 } 173 197 174 198 if (argc > 1) { … … 195 219 set_setup_teardown_callbacks(items); 196 220 221 FOR_EACH_MAIN_EXTRA(main_extras, main_extras_it) { 222 if (main_extras_it->type == PCUT_MAIN_EXTRA_INIT_HOOK) { 223 main_extras_it->init_hook(); 224 } 225 } 226 197 227 PCUT_DEBUG("run_only_suite = %d run_only_test = %d", run_only_suite, run_only_test); 198 228 … … 218 248 219 249 if (run_only_test > 0) { 250 int rc; 220 251 pcut_item_t *test = pcut_find_by_id(items, run_only_test); 221 252 if (test == NULL) { … … 228 259 } 229 260 230 int rc;231 261 if (pcut_run_mode == PCUT_RUN_MODE_SINGLE) { 232 262 rc = pcut_run_test_single(test); … … 241 271 pcut_report_init(items); 242 272 243 pcut_item_t *it = items;273 it = items; 244 274 while (it != NULL) { 245 275 if (it->kind == PCUT_KIND_TESTSUITE) {
Note:
See TracChangeset
for help on using the changeset viewer.