Changeset 1433ecda in mainline for uspace/lib/pcut/src
- Timestamp:
- 2018-04-04T15:42:37Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2c4e1cc
- Parents:
- 47b2d7e3
- Location:
- uspace/lib/pcut/src
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/pcut/src/assert.c
r47b2d7e3 r1433ecda 59 59 static int message_buffer_index = 0; 60 60 61 void pcut_failed_assertion_fmt(const char *filename, int line, const char *fmt, ...) { 61 void pcut_failed_assertion_fmt(const char *filename, int line, const char *fmt, ...) 62 { 62 63 va_list args; 63 64 char *current_buffer = message_buffer[message_buffer_index]; -
uspace/lib/pcut/src/list.c
r47b2d7e3 r1433ecda 43 43 * @return First item with actual content or NULL on end of list. 44 44 */ 45 pcut_item_t *pcut_get_real_next(pcut_item_t *item) { 45 pcut_item_t *pcut_get_real_next(pcut_item_t *item) 46 { 46 47 if (item == NULL) { 47 48 return NULL; … … 64 65 * @return First item with actual content or NULL on end of list. 65 66 */ 66 pcut_item_t *pcut_get_real(pcut_item_t *item) { 67 pcut_item_t *pcut_get_real(pcut_item_t *item) 68 { 67 69 if (item == NULL) { 68 70 return NULL; … … 81 83 * @param nested Head of the nested list. 82 84 */ 83 static void inline_nested_lists(pcut_item_t *nested) { 85 static void inline_nested_lists(pcut_item_t *nested) 86 { 84 87 pcut_item_t *first; 85 88 … … 108 111 * @param first List head. 109 112 */ 110 static void set_ids(pcut_item_t *first) { 113 static void set_ids(pcut_item_t *first) 114 { 111 115 int id = 1; 112 116 pcut_item_t *it; … … 131 135 * @param first Head of the list. 132 136 */ 133 static void detect_skipped_tests(pcut_item_t *first) { 137 static void detect_skipped_tests(pcut_item_t *first) 138 { 134 139 pcut_item_t *it; 135 140 … … 167 172 * @return Head of the fixed list. 168 173 */ 169 pcut_item_t *pcut_fix_list_get_real_head(pcut_item_t *last) { 174 pcut_item_t *pcut_fix_list_get_real_head(pcut_item_t *last) 175 { 170 176 pcut_item_t *next, *it; 171 177 … … 195 201 * @return Number of tests. 196 202 */ 197 int pcut_count_tests(pcut_item_t *it) { 203 int pcut_count_tests(pcut_item_t *it) 204 { 198 205 int count = 0; 199 206 while (it != NULL) { -
uspace/lib/pcut/src/main.c
r47b2d7e3 r1433ecda 57 57 * @return Whether @p arg is @p opt followed by a number. 58 58 */ 59 int pcut_is_arg_with_number(const char *arg, const char *opt, int *value) { 59 int pcut_is_arg_with_number(const char *arg, const char *opt, int *value) 60 { 60 61 int opt_len = pcut_str_size(opt); 61 if (! 62 if (!pcut_str_start_equals(arg, opt, opt_len)) { 62 63 return 0; 63 64 } … … 74 75 * @retval NULL No item with such id exists in the list. 75 76 */ 76 static pcut_item_t *pcut_find_by_id(pcut_item_t *first, int id) { 77 static pcut_item_t *pcut_find_by_id(pcut_item_t *first, int id) 78 { 77 79 pcut_item_t *it = pcut_get_real(first); 78 80 while (it != NULL) { … … 92 94 * @return Error code. 93 95 */ 94 static int run_suite(pcut_item_t *suite, pcut_item_t **last, const char *prog_path) { 96 static int run_suite(pcut_item_t *suite, pcut_item_t **last, const char *prog_path) 97 { 95 98 int is_first_test = 1; 96 99 int total_count = 0; … … 156 159 * @param first First item of the list. 157 160 */ 158 static void set_setup_teardown_callbacks(pcut_item_t *first) { 161 static void set_setup_teardown_callbacks(pcut_item_t *first) 162 { 159 163 pcut_item_t *active_suite = NULL; 160 164 pcut_item_t *it; … … 188 192 * @return Program exit code. 189 193 */ 190 int pcut_main(pcut_item_t *last, int argc, char *argv[]) { 194 int pcut_main(pcut_item_t *last, int argc, char *argv[]) 195 { 191 196 pcut_item_t *items = pcut_fix_list_get_real_head(last); 192 197 pcut_item_t *it; -
uspace/lib/pcut/src/os/generic.c
r47b2d7e3 r1433ecda 81 81 * @param test Test that is about to start. 82 82 */ 83 static void before_test_start(pcut_item_t *test) { 83 static void before_test_start(pcut_item_t *test) 84 { 84 85 pcut_report_test_start(test); 85 86 … … 93 94 * @return Test outcome code. 94 95 */ 95 static int convert_wait_status_to_outcome(int status) { 96 static int convert_wait_status_to_outcome(int status) 97 { 96 98 if (status < 0) { 97 99 return PCUT_OUTCOME_INTERNAL_ERROR; … … 108 110 * @param test Test to be run. 109 111 */ 110 int pcut_run_test_forking(const char *self_path, pcut_item_t *test) { 112 int pcut_run_test_forking(const char *self_path, pcut_item_t *test) 113 { 111 114 int rc, outcome; 112 115 FILE *tempfile; … … 118 121 FORMAT_TEMP_FILENAME(tempfile_name, PCUT_TEMP_FILENAME_BUFFER_SIZE - 1); 119 122 FORMAT_COMMAND(command, PCUT_COMMAND_LINE_BUFFER_SIZE - 1, 120 123 self_path, (test)->id, tempfile_name); 121 124 122 125 PCUT_DEBUG("Will execute <%s> (temp file <%s>) with system().", 123 126 command, tempfile_name); 124 127 125 128 rc = system(command); … … 144 147 } 145 148 146 void pcut_hook_before_test(pcut_item_t *test) { 149 void pcut_hook_before_test(pcut_item_t *test) 150 { 147 151 PCUT_UNUSED(test); 148 152 -
uspace/lib/pcut/src/os/stdc.c
r47b2d7e3 r1433ecda 35 35 #include "../internal.h" 36 36 37 int pcut_str_equals(const char *a, const char *b) { 37 int pcut_str_equals(const char *a, const char *b) 38 { 38 39 return strcmp(a, b) == 0; 39 40 } 40 41 41 int pcut_str_start_equals(const char *a, const char *b, int len) { 42 int pcut_str_start_equals(const char *a, const char *b, int len) 43 { 42 44 return strncmp(a, b, len) == 0; 43 45 } 44 46 45 int pcut_str_size(const char *s) { 47 int pcut_str_size(const char *s) 48 { 46 49 return strlen(s); 47 50 } 48 51 49 int pcut_str_to_int(const char *s) { 52 int pcut_str_to_int(const char *s) 53 { 50 54 return atoi(s); 51 55 } 52 56 53 char *pcut_str_find_char(const char *haystack, const char needle) { 57 char *pcut_str_find_char(const char *haystack, const char needle) 58 { 54 59 return strchr(haystack, needle); 55 60 } 56 61 57 void pcut_str_error(int error, char *buffer, int size) { 62 void pcut_str_error(int error, char *buffer, int size) 63 { 58 64 const char *str = strerror(error); 59 65 if (str == NULL) { -
uspace/lib/pcut/src/os/unix.c
r47b2d7e3 r1433ecda 64 64 * @param test Test that is about to be run. 65 65 */ 66 static void before_test_start(pcut_item_t *test) { 66 static void before_test_start(pcut_item_t *test) 67 { 67 68 pcut_report_test_start(test); 68 69 … … 78 79 * @param sig Signal number. 79 80 */ 80 static void kill_child_on_alarm(int sig) { 81 static void kill_child_on_alarm(int sig) 82 { 81 83 PCUT_UNUSED(sig); 82 84 kill(child_pid, SIGKILL); … … 94 96 * @return Number of actually read bytes. 95 97 */ 96 static size_t read_all(int fd, char *buffer, size_t buffer_size) { 98 static size_t read_all(int fd, char *buffer, size_t buffer_size) 99 { 97 100 ssize_t actually_read; 98 101 char *buffer_start = buffer; … … 121 124 * @return Test outcome code. 122 125 */ 123 static int convert_wait_status_to_outcome(int status) { 126 static int convert_wait_status_to_outcome(int status) 127 { 124 128 if (WIFEXITED(status)) { 125 129 if (WEXITSTATUS(status) != 0) { … … 142 146 * @param test Test to be run. 143 147 */ 144 int pcut_run_test_forking(const char *self_path, pcut_item_t *test) { 148 int pcut_run_test_forking(const char *self_path, pcut_item_t *test) 149 { 145 150 int link_stdout[2], link_stderr[2]; 146 151 int rc, status, outcome; … … 155 160 if (rc == -1) { 156 161 snprintf(error_message_buffer, OUTPUT_BUFFER_SIZE - 1, 157 162 "pipe() failed: %s.", strerror(rc)); 158 163 pcut_report_test_done(test, PCUT_OUTCOME_INTERNAL_ERROR, error_message_buffer, NULL, NULL); 159 164 return PCUT_OUTCOME_INTERNAL_ERROR; … … 162 167 if (rc == -1) { 163 168 snprintf(error_message_buffer, OUTPUT_BUFFER_SIZE - 1, 164 169 "pipe() failed: %s.", strerror(rc)); 165 170 pcut_report_test_done(test, PCUT_OUTCOME_INTERNAL_ERROR, error_message_buffer, NULL, NULL); 166 171 return PCUT_OUTCOME_INTERNAL_ERROR; … … 170 175 if (child_pid == (pid_t)-1) { 171 176 snprintf(error_message_buffer, OUTPUT_BUFFER_SIZE - 1, 172 177 "fork() failed: %s.", strerror(rc)); 173 178 outcome = PCUT_OUTCOME_INTERNAL_ERROR; 174 179 goto leave_close_pipes; … … 215 220 } 216 221 217 void pcut_hook_before_test(pcut_item_t *test) { 222 void pcut_hook_before_test(pcut_item_t *test) 223 { 218 224 PCUT_UNUSED(test); 219 225 -
uspace/lib/pcut/src/os/windows.c
r47b2d7e3 r1433ecda 61 61 * @param test Test that is about to be run. 62 62 */ 63 static void before_test_start(pcut_item_t *test) { 63 static void before_test_start(pcut_item_t *test) 64 { 64 65 pcut_report_test_start(test); 65 66 … … 73 74 * @param failed_function_name Name of the failed function. 74 75 */ 75 static void report_func_fail(pcut_item_t *test, const char *failed_function_name) { 76 static void report_func_fail(pcut_item_t *test, const char *failed_function_name) 77 { 76 78 /* TODO: get error description. */ 77 79 sprintf_s(error_message_buffer, OUTPUT_BUFFER_SIZE - 1, 78 80 "%s failed: %s.", failed_function_name, "unknown reason"); 79 81 pcut_report_test_done(test, TEST_OUTCOME_ERROR, error_message_buffer, NULL, NULL); 80 82 } … … 91 93 * @return Number of actually read bytes. 92 94 */ 93 static size_t read_all(HANDLE fd, char *buffer, size_t buffer_size) { 95 static size_t read_all(HANDLE fd, char *buffer, size_t buffer_size) 96 { 94 97 DWORD actually_read; 95 98 char *buffer_start = buffer; … … 125 128 }; 126 129 127 static DWORD WINAPI read_test_output_on_background(LPVOID test_output_data_ptr) { 130 static DWORD WINAPI read_test_output_on_background(LPVOID test_output_data_ptr) 131 { 128 132 size_t stderr_size = 0; 129 133 struct test_output_data *test_output_data = (struct test_output_data *) test_output_data_ptr; 130 134 131 135 stderr_size = read_all(test_output_data->pipe_stderr, 132 133 136 test_output_data->output_buffer, 137 test_output_data->output_buffer_size - 1); 134 138 read_all(test_output_data->pipe_stdout, 135 136 139 test_output_data->output_buffer, 140 test_output_data->output_buffer_size - 1 - stderr_size); 137 141 138 142 return 0; … … 144 148 * @param test Test to be run. 145 149 */ 146 int pcut_run_test_forking(const char *self_path, pcut_item_t *test) { 150 int pcut_run_test_forking(const char *self_path, pcut_item_t *test) 151 { 147 152 /* TODO: clean-up if something goes wrong "in the middle" */ 148 153 BOOL okay = FALSE; … … 216 221 /* Format the command line. */ 217 222 sprintf_s(command, PCUT_COMMAND_LINE_BUFFER_SIZE - 1, 218 223 "\"%s\" -t%d", self_path, test->id); 219 224 220 225 /* Run the process. */ 221 226 okay = CreateProcess(NULL, command, NULL, NULL, TRUE, 0, NULL, NULL, 222 227 &start_info, &process_info); 223 228 224 229 if (!okay) { … … 262 267 263 268 test_output_thread_reader = CreateThread(NULL, 0, 264 265 269 read_test_output_on_background, &test_output_data, 270 0, NULL); 266 271 267 272 if (test_output_thread_reader == NULL) { … … 317 322 } 318 323 319 void pcut_hook_before_test(pcut_item_t *test) { 324 void pcut_hook_before_test(pcut_item_t *test) 325 { 320 326 PCUT_UNUSED(test); 321 327 -
uspace/lib/pcut/src/preproc.c
r47b2d7e3 r1433ecda 36 36 static int counter = 0; 37 37 38 static void print_numbered_identifier(int value, FILE *output) { 38 static void print_numbered_identifier(int value, FILE *output) 39 { 39 40 fprintf(output, "pcut_item_%d", value); 40 41 } 41 42 42 static void print_numbered_identifier2(int value, FILE *output) { 43 static void print_numbered_identifier2(int value, FILE *output) 44 { 43 45 fprintf(output, "pcut_item2_%d", value); 44 46 } 45 47 46 static void print_numbered_identifier3(int value, FILE *output) { 48 static void print_numbered_identifier3(int value, FILE *output) 49 { 47 50 fprintf(output, "pcut_item3_%d", value); 48 51 } … … 53 56 } identifier_t; 54 57 55 static void identifier_init(identifier_t *identifier) { 58 static void identifier_init(identifier_t *identifier) 59 { 56 60 identifier->name[0] = 0; 57 61 identifier->length = 0; 58 62 } 59 63 60 static void identifier_add_char(identifier_t *identifier, char c) { 64 static void identifier_add_char(identifier_t *identifier, char c) 65 { 61 66 if (identifier->length + 1 >= MAX_IDENTIFIER_LENGTH) { 62 67 fprintf(stderr, "Identifier %s is too long, aborting!\n", identifier->name); … … 69 74 } 70 75 71 static void identifier_print_or_expand(identifier_t *identifier, FILE *output) { 76 static void identifier_print_or_expand(identifier_t *identifier, FILE *output) 77 { 72 78 const char *name = identifier->name; 73 79 if (strcmp(name, "PCUT_ITEM_NAME") == 0) { … … 86 92 } 87 93 88 static int is_identifier_char(int c, int inside_identifier) {89 return isalpha(c) || (c == '_') 90 94 static int is_identifier_char(int c, int inside_identifier) 95 { 96 return isalpha(c) || (c == '_') || (inside_identifier && isdigit(c)); 91 97 } 92 98 93 int main(int argc, char *argv[]) { 99 int main(int argc, char *argv[]) 100 { 94 101 FILE *input = stdin; 95 102 FILE *output = stdout; -
uspace/lib/pcut/src/print.c
r47b2d7e3 r1433ecda 42 42 * @param first First item to be printed. 43 43 */ 44 void pcut_print_items(pcut_item_t *first) { 44 void pcut_print_items(pcut_item_t *first) 45 { 45 46 pcut_item_t *it = first; 46 47 printf("====>\n"); … … 71 72 * @param first First item to be printed. 72 73 */ 73 void pcut_print_tests(pcut_item_t *first) { 74 void pcut_print_tests(pcut_item_t *first) 75 { 74 76 pcut_item_t *it; 75 77 for (it = pcut_get_real(first); it != NULL; it = pcut_get_real_next(it)) { -
uspace/lib/pcut/src/report/report.c
r47b2d7e3 r1433ecda 67 67 * @param msg The message to be printed. 68 68 */ 69 void pcut_print_fail_message(const char *msg) { 69 void pcut_print_fail_message(const char *msg) 70 { 70 71 if (msg == NULL) { 71 72 return; … … 97 98 */ 98 99 static void parse_command_output(const char *full_output, size_t full_output_size, 99 char *stdio_buffer, size_t stdio_buffer_size, 100 char *error_buffer, size_t error_buffer_size) { 100 char *stdio_buffer, size_t stdio_buffer_size, 101 char *error_buffer, size_t error_buffer_size) 102 { 101 103 memset(stdio_buffer, 0, stdio_buffer_size); 102 104 memset(error_buffer, 0, error_buffer_size); … … 154 156 * @param ops Functions to use. 155 157 */ 156 void pcut_report_register_handler(pcut_report_ops_t *ops) { 158 void pcut_report_register_handler(pcut_report_ops_t *ops) 159 { 157 160 report_ops = ops; 158 161 } … … 162 165 * @param all_items List of all tests that could be run. 163 166 */ 164 void pcut_report_init(pcut_item_t *all_items) { 167 void pcut_report_init(pcut_item_t *all_items) 168 { 165 169 REPORT_CALL(init, all_items); 166 170 } … … 170 174 * @param suite Suite that was just started. 171 175 */ 172 void pcut_report_suite_start(pcut_item_t *suite) { 176 void pcut_report_suite_start(pcut_item_t *suite) 177 { 173 178 REPORT_CALL(suite_start, suite); 174 179 } … … 178 183 * @param suite Suite that just completed. 179 184 */ 180 void pcut_report_suite_done(pcut_item_t *suite) { 185 void pcut_report_suite_done(pcut_item_t *suite) 186 { 181 187 REPORT_CALL(suite_done, suite); 182 188 } … … 186 192 * @param test Test to be run just about now. 187 193 */ 188 void pcut_report_test_start(pcut_item_t *test) { 194 void pcut_report_test_start(pcut_item_t *test) 195 { 189 196 REPORT_CALL(test_start, test); 190 197 } … … 199 206 */ 200 207 void pcut_report_test_done(pcut_item_t *test, int outcome, 201 const char *error_message, const char *teardown_error_message, 202 const char *extra_output) { 208 const char *error_message, const char *teardown_error_message, 209 const char *extra_output) 210 { 203 211 REPORT_CALL(test_done, test, outcome, error_message, teardown_error_message, 204 212 extra_output); 205 213 } 206 214 … … 213 221 */ 214 222 void pcut_report_test_done_unparsed(pcut_item_t *test, int outcome, 215 const char *unparsed_output, size_t unparsed_output_size) { 223 const char *unparsed_output, size_t unparsed_output_size) 224 { 216 225 217 226 parse_command_output(unparsed_output, unparsed_output_size, 218 219 227 buffer_for_extra_output, BUFFER_SIZE, 228 buffer_for_error_messages, BUFFER_SIZE); 220 229 221 230 pcut_report_test_done(test, outcome, buffer_for_error_messages, NULL, buffer_for_extra_output); … … 225 234 * 226 235 */ 227 void pcut_report_done(void) { 236 void pcut_report_done(void) 237 { 228 238 REPORT_CALL_NO_ARGS(done); 229 239 } -
uspace/lib/pcut/src/report/tap.c
r47b2d7e3 r1433ecda 55 55 * @param all_items Start of the list with all items. 56 56 */ 57 static void tap_init(pcut_item_t *all_items) { 57 static void tap_init(pcut_item_t *all_items) 58 { 58 59 int tests_total = pcut_count_tests(all_items); 59 60 test_counter = 0; … … 67 68 * @param suite Suite that just started. 68 69 */ 69 static void tap_suite_start(pcut_item_t *suite) { 70 static void tap_suite_start(pcut_item_t *suite) 71 { 70 72 tests_in_suite = 0; 71 73 failed_tests_in_suite = 0; … … 78 80 * @param suite Suite that just ended. 79 81 */ 80 static void tap_suite_done(pcut_item_t *suite) { 82 static void tap_suite_done(pcut_item_t *suite) 83 { 81 84 if (failed_tests_in_suite == 0) { 82 85 printf("#> Finished suite %s (passed).\n", 83 86 suite->name); 84 87 } else { 85 88 printf("#> Finished suite %s (failed %d of %d).\n", 86 89 suite->name, failed_tests_in_suite, tests_in_suite); 87 90 } 88 91 } … … 94 97 * @param test Test that is started. 95 98 */ 96 static void tap_test_start(pcut_item_t *test) { 99 static void tap_test_start(pcut_item_t *test) 100 { 97 101 PCUT_UNUSED(test); 98 102 … … 106 110 * @param prefix Prefix for each new line, such as comment character. 107 111 */ 108 static void print_by_lines(const char *message, const char *prefix) { 112 static void print_by_lines(const char *message, const char *prefix) 113 { 109 114 char *next_line_start; 110 115 if ((message == NULL) || (message[0] == 0)) { … … 132 137 */ 133 138 static void tap_test_done(pcut_item_t *test, int outcome, 134 const char *error_message, const char *teardown_error_message, 135 const char *extra_output) { 139 const char *error_message, const char *teardown_error_message, 140 const char *extra_output) 141 { 136 142 const char *test_name = test->name; 137 143 const char *status_str = NULL; … … 166 172 167 173 /** Report testing done. */ 168 static void tap_done(void) { 174 static void tap_done(void) 175 { 169 176 if (failed_test_counter == 0) { 170 177 printf("#> Done: all tests passed.\n"); -
uspace/lib/pcut/src/report/xml.c
r47b2d7e3 r1433ecda 52 52 * @param all_items Start of the list with all items. 53 53 */ 54 static void xml_init(pcut_item_t *all_items) { 54 static void xml_init(pcut_item_t *all_items) 55 { 55 56 int tests_total = pcut_count_tests(all_items); 56 57 test_counter = 0; … … 64 65 * @param suite Suite that just started. 65 66 */ 66 static void xml_suite_start(pcut_item_t *suite) { 67 static void xml_suite_start(pcut_item_t *suite) 68 { 67 69 tests_in_suite = 0; 68 70 failed_tests_in_suite = 0; … … 75 77 * @param suite Suite that just ended. 76 78 */ 77 static void xml_suite_done(pcut_item_t *suite) { 79 static void xml_suite_done(pcut_item_t *suite) 80 { 78 81 printf("\t</suite><!-- %s: %d / %d -->\n", suite->name, 79 82 failed_tests_in_suite, tests_in_suite); 80 83 } 81 84 … … 86 89 * @param test Test that is started. 87 90 */ 88 static void xml_test_start(pcut_item_t *test) { 91 static void xml_test_start(pcut_item_t *test) 92 { 89 93 PCUT_UNUSED(test); 90 94 … … 98 102 * @param element_name Wrapping XML element name. 99 103 */ 100 static void print_by_lines(const char *message, const char *element_name) { 104 static void print_by_lines(const char *message, const char *element_name) 105 { 101 106 char *next_line_start; 102 107 … … 130 135 */ 131 136 static void xml_test_done(pcut_item_t *test, int outcome, 132 const char *error_message, const char *teardown_error_message, 133 const char *extra_output) { 137 const char *error_message, const char *teardown_error_message, 138 const char *extra_output) 139 { 134 140 const char *test_name = test->name; 135 141 const char *status_str = NULL; … … 152 158 153 159 printf("\t\t<testcase name=\"%s\" status=\"%s\">\n", test_name, 154 160 status_str); 155 161 156 162 print_by_lines(error_message, "error-message"); … … 163 169 164 170 /** Report testing done. */ 165 static void xml_done(void) { 171 static void xml_done(void) 172 { 166 173 printf("</report>\n"); 167 174 } -
uspace/lib/pcut/src/run.c
r47b2d7e3 r1433ecda 73 73 static int default_suite_initialized = 0; 74 74 75 static void init_default_suite_when_needed() { 75 static void init_default_suite_when_needed() 76 { 76 77 if (default_suite_initialized) { 77 78 return; … … 91 92 * @return Always a valid test suite item. 92 93 */ 93 static pcut_item_t *pcut_find_parent_suite(pcut_item_t *it) { 94 static pcut_item_t *pcut_find_parent_suite(pcut_item_t *it) 95 { 94 96 while (it != NULL) { 95 97 if (it->kind == PCUT_KIND_TESTSUITE) { … … 106 108 * @param func Function to run (can be NULL). 107 109 */ 108 static void run_setup_teardown(pcut_setup_func_t func) { 110 static void run_setup_teardown(pcut_setup_func_t func) 111 { 109 112 if (func != NULL) { 110 113 func(); … … 119 122 * @param outcome Outcome of the current test. 120 123 */ 121 static void leave_test(int outcome) { 124 static void leave_test(int outcome) 125 { 122 126 PCUT_DEBUG("leave_test(outcome=%d), will_exit=%s", outcome, 123 127 leave_means_exit ? "yes" : "no"); 124 128 if (leave_means_exit) { 125 129 exit(outcome); … … 138 142 * @param message Message describing the failure. 139 143 */ 140 void pcut_failed_assertion(const char *message) { 144 void pcut_failed_assertion(const char *message) 145 { 141 146 static const char *prev_message = NULL; 142 147 /* … … 157 162 if (report_test_result) { 158 163 pcut_report_test_done(current_test, PCUT_OUTCOME_FAIL, 159 164 message, NULL, NULL); 160 165 } 161 166 } else { 162 167 if (report_test_result) { 163 168 pcut_report_test_done(current_test, PCUT_OUTCOME_FAIL, 164 169 prev_message, message, NULL); 165 170 } 166 171 } … … 176 181 * @return Error status (zero means success). 177 182 */ 178 static int run_test(pcut_item_t *test) { 183 static int run_test(pcut_item_t *test) 184 { 179 185 /* 180 186 * Set here as the returning point in case of test failure. … … 228 234 if (report_test_result) { 229 235 pcut_report_test_done(current_test, PCUT_OUTCOME_PASS, 230 236 NULL, NULL, NULL); 231 237 } 232 238 … … 242 248 * @return Error status (zero means success). 243 249 */ 244 int pcut_run_test_forked(pcut_item_t *test) { 250 int pcut_run_test_forked(pcut_item_t *test) 251 { 245 252 int rc; 246 253 … … 265 272 * @return Error status (zero means success). 266 273 */ 267 int pcut_run_test_single(pcut_item_t *test) { 274 int pcut_run_test_single(pcut_item_t *test) 275 { 268 276 int rc; 269 277 … … 285 293 * @return Timeout in seconds. 286 294 */ 287 int pcut_get_test_timeout(pcut_item_t *test) { 295 int pcut_get_test_timeout(pcut_item_t *test) 296 { 288 297 int timeout = PCUT_DEFAULT_TEST_TIMEOUT; 289 298 pcut_extra_t *extras = test->extras;
Note:
See TracChangeset
for help on using the changeset viewer.