summaryrefslogtreecommitdiff
path: root/deps/uv/test
diff options
context:
space:
mode:
authorSaúl Ibarra Corretgé <saghul@gmail.com>2015-02-09 21:16:26 +0100
committerBen Noordhuis <info@bnoordhuis.nl>2015-02-09 22:07:25 +0100
commit9681fcacf0fd477f999a52f6ff4151d4125d49d0 (patch)
treeb8a3a583daacf82af5b5298961e145b836fa8bfb /deps/uv/test
parent5e825d1073b57a87fc9a77751ed3e21c86970082 (diff)
downloadandroid-node-v8-9681fcacf0fd477f999a52f6ff4151d4125d49d0.tar.gz
android-node-v8-9681fcacf0fd477f999a52f6ff4151d4125d49d0.tar.bz2
android-node-v8-9681fcacf0fd477f999a52f6ff4151d4125d49d0.zip
deps: update libuv to 1.4.0
PR-URL: https://github.com/iojs/io.js/pull/773 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'deps/uv/test')
-rw-r--r--deps/uv/test/test-list.h2
-rw-r--r--deps/uv/test/test-pipe-set-non-blocking.c99
-rw-r--r--deps/uv/test/test-spawn.c2
3 files changed, 102 insertions, 1 deletions
diff --git a/deps/uv/test/test-list.h b/deps/uv/test/test-list.h
index d00d0f2621..9eb6a38dcd 100644
--- a/deps/uv/test/test-list.h
+++ b/deps/uv/test/test-list.h
@@ -167,6 +167,7 @@ TEST_DECLARE (pipe_ref4)
#ifndef _WIN32
TEST_DECLARE (pipe_close_stdout_read_stdin)
#endif
+TEST_DECLARE (pipe_set_non_blocking)
TEST_DECLARE (process_ref)
TEST_DECLARE (has_ref)
TEST_DECLARE (active)
@@ -339,6 +340,7 @@ TASK_LIST_START
#ifndef _WIN32
TEST_ENTRY (pipe_close_stdout_read_stdin)
#endif
+ TEST_ENTRY (pipe_set_non_blocking)
TEST_ENTRY (tty)
TEST_ENTRY (stdio_over_pipes)
TEST_ENTRY (ip6_pton)
diff --git a/deps/uv/test/test-pipe-set-non-blocking.c b/deps/uv/test/test-pipe-set-non-blocking.c
new file mode 100644
index 0000000000..5cf2c19e7f
--- /dev/null
+++ b/deps/uv/test/test-pipe-set-non-blocking.c
@@ -0,0 +1,99 @@
+/* Copyright (c) 2015, Ben Noordhuis <info@bnoordhuis.nl>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include "uv.h"
+#include "task.h"
+
+#ifdef _WIN32
+
+TEST_IMPL(pipe_set_non_blocking) {
+ RETURN_SKIP("Test not implemented on Windows.");
+}
+
+#else /* !_WIN32 */
+
+#include <errno.h>
+#include <string.h>
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <sys/un.h>
+#include <unistd.h>
+
+struct thread_ctx {
+ uv_barrier_t barrier;
+ int fd;
+};
+
+static void thread_main(void* arg) {
+ struct thread_ctx* ctx;
+ char buf[4096];
+ ssize_t n;
+
+ ctx = arg;
+ uv_barrier_wait(&ctx->barrier);
+
+ do
+ n = read(ctx->fd, buf, sizeof(buf));
+ while (n > 0 || (n == -1 && errno == EINTR));
+
+ ASSERT(n == 0);
+}
+
+TEST_IMPL(pipe_set_non_blocking) {
+ struct thread_ctx ctx;
+ uv_pipe_t pipe_handle;
+ uv_thread_t thread;
+ size_t nwritten;
+ char data[4096];
+ uv_buf_t buf;
+ int fd[2];
+ int n;
+
+ ASSERT(0 == uv_pipe_init(uv_default_loop(), &pipe_handle, 0));
+ ASSERT(0 == socketpair(AF_UNIX, SOCK_STREAM, 0, fd));
+ ASSERT(0 == uv_pipe_open(&pipe_handle, fd[0]));
+ ASSERT(0 == uv_stream_set_blocking((uv_stream_t*) &pipe_handle, 1));
+
+ ctx.fd = fd[1];
+ ASSERT(0 == uv_barrier_init(&ctx.barrier, 2));
+ ASSERT(0 == uv_thread_create(&thread, thread_main, &ctx));
+ uv_barrier_wait(&ctx.barrier);
+
+ buf.len = sizeof(data);
+ buf.base = data;
+ memset(data, '.', sizeof(data));
+
+ nwritten = 0;
+ while (nwritten < 10 << 20) {
+ /* The stream is in blocking mode so uv_try_write() should always succeed
+ * with the exact number of bytes that we wanted written.
+ */
+ n = uv_try_write((uv_stream_t*) &pipe_handle, &buf, 1);
+ ASSERT(n == sizeof(data));
+ nwritten += n;
+ }
+
+ uv_close((uv_handle_t*) &pipe_handle, NULL);
+ ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT));
+
+ ASSERT(0 == close(fd[1])); /* fd[0] is closed by uv_close(). */
+ ASSERT(0 == uv_thread_join(&thread));
+ uv_barrier_destroy(&ctx.barrier);
+
+ MAKE_VALGRIND_HAPPY();
+ return 0;
+}
+
+#endif /* !_WIN32 */
diff --git a/deps/uv/test/test-spawn.c b/deps/uv/test/test-spawn.c
index d3c0693b68..9b0030029c 100644
--- a/deps/uv/test/test-spawn.c
+++ b/deps/uv/test/test-spawn.c
@@ -1015,7 +1015,7 @@ TEST_IMPL(spawn_with_an_odd_path) {
char *path = getenv("PATH");
ASSERT(path != NULL);
snprintf(newpath, 2048, ";.;%s", path);
- SetEnvironmentVariable("PATH", path);
+ SetEnvironmentVariable("PATH", newpath);
init_process_options("", exit_cb);
options.file = options.args[0] = "program-that-had-better-not-exist";