Changeset 9b20126 in mainline for uspace/lib/pcut/src/report


Ignore:
Timestamp:
2014-09-19T08:23:01Z (11 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

Location:
uspace/lib/pcut/src/report
Files:
3 edited

Legend:

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

    r15d0046 r9b20126  
    4444 *
    4545 * @param op Operation to be called on the pcut_report_ops_t.
     46 * @param ... Arguments to the operation.
    4647 */
    4748#define REPORT_CALL(op, ...) \
    4849        if ((report_ops != NULL) && (report_ops->op != NULL)) report_ops->op(__VA_ARGS__)
     50
     51/** Call a report function if it is available.
     52 *
     53 * @param op Operation to be called on the pcut_report_ops_t.
     54 */
     55#define REPORT_CALL_NO_ARGS(op) \
     56                if ((report_ops != NULL) && (report_ops->op != NULL)) report_ops->op()
    4957
    5058/** Print error message.
     
    94102        /* Ensure that we do not read past the full_output. */
    95103        if (full_output[full_output_size - 1] != 0) {
    96                 // FIXME: can this happen?
     104                /* FIXME: can this happen? */
    97105                return;
    98106        }
    99107
    100108        while (1) {
     109                size_t message_length;
     110
    101111                /* First of all, count number of zero bytes before the text. */
    102112                size_t cont_zeros_count = 0;
     
    111121
    112122                /* Determine the length of the text after the zeros. */
    113                 size_t message_length = pcut_str_size(full_output);
     123                message_length = pcut_str_size(full_output);
    114124
    115125                if (cont_zeros_count < 2) {
    116126                        /* Okay, standard I/O. */
    117127                        if (message_length > stdio_buffer_size) {
    118                                 // TODO: handle gracefully
     128                                /* TODO: handle gracefully */
    119129                                return;
    120130                        }
     
    125135                        /* Error message. */
    126136                        if (message_length > error_buffer_size) {
    127                                 // TODO: handle gracefully
     137                                /* TODO: handle gracefully */
    128138                                return;
    129139                        }
     
    213223 *
    214224 */
    215 void pcut_report_done() {
    216         REPORT_CALL(done);
    217 }
    218 
     225void pcut_report_done(void) {
     226        REPORT_CALL_NO_ARGS(done);
     227}
     228
  • uspace/lib/pcut/src/report/tap.c

    r15d0046 r9b20126  
    6767        failed_tests_in_suite = 0;
    6868
    69         printf("#> Starting suite %s.\n", suite->suite.name);
     69        printf("#> Starting suite %s.\n", suite->name);
    7070}
    7171
     
    7676static void tap_suite_done(pcut_item_t *suite) {
    7777        printf("#> Finished suite %s (failed %d of %d).\n",
    78                         suite->suite.name, failed_tests_in_suite, tests_in_suite);
     78                        suite->name, failed_tests_in_suite, tests_in_suite);
    7979}
    8080
     
    9898 */
    9999static void print_by_lines(const char *message, const char *prefix) {
     100        char *next_line_start;
    100101        if ((message == NULL) || (message[0] == 0)) {
    101102                return;
    102103        }
    103         char *next_line_start = pcut_str_find_char(message, '\n');
     104        next_line_start = pcut_str_find_char(message, '\n');
    104105        while (next_line_start != NULL) {
    105106                next_line_start[0] = 0;
     
    124125                const char *error_message, const char *teardown_error_message,
    125126                const char *extra_output) {
    126         const char *test_name = test->test.name;
     127        const char *test_name = test->name;
     128        const char *status_str = NULL;
     129        const char *fail_error_str = NULL;
    127130
    128131        if (outcome != TEST_OUTCOME_PASS) {
     
    130133        }
    131134
    132         const char *status_str = NULL;
    133         const char *fail_error_str = NULL;
    134135        switch (outcome) {
    135136        case TEST_OUTCOME_PASS:
     
    158159
    159160/** Report testing done. */
    160 static void tap_done() {
     161static void tap_done(void) {
    161162}
    162163
    163164
    164165pcut_report_ops_t pcut_report_tap = {
    165         .init = tap_init,
    166         .done = tap_done,
    167         .suite_start = tap_suite_start,
    168         .suite_done = tap_suite_done,
    169         .test_start = tap_test_start,
    170         .test_done = tap_test_done
     166        tap_init, tap_done,
     167        tap_suite_start, tap_suite_done,
     168        tap_test_start, tap_test_done
    171169};
  • uspace/lib/pcut/src/report/xml.c

    r15d0046 r9b20126  
    5353 */
    5454static void xml_init(pcut_item_t *all_items) {
    55         printf("<?xml version=\"1.0\"?>\n");
    56 
    5755        int tests_total = pcut_count_tests(all_items);
    5856        test_counter = 0;
    5957
     58        printf("<?xml version=\"1.0\"?>\n");
    6059        printf("<report tests-total=\"%d\">\n", tests_total);
    6160}
     
    6968        failed_tests_in_suite = 0;
    7069
    71         printf("\t<suite name=\"%s\">\n", suite->suite.name);
     70        printf("\t<suite name=\"%s\">\n", suite->name);
    7271}
    7372
     
    7776 */
    7877static void xml_suite_done(pcut_item_t *suite) {
    79         printf("\t</suite><!-- %s: %d / %d -->\n", suite->suite.name,
     78        printf("\t</suite><!-- %s: %d / %d -->\n", suite->name,
    8079                failed_tests_in_suite, tests_in_suite);
    8180}
     
    10099 */
    101100static void print_by_lines(const char *message, const char *element_name) {
     101        char *next_line_start;
     102
    102103        if ((message == NULL) || (message[0] == 0)) {
    103104                return;
     
    106107        printf("\t\t\t<%s><![CDATA[", element_name);
    107108
    108         char *next_line_start = pcut_str_find_char(message, '\n');
     109        next_line_start = pcut_str_find_char(message, '\n');
    109110        while (next_line_start != NULL) {
    110111                next_line_start[0] = 0;
     
    131132                const char *error_message, const char *teardown_error_message,
    132133                const char *extra_output) {
    133         const char *test_name = test->test.name;
     134        const char *test_name = test->name;
     135        const char *status_str = NULL;
    134136
    135137        if (outcome != TEST_OUTCOME_PASS) {
     
    137139        }
    138140
    139         const char *status_str = NULL;
    140141        switch (outcome) {
    141142        case TEST_OUTCOME_PASS:
     
    165166
    166167/** Report testing done. */
    167 static void xml_done() {
     168static void xml_done(void) {
    168169        printf("</report>\n");
    169170}
     
    171172
    172173pcut_report_ops_t pcut_report_xml = {
    173         .init = xml_init,
    174         .done = xml_done,
    175         .suite_start = xml_suite_start,
    176         .suite_done = xml_suite_done,
    177         .test_start = xml_test_start,
    178         .test_done = xml_test_done
     174        xml_init, xml_done,
     175        xml_suite_start, xml_suite_done,
     176        xml_test_start, xml_test_done
    179177};
Note: See TracChangeset for help on using the changeset viewer.