Changeset 4b54bd9 in mainline for uspace/lib/pcut/src/os/windows.c
- 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
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note:
See TracChangeset
for help on using the changeset viewer.