Changeset 4b54bd9 in mainline
- Timestamp:
- 2018-09-12T13:23:03Z (6 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
- Files:
-
- 1 added
- 1 deleted
- 39 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/pcut/Makefile
r275530a4 r4b54bd9 23 23 $(PCUT_TEST_PREFIX)testlist$(PCUT_TEST_SUFFIX) \ 24 24 $(PCUT_TEST_PREFIX)timeout$(PCUT_TEST_SUFFIX) \ 25 $(PCUT_TEST_PREFIX)xmlreport$(PCUT_TEST_SUFFIX) 25 $(PCUT_TEST_PREFIX)xmlreport$(PCUT_TEST_SUFFIX) 26 26 27 27 EXTRA_CLEAN = $(SELF_TESTS) -
uspace/lib/pcut/helenos.mak
r275530a4 r4b54bd9 30 30 src/os/helenos.c \ 31 31 src/assert.c \ 32 src/helper.c \ 32 33 src/list.c \ 33 34 src/main.c \ … … 38 39 src/run.c 39 40 40 EXTRA_CFLAGS = -D__helenos__ 41 EXTRA_CFLAGS = -D__helenos__ -Wno-unknown-pragmas 41 42 42 43 LIBRARY = libpcut -
uspace/lib/pcut/include/pcut/asserts.h
r275530a4 r4b54bd9 77 77 * @param size Size of the buffer. 78 78 */ 79 void pcut_str_error( errno_t error, char *buffer, int size);79 void pcut_str_error(int error, char *buffer, int size); 80 80 81 81 /** Raise assertion error (internal version). … … 264 264 #define PCUT_ASSERT_ERRNO_VAL_WITH_NAME(expected_value, expected_quoted, actual_value) \ 265 265 do {\ 266 errno_t pcut_expected_eval = (expected_value); \267 errno_t pcut_actual_eval = (actual_value); \266 int pcut_expected_eval = (expected_value); \ 267 int pcut_actual_eval = (actual_value); \ 268 268 if (pcut_expected_eval != pcut_actual_eval) { \ 269 269 char pcut_expected_description[100]; \ -
uspace/lib/pcut/src/assert.c
r275530a4 r4b54bd9 43 43 44 44 #include "internal.h" 45 46 #pragma warning(push, 0) 45 47 #include <setjmp.h> 46 48 #include <stdarg.h> 47 49 #include <stdio.h> 50 #pragma warning(pop) 51 48 52 49 53 /** Maximum length of failed-assert message. */ … … 59 63 static int message_buffer_index = 0; 60 64 61 void pcut_failed_assertion_fmt(const char *filename, int line, const char *fmt, ...) 62 { 65 void pcut_failed_assertion_fmt(const char *filename, int line, const char *fmt, ...) { 63 66 va_list args; 64 67 char *current_buffer = message_buffer[message_buffer_index]; … … 66 69 message_buffer_index = (message_buffer_index + 1) % MESSAGE_BUFFER_COUNT; 67 70 68 snprintf(current_buffer, MAX_MESSAGE_LENGTH, "%s:%d: ", filename, line);71 pcut_snprintf(current_buffer, MAX_MESSAGE_LENGTH, "%s:%d: ", filename, line); 69 72 offset = pcut_str_size(current_buffer); 70 73 -
uspace/lib/pcut/src/internal.h
r275530a4 r4b54bd9 35 35 36 36 #include <pcut/pcut.h> 37 38 #pragma warning(push, 0) 37 39 #include <stdlib.h> 40 #pragma warning(pop) 38 41 39 42 … … 48 51 */ 49 52 #ifdef PCUT_DEBUG_BUILD 53 #pragma warning(push, 0) 50 54 #include <stdio.h> 55 #pragma warning(pop) 51 56 #define PCUT_DEBUG_INTERNAL(msg, ...) \ 52 57 fprintf(stderr, "[PCUT %s:%d]: " msg "%s", __FILE__, __LINE__, __VA_ARGS__) … … 78 83 */ 79 84 #define PCUT_RUN_MODE_SINGLE 2 80 81 /*82 * Use sprintf_s in Windows but only with Microsoft compiler.83 * Namely, let MinGW use snprintf.84 */85 #if (defined(__WIN64) || defined(__WIN32) || defined(_WIN32)) && defined(_MSC_VER)86 #define snprintf sprintf_s87 #endif88 85 89 86 extern int pcut_run_mode; … … 125 122 /** Test completed. */ 126 123 void (*test_done)(pcut_item_t *, int, const char *, const char *, 127 124 const char *); 128 125 }; 129 126 … … 135 132 void pcut_report_test_start(pcut_item_t *test); 136 133 void pcut_report_test_done(pcut_item_t *test, int outcome, 137 138 134 const char *error_message, const char *teardown_error_message, 135 const char *extra_output); 139 136 void pcut_report_test_done_unparsed(pcut_item_t *test, int outcome, 140 137 const char *unparsed_output, size_t unparsed_output_size); 141 138 void pcut_report_done(void); 142 139 … … 187 184 char *pcut_str_find_char(const char *haystack, const char needle); 188 185 186 /** Format string to a buffer. 187 * 188 */ 189 int pcut_snprintf(char *dest, size_t size, const char *format, ...); 189 190 190 191 #endif -
uspace/lib/pcut/src/list.c
r275530a4 r4b54bd9 32 32 */ 33 33 34 #pragma warning(push, 0) 34 35 #include <assert.h> 35 36 #include <stdlib.h> 37 #pragma warning(pop) 38 36 39 #include "internal.h" 37 40 #include <pcut/pcut.h> … … 43 46 * @return First item with actual content or NULL on end of list. 44 47 */ 45 pcut_item_t *pcut_get_real_next(pcut_item_t *item) 46 { 48 pcut_item_t *pcut_get_real_next(pcut_item_t *item) { 47 49 if (item == NULL) { 48 50 return NULL; … … 65 67 * @return First item with actual content or NULL on end of list. 66 68 */ 67 pcut_item_t *pcut_get_real(pcut_item_t *item) 68 { 69 pcut_item_t *pcut_get_real(pcut_item_t *item) { 69 70 if (item == NULL) { 70 71 return NULL; … … 83 84 * @param nested Head of the nested list. 84 85 */ 85 static void inline_nested_lists(pcut_item_t *nested) 86 { 86 static void inline_nested_lists(pcut_item_t *nested) { 87 87 pcut_item_t *first; 88 88 … … 111 111 * @param first List head. 112 112 */ 113 static void set_ids(pcut_item_t *first) 114 { 113 static void set_ids(pcut_item_t *first) { 115 114 int id = 1; 116 115 pcut_item_t *it; … … 135 134 * @param first Head of the list. 136 135 */ 137 static void detect_skipped_tests(pcut_item_t *first) 138 { 136 static void detect_skipped_tests(pcut_item_t *first) { 139 137 pcut_item_t *it; 140 138 … … 172 170 * @return Head of the fixed list. 173 171 */ 174 pcut_item_t *pcut_fix_list_get_real_head(pcut_item_t *last) 175 { 172 pcut_item_t *pcut_fix_list_get_real_head(pcut_item_t *last) { 176 173 pcut_item_t *next, *it; 177 174 … … 201 198 * @return Number of tests. 202 199 */ 203 int pcut_count_tests(pcut_item_t *it) 204 { 200 int pcut_count_tests(pcut_item_t *it) { 205 201 int count = 0; 206 202 while (it != NULL) { -
uspace/lib/pcut/src/main.c
r275530a4 r4b54bd9 34 34 #include "internal.h" 35 35 #include "report/report.h" 36 37 #pragma warning(push, 0) 36 38 #include <assert.h> 37 39 #include <stdlib.h> 38 40 #include <stdio.h> 41 #pragma warning(pop) 42 39 43 40 44 /** Current running mode. */ … … 57 61 * @return Whether @p arg is @p opt followed by a number. 58 62 */ 59 int pcut_is_arg_with_number(const char *arg, const char *opt, int *value) 60 { 63 int pcut_is_arg_with_number(const char *arg, const char *opt, int *value) { 61 64 int opt_len = pcut_str_size(opt); 62 if (! pcut_str_start_equals(arg, opt, opt_len)) {65 if (! pcut_str_start_equals(arg, opt, opt_len)) { 63 66 return 0; 64 67 } … … 75 78 * @retval NULL No item with such id exists in the list. 76 79 */ 77 static pcut_item_t *pcut_find_by_id(pcut_item_t *first, int id) 78 { 80 static pcut_item_t *pcut_find_by_id(pcut_item_t *first, int id) { 79 81 pcut_item_t *it = pcut_get_real(first); 80 82 while (it != NULL) { … … 94 96 * @return Error code. 95 97 */ 96 static int run_suite(pcut_item_t *suite, pcut_item_t **last, const char *prog_path) 97 { 98 static int run_suite(pcut_item_t *suite, pcut_item_t **last, const char *prog_path) { 98 99 int is_first_test = 1; 99 100 int total_count = 0; … … 159 160 * @param first First item of the list. 160 161 */ 161 static void set_setup_teardown_callbacks(pcut_item_t *first) 162 { 162 static void set_setup_teardown_callbacks(pcut_item_t *first) { 163 163 pcut_item_t *active_suite = NULL; 164 164 pcut_item_t *it; … … 192 192 * @return Program exit code. 193 193 */ 194 int pcut_main(pcut_item_t *last, int argc, char *argv[]) 195 { 194 int pcut_main(pcut_item_t *last, int argc, char *argv[]) { 196 195 pcut_item_t *items = pcut_fix_list_get_real_head(last); 197 196 pcut_item_t *it; -
uspace/lib/pcut/src/os/generic.c
r275530a4 r4b54bd9 31 31 * Platform-dependent test execution function when system() is available. 32 32 */ 33 33 #pragma warning(push, 0) 34 34 #include <stdlib.h> 35 35 #include <stdio.h> … … 38 38 #include <assert.h> 39 39 #include <string.h> 40 #pragma warning(pop) 41 40 42 #include "../internal.h" 41 43 … … 55 57 56 58 #define FORMAT_COMMAND(buffer, buffer_size, self_path, test_id, temp_file) \ 57 snprintf(buffer, buffer_size, "\"\"%s\" -t%d >%s\"", self_path, test_id, temp_file)59 pcut_snprintf(buffer, buffer_size, "\"\"%s\" -t%d >%s\"", self_path, test_id, temp_file) 58 60 #define FORMAT_TEMP_FILENAME(buffer, buffer_size) \ 59 snprintf(buffer, buffer_size, "pcut_%d.tmp", _getpid())61 pcut_snprintf(buffer, buffer_size, "pcut_%d.tmp", _getpid()) 60 62 61 63 #elif defined(__unix) … … 63 65 64 66 #define FORMAT_COMMAND(buffer, buffer_size, self_path, test_id, temp_file) \ 65 snprintf(buffer, buffer_size, "%s -t%d &>%s", self_path, test_id, temp_file)67 pcut_snprintf(buffer, buffer_size, "%s -t%d &>%s", self_path, test_id, temp_file) 66 68 #define FORMAT_TEMP_FILENAME(buffer, buffer_size) \ 67 snprintf(buffer, buffer_size, "pcut_%d.tmp", getpid())69 pcut_snprintf(buffer, buffer_size, "pcut_%d.tmp", getpid()) 68 70 69 71 #else … … 81 83 * @param test Test that is about to start. 82 84 */ 83 static void before_test_start(pcut_item_t *test) 84 { 85 static void before_test_start(pcut_item_t *test) { 85 86 pcut_report_test_start(test); 86 87 … … 94 95 * @return Test outcome code. 95 96 */ 96 static int convert_wait_status_to_outcome(int status) 97 { 97 static int convert_wait_status_to_outcome(int status) { 98 98 if (status < 0) { 99 99 return PCUT_OUTCOME_INTERNAL_ERROR; … … 110 110 * @param test Test to be run. 111 111 */ 112 int pcut_run_test_forking(const char *self_path, pcut_item_t *test) 113 { 112 int pcut_run_test_forking(const char *self_path, pcut_item_t *test) { 114 113 int rc, outcome; 115 114 FILE *tempfile; … … 121 120 FORMAT_TEMP_FILENAME(tempfile_name, PCUT_TEMP_FILENAME_BUFFER_SIZE - 1); 122 121 FORMAT_COMMAND(command, PCUT_COMMAND_LINE_BUFFER_SIZE - 1, 123 124 122 self_path, (test)->id, tempfile_name); 123 125 124 PCUT_DEBUG("Will execute <%s> (temp file <%s>) with system().", 126 125 command, tempfile_name); 127 126 128 127 rc = system(command); … … 147 146 } 148 147 149 void pcut_hook_before_test(pcut_item_t *test) 150 { 148 void pcut_hook_before_test(pcut_item_t *test) { 151 149 PCUT_UNUSED(test); 152 150 -
uspace/lib/pcut/src/os/helenos.c
r275530a4 r4b54bd9 46 46 /* String functions. */ 47 47 48 int pcut_str_equals(const char *a, const char *b) 49 { 48 int pcut_str_equals(const char *a, const char *b) { 50 49 return str_cmp(a, b) == 0; 51 50 } 52 51 53 52 54 int pcut_str_start_equals(const char *a, const char *b, int len) 55 { 53 int pcut_str_start_equals(const char *a, const char *b, int len) { 56 54 return str_lcmp(a, b, len) == 0; 57 55 } 58 56 59 int pcut_str_size(const char *s) 60 { 57 int pcut_str_size(const char *s) { 61 58 return str_size(s); 62 59 } 63 60 64 int pcut_str_to_int(const char *s) 65 { 61 int pcut_str_to_int(const char *s) { 66 62 int result = strtol(s, NULL, 10); 67 63 return result; 68 64 } 69 65 70 char *pcut_str_find_char(const char *haystack, const char needle) 71 { 66 char *pcut_str_find_char(const char *haystack, const char needle) { 72 67 return str_chr(haystack, needle); 73 68 } 74 69 75 void pcut_str_error(errno_t error, char *buffer, int size) 76 { 70 void pcut_str_error(int error, char *buffer, int size) { 77 71 const char *str = str_error(error); 78 72 if (str == NULL) { … … 107 101 * @param test Test that is about to be run. 108 102 */ 109 static void before_test_start(pcut_item_t *test) 110 { 103 static void before_test_start(pcut_item_t *test) { 111 104 pcut_report_test_start(test); 112 105 … … 116 109 117 110 /** Mutex guard for forced_termination_cv. */ 118 static fibril_mutex_t forced_termination_mutex =119 111 static fibril_mutex_t forced_termination_mutex 112 = FIBRIL_MUTEX_INITIALIZER(forced_termination_mutex); 120 113 121 114 /** Condition-variable for checking whether test timed-out. */ 122 static fibril_condvar_t forced_termination_cv =123 115 static fibril_condvar_t forced_termination_cv 116 = FIBRIL_CONDVAR_INITIALIZER(forced_termination_cv); 124 117 125 118 /** Spawned task id. */ … … 137 130 * @return EOK Always. 138 131 */ 139 static errno_t test_timeout_handler_fibril(void *arg) 140 { 132 static int test_timeout_handler_fibril(void *arg) { 141 133 pcut_item_t *test = arg; 142 134 int timeout_sec = pcut_get_test_timeout(test); … … 148 140 } 149 141 errno_t rc = fibril_condvar_wait_timeout(&forced_termination_cv, 150 142 &forced_termination_mutex, timeout_us); 151 143 if (rc == ETIMEOUT) { 152 144 task_kill(test_task_id); … … 162 154 * @param test Test to be run. 163 155 */ 164 int pcut_run_test_forking(const char *self_path, pcut_item_t *test) 165 { 156 int pcut_run_test_forking(const char *self_path, pcut_item_t *test) { 166 157 before_test_start(test); 167 158 … … 235 226 } 236 227 237 void pcut_hook_before_test(pcut_item_t *test) 238 { 228 void pcut_hook_before_test(pcut_item_t *test) { 239 229 PCUT_UNUSED(test); 240 230 -
uspace/lib/pcut/src/os/stdc.c
r275530a4 r4b54bd9 32 32 */ 33 33 34 #pragma warning(push, 0) 34 35 #include <string.h> 36 #pragma warning(pop) 37 35 38 #include "../internal.h" 36 39 37 int pcut_str_equals(const char *a, const char *b) 38 { 40 int pcut_str_equals(const char *a, const char *b) { 39 41 return strcmp(a, b) == 0; 40 42 } 41 43 42 int pcut_str_start_equals(const char *a, const char *b, int len) 43 { 44 int pcut_str_start_equals(const char *a, const char *b, int len) { 44 45 return strncmp(a, b, len) == 0; 45 46 } 46 47 47 int pcut_str_size(const char *s) 48 { 48 int pcut_str_size(const char *s) { 49 49 return strlen(s); 50 50 } 51 51 52 int pcut_str_to_int(const char *s) 53 { 52 int pcut_str_to_int(const char *s) { 54 53 return atoi(s); 55 54 } 56 55 57 char *pcut_str_find_char(const char *haystack, const char needle) 58 { 56 char *pcut_str_find_char(const char *haystack, const char needle) { 59 57 return strchr(haystack, needle); 60 58 } 61 59 62 void pcut_str_error(int error, char *buffer, int size) 63 { 60 void pcut_str_error(int error, char *buffer, int size) { 64 61 const char *str = strerror(error); 65 62 if (str == NULL) { -
uspace/lib/pcut/src/os/unix.c
r275530a4 r4b54bd9 64 64 * @param test Test that is about to be run. 65 65 */ 66 static void before_test_start(pcut_item_t *test) 67 { 66 static void before_test_start(pcut_item_t *test) { 68 67 pcut_report_test_start(test); 69 68 … … 79 78 * @param sig Signal number. 80 79 */ 81 static void kill_child_on_alarm(int sig) 82 { 80 static void kill_child_on_alarm(int sig) { 83 81 PCUT_UNUSED(sig); 84 82 kill(child_pid, SIGKILL); … … 96 94 * @return Number of actually read bytes. 97 95 */ 98 static size_t read_all(int fd, char *buffer, size_t buffer_size) 99 { 96 static size_t read_all(int fd, char *buffer, size_t buffer_size) { 100 97 ssize_t actually_read; 101 98 char *buffer_start = buffer; … … 124 121 * @return Test outcome code. 125 122 */ 126 static int convert_wait_status_to_outcome(int status) 127 { 123 static int convert_wait_status_to_outcome(int status) { 128 124 if (WIFEXITED(status)) { 129 125 if (WEXITSTATUS(status) != 0) { … … 146 142 * @param test Test to be run. 147 143 */ 148 int pcut_run_test_forking(const char *self_path, pcut_item_t *test) 149 { 144 int pcut_run_test_forking(const char *self_path, pcut_item_t *test) { 150 145 int link_stdout[2], link_stderr[2]; 151 146 int rc, status, outcome; … … 159 154 rc = pipe(link_stdout); 160 155 if (rc == -1) { 161 snprintf(error_message_buffer, OUTPUT_BUFFER_SIZE - 1,162 156 pcut_snprintf(error_message_buffer, OUTPUT_BUFFER_SIZE - 1, 157 "pipe() failed: %s.", strerror(rc)); 163 158 pcut_report_test_done(test, PCUT_OUTCOME_INTERNAL_ERROR, error_message_buffer, NULL, NULL); 164 159 return PCUT_OUTCOME_INTERNAL_ERROR; … … 166 161 rc = pipe(link_stderr); 167 162 if (rc == -1) { 168 snprintf(error_message_buffer, OUTPUT_BUFFER_SIZE - 1,169 163 pcut_snprintf(error_message_buffer, OUTPUT_BUFFER_SIZE - 1, 164 "pipe() failed: %s.", strerror(rc)); 170 165 pcut_report_test_done(test, PCUT_OUTCOME_INTERNAL_ERROR, error_message_buffer, NULL, NULL); 171 166 return PCUT_OUTCOME_INTERNAL_ERROR; … … 174 169 child_pid = fork(); 175 170 if (child_pid == (pid_t)-1) { 176 snprintf(error_message_buffer, OUTPUT_BUFFER_SIZE - 1,177 171 pcut_snprintf(error_message_buffer, OUTPUT_BUFFER_SIZE - 1, 172 "fork() failed: %s.", strerror(rc)); 178 173 outcome = PCUT_OUTCOME_INTERNAL_ERROR; 179 174 goto leave_close_pipes; … … 220 215 } 221 216 222 void pcut_hook_before_test(pcut_item_t *test) 223 { 217 void pcut_hook_before_test(pcut_item_t *test) { 224 218 PCUT_UNUSED(test); 225 219 -
uspace/lib/pcut/src/os/windows.c
r275530a4 r4b54bd9 39 39 #include "../internal.h" 40 40 41 #pragma warning(push, 0) 41 42 #include <windows.h> 42 43 #include <tchar.h> 43 44 #include <stdio.h> 44 45 #include <strsafe.h> 46 #pragma warning(pop) 47 45 48 46 49 … … 61 64 * @param test Test that is about to be run. 62 65 */ 63 static void before_test_start(pcut_item_t *test) 64 { 66 static void before_test_start(pcut_item_t *test) { 65 67 pcut_report_test_start(test); 66 68 … … 74 76 * @param failed_function_name Name of the failed function. 75 77 */ 76 static void report_func_fail(pcut_item_t *test, const char *failed_function_name) 77 { 78 static void report_func_fail(pcut_item_t *test, const char *failed_function_name) { 78 79 /* TODO: get error description. */ 79 sprintf_s(error_message_buffer, OUTPUT_BUFFER_SIZE - 1,80 81 pcut_report_test_done(test, TEST_OUTCOME_ERROR, error_message_buffer, NULL, NULL);80 pcut_snprintf(error_message_buffer, OUTPUT_BUFFER_SIZE - 1, 81 "%s failed: %s.", failed_function_name, "unknown reason"); 82 pcut_report_test_done(test, PCUT_OUTCOME_INTERNAL_ERROR, error_message_buffer, NULL, NULL); 82 83 } 83 84 … … 93 94 * @return Number of actually read bytes. 94 95 */ 95 static size_t read_all(HANDLE fd, char *buffer, size_t buffer_size) 96 { 96 static size_t read_all(HANDLE fd, char *buffer, size_t buffer_size) { 97 97 DWORD actually_read; 98 98 char *buffer_start = buffer; … … 128 128 }; 129 129 130 static DWORD WINAPI read_test_output_on_background(LPVOID test_output_data_ptr) 131 { 130 static DWORD WINAPI read_test_output_on_background(LPVOID test_output_data_ptr) { 132 131 size_t stderr_size = 0; 133 132 struct test_output_data *test_output_data = (struct test_output_data *) test_output_data_ptr; 134 133 135 134 stderr_size = read_all(test_output_data->pipe_stderr, 136 137 135 test_output_data->output_buffer, 136 test_output_data->output_buffer_size - 1); 138 137 read_all(test_output_data->pipe_stdout, 139 140 138 test_output_data->output_buffer, 139 test_output_data->output_buffer_size - 1 - stderr_size); 141 140 142 141 return 0; … … 148 147 * @param test Test to be run. 149 148 */ 150 int pcut_run_test_forking(const char *self_path, pcut_item_t *test) 151 { 149 int pcut_run_test_forking(const char *self_path, pcut_item_t *test) { 152 150 /* TODO: clean-up if something goes wrong "in the middle" */ 153 151 BOOL okay = FALSE; … … 220 218 221 219 /* Format the command line. */ 222 sprintf_s(command, PCUT_COMMAND_LINE_BUFFER_SIZE - 1,223 220 pcut_snprintf(command, PCUT_COMMAND_LINE_BUFFER_SIZE - 1, 221 "\"%s\" -t%d", self_path, test->id); 224 222 225 223 /* Run the process. */ 226 224 okay = CreateProcess(NULL, command, NULL, NULL, TRUE, 0, NULL, NULL, 227 225 &start_info, &process_info); 228 226 229 227 if (!okay) { … … 267 265 268 266 test_output_thread_reader = CreateThread(NULL, 0, 269 270 267 read_test_output_on_background, &test_output_data, 268 0, NULL); 271 269 272 270 if (test_output_thread_reader == NULL) { … … 286 284 if (!okay) { 287 285 report_func_fail(test, "TerminateProcess(/* PROCESS_INFORMATION.hProcess */)"); 288 return PCUT_ ERROR_INTERNAL_FAILURE;286 return PCUT_OUTCOME_INTERNAL_ERROR; 289 287 } 290 288 rc = WaitForSingleObject(process_info.hProcess, INFINITE); … … 314 312 if (rc != WAIT_OBJECT_0) { 315 313 report_func_fail(test, "WaitForSingleObject(/* stdout reader thread */)"); 316 return PCUT_ ERROR_INTERNAL_FAILURE;314 return PCUT_OUTCOME_INTERNAL_ERROR; 317 315 } 318 316 … … 322 320 } 323 321 324 void pcut_hook_before_test(pcut_item_t *test) 325 { 322 void pcut_hook_before_test(pcut_item_t *test) { 326 323 PCUT_UNUSED(test); 327 324 -
uspace/lib/pcut/src/preproc.c
r275530a4 r4b54bd9 27 27 */ 28 28 29 # include <stdbool.h>29 #pragma warning(push, 0) 30 30 #include <stdio.h> 31 31 #include <stdlib.h> 32 32 #include <ctype.h> 33 33 #include <string.h> 34 #pragma warning(pop) 35 34 36 35 37 #define MAX_IDENTIFIER_LENGTH 256 … … 37 39 static int counter = 0; 38 40 39 static void print_numbered_identifier(int value, FILE *output) 40 { 41 static void print_numbered_identifier(int value, FILE *output) { 41 42 fprintf(output, "pcut_item_%d", value); 42 43 } 43 44 44 static void print_numbered_identifier2(int value, FILE *output) 45 { 45 static void print_numbered_identifier2(int value, FILE *output) { 46 46 fprintf(output, "pcut_item2_%d", value); 47 47 } 48 48 49 static void print_numbered_identifier3(int value, FILE *output) 50 { 49 static void print_numbered_identifier3(int value, FILE *output) { 51 50 fprintf(output, "pcut_item3_%d", value); 52 51 } … … 57 56 } identifier_t; 58 57 59 static void identifier_init(identifier_t *identifier) 60 { 58 static void identifier_init(identifier_t *identifier) { 61 59 identifier->name[0] = 0; 62 60 identifier->length = 0; 63 61 } 64 62 65 static void identifier_add_char(identifier_t *identifier, char c) 66 { 63 static void identifier_add_char(identifier_t *identifier, char c) { 67 64 if (identifier->length + 1 >= MAX_IDENTIFIER_LENGTH) { 68 65 fprintf(stderr, "Identifier %s is too long, aborting!\n", identifier->name); … … 75 72 } 76 73 77 static void identifier_print_or_expand(identifier_t *identifier, FILE *output) 78 { 74 static void identifier_print_or_expand(identifier_t *identifier, FILE *output) { 79 75 const char *name = identifier->name; 80 76 if (strcmp(name, "PCUT_ITEM_NAME") == 0) { … … 93 89 } 94 90 95 static int is_identifier_char(int c, int inside_identifier) 96 { 97 return isalpha(c) || (c == '_')|| (inside_identifier && isdigit(c));91 static int is_identifier_char(int c, int inside_identifier) { 92 return isalpha(c) || (c == '_') 93 || (inside_identifier && isdigit(c)); 98 94 } 99 95 100 int main(int argc, char *argv[]) 101 { 96 int main(int argc, char *argv[]) { 102 97 FILE *input = stdin; 103 98 FILE *output = stdout; … … 110 105 (void) argv; 111 106 112 while ( true) {107 while (1) { 113 108 int current_char_denotes_identifier; 114 109 -
uspace/lib/pcut/src/print.c
r275530a4 r4b54bd9 33 33 34 34 #include <pcut/pcut.h> 35 36 #pragma warning(push, 0) 35 37 #include <stdio.h> 36 38 #include <stdlib.h> 37 39 #include <assert.h> 40 #pragma warning(pop) 41 38 42 #include "internal.h" 39 43 … … 42 46 * @param first First item to be printed. 43 47 */ 44 void pcut_print_items(pcut_item_t *first) 45 { 48 void pcut_print_items(pcut_item_t *first) { 46 49 pcut_item_t *it = first; 47 50 printf("====>\n"); … … 72 75 * @param first First item to be printed. 73 76 */ 74 void pcut_print_tests(pcut_item_t *first) 75 { 77 void pcut_print_tests(pcut_item_t *first) { 76 78 pcut_item_t *it; 77 79 for (it = pcut_get_real(first); it != NULL; it = pcut_get_real_next(it)) { -
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 } -
uspace/lib/pcut/src/run.c
r275530a4 r4b54bd9 33 33 34 34 #include "internal.h" 35 35 36 #ifndef PCUT_NO_LONG_JUMP 37 #pragma warning(push, 0) 36 38 #include <setjmp.h> 39 #pragma warning(pop) 37 40 #endif 38 41 … … 73 76 static int default_suite_initialized = 0; 74 77 75 static void init_default_suite_when_needed() 76 { 78 static void init_default_suite_when_needed() { 77 79 if (default_suite_initialized) { 78 80 return; … … 92 94 * @return Always a valid test suite item. 93 95 */ 94 static pcut_item_t *pcut_find_parent_suite(pcut_item_t *it) 95 { 96 static pcut_item_t *pcut_find_parent_suite(pcut_item_t *it) { 96 97 while (it != NULL) { 97 98 if (it->kind == PCUT_KIND_TESTSUITE) { … … 108 109 * @param func Function to run (can be NULL). 109 110 */ 110 static void run_setup_teardown(pcut_setup_func_t func) 111 { 111 static void run_setup_teardown(pcut_setup_func_t func) { 112 112 if (func != NULL) { 113 113 func(); … … 122 122 * @param outcome Outcome of the current test. 123 123 */ 124 static void leave_test(int outcome) 125 { 124 static void leave_test(int outcome) { 126 125 PCUT_DEBUG("leave_test(outcome=%d), will_exit=%s", outcome, 127 126 leave_means_exit ? "yes" : "no"); 128 127 if (leave_means_exit) { 129 128 exit(outcome); … … 142 141 * @param message Message describing the failure. 143 142 */ 144 void pcut_failed_assertion(const char *message) 145 { 143 void pcut_failed_assertion(const char *message) { 146 144 static const char *prev_message = NULL; 147 145 /* … … 162 160 if (report_test_result) { 163 161 pcut_report_test_done(current_test, PCUT_OUTCOME_FAIL, 164 162 message, NULL, NULL); 165 163 } 166 164 } else { 167 165 if (report_test_result) { 168 166 pcut_report_test_done(current_test, PCUT_OUTCOME_FAIL, 169 167 prev_message, message, NULL); 170 168 } 171 169 } … … 181 179 * @return Error status (zero means success). 182 180 */ 183 static int run_test(pcut_item_t *test) 184 { 181 static int run_test(pcut_item_t *test) { 185 182 /* 186 183 * Set here as the returning point in case of test failure. … … 234 231 if (report_test_result) { 235 232 pcut_report_test_done(current_test, PCUT_OUTCOME_PASS, 236 233 NULL, NULL, NULL); 237 234 } 238 235 … … 248 245 * @return Error status (zero means success). 249 246 */ 250 int pcut_run_test_forked(pcut_item_t *test) 251 { 247 int pcut_run_test_forked(pcut_item_t *test) { 252 248 int rc; 253 249 … … 272 268 * @return Error status (zero means success). 273 269 */ 274 int pcut_run_test_single(pcut_item_t *test) 275 { 270 int pcut_run_test_single(pcut_item_t *test) { 276 271 int rc; 277 272 … … 293 288 * @return Timeout in seconds. 294 289 */ 295 int pcut_get_test_timeout(pcut_item_t *test) 296 { 290 int pcut_get_test_timeout(pcut_item_t *test) { 297 291 int timeout = PCUT_DEFAULT_TEST_TIMEOUT; 298 292 pcut_extra_t *extras = test->extras; -
uspace/lib/pcut/tests/abort.c
r275530a4 r4b54bd9 30 30 #include <stdlib.h> 31 31 32 PCUT_INIT ;32 PCUT_INIT 33 33 34 PCUT_TEST(access_null_pointer) 35 { 34 PCUT_TEST(access_null_pointer) { 36 35 abort(); 37 36 } 38 37 39 PCUT_MAIN() ;38 PCUT_MAIN() -
uspace/lib/pcut/tests/asserts.c
r275530a4 r4b54bd9 30 30 #include "tested.h" 31 31 32 PCUT_INIT ;32 PCUT_INIT 33 33 34 PCUT_TEST(int_equals) 35 { 34 PCUT_TEST(int_equals) { 36 35 PCUT_ASSERT_INT_EQUALS(1, 1); 37 36 PCUT_ASSERT_INT_EQUALS(1, 0); 38 37 } 39 38 40 PCUT_TEST(double_equals) 41 { 39 PCUT_TEST(double_equals) { 42 40 PCUT_ASSERT_DOUBLE_EQUALS(1., 1., 0.001); 43 41 PCUT_ASSERT_DOUBLE_EQUALS(1., 0.5, 0.4); 44 42 } 45 43 46 PCUT_TEST(str_equals) 47 { 44 PCUT_TEST(str_equals) { 48 45 PCUT_ASSERT_STR_EQUALS("xyz", "xyz"); 49 46 PCUT_ASSERT_STR_EQUALS("abc", "xyz"); 50 47 } 51 48 52 PCUT_TEST(str_equals_or_null_base) 53 { 49 PCUT_TEST(str_equals_or_null_base) { 54 50 PCUT_ASSERT_STR_EQUALS_OR_NULL("xyz", "xyz"); 55 51 } 56 52 57 PCUT_TEST(str_equals_or_null_different) 58 { 53 PCUT_TEST(str_equals_or_null_different) { 59 54 PCUT_ASSERT_STR_EQUALS_OR_NULL("abc", "xyz"); 60 55 } 61 56 62 PCUT_TEST(str_equals_or_null_one_null) 63 { 57 PCUT_TEST(str_equals_or_null_one_null) { 64 58 PCUT_ASSERT_STR_EQUALS_OR_NULL(NULL, "xyz"); 65 59 } 66 60 67 PCUT_TEST(str_equals_or_null_both) 68 { 61 PCUT_TEST(str_equals_or_null_both) { 69 62 PCUT_ASSERT_STR_EQUALS_OR_NULL(NULL, NULL); 70 63 } 71 64 72 PCUT_TEST(assert_true) 73 { 65 PCUT_TEST(assert_true) { 74 66 PCUT_ASSERT_TRUE(42); 75 67 PCUT_ASSERT_TRUE(0); 76 68 } 77 69 78 PCUT_TEST(assert_false) 79 { 70 PCUT_TEST(assert_false) { 80 71 PCUT_ASSERT_FALSE(0); 81 72 PCUT_ASSERT_FALSE(42); 82 73 } 83 74 84 PCUT_MAIN() ;75 PCUT_MAIN() -
uspace/lib/pcut/tests/beforeafter.c
r275530a4 r4b54bd9 34 34 #include <stdio.h> 35 35 36 /* 37 * Use sprintf_s in Windows but only with Microsoft compiler. 38 * Namely, let MinGW use snprintf. 39 */ 40 #if (defined(__WIN64) || defined(__WIN32) || defined(_WIN32)) && defined(_MSC_VER) 41 #define snprintf sprintf_s 42 #endif 43 44 PCUT_INIT; 36 PCUT_INIT 45 37 46 38 static char *buffer = NULL; … … 49 41 PCUT_TEST_SUITE(suite_with_setup_and_teardown); 50 42 51 PCUT_TEST_BEFORE 52 { 43 PCUT_TEST_BEFORE { 53 44 buffer = malloc(BUFFER_SIZE); 54 45 PCUT_ASSERT_NOT_NULL(buffer); 55 46 } 56 47 57 PCUT_TEST_AFTER 58 { 48 PCUT_TEST_AFTER { 59 49 free(buffer); 60 50 buffer = NULL; 61 51 } 62 52 63 PCUT_TEST(test_with_setup_and_teardown) 64 { 53 PCUT_TEST(test_with_setup_and_teardown) { 54 #if (defined(__WIN64) || defined(__WIN32) || defined(_WIN32)) && defined(_MSC_VER) 55 _snprintf_s(buffer, BUFFER_SIZE - 1, _TRUNCATE, "%d-%s", 56, "abcd"); 56 #else 65 57 snprintf(buffer, BUFFER_SIZE - 1, "%d-%s", 56, "abcd"); 58 #endif 59 66 60 PCUT_ASSERT_STR_EQUALS("56-abcd", buffer); 67 61 } … … 69 63 PCUT_TEST_SUITE(another_without_setup); 70 64 71 PCUT_TEST(test_without_any_setup_or_teardown) 72 { 65 PCUT_TEST(test_without_any_setup_or_teardown) { 73 66 PCUT_ASSERT_NULL(buffer); 74 67 } 75 68 76 69 77 PCUT_MAIN() ;70 PCUT_MAIN() -
uspace/lib/pcut/tests/errno.c
r275530a4 r4b54bd9 35 35 #endif 36 36 37 PCUT_INIT ;37 PCUT_INIT 38 38 39 PCUT_TEST(errno_value) 40 { 41 errno_t value = EOK; 39 PCUT_TEST(errno_value) { 40 int value = EOK; 42 41 PCUT_ASSERT_ERRNO_VAL(EOK, value); 43 42 value = ENOENT; … … 48 47 } 49 48 50 PCUT_TEST(errno_variable) 51 { 49 PCUT_TEST(errno_variable) { 52 50 errno = ENOENT; 53 51 PCUT_ASSERT_ERRNO(ENOENT); … … 57 55 } 58 56 59 PCUT_MAIN() ;57 PCUT_MAIN() -
uspace/lib/pcut/tests/inithook.c
r275530a4 r4b54bd9 30 30 #include "tested.h" 31 31 32 PCUT_INIT ;32 PCUT_INIT 33 33 34 34 static int init_counter = 0; 35 35 36 static void init_hook(void) 37 { 36 static void init_hook(void) { 38 37 init_counter++; 39 38 } 40 39 41 PCUT_TEST_BEFORE 42 { 40 PCUT_TEST_BEFORE { 43 41 PCUT_ASSERT_INT_EQUALS(1, init_counter); 44 42 init_counter++; 45 43 } 46 44 47 PCUT_TEST(check_init_counter) 48 { 45 PCUT_TEST(check_init_counter) { 49 46 PCUT_ASSERT_INT_EQUALS(2, init_counter); 50 47 } 51 48 52 PCUT_TEST(check_init_counter_2) 53 { 49 PCUT_TEST(check_init_counter_2) { 54 50 PCUT_ASSERT_INT_EQUALS(2, init_counter); 55 51 } 56 52 57 53 58 PCUT_CUSTOM_MAIN(PCUT_MAIN_SET_INIT_HOOK(init_hook)); 54 PCUT_CUSTOM_MAIN( 55 PCUT_MAIN_SET_INIT_HOOK(init_hook) 56 ) 59 57 -
uspace/lib/pcut/tests/manytests.c
r275530a4 r4b54bd9 34 34 */ 35 35 36 PCUT_INIT ;36 PCUT_INIT 37 37 38 PCUT_TEST(my_test_001) 39 { 40 } 41 PCUT_TEST(my_test_002) 42 { 43 } 44 PCUT_TEST(my_test_003) 45 { 46 } 47 PCUT_TEST(my_test_004) 48 { 49 } 50 PCUT_TEST(my_test_005) 51 { 52 } 53 PCUT_TEST(my_test_006) 54 { 55 } 56 PCUT_TEST(my_test_007) 57 { 58 } 59 PCUT_TEST(my_test_008) 60 { 61 } 62 PCUT_TEST(my_test_009) 63 { 64 } 65 PCUT_TEST(my_test_010) 66 { 67 } 68 PCUT_TEST(my_test_011) 69 { 70 } 71 PCUT_TEST(my_test_012) 72 { 73 } 74 PCUT_TEST(my_test_013) 75 { 76 } 77 PCUT_TEST(my_test_014) 78 { 79 } 80 PCUT_TEST(my_test_015) 81 { 82 } 83 PCUT_TEST(my_test_016) 84 { 85 } 86 PCUT_TEST(my_test_017) 87 { 88 } 89 PCUT_TEST(my_test_018) 90 { 91 } 92 PCUT_TEST(my_test_019) 93 { 94 } 95 PCUT_TEST(my_test_020) 96 { 97 } 98 PCUT_TEST(my_test_021) 99 { 100 } 101 PCUT_TEST(my_test_022) 102 { 103 } 104 PCUT_TEST(my_test_023) 105 { 106 } 107 PCUT_TEST(my_test_024) 108 { 109 } 110 PCUT_TEST(my_test_025) 111 { 112 } 113 PCUT_TEST(my_test_026) 114 { 115 } 116 PCUT_TEST(my_test_027) 117 { 118 } 119 PCUT_TEST(my_test_028) 120 { 121 } 122 PCUT_TEST(my_test_029) 123 { 124 } 125 PCUT_TEST(my_test_030) 126 { 127 } 128 PCUT_TEST(my_test_031) 129 { 130 } 131 PCUT_TEST(my_test_032) 132 { 133 } 134 PCUT_TEST(my_test_033) 135 { 136 } 137 PCUT_TEST(my_test_034) 138 { 139 } 140 PCUT_TEST(my_test_035) 141 { 142 } 143 PCUT_TEST(my_test_036) 144 { 145 } 146 PCUT_TEST(my_test_037) 147 { 148 } 149 PCUT_TEST(my_test_038) 150 { 151 } 152 PCUT_TEST(my_test_039) 153 { 154 } 155 PCUT_TEST(my_test_040) 156 { 157 } 158 PCUT_TEST(my_test_041) 159 { 160 } 161 PCUT_TEST(my_test_042) 162 { 163 } 164 PCUT_TEST(my_test_043) 165 { 166 } 167 PCUT_TEST(my_test_044) 168 { 169 } 170 PCUT_TEST(my_test_045) 171 { 172 } 173 PCUT_TEST(my_test_046) 174 { 175 } 176 PCUT_TEST(my_test_047) 177 { 178 } 179 PCUT_TEST(my_test_048) 180 { 181 } 182 PCUT_TEST(my_test_049) 183 { 184 } 185 PCUT_TEST(my_test_050) 186 { 187 } 188 PCUT_TEST(my_test_051) 189 { 190 } 191 PCUT_TEST(my_test_052) 192 { 193 } 194 PCUT_TEST(my_test_053) 195 { 196 } 197 PCUT_TEST(my_test_054) 198 { 199 } 200 PCUT_TEST(my_test_055) 201 { 202 } 203 PCUT_TEST(my_test_056) 204 { 205 } 206 PCUT_TEST(my_test_057) 207 { 208 } 209 PCUT_TEST(my_test_058) 210 { 211 } 212 PCUT_TEST(my_test_059) 213 { 214 } 215 PCUT_TEST(my_test_060) 216 { 217 } 218 PCUT_TEST(my_test_061) 219 { 220 } 221 PCUT_TEST(my_test_062) 222 { 223 } 224 PCUT_TEST(my_test_063) 225 { 226 } 227 PCUT_TEST(my_test_064) 228 { 229 } 230 PCUT_TEST(my_test_065) 231 { 232 } 233 PCUT_TEST(my_test_066) 234 { 235 } 236 PCUT_TEST(my_test_067) 237 { 238 } 239 PCUT_TEST(my_test_068) 240 { 241 } 242 PCUT_TEST(my_test_069) 243 { 244 } 245 PCUT_TEST(my_test_070) 246 { 247 } 248 PCUT_TEST(my_test_071) 249 { 250 } 251 PCUT_TEST(my_test_072) 252 { 253 } 254 PCUT_TEST(my_test_073) 255 { 256 } 257 PCUT_TEST(my_test_074) 258 { 259 } 260 PCUT_TEST(my_test_075) 261 { 262 } 263 PCUT_TEST(my_test_076) 264 { 265 } 266 PCUT_TEST(my_test_077) 267 { 268 } 269 PCUT_TEST(my_test_078) 270 { 271 } 272 PCUT_TEST(my_test_079) 273 { 274 } 275 PCUT_TEST(my_test_080) 276 { 277 } 38 PCUT_TEST(my_test_001) { } 39 PCUT_TEST(my_test_002) { } 40 PCUT_TEST(my_test_003) { } 41 PCUT_TEST(my_test_004) { } 42 PCUT_TEST(my_test_005) { } 43 PCUT_TEST(my_test_006) { } 44 PCUT_TEST(my_test_007) { } 45 PCUT_TEST(my_test_008) { } 46 PCUT_TEST(my_test_009) { } 47 PCUT_TEST(my_test_010) { } 48 PCUT_TEST(my_test_011) { } 49 PCUT_TEST(my_test_012) { } 50 PCUT_TEST(my_test_013) { } 51 PCUT_TEST(my_test_014) { } 52 PCUT_TEST(my_test_015) { } 53 PCUT_TEST(my_test_016) { } 54 PCUT_TEST(my_test_017) { } 55 PCUT_TEST(my_test_018) { } 56 PCUT_TEST(my_test_019) { } 57 PCUT_TEST(my_test_020) { } 58 PCUT_TEST(my_test_021) { } 59 PCUT_TEST(my_test_022) { } 60 PCUT_TEST(my_test_023) { } 61 PCUT_TEST(my_test_024) { } 62 PCUT_TEST(my_test_025) { } 63 PCUT_TEST(my_test_026) { } 64 PCUT_TEST(my_test_027) { } 65 PCUT_TEST(my_test_028) { } 66 PCUT_TEST(my_test_029) { } 67 PCUT_TEST(my_test_030) { } 68 PCUT_TEST(my_test_031) { } 69 PCUT_TEST(my_test_032) { } 70 PCUT_TEST(my_test_033) { } 71 PCUT_TEST(my_test_034) { } 72 PCUT_TEST(my_test_035) { } 73 PCUT_TEST(my_test_036) { } 74 PCUT_TEST(my_test_037) { } 75 PCUT_TEST(my_test_038) { } 76 PCUT_TEST(my_test_039) { } 77 PCUT_TEST(my_test_040) { } 78 PCUT_TEST(my_test_041) { } 79 PCUT_TEST(my_test_042) { } 80 PCUT_TEST(my_test_043) { } 81 PCUT_TEST(my_test_044) { } 82 PCUT_TEST(my_test_045) { } 83 PCUT_TEST(my_test_046) { } 84 PCUT_TEST(my_test_047) { } 85 PCUT_TEST(my_test_048) { } 86 PCUT_TEST(my_test_049) { } 87 PCUT_TEST(my_test_050) { } 88 PCUT_TEST(my_test_051) { } 89 PCUT_TEST(my_test_052) { } 90 PCUT_TEST(my_test_053) { } 91 PCUT_TEST(my_test_054) { } 92 PCUT_TEST(my_test_055) { } 93 PCUT_TEST(my_test_056) { } 94 PCUT_TEST(my_test_057) { } 95 PCUT_TEST(my_test_058) { } 96 PCUT_TEST(my_test_059) { } 97 PCUT_TEST(my_test_060) { } 98 PCUT_TEST(my_test_061) { } 99 PCUT_TEST(my_test_062) { } 100 PCUT_TEST(my_test_063) { } 101 PCUT_TEST(my_test_064) { } 102 PCUT_TEST(my_test_065) { } 103 PCUT_TEST(my_test_066) { } 104 PCUT_TEST(my_test_067) { } 105 PCUT_TEST(my_test_068) { } 106 PCUT_TEST(my_test_069) { } 107 PCUT_TEST(my_test_070) { } 108 PCUT_TEST(my_test_071) { } 109 PCUT_TEST(my_test_072) { } 110 PCUT_TEST(my_test_073) { } 111 PCUT_TEST(my_test_074) { } 112 PCUT_TEST(my_test_075) { } 113 PCUT_TEST(my_test_076) { } 114 PCUT_TEST(my_test_077) { } 115 PCUT_TEST(my_test_078) { } 116 PCUT_TEST(my_test_079) { } 117 PCUT_TEST(my_test_080) { } 278 118 279 119 280 PCUT_MAIN() ;120 PCUT_MAIN() -
uspace/lib/pcut/tests/preinithook.c
r275530a4 r4b54bd9 30 30 #include "tested.h" 31 31 32 PCUT_INIT ;32 PCUT_INIT 33 33 34 34 static int init_counter = 1; 35 35 36 static void init_hook(void) 37 { 36 static void init_hook(void) { 38 37 init_counter++; 39 38 } 40 39 41 static void pre_init_hook(int *argc, char **argv[]) 42 { 40 static void pre_init_hook(int *argc, char **argv[]) { 43 41 (void) argc; 44 42 (void) argv; … … 46 44 } 47 45 48 PCUT_TEST_BEFORE 49 { 46 PCUT_TEST_BEFORE { 50 47 PCUT_ASSERT_INT_EQUALS(4, init_counter); 51 48 init_counter++; 52 49 } 53 50 54 PCUT_TEST(check_init_counter) 55 { 51 PCUT_TEST(check_init_counter) { 56 52 PCUT_ASSERT_INT_EQUALS(5, init_counter); 57 53 } 58 54 59 PCUT_TEST(check_init_counter_2) 60 { 55 PCUT_TEST(check_init_counter_2) { 61 56 PCUT_ASSERT_INT_EQUALS(5, init_counter); 62 57 } 63 58 64 59 65 PCUT_CUSTOM_MAIN(PCUT_MAIN_SET_INIT_HOOK(init_hook), 66 PCUT_MAIN_SET_PREINIT_HOOK(pre_init_hook)); 60 PCUT_CUSTOM_MAIN( 61 PCUT_MAIN_SET_INIT_HOOK(init_hook), 62 PCUT_MAIN_SET_PREINIT_HOOK(pre_init_hook) 63 ) 67 64 -
uspace/lib/pcut/tests/printing.c
r275530a4 r4b54bd9 31 31 #include <stdio.h> 32 32 33 PCUT_INIT ;33 PCUT_INIT 34 34 35 PCUT_TEST(print_to_stdout) 36 { 35 PCUT_TEST(print_to_stdout) { 37 36 printf("Printed from a test to stdout!\n"); 38 37 } 39 38 40 PCUT_TEST(print_to_stderr) 41 { 39 PCUT_TEST(print_to_stderr) { 42 40 fprintf(stderr, "Printed from a test to stderr!\n"); 43 41 } 44 42 45 PCUT_TEST(print_to_stdout_and_fail) 46 { 43 PCUT_TEST(print_to_stdout_and_fail) { 47 44 printf("Printed from a test to stdout!\n"); 48 45 PCUT_ASSERT_NOT_NULL(0); 49 46 } 50 47 51 PCUT_MAIN() ;48 PCUT_MAIN() -
uspace/lib/pcut/tests/simple.c
r275530a4 r4b54bd9 30 30 #include "tested.h" 31 31 32 PCUT_INIT ;32 PCUT_INIT 33 33 34 PCUT_TEST(zero_exponent) 35 { 34 PCUT_TEST(zero_exponent) { 36 35 PCUT_ASSERT_INT_EQUALS(1, intpow(2, 0)); 37 36 } 38 37 39 PCUT_TEST(one_exponent) 40 { 38 PCUT_TEST(one_exponent) { 41 39 PCUT_ASSERT_INT_EQUALS(2, intpow(2, 1)); 42 40 PCUT_ASSERT_INT_EQUALS(39, intpow(39, 1)); 43 41 } 44 42 45 PCUT_TEST(same_strings) 46 { 43 PCUT_TEST(same_strings) { 47 44 const char *p = "xyz"; 48 45 PCUT_ASSERT_STR_EQUALS("xyz", p); … … 50 47 } 51 48 52 PCUT_MAIN() ;49 PCUT_MAIN() -
uspace/lib/pcut/tests/skip.c
r275530a4 r4b54bd9 30 30 #include "tested.h" 31 31 32 PCUT_INIT ;32 PCUT_INIT 33 33 34 PCUT_TEST(normal_test) 35 { 34 PCUT_TEST(normal_test) { 36 35 PCUT_ASSERT_INT_EQUALS(1, 1); 37 36 } 38 37 39 PCUT_TEST(skipped, PCUT_TEST_SKIP) 40 { 38 PCUT_TEST(skipped, PCUT_TEST_SKIP) { 41 39 PCUT_ASSERT_STR_EQUALS("skip", "not skipped"); 42 40 } 43 41 44 PCUT_TEST(again_normal_test) 45 { 42 PCUT_TEST(again_normal_test) { 46 43 PCUT_ASSERT_INT_EQUALS(1, 1); 47 44 } 48 45 49 PCUT_MAIN() ;46 PCUT_MAIN() -
uspace/lib/pcut/tests/suite1.c
r275530a4 r4b54bd9 30 30 #include "tested.h" 31 31 32 PCUT_INIT ;32 PCUT_INIT 33 33 34 34 PCUT_TEST_SUITE(intpow); 35 35 36 PCUT_TEST(zero_exponent) 37 { 36 PCUT_TEST(zero_exponent) { 38 37 PCUT_ASSERT_INT_EQUALS(1, intpow(2, 0)); 39 38 } 40 39 41 PCUT_TEST(one_exponent) 42 { 40 PCUT_TEST(one_exponent) { 43 41 PCUT_ASSERT_INT_EQUALS(2, intpow(2, 1)); 44 42 PCUT_ASSERT_INT_EQUALS(39, intpow(39, 1)); -
uspace/lib/pcut/tests/suite2.c
r275530a4 r4b54bd9 30 30 #include "tested.h" 31 31 32 PCUT_INIT ;32 PCUT_INIT 33 33 34 34 PCUT_TEST_SUITE(intmin); 35 35 36 PCUT_TEST(test_min) 37 { 36 PCUT_TEST(test_min) { 38 37 PCUT_ASSERT_INT_EQUALS(5, intmin(5, 654)); 39 38 PCUT_ASSERT_INT_EQUALS(5, intmin(654, 5)); … … 42 41 } 43 42 44 PCUT_TEST(test_same_numbers) 45 { 43 PCUT_TEST(test_same_numbers) { 46 44 PCUT_ASSERT_INT_EQUALS(5, intmin(5, 5)); 47 45 PCUT_ASSERT_INT_EQUALS(719, intmin(719, 719)); -
uspace/lib/pcut/tests/suite_all.c
r275530a4 r4b54bd9 29 29 #include <pcut/pcut.h> 30 30 31 PCUT_INIT ;31 PCUT_INIT 32 32 33 33 PCUT_IMPORT(intpow_suite); 34 34 PCUT_IMPORT(intmin_suite); 35 35 36 PCUT_MAIN() ;36 PCUT_MAIN() -
uspace/lib/pcut/tests/suites.c
r275530a4 r4b54bd9 30 30 #include "tested.h" 31 31 32 PCUT_INIT ;32 PCUT_INIT 33 33 34 34 PCUT_TEST_SUITE(intpow); 35 35 36 PCUT_TEST(zero_exponent) 37 { 36 PCUT_TEST(zero_exponent) { 38 37 PCUT_ASSERT_INT_EQUALS(1, intpow(2, 0)); 39 38 } 40 39 41 PCUT_TEST(one_exponent) 42 { 40 PCUT_TEST(one_exponent) { 43 41 PCUT_ASSERT_INT_EQUALS(2, intpow(2, 1)); 44 42 PCUT_ASSERT_INT_EQUALS(39, intpow(39, 1)); … … 47 45 PCUT_TEST_SUITE(intmin); 48 46 49 PCUT_TEST(test_min) 50 { 47 PCUT_TEST(test_min) { 51 48 PCUT_ASSERT_INT_EQUALS(5, intmin(5, 654)); 52 49 PCUT_ASSERT_INT_EQUALS(5, intmin(654, 5)); … … 55 52 } 56 53 57 PCUT_MAIN() ;54 PCUT_MAIN() -
uspace/lib/pcut/tests/teardown.c
r275530a4 r4b54bd9 31 31 #include "tested.h" 32 32 33 PCUT_INIT ;33 PCUT_INIT 34 34 35 35 … … 37 37 PCUT_TEST_SUITE(with_teardown); 38 38 39 PCUT_TEST_AFTER 40 { 39 PCUT_TEST_AFTER { 41 40 printf("This is teardown-function.\n"); 42 41 } 43 42 44 PCUT_TEST(empty) 45 { 43 PCUT_TEST(empty) { 46 44 } 47 45 48 PCUT_TEST(failing) 49 { 46 PCUT_TEST(failing) { 50 47 PCUT_ASSERT_INT_EQUALS(10, intmin(1, 2)); 51 48 } … … 55 52 PCUT_TEST_SUITE(with_failing_teardown); 56 53 57 PCUT_TEST_AFTER 58 { 54 PCUT_TEST_AFTER { 59 55 printf("This is failing teardown-function.\n"); 60 56 PCUT_ASSERT_INT_EQUALS(42, intmin(10, 20)); 61 57 } 62 58 63 PCUT_TEST(empty2) 64 { 59 PCUT_TEST(empty2) { 65 60 } 66 61 67 PCUT_TEST(printing2) 68 { 62 PCUT_TEST(printing2) { 69 63 printf("Printed before test failure.\n"); 70 64 PCUT_ASSERT_INT_EQUALS(0, intmin(-17, -19)); 71 65 } 72 66 73 PCUT_TEST(failing2) 74 { 67 PCUT_TEST(failing2) { 75 68 PCUT_ASSERT_INT_EQUALS(12, intmin(3, 5)); 76 69 } 77 70 78 71 79 PCUT_MAIN() ;72 PCUT_MAIN() -
uspace/lib/pcut/tests/teardownaborts.c
r275530a4 r4b54bd9 31 31 #include <stdlib.h> 32 32 33 PCUT_INIT ;33 PCUT_INIT 34 34 35 PCUT_TEST_AFTER 36 { 35 PCUT_TEST_AFTER { 37 36 abort(); 38 37 } 39 38 40 PCUT_TEST(print_and_fail) 41 { 39 PCUT_TEST(print_and_fail) { 42 40 printf("Tear-down will cause null pointer access...\n"); 43 41 PCUT_ASSERT_NOT_NULL(NULL); 44 42 } 45 43 46 PCUT_MAIN() ;44 PCUT_MAIN() -
uspace/lib/pcut/tests/tested.c
r275530a4 r4b54bd9 31 31 #define UNUSED(a) ((void)a) 32 32 33 long intpow(int base, int exp) 34 { 35 UNUSED(base); 36 UNUSED(exp); 33 long intpow(int base, int exp) { 34 UNUSED(base); UNUSED(exp); 37 35 return 0; 38 36 } 39 37 40 int intmin(int a, int b) 41 { 38 int intmin(int a, int b) { 42 39 UNUSED(b); 43 40 return a; -
uspace/lib/pcut/tests/testlist.c
r275530a4 r4b54bd9 30 30 #include "tested.h" 31 31 32 PCUT_INIT ;32 PCUT_INIT 33 33 34 34 static char *argv_patched[] = { … … 38 38 }; 39 39 40 static void pre_init_hook(int *argc, char **argv[]) 41 { 40 static void pre_init_hook(int *argc, char **argv[]) { 42 41 argv_patched[0] = (*argv)[0]; 43 42 *argc = 2; … … 45 44 } 46 45 47 PCUT_TEST(unreachable) 48 { 46 PCUT_TEST(unreachable) { 49 47 PCUT_ASSERT_TRUE(0 && "unreachable code"); 50 48 } 51 49 52 50 53 PCUT_CUSTOM_MAIN(PCUT_MAIN_SET_PREINIT_HOOK(pre_init_hook)); 51 PCUT_CUSTOM_MAIN( 52 PCUT_MAIN_SET_PREINIT_HOOK(pre_init_hook) 53 ) 54 54 -
uspace/lib/pcut/tests/timeout.c
r275530a4 r4b54bd9 1 1 /* 2 * Copyright (c) 2012-201 3Vojtech Horky2 * Copyright (c) 2012-2018 Vojtech Horky 3 3 * All rights reserved. 4 4 * … … 32 32 #include <fibril.h> 33 33 #else 34 #if def __unix34 #if defined(__unix) || defined(__APPLE__) 35 35 #include <unistd.h> 36 36 #endif … … 43 43 #include "tested.h" 44 44 45 static void my_sleep(int sec) 46 { 45 static void my_sleep(int sec) { 47 46 #ifdef __helenos__ 48 47 fibril_sleep(sec); 49 48 #else 50 #if def __unix49 #if defined(__unix) || defined(__APPLE__) 51 50 sleep(sec); 52 51 #endif … … 57 56 } 58 57 59 PCUT_INIT ;58 PCUT_INIT 60 59 61 PCUT_TEST(shall_time_out) 62 { 60 PCUT_TEST(shall_time_out) { 63 61 printf("Text before sleeping.\n"); 64 62 my_sleep(PCUT_DEFAULT_TEST_TIMEOUT * 5); … … 67 65 68 66 PCUT_TEST(custom_time_out, 69 PCUT_TEST_SET_TIMEOUT(PCUT_DEFAULT_TEST_TIMEOUT * 3)) 70 { 67 PCUT_TEST_SET_TIMEOUT(PCUT_DEFAULT_TEST_TIMEOUT * 3)) { 71 68 printf("Text before sleeping.\n"); 72 69 my_sleep(PCUT_DEFAULT_TEST_TIMEOUT * 2); … … 74 71 } 75 72 76 PCUT_MAIN() ;73 PCUT_MAIN() -
uspace/lib/pcut/tests/xmlreport.c
r275530a4 r4b54bd9 33 33 #include "tested.h" 34 34 35 PCUT_INIT ;35 PCUT_INIT 36 36 37 PCUT_TEST(zero_exponent) 38 { 37 PCUT_TEST(zero_exponent) { 39 38 PCUT_ASSERT_INT_EQUALS(1, intpow(2, 0)); 40 39 } 41 40 42 PCUT_TEST(one_exponent) 43 { 41 PCUT_TEST(one_exponent) { 44 42 PCUT_ASSERT_INT_EQUALS(2, intpow(2, 1)); 45 43 PCUT_ASSERT_INT_EQUALS(39, intpow(39, 1)); 46 44 } 47 45 48 PCUT_TEST(same_strings) 49 { 46 PCUT_TEST(same_strings) { 50 47 const char *p = "xyz"; 51 48 PCUT_ASSERT_STR_EQUALS("xyz", p); … … 53 50 } 54 51 55 PCUT_CUSTOM_MAIN(PCUT_MAIN_SET_XML_REPORT); 52 PCUT_CUSTOM_MAIN( 53 PCUT_MAIN_SET_XML_REPORT 54 ) -
uspace/lib/pcut/update-from-master.sh
r275530a4 r4b54bd9 43 43 fi 44 44 45 $RUN find -not -name update-from-master.sh - delete45 $RUN find -not -name update-from-master.sh -and -not -name doc -and -not -name 'doxygroups.h' -delete 46 46 $RUN wget -q https://github.com/vhotspur/pcut/archive/master.zip -O pcut-master.zip 47 47 $RUN unzip -q -u pcut-master.zip 48 $RUN mv -f pcut-master/* . 48 $RUN mv -f pcut-master/src . 49 $RUN mv -f pcut-master/include . 50 $RUN mv -f pcut-master/tests . 51 $RUN mv -f pcut-master/helenos*.mak . 49 52 $RUN rm -rf pcut-master pcut-master.zip 50 $RUN rm -rf contrib doc51 53 $RUN rm -f CMakeLists.txt *.cmake run_test.sh 52 54
Note:
See TracChangeset
for help on using the changeset viewer.