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


Ignore:
Timestamp:
2014-09-19T08:23:01Z (10 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c85a57f
Parents:
15d0046
Message:

Update PCUT to newest version

File:
1 edited

Legend:

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

    r15d0046 r9b20126  
    4141int pcut_run_mode = PCUT_RUN_MODE_FORKING;
    4242
     43/** Empty list to bypass special handling for NULL. */
     44static 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++)
    4351
    4452/** Checks whether the argument is an option followed by a number.
     
    5462                return 0;
    5563        }
    56         int val = pcut_str_to_int(arg + opt_len);
    57         *value = val;
     64        *value = pcut_str_to_int(arg + opt_len);
    5865        return 1;
    5966}
     
    8592 */
    8693static 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
    8797        pcut_item_t *it = pcut_get_real_next(suite);
    8898        if ((it == NULL) || (it->kind == PCUT_KIND_TESTSUITE)) {
     
    90100        }
    91101
    92         int is_first_test = 1;
    93         int total_count = 0;
    94 
    95102        for (; it != NULL; it = pcut_get_real_next(it)) {
    96103                if (it->kind == PCUT_KIND_TESTSUITE) {
     
    135142static void set_setup_teardown_callbacks(pcut_item_t *first) {
    136143        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)) {
    138146                if (it->kind == PCUT_KIND_TESTSUITE) {
    139147                        active_suite = it;
    140148                } else if (it->kind == PCUT_KIND_SETUP) {
    141149                        if (active_suite != NULL) {
    142                                 active_suite->suite.setup = it->setup.func;
     150                                active_suite->setup_func = it->setup_func;
    143151                        }
    144152                        it->kind = PCUT_KIND_SKIP;
    145153                } else if (it->kind == PCUT_KIND_TEARDOWN) {
    146154                        if (active_suite != NULL) {
    147                                 active_suite->suite.teardown = it->setup.func;
     155                                active_suite->teardown_func = it->teardown_func;
    148156                        }
    149157                        it->kind = PCUT_KIND_SKIP;
     
    166174int pcut_main(pcut_item_t *last, int argc, char *argv[]) {
    167175        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;
    168179
    169180        int run_only_suite = -1;
    170181        int run_only_test = -1;
    171182
     183        if (main_extras == NULL) {
     184                main_extras = empty_main_extra;
     185        }
     186
    172187        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        }
    173197
    174198        if (argc > 1) {
     
    195219        set_setup_teardown_callbacks(items);
    196220
     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
    197227        PCUT_DEBUG("run_only_suite = %d   run_only_test = %d", run_only_suite, run_only_test);
    198228
     
    218248
    219249        if (run_only_test > 0) {
     250                int rc;
    220251                pcut_item_t *test = pcut_find_by_id(items, run_only_test);
    221252                if (test == NULL) {
     
    228259                }
    229260
    230                 int rc;
    231261                if (pcut_run_mode == PCUT_RUN_MODE_SINGLE) {
    232262                        rc = pcut_run_test_single(test);
     
    241271        pcut_report_init(items);
    242272
    243         pcut_item_t *it = items;
     273        it = items;
    244274        while (it != NULL) {
    245275                if (it->kind == PCUT_KIND_TESTSUITE) {
Note: See TracChangeset for help on using the changeset viewer.