Changeset 9b20126 in mainline for uspace/lib/pcut/src/report
- Timestamp:
- 2014-09-19T08:23:01Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c85a57f
- Parents:
- 15d0046
- Location:
- uspace/lib/pcut/src/report
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/pcut/src/report/report.c
r15d0046 r9b20126 44 44 * 45 45 * @param op Operation to be called on the pcut_report_ops_t. 46 * @param ... Arguments to the operation. 46 47 */ 47 48 #define REPORT_CALL(op, ...) \ 48 49 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() 49 57 50 58 /** Print error message. … … 94 102 /* Ensure that we do not read past the full_output. */ 95 103 if (full_output[full_output_size - 1] != 0) { 96 / / FIXME: can this happen?104 /* FIXME: can this happen? */ 97 105 return; 98 106 } 99 107 100 108 while (1) { 109 size_t message_length; 110 101 111 /* First of all, count number of zero bytes before the text. */ 102 112 size_t cont_zeros_count = 0; … … 111 121 112 122 /* Determine the length of the text after the zeros. */ 113 size_tmessage_length = pcut_str_size(full_output);123 message_length = pcut_str_size(full_output); 114 124 115 125 if (cont_zeros_count < 2) { 116 126 /* Okay, standard I/O. */ 117 127 if (message_length > stdio_buffer_size) { 118 / / TODO: handle gracefully128 /* TODO: handle gracefully */ 119 129 return; 120 130 } … … 125 135 /* Error message. */ 126 136 if (message_length > error_buffer_size) { 127 / / TODO: handle gracefully137 /* TODO: handle gracefully */ 128 138 return; 129 139 } … … 213 223 * 214 224 */ 215 void pcut_report_done( ) {216 REPORT_CALL (done);217 } 218 225 void pcut_report_done(void) { 226 REPORT_CALL_NO_ARGS(done); 227 } 228 -
uspace/lib/pcut/src/report/tap.c
r15d0046 r9b20126 67 67 failed_tests_in_suite = 0; 68 68 69 printf("#> Starting suite %s.\n", suite-> suite.name);69 printf("#> Starting suite %s.\n", suite->name); 70 70 } 71 71 … … 76 76 static void tap_suite_done(pcut_item_t *suite) { 77 77 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); 79 79 } 80 80 … … 98 98 */ 99 99 static void print_by_lines(const char *message, const char *prefix) { 100 char *next_line_start; 100 101 if ((message == NULL) || (message[0] == 0)) { 101 102 return; 102 103 } 103 char *next_line_start = pcut_str_find_char(message, '\n');104 next_line_start = pcut_str_find_char(message, '\n'); 104 105 while (next_line_start != NULL) { 105 106 next_line_start[0] = 0; … … 124 125 const char *error_message, const char *teardown_error_message, 125 126 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; 127 130 128 131 if (outcome != TEST_OUTCOME_PASS) { … … 130 133 } 131 134 132 const char *status_str = NULL;133 const char *fail_error_str = NULL;134 135 switch (outcome) { 135 136 case TEST_OUTCOME_PASS: … … 158 159 159 160 /** Report testing done. */ 160 static void tap_done( ) {161 static void tap_done(void) { 161 162 } 162 163 163 164 164 165 pcut_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 171 169 }; -
uspace/lib/pcut/src/report/xml.c
r15d0046 r9b20126 53 53 */ 54 54 static void xml_init(pcut_item_t *all_items) { 55 printf("<?xml version=\"1.0\"?>\n");56 57 55 int tests_total = pcut_count_tests(all_items); 58 56 test_counter = 0; 59 57 58 printf("<?xml version=\"1.0\"?>\n"); 60 59 printf("<report tests-total=\"%d\">\n", tests_total); 61 60 } … … 69 68 failed_tests_in_suite = 0; 70 69 71 printf("\t<suite name=\"%s\">\n", suite-> suite.name);70 printf("\t<suite name=\"%s\">\n", suite->name); 72 71 } 73 72 … … 77 76 */ 78 77 static 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, 80 79 failed_tests_in_suite, tests_in_suite); 81 80 } … … 100 99 */ 101 100 static void print_by_lines(const char *message, const char *element_name) { 101 char *next_line_start; 102 102 103 if ((message == NULL) || (message[0] == 0)) { 103 104 return; … … 106 107 printf("\t\t\t<%s><![CDATA[", element_name); 107 108 108 char *next_line_start = pcut_str_find_char(message, '\n');109 next_line_start = pcut_str_find_char(message, '\n'); 109 110 while (next_line_start != NULL) { 110 111 next_line_start[0] = 0; … … 131 132 const char *error_message, const char *teardown_error_message, 132 133 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; 134 136 135 137 if (outcome != TEST_OUTCOME_PASS) { … … 137 139 } 138 140 139 const char *status_str = NULL;140 141 switch (outcome) { 141 142 case TEST_OUTCOME_PASS: … … 165 166 166 167 /** Report testing done. */ 167 static void xml_done( ) {168 static void xml_done(void) { 168 169 printf("</report>\n"); 169 170 } … … 171 172 172 173 pcut_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 179 177 };
Note:
See TracChangeset
for help on using the changeset viewer.