Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/pcut/src/main.c

    r9eb1ff5 r9b20126  
    9090 * @param last Pointer to first item after this suite is stored here.
    9191 * @param prog_path Path to the current binary (used in forked mode).
    92  * @return Error code.
    93  */
    94 static int run_suite(pcut_item_t *suite, pcut_item_t **last, const char *prog_path) {
     92 */
     93static void run_suite(pcut_item_t *suite, pcut_item_t **last, const char *prog_path) {
    9594        int is_first_test = 1;
    9695        int total_count = 0;
    97         int ret_code = PCUT_OUTCOME_PASS;
    98         int ret_code_tmp;
    9996
    10097        pcut_item_t *it = pcut_get_real_next(suite);
     
    117114
    118115                if (pcut_run_mode == PCUT_RUN_MODE_FORKING) {
    119                         ret_code_tmp = pcut_run_test_forking(prog_path, it);
    120                 } else {
    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 
     116                        pcut_run_test_forking(prog_path, it);
     117                } else {
     118                        pcut_run_test_single(it);
     119                }
    134120                total_count++;
    135121        }
     
    144130                *last = it;
    145131        }
    146 
    147         return ret_code;
    148132}
    149133
     
    197181        int run_only_test = -1;
    198182
    199         int rc, rc_tmp;
    200 
    201183        if (main_extras == NULL) {
    202184                main_extras = empty_main_extra;
     
    221203                        if (pcut_str_equals(argv[i], "-l")) {
    222204                                pcut_print_tests(items);
    223                                 return PCUT_OUTCOME_PASS;
     205                                return 0;
    224206                        }
    225207                        if (pcut_str_equals(argv[i], "-x")) {
     
    247229        if ((run_only_suite >= 0) && (run_only_test >= 0)) {
    248230                printf("Specify either -s or -t!\n");
    249                 return PCUT_OUTCOME_BAD_INVOCATION;
     231                return 1;
    250232        }
    251233
     
    254236                if (suite == NULL) {
    255237                        printf("Suite not found, aborting!\n");
    256                         return PCUT_OUTCOME_BAD_INVOCATION;
     238                        return 2;
    257239                }
    258240                if (suite->kind != PCUT_KIND_TESTSUITE) {
    259241                        printf("Invalid suite id!\n");
    260                         return PCUT_OUTCOME_BAD_INVOCATION;
     242                        return 3;
    261243                }
    262244
    263245                run_suite(suite, NULL, argv[0]);
    264                 return PCUT_OUTCOME_PASS;
     246                return 0;
    265247        }
    266248
    267249        if (run_only_test > 0) {
     250                int rc;
    268251                pcut_item_t *test = pcut_find_by_id(items, run_only_test);
    269252                if (test == NULL) {
    270253                        printf("Test not found, aborting!\n");
    271                         return PCUT_OUTCOME_BAD_INVOCATION;
     254                        return 2;
    272255                }
    273256                if (test->kind != PCUT_KIND_TEST) {
    274257                        printf("Invalid test id!\n");
    275                         return PCUT_OUTCOME_BAD_INVOCATION;
     258                        return 3;
    276259                }
    277260
     
    287270        /* Otherwise, run the whole thing. */
    288271        pcut_report_init(items);
    289 
    290         rc = PCUT_OUTCOME_PASS;
    291272
    292273        it = items;
     
    294275                if (it->kind == PCUT_KIND_TESTSUITE) {
    295276                        pcut_item_t *tmp;
    296                         rc_tmp = run_suite(it, &tmp, argv[0]);
    297                         if (rc_tmp != PCUT_OUTCOME_PASS) {
    298                                 rc = rc_tmp;
    299                         }
     277                        run_suite(it, &tmp, argv[0]);
    300278                        it = tmp;
    301279                } else {
     
    306284        pcut_report_done();
    307285
    308         return rc;
    309 }
     286        return 0;
     287}
Note: See TracChangeset for help on using the changeset viewer.