Changeset 9eb1ff5 in mainline for uspace/lib/pcut/src/main.c
- Timestamp:
- 2017-12-08T14:47:08Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c1694b6b
- Parents:
- 6fb8b2c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/pcut/src/main.c
r6fb8b2c r9eb1ff5 90 90 * @param last Pointer to first item after this suite is stored here. 91 91 * @param prog_path Path to the current binary (used in forked mode). 92 */ 93 static void run_suite(pcut_item_t *suite, pcut_item_t **last, const char *prog_path) { 92 * @return Error code. 93 */ 94 static int run_suite(pcut_item_t *suite, pcut_item_t **last, const char *prog_path) { 94 95 int is_first_test = 1; 95 96 int total_count = 0; 97 int ret_code = PCUT_OUTCOME_PASS; 98 int ret_code_tmp; 96 99 97 100 pcut_item_t *it = pcut_get_real_next(suite); … … 114 117 115 118 if (pcut_run_mode == PCUT_RUN_MODE_FORKING) { 116 pcut_run_test_forking(prog_path, it);119 ret_code_tmp = pcut_run_test_forking(prog_path, it); 117 120 } else { 118 pcut_run_test_single(it); 119 } 121 ret_code_tmp = pcut_run_test_single(it); 122 } 123 124 /* 125 * Override final return code in case of failure. 126 * 127 * In this case we suppress any special error codes as 128 * to the outside, there was a failure. 129 */ 130 if (ret_code_tmp != PCUT_OUTCOME_PASS) { 131 ret_code = PCUT_OUTCOME_FAIL; 132 } 133 120 134 total_count++; 121 135 } … … 130 144 *last = it; 131 145 } 146 147 return ret_code; 132 148 } 133 149 … … 181 197 int run_only_test = -1; 182 198 199 int rc, rc_tmp; 200 183 201 if (main_extras == NULL) { 184 202 main_extras = empty_main_extra; … … 203 221 if (pcut_str_equals(argv[i], "-l")) { 204 222 pcut_print_tests(items); 205 return 0;223 return PCUT_OUTCOME_PASS; 206 224 } 207 225 if (pcut_str_equals(argv[i], "-x")) { … … 229 247 if ((run_only_suite >= 0) && (run_only_test >= 0)) { 230 248 printf("Specify either -s or -t!\n"); 231 return 1;249 return PCUT_OUTCOME_BAD_INVOCATION; 232 250 } 233 251 … … 236 254 if (suite == NULL) { 237 255 printf("Suite not found, aborting!\n"); 238 return 2;256 return PCUT_OUTCOME_BAD_INVOCATION; 239 257 } 240 258 if (suite->kind != PCUT_KIND_TESTSUITE) { 241 259 printf("Invalid suite id!\n"); 242 return 3;260 return PCUT_OUTCOME_BAD_INVOCATION; 243 261 } 244 262 245 263 run_suite(suite, NULL, argv[0]); 246 return 0;264 return PCUT_OUTCOME_PASS; 247 265 } 248 266 249 267 if (run_only_test > 0) { 250 int rc;251 268 pcut_item_t *test = pcut_find_by_id(items, run_only_test); 252 269 if (test == NULL) { 253 270 printf("Test not found, aborting!\n"); 254 return 2;271 return PCUT_OUTCOME_BAD_INVOCATION; 255 272 } 256 273 if (test->kind != PCUT_KIND_TEST) { 257 274 printf("Invalid test id!\n"); 258 return 3;275 return PCUT_OUTCOME_BAD_INVOCATION; 259 276 } 260 277 … … 271 288 pcut_report_init(items); 272 289 290 rc = PCUT_OUTCOME_PASS; 291 273 292 it = items; 274 293 while (it != NULL) { 275 294 if (it->kind == PCUT_KIND_TESTSUITE) { 276 295 pcut_item_t *tmp; 277 run_suite(it, &tmp, argv[0]); 296 rc_tmp = run_suite(it, &tmp, argv[0]); 297 if (rc_tmp != PCUT_OUTCOME_PASS) { 298 rc = rc_tmp; 299 } 278 300 it = tmp; 279 301 } else { … … 284 306 pcut_report_done(); 285 307 286 return 0;287 } 308 return rc; 309 }
Note:
See TracChangeset
for help on using the changeset viewer.