Changeset 9eb1ff5 in mainline for uspace/lib/pcut/src/main.c


Ignore:
Timestamp:
2017-12-08T14:47:08Z (8 years ago)
Author:
Vojtech Horky <vojtech.horky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c1694b6b
Parents:
6fb8b2c
Message:

Update PCUT

Updated PCUT to commit 7ce059f.

Notable changes include:

  • overall summary is printed when tests finish
  • when tests passed, the status message does not use the word 'failure'
  • program exit code is zero only when all tests passed

These changes fixes tickets 713 and 714.

http://www.helenos.org/ticket/713
http://www.helenos.org/ticket/714

File:
1 edited

Legend:

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

    r6fb8b2c r9eb1ff5  
    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  */
    93 static void run_suite(pcut_item_t *suite, pcut_item_t **last, const char *prog_path) {
     92 * @return Error code.
     93 */
     94static int run_suite(pcut_item_t *suite, pcut_item_t **last, const char *prog_path) {
    9495        int is_first_test = 1;
    9596        int total_count = 0;
     97        int ret_code = PCUT_OUTCOME_PASS;
     98        int ret_code_tmp;
    9699
    97100        pcut_item_t *it = pcut_get_real_next(suite);
     
    114117
    115118                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);
    117120                } 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
    120134                total_count++;
    121135        }
     
    130144                *last = it;
    131145        }
     146
     147        return ret_code;
    132148}
    133149
     
    181197        int run_only_test = -1;
    182198
     199        int rc, rc_tmp;
     200
    183201        if (main_extras == NULL) {
    184202                main_extras = empty_main_extra;
     
    203221                        if (pcut_str_equals(argv[i], "-l")) {
    204222                                pcut_print_tests(items);
    205                                 return 0;
     223                                return PCUT_OUTCOME_PASS;
    206224                        }
    207225                        if (pcut_str_equals(argv[i], "-x")) {
     
    229247        if ((run_only_suite >= 0) && (run_only_test >= 0)) {
    230248                printf("Specify either -s or -t!\n");
    231                 return 1;
     249                return PCUT_OUTCOME_BAD_INVOCATION;
    232250        }
    233251
     
    236254                if (suite == NULL) {
    237255                        printf("Suite not found, aborting!\n");
    238                         return 2;
     256                        return PCUT_OUTCOME_BAD_INVOCATION;
    239257                }
    240258                if (suite->kind != PCUT_KIND_TESTSUITE) {
    241259                        printf("Invalid suite id!\n");
    242                         return 3;
     260                        return PCUT_OUTCOME_BAD_INVOCATION;
    243261                }
    244262
    245263                run_suite(suite, NULL, argv[0]);
    246                 return 0;
     264                return PCUT_OUTCOME_PASS;
    247265        }
    248266
    249267        if (run_only_test > 0) {
    250                 int rc;
    251268                pcut_item_t *test = pcut_find_by_id(items, run_only_test);
    252269                if (test == NULL) {
    253270                        printf("Test not found, aborting!\n");
    254                         return 2;
     271                        return PCUT_OUTCOME_BAD_INVOCATION;
    255272                }
    256273                if (test->kind != PCUT_KIND_TEST) {
    257274                        printf("Invalid test id!\n");
    258                         return 3;
     275                        return PCUT_OUTCOME_BAD_INVOCATION;
    259276                }
    260277
     
    271288        pcut_report_init(items);
    272289
     290        rc = PCUT_OUTCOME_PASS;
     291
    273292        it = items;
    274293        while (it != NULL) {
    275294                if (it->kind == PCUT_KIND_TESTSUITE) {
    276295                        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                        }
    278300                        it = tmp;
    279301                } else {
     
    284306        pcut_report_done();
    285307
    286         return 0;
    287 }
     308        return rc;
     309}
Note: See TracChangeset for help on using the changeset viewer.