diff options
author | Steven Murdoch <Steven.Murdoch@cl.cam.ac.uk> | 2011-07-21 19:26:19 +0100 |
---|---|---|
committer | Steven Murdoch <Steven.Murdoch@cl.cam.ac.uk> | 2011-07-21 19:26:19 +0100 |
commit | fec902dd6024dd170d151409387df5319b6e2ad0 (patch) | |
tree | 16f8e7abdb1c313a8fbee19416b34c56a00db1d9 /src/test/test_util.c | |
parent | 35c89be02b535e2951b695429bd9b255afb2a7b2 (diff) | |
download | tor-fec902dd6024dd170d151409387df5319b6e2ad0.tar tor-fec902dd6024dd170d151409387df5319b6e2ad0.tar.gz |
Add Windows version of tor_spawn_background and ancillary functions
Diffstat (limited to 'src/test/test_util.c')
-rw-r--r-- | src/test/test_util.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/test/test_util.c b/src/test/test_util.c index fce53b835..28030b79b 100644 --- a/src/test/test_util.c +++ b/src/test/test_util.c @@ -1394,24 +1394,25 @@ run_util_spawn_background(const char *argv[], const char *expected_out, tt_int_op(process_handle.stderr_pipe, >, 0); /* Check stdout */ - pos = tor_read_all_from_process_stdin(process_handle, stdout_buf, + pos = tor_read_all_from_process_stdout(process_handle, stdout_buf, sizeof(stdout_buf) - 1); tt_assert(pos >= 0); stdout_buf[pos] = '\0'; - tt_int_op(pos, ==, strlen(expected_out)); tt_str_op(stdout_buf, ==, expected_out); + tt_int_op(pos, ==, strlen(expected_out)); /* Check it terminated correctly */ retval = tor_get_exit_code(process_handle); tt_int_op(retval, ==, expected_exit); + // TODO: Make test-child exit with something other than 0 /* Check stderr */ pos = tor_read_all_from_process_stderr(process_handle, stderr_buf, sizeof(stderr_buf) - 1); tt_assert(pos >= 0); stderr_buf[pos] = '\0'; - tt_int_op(pos, ==, strlen(expected_err)); tt_str_op(stderr_buf, ==, expected_err); + tt_int_op(pos, ==, strlen(expected_err)); done: ; @@ -1421,9 +1422,16 @@ run_util_spawn_background(const char *argv[], const char *expected_out, static void test_util_spawn_background_ok(void *ptr) { +#ifdef MS_WINDOWS + // TODO: Under MSYS, BUILDDIR in orconfig.h needs to be tweaked + const char *argv[] = {BUILDDIR "/src/test/test-child.exe", "--test", NULL}; + const char *expected_out = "OUT\r\n--test\r\nDONE\r\n"; + const char *expected_err = "ERR\r\n"; +#else const char *argv[] = {BUILDDIR "/src/test/test-child", "--test", NULL}; const char *expected_out = "OUT\n--test\nDONE\n"; const char *expected_err = "ERR\n"; +#endif (void)ptr; |