diff options
author | Fedor Indutny <fedor.indutny@gmail.com> | 2012-05-28 23:52:34 +0400 |
---|---|---|
committer | Fedor Indutny <fedor.indutny@gmail.com> | 2012-05-29 18:26:40 +0400 |
commit | 761e0c460a8e9a40cd1126cf0ba354e50e38d6da (patch) | |
tree | 314a084790dd95dcea5ea4928321a9d47c3aaa93 /deps/uv/test | |
parent | fa9aa1c961125f5c5527c7b5e3720eadf84a979f (diff) | |
download | android-node-v8-761e0c460a8e9a40cd1126cf0ba354e50e38d6da.tar.gz android-node-v8-761e0c460a8e9a40cd1126cf0ba354e50e38d6da.tar.bz2 android-node-v8-761e0c460a8e9a40cd1126cf0ba354e50e38d6da.zip |
deps: upgrade libuv to 7556590
Diffstat (limited to 'deps/uv/test')
-rw-r--r-- | deps/uv/test/benchmark-spawn.c | 8 | ||||
-rw-r--r-- | deps/uv/test/runner-win.c | 5 | ||||
-rw-r--r-- | deps/uv/test/test-ipc.c | 10 | ||||
-rw-r--r-- | deps/uv/test/test-list.h | 2 | ||||
-rw-r--r-- | deps/uv/test/test-spawn.c | 101 | ||||
-rw-r--r-- | deps/uv/test/test-stdio-over-pipes.c | 11 |
6 files changed, 121 insertions, 16 deletions
diff --git a/deps/uv/test/benchmark-spawn.c b/deps/uv/test/benchmark-spawn.c index d34f42b9fe..74cc3d238f 100644 --- a/deps/uv/test/benchmark-spawn.c +++ b/deps/uv/test/benchmark-spawn.c @@ -101,6 +101,7 @@ void on_read(uv_stream_t* pipe, ssize_t nread, uv_buf_t buf) { static void spawn() { + uv_stdio_container_t stdio[2]; int r; ASSERT(process_open == 0); @@ -114,7 +115,12 @@ static void spawn() { options.exit_cb = exit_cb; uv_pipe_init(loop, &out, 0); - options.stdout_stream = &out; + + options.stdio = stdio; + options.stdio_count = 2; + options.stdio[0].flags = UV_IGNORE; + options.stdio[1].flags = UV_CREATE_PIPE | UV_WRITABLE_PIPE; + options.stdio[1].data.stream = (uv_stream_t*)&out; r = uv_spawn(loop, &process, options); ASSERT(r == 0); diff --git a/deps/uv/test/runner-win.c b/deps/uv/test/runner-win.c index e758dd1dd3..ad36719c8f 100644 --- a/deps/uv/test/runner-win.c +++ b/deps/uv/test/runner-win.c @@ -19,6 +19,7 @@ * IN THE SOFTWARE. */ +#include <fcntl.h> #include <io.h> #include <malloc.h> #include <stdio.h> @@ -44,6 +45,10 @@ void platform_init(int argc, char **argv) { SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX); + _setmode(0, _O_BINARY); + _setmode(1, _O_BINARY); + _setmode(2, _O_BINARY); + /* Disable stdio output buffering. */ setvbuf(stdout, NULL, _IONBF, 0); setvbuf(stderr, NULL, _IONBF, 0); diff --git a/deps/uv/test/test-ipc.c b/deps/uv/test/test-ipc.c index 1ea0e7f963..61add0b4b8 100644 --- a/deps/uv/test/test-ipc.c +++ b/deps/uv/test/test-ipc.c @@ -200,6 +200,7 @@ void spawn_helper(uv_pipe_t* channel, char exepath[1024]; char* args[3]; int r; + uv_stdio_container_t stdio[1]; r = uv_pipe_init(uv_default_loop(), channel, 1); ASSERT(r == 0); @@ -218,7 +219,12 @@ void spawn_helper(uv_pipe_t* channel, options.file = exepath; options.args = args; options.exit_cb = exit_cb; - options.stdin_stream = channel; + + options.stdio = stdio; + options.stdio[0].flags = UV_CREATE_PIPE | + UV_READABLE_PIPE | UV_WRITABLE_PIPE; + options.stdio[0].data.stream = (uv_stream_t*)channel; + options.stdio_count = 1; r = uv_spawn(uv_default_loop(), process, options); ASSERT(r == 0); @@ -611,4 +617,4 @@ int ipc_helper_tcp_connection() { ASSERT(close_cb_called == 4); return 0; -}
\ No newline at end of file +} diff --git a/deps/uv/test/test-list.h b/deps/uv/test/test-list.h index 63683f28ed..ffb1fe2346 100644 --- a/deps/uv/test/test-list.h +++ b/deps/uv/test/test-list.h @@ -123,6 +123,7 @@ TEST_DECLARE (spawn_and_kill_with_std) TEST_DECLARE (spawn_and_ping) TEST_DECLARE (spawn_setuid_fails) TEST_DECLARE (spawn_setgid_fails) +TEST_DECLARE (spawn_stdout_to_file) TEST_DECLARE (kill) TEST_DECLARE (fs_file_noent) TEST_DECLARE (fs_file_nametoolong) @@ -334,6 +335,7 @@ TASK_LIST_START TEST_ENTRY (spawn_and_ping) TEST_ENTRY (spawn_setuid_fails) TEST_ENTRY (spawn_setgid_fails) + TEST_ENTRY (spawn_stdout_to_file) TEST_ENTRY (kill) #ifdef _WIN32 TEST_ENTRY (spawn_detect_pipe_name_collisions_on_windows) diff --git a/deps/uv/test/test-spawn.c b/deps/uv/test/test-spawn.c index ccb9538f90..25863de6a5 100644 --- a/deps/uv/test/test-spawn.c +++ b/deps/uv/test/test-spawn.c @@ -21,6 +21,7 @@ #include "uv.h" #include "task.h" +#include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -167,11 +168,16 @@ TEST_IMPL(spawn_exit_code) { TEST_IMPL(spawn_stdout) { int r; uv_pipe_t out; + uv_stdio_container_t stdio[2]; init_process_options("spawn_helper2", exit_cb); uv_pipe_init(uv_default_loop(), &out, 0); - options.stdout_stream = &out; + options.stdio = stdio; + options.stdio[0].flags = UV_IGNORE; + options.stdio[1].flags = UV_CREATE_PIPE | UV_WRITABLE_PIPE; + options.stdio[1].data.stream = (uv_stream_t*)&out; + options.stdio_count = 2; r = uv_spawn(uv_default_loop(), &process, options); ASSERT(r == 0); @@ -185,7 +191,59 @@ TEST_IMPL(spawn_stdout) { ASSERT(exit_cb_called == 1); ASSERT(close_cb_called == 2); /* Once for process once for the pipe. */ printf("output is: %s", output); - ASSERT(strcmp("hello world\n", output) == 0 || strcmp("hello world\r\n", output) == 0); + ASSERT(strcmp("hello world\n", output) == 0); + + return 0; +} + + +TEST_IMPL(spawn_stdout_to_file) { + int r; + uv_file file; + uv_fs_t fs_req; + uv_stdio_container_t stdio[2]; + + /* Setup. */ + unlink("stdout_file"); + + init_process_options("spawn_helper2", exit_cb); + + r = uv_fs_open(uv_default_loop(), &fs_req, "stdout_file", O_CREAT | O_RDWR, + S_IREAD | S_IWRITE, NULL); + ASSERT(r != -1); + uv_fs_req_cleanup(&fs_req); + + file = r; + + options.stdio = stdio; + options.stdio[0].flags = UV_IGNORE; + options.stdio[1].flags = UV_RAW_FD; + options.stdio[1].data.fd = file; + options.stdio_count = 2; + + r = uv_spawn(uv_default_loop(), &process, options); + ASSERT(r == 0); + + r = uv_run(uv_default_loop()); + ASSERT(r == 0); + + ASSERT(exit_cb_called == 1); + ASSERT(close_cb_called == 1); + + r = uv_fs_read(uv_default_loop(), &fs_req, file, output, sizeof(output), + 0, NULL); + ASSERT(r == 12); + uv_fs_req_cleanup(&fs_req); + + r = uv_fs_close(uv_default_loop(), &fs_req, file, NULL); + ASSERT(r == 0); + uv_fs_req_cleanup(&fs_req); + + printf("output is: %s", output); + ASSERT(strcmp("hello world\n", output) == 0); + + /* Cleanup. */ + unlink("stdout_file"); return 0; } @@ -197,14 +255,19 @@ TEST_IMPL(spawn_stdin) { uv_pipe_t in; uv_write_t write_req; uv_buf_t buf; + uv_stdio_container_t stdio[2]; char buffer[] = "hello-from-spawn_stdin"; init_process_options("spawn_helper3", exit_cb); uv_pipe_init(uv_default_loop(), &out, 0); uv_pipe_init(uv_default_loop(), &in, 0); - options.stdout_stream = &out; - options.stdin_stream = ∈ + options.stdio = stdio; + options.stdio[0].flags = UV_CREATE_PIPE | UV_READABLE_PIPE; + options.stdio[0].data.stream = (uv_stream_t*)∈ + options.stdio[1].flags = UV_CREATE_PIPE | UV_WRITABLE_PIPE; + options.stdio[1].data.stream = (uv_stream_t*)&out; + options.stdio_count = 2; r = uv_spawn(uv_default_loop(), &process, options); ASSERT(r == 0); @@ -259,6 +322,7 @@ TEST_IMPL(spawn_and_kill_with_std) { char message[] = "Nancy's joining me because the message this evening is " "not my message but ours."; uv_buf_t buf; + uv_stdio_container_t stdio[3]; init_process_options("spawn_helper4", kill_cb); @@ -271,9 +335,14 @@ TEST_IMPL(spawn_and_kill_with_std) { r = uv_pipe_init(uv_default_loop(), &err, 0); ASSERT(r == 0); - options.stdin_stream = ∈ - options.stdout_stream = &out; - options.stderr_stream = &err; + options.stdio = stdio; + options.stdio[0].flags = UV_CREATE_PIPE | UV_READABLE_PIPE; + options.stdio[0].data.stream = (uv_stream_t*)∈ + options.stdio[1].flags = UV_CREATE_PIPE | UV_WRITABLE_PIPE; + options.stdio[1].data.stream = (uv_stream_t*)&out; + options.stdio[2].flags = UV_CREATE_PIPE | UV_WRITABLE_PIPE; + options.stdio[2].data.stream = (uv_stream_t*)&err; + options.stdio_count = 3; r = uv_spawn(uv_default_loop(), &process, options); ASSERT(r == 0); @@ -308,6 +377,7 @@ TEST_IMPL(spawn_and_ping) { uv_write_t write_req; uv_pipe_t in, out; uv_buf_t buf; + uv_stdio_container_t stdio[2]; int r; init_process_options("spawn_helper3", exit_cb); @@ -315,8 +385,12 @@ TEST_IMPL(spawn_and_ping) { uv_pipe_init(uv_default_loop(), &out, 0); uv_pipe_init(uv_default_loop(), &in, 0); - options.stdout_stream = &out; - options.stdin_stream = ∈ + options.stdio = stdio; + options.stdio[0].flags = UV_CREATE_PIPE | UV_READABLE_PIPE; + options.stdio[0].data.stream = (uv_stream_t*)∈ + options.stdio[1].flags = UV_CREATE_PIPE | UV_WRITABLE_PIPE; + options.stdio[1].data.stream = (uv_stream_t*)&out; + options.stdio_count = 2; r = uv_spawn(uv_default_loop(), &process, options); ASSERT(r == 0); @@ -384,11 +458,16 @@ TEST_IMPL(spawn_detect_pipe_name_collisions_on_windows) { uv_pipe_t out; char name[64]; HANDLE pipe_handle; + uv_stdio_container_t stdio[2]; init_process_options("spawn_helper2", exit_cb); uv_pipe_init(uv_default_loop(), &out, 0); - options.stdout_stream = &out; + options.stdio = stdio; + options.stdio[0].flags = UV_IGNORE; + options.stdio[1].flags = UV_CREATE_PIPE | UV_WRITABLE_PIPE; + options.stdio[1].data.stream = (uv_stream_t*)&out; + options.stdio_count = 2; /* Create a pipe that'll cause a collision. */ _snprintf(name, sizeof(name), "\\\\.\\pipe\\uv\\%p-%d", &out, GetCurrentProcessId()); @@ -414,7 +493,7 @@ TEST_IMPL(spawn_detect_pipe_name_collisions_on_windows) { ASSERT(exit_cb_called == 1); ASSERT(close_cb_called == 2); /* Once for process once for the pipe. */ printf("output is: %s", output); - ASSERT(strcmp("hello world\n", output) == 0 || strcmp("hello world\r\n", output) == 0); + ASSERT(strcmp("hello world\n", output) == 0); return 0; } diff --git a/deps/uv/test/test-stdio-over-pipes.c b/deps/uv/test/test-stdio-over-pipes.c index 0a3f04c692..7603027fb8 100644 --- a/deps/uv/test/test-stdio-over-pipes.c +++ b/deps/uv/test/test-stdio-over-pipes.c @@ -115,14 +115,21 @@ static void on_read(uv_stream_t* tcp, ssize_t nread, uv_buf_t rdbuf) { TEST_IMPL(stdio_over_pipes) { int r; uv_process_t process; + uv_stdio_container_t stdio[2]; + loop = uv_default_loop(); init_process_options("stdio_over_pipes_helper", exit_cb); uv_pipe_init(loop, &out, 0); - options.stdout_stream = &out; uv_pipe_init(loop, &in, 0); - options.stdin_stream = ∈ + + options.stdio = stdio; + options.stdio[0].flags = UV_CREATE_PIPE | UV_READABLE_PIPE; + options.stdio[0].data.stream = (uv_stream_t*)∈ + options.stdio[1].flags = UV_CREATE_PIPE | UV_WRITABLE_PIPE; + options.stdio[1].data.stream = (uv_stream_t*)&out; + options.stdio_count = 2; r = uv_spawn(loop, &process, options); ASSERT(r == 0); |