Changeset 4b54bd9 in mainline for uspace/lib/pcut/src/report
- Timestamp:
- 2018-09-12T13:23:03Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3da0ee4
- Parents:
- 275530a4
- Location:
- uspace/lib/pcut/src/report
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/pcut/src/report/report.c
r275530a4 r4b54bd9 33 33 34 34 #include "../internal.h" 35 35 36 #ifdef __helenos__ 36 #include < str.h>37 #include <mem.h> 37 38 #else 39 #pragma warning(push, 0) 38 40 #include <string.h> 41 #pragma warning(pop) 39 42 #endif 40 #include <stdbool.h> 43 44 #pragma warning(push, 0) 41 45 #include <stdio.h> 46 #pragma warning(pop) 47 42 48 43 49 /** Currently used report ops. */ … … 68 74 * @param msg The message to be printed. 69 75 */ 70 void pcut_print_fail_message(const char *msg) 71 { 76 void pcut_print_fail_message(const char *msg) { 72 77 if (msg == NULL) { 73 78 return; … … 99 104 */ 100 105 static void parse_command_output(const char *full_output, size_t full_output_size, 101 char *stdio_buffer, size_t stdio_buffer_size, 102 char *error_buffer, size_t error_buffer_size) 103 { 106 char *stdio_buffer, size_t stdio_buffer_size, 107 char *error_buffer, size_t error_buffer_size) { 104 108 memset(stdio_buffer, 0, stdio_buffer_size); 105 109 memset(error_buffer, 0, error_buffer_size); … … 111 115 } 112 116 113 while ( true) {117 while (1) { 114 118 size_t message_length; 115 119 … … 157 161 * @param ops Functions to use. 158 162 */ 159 void pcut_report_register_handler(pcut_report_ops_t *ops) 160 { 163 void pcut_report_register_handler(pcut_report_ops_t *ops) { 161 164 report_ops = ops; 162 165 } … … 166 169 * @param all_items List of all tests that could be run. 167 170 */ 168 void pcut_report_init(pcut_item_t *all_items) 169 { 171 void pcut_report_init(pcut_item_t *all_items) { 170 172 REPORT_CALL(init, all_items); 171 173 } … … 175 177 * @param suite Suite that was just started. 176 178 */ 177 void pcut_report_suite_start(pcut_item_t *suite) 178 { 179 void pcut_report_suite_start(pcut_item_t *suite) { 179 180 REPORT_CALL(suite_start, suite); 180 181 } … … 184 185 * @param suite Suite that just completed. 185 186 */ 186 void pcut_report_suite_done(pcut_item_t *suite) 187 { 187 void pcut_report_suite_done(pcut_item_t *suite) { 188 188 REPORT_CALL(suite_done, suite); 189 189 } … … 193 193 * @param test Test to be run just about now. 194 194 */ 195 void pcut_report_test_start(pcut_item_t *test) 196 { 195 void pcut_report_test_start(pcut_item_t *test) { 197 196 REPORT_CALL(test_start, test); 198 197 } … … 207 206 */ 208 207 void pcut_report_test_done(pcut_item_t *test, int outcome, 209 const char *error_message, const char *teardown_error_message, 210 const char *extra_output) 211 { 208 const char *error_message, const char *teardown_error_message, 209 const char *extra_output) { 212 210 REPORT_CALL(test_done, test, outcome, error_message, teardown_error_message, 213 211 extra_output); 214 212 } 215 213 … … 222 220 */ 223 221 void pcut_report_test_done_unparsed(pcut_item_t *test, int outcome, 224 const char *unparsed_output, size_t unparsed_output_size) 225 { 222 const char *unparsed_output, size_t unparsed_output_size) { 226 223 227 224 parse_command_output(unparsed_output, unparsed_output_size, 228 229 225 buffer_for_extra_output, BUFFER_SIZE, 226 buffer_for_error_messages, BUFFER_SIZE); 230 227 231 228 pcut_report_test_done(test, outcome, buffer_for_error_messages, NULL, buffer_for_extra_output); … … 235 232 * 236 233 */ 237 void pcut_report_done(void) 238 { 234 void pcut_report_done(void) { 239 235 REPORT_CALL_NO_ARGS(done); 240 236 } -
uspace/lib/pcut/src/report/tap.c
r275530a4 r4b54bd9 34 34 #include "../internal.h" 35 35 #include "report.h" 36 36 37 #ifndef __helenos__ 38 #pragma warning(push, 0) 37 39 #include <string.h> 40 #pragma warning(pop) 38 41 #endif 42 43 #pragma warning(push, 0) 39 44 #include <stdio.h> 45 #pragma warning(pop) 46 40 47 41 48 /** Counter of all run tests. */ … … 55 62 * @param all_items Start of the list with all items. 56 63 */ 57 static void tap_init(pcut_item_t *all_items) 58 { 64 static void tap_init(pcut_item_t *all_items) { 59 65 int tests_total = pcut_count_tests(all_items); 60 66 test_counter = 0; … … 68 74 * @param suite Suite that just started. 69 75 */ 70 static void tap_suite_start(pcut_item_t *suite) 71 { 76 static void tap_suite_start(pcut_item_t *suite) { 72 77 tests_in_suite = 0; 73 78 failed_tests_in_suite = 0; … … 80 85 * @param suite Suite that just ended. 81 86 */ 82 static void tap_suite_done(pcut_item_t *suite) 83 { 87 static void tap_suite_done(pcut_item_t *suite) { 84 88 if (failed_tests_in_suite == 0) { 85 89 printf("#> Finished suite %s (passed).\n", 86 90 suite->name); 87 91 } else { 88 92 printf("#> Finished suite %s (failed %d of %d).\n", 89 93 suite->name, failed_tests_in_suite, tests_in_suite); 90 94 } 91 95 } … … 97 101 * @param test Test that is started. 98 102 */ 99 static void tap_test_start(pcut_item_t *test) 100 { 103 static void tap_test_start(pcut_item_t *test) { 101 104 PCUT_UNUSED(test); 102 105 … … 110 113 * @param prefix Prefix for each new line, such as comment character. 111 114 */ 112 static void print_by_lines(const char *message, const char *prefix) 113 { 115 static void print_by_lines(const char *message, const char *prefix) { 114 116 char *next_line_start; 115 117 if ((message == NULL) || (message[0] == 0)) { … … 137 139 */ 138 140 static void tap_test_done(pcut_item_t *test, int outcome, 139 const char *error_message, const char *teardown_error_message, 140 const char *extra_output) 141 { 141 const char *error_message, const char *teardown_error_message, 142 const char *extra_output) { 142 143 const char *test_name = test->name; 143 144 const char *status_str = NULL; … … 172 173 173 174 /** Report testing done. */ 174 static void tap_done(void) 175 { 175 static void tap_done(void) { 176 176 if (failed_test_counter == 0) { 177 177 printf("#> Done: all tests passed.\n"); -
uspace/lib/pcut/src/report/xml.c
r275530a4 r4b54bd9 34 34 #include "../internal.h" 35 35 #include "report.h" 36 36 37 #ifndef __helenos__ 38 #pragma warning(push, 0) 37 39 #include <string.h> 40 #pragma warning(pop) 38 41 #endif 42 43 #pragma warning(push, 0) 39 44 #include <stdio.h> 45 #pragma warning(pop) 46 40 47 41 48 /** Counter of all run tests. */ … … 52 59 * @param all_items Start of the list with all items. 53 60 */ 54 static void xml_init(pcut_item_t *all_items) 55 { 61 static void xml_init(pcut_item_t *all_items) { 56 62 int tests_total = pcut_count_tests(all_items); 57 63 test_counter = 0; … … 65 71 * @param suite Suite that just started. 66 72 */ 67 static void xml_suite_start(pcut_item_t *suite) 68 { 73 static void xml_suite_start(pcut_item_t *suite) { 69 74 tests_in_suite = 0; 70 75 failed_tests_in_suite = 0; … … 77 82 * @param suite Suite that just ended. 78 83 */ 79 static void xml_suite_done(pcut_item_t *suite) 80 { 84 static void xml_suite_done(pcut_item_t *suite) { 81 85 printf("\t</suite><!-- %s: %d / %d -->\n", suite->name, 82 86 failed_tests_in_suite, tests_in_suite); 83 87 } 84 88 … … 89 93 * @param test Test that is started. 90 94 */ 91 static void xml_test_start(pcut_item_t *test) 92 { 95 static void xml_test_start(pcut_item_t *test) { 93 96 PCUT_UNUSED(test); 94 97 … … 102 105 * @param element_name Wrapping XML element name. 103 106 */ 104 static void print_by_lines(const char *message, const char *element_name) 105 { 107 static void print_by_lines(const char *message, const char *element_name) { 106 108 char *next_line_start; 107 109 … … 135 137 */ 136 138 static void xml_test_done(pcut_item_t *test, int outcome, 137 const char *error_message, const char *teardown_error_message, 138 const char *extra_output) 139 { 139 const char *error_message, const char *teardown_error_message, 140 const char *extra_output) { 140 141 const char *test_name = test->name; 141 142 const char *status_str = NULL; … … 158 159 159 160 printf("\t\t<testcase name=\"%s\" status=\"%s\">\n", test_name, 160 161 status_str); 161 162 162 163 print_by_lines(error_message, "error-message"); … … 169 170 170 171 /** Report testing done. */ 171 static void xml_done(void) 172 { 172 static void xml_done(void) { 173 173 printf("</report>\n"); 174 174 }
Note:
See TracChangeset
for help on using the changeset viewer.