summaryrefslogtreecommitdiff
path: root/deps/uv/test
diff options
context:
space:
mode:
authorFedor Indutny <fedor@indutny.com>2014-09-19 21:37:55 +0400
committerTimothy J Fontaine <tjfontaine@gmail.com>2014-09-23 08:18:41 -0700
commitc5f5d4cd11c2aec74fa03985405122d1ecb06f69 (patch)
tree17accc5b501eb89e6810cac8df50b54901b6cfee /deps/uv/test
parent6e08bb94e8b1aaf913cf88106cb59f9d2ae85925 (diff)
downloadandroid-node-v8-c5f5d4cd11c2aec74fa03985405122d1ecb06f69.tar.gz
android-node-v8-c5f5d4cd11c2aec74fa03985405122d1ecb06f69.tar.bz2
android-node-v8-c5f5d4cd11c2aec74fa03985405122d1ecb06f69.zip
deps: update uv to v1.0.0-rc1
Diffstat (limited to 'deps/uv/test')
-rw-r--r--deps/uv/test/echo-server.c22
-rw-r--r--deps/uv/test/test-default-loop-close.c59
-rw-r--r--deps/uv/test/test-fs.c28
-rw-r--r--deps/uv/test/test-handle-fileno.c120
-rw-r--r--deps/uv/test/test-list.h29
-rw-r--r--deps/uv/test/test-osx-select.c48
-rw-r--r--deps/uv/test/test-pipe-close-stdout-read-stdin.c103
-rw-r--r--deps/uv/test/test-pipe-getsockname.c58
-rw-r--r--deps/uv/test/test-socket-buffer-size.c77
-rw-r--r--deps/uv/test/test-spawn.c6
-rw-r--r--deps/uv/test/test-tcp-write-after-connect.c68
-rw-r--r--deps/uv/test/test-tcp-write-queue-order.c2
-rw-r--r--deps/uv/test/test-timer.c11
-rw-r--r--deps/uv/test/test-udp-ipv6.c7
-rw-r--r--deps/uv/test/test-udp-multicast-interface6.c2
-rw-r--r--deps/uv/test/test-udp-send-unreachable.c150
-rw-r--r--deps/uv/test/test-watcher-cross-stop.c2
17 files changed, 768 insertions, 24 deletions
diff --git a/deps/uv/test/echo-server.c b/deps/uv/test/echo-server.c
index f0937ccaac..f223981c26 100644
--- a/deps/uv/test/echo-server.c
+++ b/deps/uv/test/echo-server.c
@@ -51,20 +51,21 @@ static void after_write(uv_write_t* req, int status) {
/* Free the read/write buffer and the request */
wr = (write_req_t*) req;
free(wr->buf.base);
+ free(wr);
- if (status == 0) {
- free(wr);
+ if (status == 0)
return;
- }
fprintf(stderr,
"uv_write error: %s - %s\n",
uv_err_name(status),
uv_strerror(status));
+}
- if (!uv_is_closing((uv_handle_t*) req->handle))
- uv_close((uv_handle_t*) req->handle, on_close);
- free(wr);
+
+static void after_shutdown(uv_shutdown_t* req, int status) {
+ uv_close((uv_handle_t*) req->handle, on_close);
+ free(req);
}
@@ -73,16 +74,15 @@ static void after_read(uv_stream_t* handle,
const uv_buf_t* buf) {
int i;
write_req_t *wr;
+ uv_shutdown_t* sreq;
if (nread < 0) {
/* Error or EOF */
ASSERT(nread == UV_EOF);
- if (buf->base) {
- free(buf->base);
- }
-
- uv_close((uv_handle_t*) handle, on_close);
+ free(buf->base);
+ sreq = malloc(sizeof* sreq);
+ ASSERT(0 == uv_shutdown(sreq, handle, after_shutdown));
return;
}
diff --git a/deps/uv/test/test-default-loop-close.c b/deps/uv/test/test-default-loop-close.c
new file mode 100644
index 0000000000..fd11cfa8c1
--- /dev/null
+++ b/deps/uv/test/test-default-loop-close.c
@@ -0,0 +1,59 @@
+/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "uv.h"
+#include "task.h"
+
+
+static int timer_cb_called;
+
+
+static void timer_cb(uv_timer_t* timer) {
+ timer_cb_called++;
+ uv_close((uv_handle_t*) timer, NULL);
+}
+
+
+TEST_IMPL(default_loop_close) {
+ uv_loop_t* loop;
+ uv_timer_t timer_handle;
+
+ loop = uv_default_loop();
+ ASSERT(loop != NULL);
+
+ ASSERT(0 == uv_timer_init(loop, &timer_handle));
+ ASSERT(0 == uv_timer_start(&timer_handle, timer_cb, 1, 0));
+ ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT));
+ ASSERT(1 == timer_cb_called);
+ ASSERT(0 == uv_loop_close(loop));
+
+ loop = uv_default_loop();
+ ASSERT(loop != NULL);
+
+ ASSERT(0 == uv_timer_init(loop, &timer_handle));
+ ASSERT(0 == uv_timer_start(&timer_handle, timer_cb, 1, 0));
+ ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT));
+ ASSERT(2 == timer_cb_called);
+ ASSERT(0 == uv_loop_close(loop));
+
+ MAKE_VALGRIND_HAPPY();
+ return 0;
+}
diff --git a/deps/uv/test/test-fs.c b/deps/uv/test/test-fs.c
index 4c6ccfab2c..a06ddada8e 100644
--- a/deps/uv/test/test-fs.c
+++ b/deps/uv/test/test-fs.c
@@ -417,12 +417,16 @@ static void rmdir_cb(uv_fs_t* req) {
static void readdir_cb(uv_fs_t* req) {
+ uv_dirent_t dent;
ASSERT(req == &readdir_req);
ASSERT(req->fs_type == UV_FS_READDIR);
ASSERT(req->result == 2);
ASSERT(req->ptr);
- ASSERT(memcmp(req->ptr, "file1\0file2\0", 12) == 0
- || memcmp(req->ptr, "file2\0file1\0", 12) == 0);
+
+ while (UV_EOF != uv_fs_readdir_next(req, &dent)) {
+ ASSERT(strcmp(dent.name, "file1") == 0 || strcmp(dent.name, "file2") == 0);
+ ASSERT(dent.type == UV_DIRENT_FILE || dent.type == UV_DIRENT_UNKNOWN);
+ }
readdir_cb_count++;
ASSERT(req->path);
ASSERT(memcmp(req->path, "test_dir\0", 9) == 0);
@@ -802,6 +806,7 @@ TEST_IMPL(fs_file_write_null_buffer) {
TEST_IMPL(fs_async_dir) {
int r;
+ uv_dirent_t dent;
/* Setup */
unlink("test_dir/file1");
@@ -844,8 +849,10 @@ TEST_IMPL(fs_async_dir) {
ASSERT(r == 2);
ASSERT(readdir_req.result == 2);
ASSERT(readdir_req.ptr);
- ASSERT(memcmp(readdir_req.ptr, "file1\0file2\0", 12) == 0
- || memcmp(readdir_req.ptr, "file2\0file1\0", 12) == 0);
+ while (UV_EOF != uv_fs_readdir_next(&readdir_req, &dent)) {
+ ASSERT(strcmp(dent.name, "file1") == 0 || strcmp(dent.name, "file2") == 0);
+ ASSERT(dent.type == UV_DIRENT_FILE || dent.type == UV_DIRENT_UNKNOWN);
+ }
uv_fs_req_cleanup(&readdir_req);
ASSERT(!readdir_req.ptr);
@@ -1521,6 +1528,7 @@ TEST_IMPL(fs_symlink_dir) {
uv_fs_t req;
int r;
char* test_dir;
+ uv_dirent_t dent;
/* set-up */
unlink("test_dir/file1");
@@ -1597,8 +1605,10 @@ TEST_IMPL(fs_symlink_dir) {
ASSERT(r == 2);
ASSERT(readdir_req.result == 2);
ASSERT(readdir_req.ptr);
- ASSERT(memcmp(readdir_req.ptr, "file1\0file2\0", 12) == 0
- || memcmp(readdir_req.ptr, "file2\0file1\0", 12) == 0);
+ while (UV_EOF != uv_fs_readdir_next(&readdir_req, &dent)) {
+ ASSERT(strcmp(dent.name, "file1") == 0 || strcmp(dent.name, "file2") == 0);
+ ASSERT(dent.type == UV_DIRENT_FILE || dent.type == UV_DIRENT_UNKNOWN);
+ }
uv_fs_req_cleanup(&readdir_req);
ASSERT(!readdir_req.ptr);
@@ -1615,8 +1625,10 @@ TEST_IMPL(fs_symlink_dir) {
ASSERT(r == 2);
ASSERT(readdir_req.result == 2);
ASSERT(readdir_req.ptr);
- ASSERT(memcmp(readdir_req.ptr, "file1\0file2\0", 12) == 0
- || memcmp(readdir_req.ptr, "file2\0file1\0", 12) == 0);
+ while (UV_EOF != uv_fs_readdir_next(&readdir_req, &dent)) {
+ ASSERT(strcmp(dent.name, "file1") == 0 || strcmp(dent.name, "file2") == 0);
+ ASSERT(dent.type == UV_DIRENT_FILE || dent.type == UV_DIRENT_UNKNOWN);
+ }
uv_fs_req_cleanup(&readdir_req);
ASSERT(!readdir_req.ptr);
diff --git a/deps/uv/test/test-handle-fileno.c b/deps/uv/test/test-handle-fileno.c
new file mode 100644
index 0000000000..df5e984ab7
--- /dev/null
+++ b/deps/uv/test/test-handle-fileno.c
@@ -0,0 +1,120 @@
+/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "uv.h"
+#include "task.h"
+
+
+static int get_tty_fd(void) {
+ /* Make sure we have an FD that refers to a tty */
+#ifdef _WIN32
+ HANDLE handle;
+ handle = CreateFileA("conout$",
+ GENERIC_READ | GENERIC_WRITE,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ NULL,
+ OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+ if (handle == INVALID_HANDLE_VALUE)
+ return -1;
+ return _open_osfhandle((intptr_t) handle, 0);
+#else /* unix */
+ return open("/dev/tty", O_RDONLY, 0);
+#endif
+}
+
+
+TEST_IMPL(handle_fileno) {
+ int r;
+ int tty_fd;
+ struct sockaddr_in addr;
+ uv_os_fd_t fd;
+ uv_tcp_t tcp;
+ uv_udp_t udp;
+ uv_pipe_t pipe;
+ uv_tty_t tty;
+ uv_idle_t idle;
+ uv_loop_t* loop;
+
+ loop = uv_default_loop();
+ ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr));
+
+ r = uv_idle_init(loop, &idle);
+ ASSERT(r == 0);
+ r = uv_fileno((uv_handle_t*) &idle, &fd);
+ ASSERT(r == UV_EINVAL);
+ uv_close((uv_handle_t*) &idle, NULL);
+
+ r = uv_tcp_init(loop, &tcp);
+ ASSERT(r == 0);
+ r = uv_fileno((uv_handle_t*) &tcp, &fd);
+ ASSERT(r == UV_EBADF);
+ r = uv_tcp_bind(&tcp, (const struct sockaddr*) &addr, 0);
+ ASSERT(r == 0);
+ r = uv_fileno((uv_handle_t*) &tcp, &fd);
+ ASSERT(r == 0);
+ uv_close((uv_handle_t*) &tcp, NULL);
+ r = uv_fileno((uv_handle_t*) &tcp, &fd);
+ ASSERT(r == UV_EBADF);
+
+ r = uv_udp_init(loop, &udp);
+ ASSERT(r == 0);
+ r = uv_fileno((uv_handle_t*) &udp, &fd);
+ ASSERT(r == UV_EBADF);
+ r = uv_udp_bind(&udp, (const struct sockaddr*) &addr, 0);
+ ASSERT(r == 0);
+ r = uv_fileno((uv_handle_t*) &udp, &fd);
+ ASSERT(r == 0);
+ uv_close((uv_handle_t*) &udp, NULL);
+ r = uv_fileno((uv_handle_t*) &udp, &fd);
+ ASSERT(r == UV_EBADF);
+
+ r = uv_pipe_init(loop, &pipe, 0);
+ ASSERT(r == 0);
+ r = uv_fileno((uv_handle_t*) &pipe, &fd);
+ ASSERT(r == UV_EBADF);
+ r = uv_pipe_bind(&pipe, TEST_PIPENAME);
+ ASSERT(r == 0);
+ r = uv_fileno((uv_handle_t*) &pipe, &fd);
+ ASSERT(r == 0);
+ uv_close((uv_handle_t*) &pipe, NULL);
+ r = uv_fileno((uv_handle_t*) &pipe, &fd);
+ ASSERT(r == UV_EBADF);
+
+ tty_fd = get_tty_fd();
+ if (tty_fd < 0) {
+ LOGF("Cannot open a TTY fd");
+ } else {
+ r = uv_tty_init(loop, &tty, tty_fd, 0);
+ ASSERT(r == 0);
+ r = uv_fileno((uv_handle_t*) &tty, &fd);
+ ASSERT(r == 0);
+ uv_close((uv_handle_t*) &tty, NULL);
+ r = uv_fileno((uv_handle_t*) &tty, &fd);
+ ASSERT(r == UV_EBADF);
+ }
+
+ uv_run(loop, UV_RUN_DEFAULT);
+
+ MAKE_VALGRIND_HAPPY();
+ return 0;
+}
diff --git a/deps/uv/test/test-list.h b/deps/uv/test/test-list.h
index 6dbe22307e..9cb65c393f 100644
--- a/deps/uv/test/test-list.h
+++ b/deps/uv/test/test-list.h
@@ -29,6 +29,7 @@ TEST_DECLARE (loop_close)
TEST_DECLARE (loop_stop)
TEST_DECLARE (loop_update_time)
TEST_DECLARE (loop_backend_timeout)
+TEST_DECLARE (default_loop_close)
TEST_DECLARE (barrier_1)
TEST_DECLARE (barrier_2)
TEST_DECLARE (barrier_3)
@@ -55,6 +56,9 @@ TEST_DECLARE (tcp_ping_pong_v6)
TEST_DECLARE (pipe_ping_pong)
TEST_DECLARE (delayed_accept)
TEST_DECLARE (multiple_listen)
+#ifndef _WIN32
+TEST_DECLARE (tcp_write_after_connect)
+#endif
TEST_DECLARE (tcp_writealot)
TEST_DECLARE (tcp_try_write)
TEST_DECLARE (tcp_write_queue_order)
@@ -89,6 +93,7 @@ TEST_DECLARE (udp_bind)
TEST_DECLARE (udp_bind_reuseaddr)
TEST_DECLARE (udp_send_and_recv)
TEST_DECLARE (udp_send_immediate)
+TEST_DECLARE (udp_send_unreachable)
TEST_DECLARE (udp_multicast_join)
TEST_DECLARE (udp_multicast_join6)
TEST_DECLARE (udp_multicast_ttl)
@@ -109,6 +114,7 @@ TEST_DECLARE (pipe_connect_bad_name)
TEST_DECLARE (pipe_connect_to_file)
TEST_DECLARE (pipe_getsockname)
TEST_DECLARE (pipe_getsockname_abstract)
+TEST_DECLARE (pipe_getsockname_blocking)
TEST_DECLARE (pipe_sendmsg)
TEST_DECLARE (pipe_server_close)
TEST_DECLARE (connection_fail)
@@ -128,6 +134,7 @@ TEST_DECLARE (timer_huge_timeout)
TEST_DECLARE (timer_huge_repeat)
TEST_DECLARE (timer_run_once)
TEST_DECLARE (timer_from_check)
+TEST_DECLARE (timer_null_callback)
TEST_DECLARE (idle_starvation)
TEST_DECLARE (loop_handles)
TEST_DECLARE (get_loadavg)
@@ -155,6 +162,9 @@ TEST_DECLARE (pipe_ref)
TEST_DECLARE (pipe_ref2)
TEST_DECLARE (pipe_ref3)
TEST_DECLARE (pipe_ref4)
+#ifndef _WIN32
+TEST_DECLARE (pipe_close_stdout_read_stdin)
+#endif
TEST_DECLARE (process_ref)
TEST_DECLARE (has_ref)
TEST_DECLARE (active)
@@ -165,6 +175,7 @@ TEST_DECLARE (get_currentexe)
TEST_DECLARE (process_title)
TEST_DECLARE (cwd_and_chdir)
TEST_DECLARE (get_memory)
+TEST_DECLARE (handle_fileno)
TEST_DECLARE (hrtime)
TEST_DECLARE (getaddrinfo_fail)
TEST_DECLARE (getaddrinfo_basic)
@@ -175,6 +186,7 @@ TEST_DECLARE (getsockname_tcp)
TEST_DECLARE (getsockname_udp)
TEST_DECLARE (fail_always)
TEST_DECLARE (pass_always)
+TEST_DECLARE (socket_buffer_size)
TEST_DECLARE (spawn_fails)
TEST_DECLARE (spawn_exit_code)
TEST_DECLARE (spawn_stdout)
@@ -275,6 +287,7 @@ TEST_DECLARE (closed_fd_events)
#endif
#ifdef __APPLE__
TEST_DECLARE (osx_select)
+TEST_DECLARE (osx_select_many_fds)
#endif
HELPER_DECLARE (tcp4_echo_server)
HELPER_DECLARE (tcp6_echo_server)
@@ -296,6 +309,7 @@ TASK_LIST_START
TEST_ENTRY (loop_stop)
TEST_ENTRY (loop_update_time)
TEST_ENTRY (loop_backend_timeout)
+ TEST_ENTRY (default_loop_close)
TEST_ENTRY (barrier_1)
TEST_ENTRY (barrier_2)
TEST_ENTRY (barrier_3)
@@ -312,6 +326,9 @@ TASK_LIST_START
TEST_ENTRY (pipe_connect_to_file)
TEST_ENTRY (pipe_server_close)
+#ifndef _WIN32
+ TEST_ENTRY (pipe_close_stdout_read_stdin)
+#endif
TEST_ENTRY (tty)
TEST_ENTRY (stdio_over_pipes)
TEST_ENTRY (ip6_pton)
@@ -335,6 +352,10 @@ TASK_LIST_START
TEST_ENTRY (delayed_accept)
TEST_ENTRY (multiple_listen)
+#ifndef _WIN32
+ TEST_ENTRY (tcp_write_after_connect)
+#endif
+
TEST_ENTRY (tcp_writealot)
TEST_HELPER (tcp_writealot, tcp4_echo_server)
@@ -381,6 +402,7 @@ TASK_LIST_START
TEST_ENTRY (udp_bind_reuseaddr)
TEST_ENTRY (udp_send_and_recv)
TEST_ENTRY (udp_send_immediate)
+ TEST_ENTRY (udp_send_unreachable)
TEST_ENTRY (udp_dgram_too_big)
TEST_ENTRY (udp_dual_stack)
TEST_ENTRY (udp_ipv6_only)
@@ -402,6 +424,7 @@ TASK_LIST_START
TEST_ENTRY (pipe_listen_without_bind)
TEST_ENTRY (pipe_getsockname)
TEST_ENTRY (pipe_getsockname_abstract)
+ TEST_ENTRY (pipe_getsockname_blocking)
TEST_ENTRY (pipe_sendmsg)
TEST_ENTRY (connection_fail)
@@ -432,6 +455,7 @@ TASK_LIST_START
TEST_ENTRY (timer_huge_repeat)
TEST_ENTRY (timer_run_once)
TEST_ENTRY (timer_from_check)
+ TEST_ENTRY (timer_null_callback)
TEST_ENTRY (idle_starvation)
@@ -487,6 +511,8 @@ TASK_LIST_START
TEST_ENTRY (get_loadavg)
+ TEST_ENTRY (handle_fileno)
+
TEST_ENTRY (hrtime)
TEST_ENTRY_CUSTOM (getaddrinfo_fail, 0, 0, 10000)
@@ -504,6 +530,8 @@ TASK_LIST_START
TEST_ENTRY (poll_unidirectional)
TEST_ENTRY (poll_close)
+ TEST_ENTRY (socket_buffer_size)
+
TEST_ENTRY (spawn_fails)
TEST_ENTRY (spawn_exit_code)
TEST_ENTRY (spawn_stdout)
@@ -549,6 +577,7 @@ TASK_LIST_START
#ifdef __APPLE__
TEST_ENTRY (osx_select)
+ TEST_ENTRY (osx_select_many_fds)
#endif
TEST_ENTRY (fs_file_noent)
diff --git a/deps/uv/test/test-osx-select.c b/deps/uv/test/test-osx-select.c
index e5e1bf8b46..68e5a84167 100644
--- a/deps/uv/test/test-osx-select.c
+++ b/deps/uv/test/test-osx-select.c
@@ -79,4 +79,52 @@ TEST_IMPL(osx_select) {
return 0;
}
+
+TEST_IMPL(osx_select_many_fds) {
+ int r;
+ int fd;
+ size_t i;
+ size_t len;
+ const char* str;
+ struct sockaddr_in addr;
+ uv_tty_t tty;
+ uv_tcp_t tcps[1500];
+
+ r = uv_ip4_addr("127.0.0.1", 0, &addr);
+ ASSERT(r == 0);
+
+ for (i = 0; i < ARRAY_SIZE(tcps); i++) {
+ r = uv_tcp_init(uv_default_loop(), &tcps[i]);
+ ASSERT(r == 0);
+ r = uv_tcp_bind(&tcps[i], (const struct sockaddr *) &addr, 0);
+ ASSERT(r == 0);
+ uv_unref((uv_handle_t*) &tcps[i]);
+ }
+
+ fd = open("/dev/tty", O_RDONLY);
+ ASSERT(fd >= 0);
+
+ r = uv_tty_init(uv_default_loop(), &tty, fd, 1);
+ ASSERT(r == 0);
+
+ r = uv_read_start((uv_stream_t*) &tty, alloc_cb, read_cb);
+ ASSERT(r == 0);
+
+ /* Emulate user-input */
+ str = "got some input\n"
+ "with a couple of lines\n"
+ "feel pretty happy\n";
+ for (i = 0, len = strlen(str); i < len; i++) {
+ r = ioctl(fd, TIOCSTI, str + i);
+ ASSERT(r == 0);
+ }
+
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
+
+ ASSERT(read_count == 3);
+
+ MAKE_VALGRIND_HAPPY();
+ return 0;
+}
+
#endif /* __APPLE__ */
diff --git a/deps/uv/test/test-pipe-close-stdout-read-stdin.c b/deps/uv/test/test-pipe-close-stdout-read-stdin.c
new file mode 100644
index 0000000000..26a1ee76c9
--- /dev/null
+++ b/deps/uv/test/test-pipe-close-stdout-read-stdin.c
@@ -0,0 +1,103 @@
+/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#ifndef _WIN32
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/wait.h>
+#include <sys/types.h>
+
+#include "uv.h"
+#include "task.h"
+
+void alloc_buffer(uv_handle_t *handle, size_t suggested_size, uv_buf_t* buf)
+{
+ static char buffer[1024];
+
+ buf->base = buffer;
+ buf->len = sizeof(buffer);
+}
+
+void read_stdin(uv_stream_t *stream, ssize_t nread, const uv_buf_t* buf)
+{
+ if (nread < 0) {
+ uv_close((uv_handle_t*)stream, NULL);
+ return;
+ }
+}
+
+/*
+ * This test is a reproduction of joyent/libuv#1419 .
+ */
+TEST_IMPL(pipe_close_stdout_read_stdin) {
+ int r = -1;
+ int pid;
+ int fd[2];
+ int status;
+
+ pipe(fd);
+
+ if ((pid = fork()) == 0) {
+ /*
+ * Make the read side of the pipe our stdin.
+ * The write side will be closed by the parent process.
+ */
+ close(fd[1]);
+ close(0);
+ dup(fd[0]);
+
+ /* Create a stream that reads from the pipe. */
+ uv_pipe_t stdin_pipe;
+
+ r = uv_pipe_init(uv_default_loop(), (uv_pipe_t *)&stdin_pipe, 0);
+ ASSERT(r == 0);
+
+ r = uv_pipe_open((uv_pipe_t *)&stdin_pipe, 0);
+ ASSERT(r == 0);
+
+ r = uv_read_start((uv_stream_t *)&stdin_pipe, alloc_buffer, read_stdin);
+ ASSERT(r == 0);
+
+ /*
+ * Because the other end of the pipe was closed, there should
+ * be no event left to process after one run of the event loop.
+ * Otherwise, it means that events were not processed correctly.
+ */
+ ASSERT(uv_run(uv_default_loop(), UV_RUN_NOWAIT) == 0);
+ } else {
+ /*
+ * Close both ends of the pipe so that the child
+ * get a POLLHUP event when it tries to read from
+ * the other end.
+ */
+ close(fd[1]);
+ close(fd[0]);
+
+ waitpid(pid, &status, 0);
+ ASSERT(WIFEXITED(status) && WEXITSTATUS(status) == 0);
+ }
+
+ MAKE_VALGRIND_HAPPY();
+ return 0;
+}
+
+#endif /* ifndef _WIN32 */
diff --git a/deps/uv/test/test-pipe-getsockname.c b/deps/uv/test/test-pipe-getsockname.c
index 396f72577d..d4010f3b50 100644
--- a/deps/uv/test/test-pipe-getsockname.c
+++ b/deps/uv/test/test-pipe-getsockname.c
@@ -32,6 +32,8 @@
#ifndef _WIN32
# include <unistd.h> /* close */
+#else
+# include <fcntl.h>
#endif
@@ -120,3 +122,59 @@ TEST_IMPL(pipe_getsockname_abstract) {
#endif
}
+TEST_IMPL(pipe_getsockname_blocking) {
+#ifdef _WIN32
+ uv_pipe_t reader;
+ HANDLE readh, writeh;
+ int readfd;
+ char buf1[1024], buf2[1024];
+ size_t len1, len2;
+ int r;
+
+ r = CreatePipe(&readh, &writeh, NULL, 65536);
+ ASSERT(r != 0);
+
+ r = uv_pipe_init(uv_default_loop(), &reader, 0);
+ ASSERT(r == 0);
+ readfd = _open_osfhandle((intptr_t)readh, _O_RDONLY);
+ ASSERT(r != -1);
+ r = uv_pipe_open(&reader, readfd);
+ ASSERT(r == 0);
+ r = uv_read_start((uv_stream_t*)&reader, NULL, NULL);
+ ASSERT(r == 0);
+ Sleep(100);
+ r = uv_read_stop((uv_stream_t*)&reader);
+ ASSERT(r == 0);
+
+ len1 = sizeof buf1;
+ r = uv_pipe_getsockname(&reader, buf1, &len1);
+ ASSERT(r == 0);
+
+ r = uv_read_start((uv_stream_t*)&reader, NULL, NULL);
+ ASSERT(r == 0);
+ Sleep(100);
+
+ len2 = sizeof buf2;
+ r = uv_pipe_getsockname(&reader, buf2, &len2);
+ ASSERT(r == 0);
+
+ r = uv_read_stop((uv_stream_t*)&reader);
+ ASSERT(r == 0);
+
+ ASSERT(len1 == len2);
+ ASSERT(memcmp(buf1, buf2, len1) == 0);
+
+ close_cb_called = 0;
+ uv_close((uv_handle_t*)&reader, close_cb);
+
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
+
+ ASSERT(close_cb_called == 1);
+
+ _close(readfd);
+ CloseHandle(writeh);
+#endif
+
+ MAKE_VALGRIND_HAPPY();
+ return 0;
+}
diff --git a/deps/uv/test/test-socket-buffer-size.c b/deps/uv/test/test-socket-buffer-size.c
new file mode 100644
index 0000000000..72f8c2524c
--- /dev/null
+++ b/deps/uv/test/test-socket-buffer-size.c
@@ -0,0 +1,77 @@
+/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "uv.h"
+#include "task.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static uv_udp_t udp;
+static uv_tcp_t tcp;
+static int close_cb_called;
+
+
+static void close_cb(uv_handle_t* handle) {
+ close_cb_called++;
+}
+
+
+static void check_buffer_size(uv_handle_t* handle) {
+ int value;
+
+ value = 0;
+ ASSERT(0 == uv_recv_buffer_size(handle, &value));
+ ASSERT(value > 0);
+
+ value = 10000;
+ ASSERT(0 == uv_recv_buffer_size(handle, &value));
+
+ value = 0;
+ ASSERT(0 == uv_recv_buffer_size(handle, &value));
+ /* linux sets double the value */
+ ASSERT(value == 10000 || value == 20000);
+}
+
+
+TEST_IMPL(socket_buffer_size) {
+ struct sockaddr_in addr;
+
+ ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr));
+
+ ASSERT(0 == uv_tcp_init(uv_default_loop(), &tcp));
+ ASSERT(0 == uv_tcp_bind(&tcp, (struct sockaddr*) &addr, 0));
+ check_buffer_size((uv_handle_t*) &tcp);
+ uv_close((uv_handle_t*) &tcp, close_cb);
+
+ ASSERT(0 == uv_udp_init(uv_default_loop(), &udp));
+ ASSERT(0 == uv_udp_bind(&udp, (struct sockaddr*) &addr, 0));
+ check_buffer_size((uv_handle_t*) &udp);
+ uv_close((uv_handle_t*) &udp, close_cb);
+
+ ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT));
+
+ ASSERT(close_cb_called == 2);
+
+ MAKE_VALGRIND_HAPPY();
+ return 0;
+}
diff --git a/deps/uv/test/test-spawn.c b/deps/uv/test/test-spawn.c
index 57f0862f94..11f43bdf13 100644
--- a/deps/uv/test/test-spawn.c
+++ b/deps/uv/test/test-spawn.c
@@ -1295,23 +1295,25 @@ TEST_IMPL(closed_fd_events) {
TEST_IMPL(spawn_reads_child_path) {
int r;
int len;
+ char file[64];
char path[1024];
char *env[2] = {path, NULL};
/* Set up the process, but make sure that the file to run is relative and */
/* requires a lookup into PATH */
init_process_options("spawn_helper1", exit_cb);
- options.file = "run-tests";
- args[0] = "run-tests";
/* Set up the PATH env variable */
for (len = strlen(exepath);
exepath[len - 1] != '/' && exepath[len - 1] != '\\';
len--);
+ strcpy(file, exepath + len);
exepath[len] = 0;
strcpy(path, "PATH=");
strcpy(path + 5, exepath);
+ options.file = file;
+ options.args[0] = file;
options.env = env;
r = uv_spawn(uv_default_loop(), &process, &options);
diff --git a/deps/uv/test/test-tcp-write-after-connect.c b/deps/uv/test/test-tcp-write-after-connect.c
new file mode 100644
index 0000000000..aa03228f13
--- /dev/null
+++ b/deps/uv/test/test-tcp-write-after-connect.c
@@ -0,0 +1,68 @@
+/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#ifndef _WIN32
+
+#include "uv.h"
+#include "task.h"
+
+uv_loop_t loop;
+uv_tcp_t tcp_client;
+uv_connect_t connection_request;
+uv_write_t write_request;
+uv_buf_t buf = { "HELLO", 4 };
+
+
+static void write_cb(uv_write_t *req, int status) {
+ ASSERT(status == UV_ECANCELED);
+ uv_close((uv_handle_t*) req->handle, NULL);
+}
+
+
+static void connect_cb(uv_connect_t *req, int status) {
+ ASSERT(status == UV_ECONNREFUSED);
+}
+
+
+TEST_IMPL(tcp_write_after_connect) {
+ struct sockaddr_in sa;
+ ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &sa));
+ ASSERT(0 == uv_loop_init(&loop));
+ ASSERT(0 == uv_tcp_init(&loop, &tcp_client));
+
+ ASSERT(0 == uv_tcp_connect(&connection_request,
+ &tcp_client,
+ (const struct sockaddr *)
+ &sa,
+ connect_cb));
+
+ ASSERT(0 == uv_write(&write_request,
+ (uv_stream_t *)&tcp_client,
+ &buf, 1,
+ write_cb));
+
+ uv_run(&loop, UV_RUN_DEFAULT);
+
+ MAKE_VALGRIND_HAPPY();
+ return 0;
+}
+
+#endif
diff --git a/deps/uv/test/test-tcp-write-queue-order.c b/deps/uv/test/test-tcp-write-queue-order.c
index 18e1f192b6..aa4d2acc24 100644
--- a/deps/uv/test/test-tcp-write-queue-order.c
+++ b/deps/uv/test/test-tcp-write-queue-order.c
@@ -26,7 +26,7 @@
#include "uv.h"
#include "task.h"
-#define REQ_COUNT 100000
+#define REQ_COUNT 10000
static uv_timer_t timer;
static uv_tcp_t server;
diff --git a/deps/uv/test/test-timer.c b/deps/uv/test/test-timer.c
index f26dae577f..aba050fd64 100644
--- a/deps/uv/test/test-timer.c
+++ b/deps/uv/test/test-timer.c
@@ -290,3 +290,14 @@ TEST_IMPL(timer_run_once) {
MAKE_VALGRIND_HAPPY();
return 0;
}
+
+
+TEST_IMPL(timer_null_callback) {
+ uv_timer_t handle;
+
+ ASSERT(0 == uv_timer_init(uv_default_loop(), &handle));
+ ASSERT(UV_EINVAL == uv_timer_start(&handle, NULL, 100, 100));
+
+ MAKE_VALGRIND_HAPPY();
+ return 0;
+}
diff --git a/deps/uv/test/test-udp-ipv6.c b/deps/uv/test/test-udp-ipv6.c
index 0e2fe2dcf2..0ca9f4dcff 100644
--- a/deps/uv/test/test-udp-ipv6.c
+++ b/deps/uv/test/test-udp-ipv6.c
@@ -147,12 +147,19 @@ static void do_test(uv_udp_recv_cb recv_cb, int bind_flags) {
TEST_IMPL(udp_dual_stack) {
+#if defined(__DragonFly__) || \
+ defined(__FreeBSD__) || \
+ defined(__OpenBSD__) || \
+ defined(__NetBSD__)
+ RETURN_SKIP("dual stack not enabled by default in this OS.");
+#else
do_test(ipv6_recv_ok, 0);
ASSERT(recv_cb_called == 1);
ASSERT(send_cb_called == 1);
return 0;
+#endif
}
diff --git a/deps/uv/test/test-udp-multicast-interface6.c b/deps/uv/test/test-udp-multicast-interface6.c
index e58d771197..e54e738b0b 100644
--- a/deps/uv/test/test-udp-multicast-interface6.c
+++ b/deps/uv/test/test-udp-multicast-interface6.c
@@ -69,7 +69,7 @@ TEST_IMPL(udp_multicast_interface6) {
r = uv_udp_bind(&server, (const struct sockaddr*)&baddr, 0);
ASSERT(r == 0);
-#if defined(__APPLE__)
+#if defined(__APPLE__) || defined(__FreeBSD__)
r = uv_udp_set_multicast_interface(&server, "::1%lo0");
#else
r = uv_udp_set_multicast_interface(&server, NULL);
diff --git a/deps/uv/test/test-udp-send-unreachable.c b/deps/uv/test/test-udp-send-unreachable.c
new file mode 100644
index 0000000000..c6500320d7
--- /dev/null
+++ b/deps/uv/test/test-udp-send-unreachable.c
@@ -0,0 +1,150 @@
+/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "uv.h"
+#include "task.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define CHECK_HANDLE(handle) \
+ ASSERT((uv_udp_t*)(handle) == &client)
+
+static uv_udp_t client;
+static uv_timer_t timer;
+
+static int send_cb_called;
+static int recv_cb_called;
+static int close_cb_called;
+static int alloc_cb_called;
+static int timer_cb_called;
+
+
+static void alloc_cb(uv_handle_t* handle,
+ size_t suggested_size,
+ uv_buf_t* buf) {
+ static char slab[65536];
+ CHECK_HANDLE(handle);
+ ASSERT(suggested_size <= sizeof(slab));
+ buf->base = slab;
+ buf->len = sizeof(slab);
+ alloc_cb_called++;
+}
+
+
+static void close_cb(uv_handle_t* handle) {
+ ASSERT(1 == uv_is_closing(handle));
+ close_cb_called++;
+}
+
+
+static void send_cb(uv_udp_send_t* req, int status) {
+ ASSERT(req != NULL);
+ ASSERT(status == 0);
+ CHECK_HANDLE(req->handle);
+ send_cb_called++;
+}
+
+
+static void recv_cb(uv_udp_t* handle,
+ ssize_t nread,
+ const uv_buf_t* rcvbuf,
+ const struct sockaddr* addr,
+ unsigned flags) {
+ CHECK_HANDLE(handle);
+ recv_cb_called++;
+
+ if (nread < 0) {
+ ASSERT(0 && "unexpected error");
+ } else if (nread == 0) {
+ /* Returning unused buffer */
+ ASSERT(addr == NULL);
+ } else {
+ ASSERT(addr != NULL);
+ }
+}
+
+
+static void timer_cb(uv_timer_t* h) {
+ ASSERT(h == &timer);
+ timer_cb_called++;
+ uv_close((uv_handle_t*) &client, close_cb);
+ uv_close((uv_handle_t*) h, close_cb);
+}
+
+
+TEST_IMPL(udp_send_unreachable) {
+ struct sockaddr_in addr;
+ struct sockaddr_in addr2;
+ uv_udp_send_t req1, req2;
+ uv_buf_t buf;
+ int r;
+
+ ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr));
+ ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT_2, &addr2));
+
+ r = uv_timer_init( uv_default_loop(), &timer );
+ ASSERT(r == 0);
+
+ r = uv_timer_start( &timer, timer_cb, 1000, 0 );
+ ASSERT(r == 0);
+
+ r = uv_udp_init(uv_default_loop(), &client);
+ ASSERT(r == 0);
+
+ r = uv_udp_bind(&client, (const struct sockaddr*) &addr2, 0);
+ ASSERT(r == 0);
+
+ r = uv_udp_recv_start(&client, alloc_cb, recv_cb);
+ ASSERT(r == 0);
+
+ /* client sends "PING", then "PANG" */
+ buf = uv_buf_init("PING", 4);
+
+ r = uv_udp_send(&req1,
+ &client,
+ &buf,
+ 1,
+ (const struct sockaddr*) &addr,
+ send_cb);
+ ASSERT(r == 0);
+
+ buf = uv_buf_init("PANG", 4);
+
+ r = uv_udp_send(&req2,
+ &client,
+ &buf,
+ 1,
+ (const struct sockaddr*) &addr,
+ send_cb);
+ ASSERT(r == 0);
+
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
+
+ ASSERT(send_cb_called == 2);
+ ASSERT(recv_cb_called == alloc_cb_called);
+ ASSERT(timer_cb_called == 1);
+ ASSERT(close_cb_called == 2);
+
+ MAKE_VALGRIND_HAPPY();
+ return 0;
+}
diff --git a/deps/uv/test/test-watcher-cross-stop.c b/deps/uv/test/test-watcher-cross-stop.c
index bf765cb00c..910ed0fb61 100644
--- a/deps/uv/test/test-watcher-cross-stop.c
+++ b/deps/uv/test/test-watcher-cross-stop.c
@@ -92,10 +92,10 @@ TEST_IMPL(watcher_cross_stop) {
uv_close((uv_handle_t*) &sockets[i], close_cb);
ASSERT(recv_cb_called > 0);
- ASSERT(ARRAY_SIZE(sockets) == send_cb_called);
uv_run(loop, UV_RUN_DEFAULT);
+ ASSERT(ARRAY_SIZE(sockets) == send_cb_called);
ASSERT(ARRAY_SIZE(sockets) == close_cb_called);
MAKE_VALGRIND_HAPPY();