aboutsummaryrefslogtreecommitdiff
path: root/deps/uv/test
diff options
context:
space:
mode:
Diffstat (limited to 'deps/uv/test')
-rw-r--r--deps/uv/test/runner-win.c1
-rw-r--r--deps/uv/test/test-dlerror.c2
-rw-r--r--deps/uv/test/test-fs-copyfile.c150
-rw-r--r--deps/uv/test/test-fs.c111
-rw-r--r--deps/uv/test/test-list.h20
-rw-r--r--deps/uv/test/test-poll-oob.c205
-rw-r--r--deps/uv/test/test-spawn.c32
-rw-r--r--deps/uv/test/test-tcp-oob.c13
-rw-r--r--deps/uv/test/test-tcp-open.c57
9 files changed, 585 insertions, 6 deletions
diff --git a/deps/uv/test/runner-win.c b/deps/uv/test/runner-win.c
index 0f1b56e777..d86fda3c5d 100644
--- a/deps/uv/test/runner-win.c
+++ b/deps/uv/test/runner-win.c
@@ -300,7 +300,6 @@ int process_reap(process_info_t *p) {
void process_cleanup(process_info_t *p) {
CloseHandle(p->process);
CloseHandle(p->stdio_in);
- CloseHandle(p->stdio_out);
}
diff --git a/deps/uv/test/test-dlerror.c b/deps/uv/test/test-dlerror.c
index 091200edbe..8f7697b594 100644
--- a/deps/uv/test/test-dlerror.c
+++ b/deps/uv/test/test-dlerror.c
@@ -42,11 +42,13 @@ TEST_IMPL(dlerror) {
msg = uv_dlerror(&lib);
ASSERT(msg != NULL);
+ ASSERT(strstr(msg, path) != NULL);
ASSERT(strstr(msg, dlerror_no_error) == NULL);
/* Should return the same error twice in a row. */
msg = uv_dlerror(&lib);
ASSERT(msg != NULL);
+ ASSERT(strstr(msg, path) != NULL);
ASSERT(strstr(msg, dlerror_no_error) == NULL);
uv_dlclose(&lib);
diff --git a/deps/uv/test/test-fs-copyfile.c b/deps/uv/test/test-fs-copyfile.c
new file mode 100644
index 0000000000..2d1f9079a5
--- /dev/null
+++ b/deps/uv/test/test-fs-copyfile.c
@@ -0,0 +1,150 @@
+/* Copyright libuv project 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"
+
+#if defined(__unix__) || defined(__POSIX__) || \
+ defined(__APPLE__) || defined(_AIX) || defined(__MVS__)
+#include <unistd.h> /* unlink, etc. */
+#else
+# include <direct.h>
+# include <io.h>
+# define unlink _unlink
+#endif
+
+static const char fixture[] = "test/fixtures/load_error.node";
+static const char dst[] = "test_file_dst";
+static int result_check_count;
+
+
+static void handle_result(uv_fs_t* req) {
+ uv_fs_t stat_req;
+ uint64_t size;
+ uint64_t mode;
+ int r;
+
+ ASSERT(req->fs_type == UV_FS_COPYFILE);
+ ASSERT(req->result == 0);
+
+ /* Verify that the file size and mode are the same. */
+ r = uv_fs_stat(NULL, &stat_req, req->path, NULL);
+ ASSERT(r == 0);
+ size = stat_req.statbuf.st_size;
+ mode = stat_req.statbuf.st_mode;
+ uv_fs_req_cleanup(&stat_req);
+ r = uv_fs_stat(NULL, &stat_req, dst, NULL);
+ ASSERT(r == 0);
+ ASSERT(stat_req.statbuf.st_size == size);
+ ASSERT(stat_req.statbuf.st_mode == mode);
+ uv_fs_req_cleanup(&stat_req);
+ uv_fs_req_cleanup(req);
+ result_check_count++;
+}
+
+
+static void touch_file(const char* name, unsigned int size) {
+ uv_file file;
+ uv_fs_t req;
+ uv_buf_t buf;
+ int r;
+ unsigned int i;
+
+ r = uv_fs_open(NULL, &req, name, O_WRONLY | O_CREAT, S_IWUSR | S_IRUSR, NULL);
+ uv_fs_req_cleanup(&req);
+ ASSERT(r >= 0);
+ file = r;
+
+ buf = uv_buf_init("a", 1);
+
+ /* Inefficient but simple. */
+ for (i = 0; i < size; i++) {
+ r = uv_fs_write(NULL, &req, file, &buf, 1, i, NULL);
+ uv_fs_req_cleanup(&req);
+ ASSERT(r >= 0);
+ }
+
+ r = uv_fs_close(NULL, &req, file, NULL);
+ uv_fs_req_cleanup(&req);
+ ASSERT(r == 0);
+}
+
+
+TEST_IMPL(fs_copyfile) {
+ const char src[] = "test_file_src";
+ uv_loop_t* loop;
+ uv_fs_t req;
+ int r;
+
+ loop = uv_default_loop();
+
+ /* Fails with EINVAL if bad flags are passed. */
+ r = uv_fs_copyfile(NULL, &req, src, dst, -1, NULL);
+ ASSERT(r == UV_EINVAL);
+ uv_fs_req_cleanup(&req);
+
+ /* Fails with ENOENT if source does not exist. */
+ unlink(src);
+ unlink(dst);
+ r = uv_fs_copyfile(NULL, &req, src, dst, 0, NULL);
+ ASSERT(req.result == UV_ENOENT);
+ ASSERT(r == UV_ENOENT);
+ uv_fs_req_cleanup(&req);
+ /* The destination should not exist. */
+ r = uv_fs_stat(NULL, &req, dst, NULL);
+ ASSERT(r != 0);
+ uv_fs_req_cleanup(&req);
+
+ /* Copies file synchronously. Creates new file. */
+ unlink(dst);
+ r = uv_fs_copyfile(NULL, &req, fixture, dst, 0, NULL);
+ ASSERT(r == 0);
+ handle_result(&req);
+
+ /* Copies file synchronously. Overwrites existing file. */
+ r = uv_fs_copyfile(NULL, &req, fixture, dst, 0, NULL);
+ ASSERT(r == 0);
+ handle_result(&req);
+
+ /* Fails to overwrites existing file. */
+ r = uv_fs_copyfile(NULL, &req, fixture, dst, UV_FS_COPYFILE_EXCL, NULL);
+ ASSERT(r == UV_EEXIST);
+ uv_fs_req_cleanup(&req);
+
+ /* Copies a larger file. */
+ unlink(dst);
+ touch_file(src, 4096 * 2);
+ r = uv_fs_copyfile(NULL, &req, src, dst, 0, NULL);
+ ASSERT(r == 0);
+ handle_result(&req);
+ unlink(src);
+
+ /* Copies file asynchronously */
+ unlink(dst);
+ r = uv_fs_copyfile(loop, &req, fixture, dst, 0, handle_result);
+ ASSERT(r == 0);
+ ASSERT(result_check_count == 3);
+ uv_run(loop, UV_RUN_DEFAULT);
+ ASSERT(result_check_count == 4);
+ unlink(dst); /* Cleanup */
+
+ return 0;
+}
diff --git a/deps/uv/test/test-fs.c b/deps/uv/test/test-fs.c
index 404d0426f3..0000e563a7 100644
--- a/deps/uv/test/test-fs.c
+++ b/deps/uv/test/test-fs.c
@@ -1492,12 +1492,14 @@ TEST_IMPL(fs_chown) {
uv_run(loop, UV_RUN_DEFAULT);
ASSERT(chown_cb_count == 1);
+#ifndef __MVS__
/* chown to root (fail) */
chown_cb_count = 0;
r = uv_fs_chown(loop, &req, "test_file", 0, 0, chown_root_cb);
ASSERT(r == 0);
uv_run(loop, UV_RUN_DEFAULT);
ASSERT(chown_cb_count == 1);
+#endif
/* async fchown */
r = uv_fs_fchown(loop, &req, file, -1, -1, fchown_cb);
@@ -2749,19 +2751,23 @@ TEST_IMPL(fs_write_alotof_bufs_with_offset) {
TEST_IMPL(fs_read_write_null_arguments) {
int r;
- r = uv_fs_read(NULL, NULL, 0, NULL, 0, -1, NULL);
+ r = uv_fs_read(NULL, &read_req, 0, NULL, 0, -1, NULL);
ASSERT(r == UV_EINVAL);
+ uv_fs_req_cleanup(&read_req);
- r = uv_fs_write(NULL, NULL, 0, NULL, 0, -1, NULL);
+ r = uv_fs_write(NULL, &write_req, 0, NULL, 0, -1, NULL);
ASSERT(r == UV_EINVAL);
+ uv_fs_req_cleanup(&write_req);
iov = uv_buf_init(NULL, 0);
- r = uv_fs_read(NULL, NULL, 0, &iov, 0, -1, NULL);
+ r = uv_fs_read(NULL, &read_req, 0, &iov, 0, -1, NULL);
ASSERT(r == UV_EINVAL);
+ uv_fs_req_cleanup(&read_req);
iov = uv_buf_init(NULL, 0);
- r = uv_fs_write(NULL, NULL, 0, &iov, 0, -1, NULL);
+ r = uv_fs_write(NULL, &write_req, 0, &iov, 0, -1, NULL);
ASSERT(r == UV_EINVAL);
+ uv_fs_req_cleanup(&write_req);
return 0;
}
@@ -2844,3 +2850,100 @@ TEST_IMPL(fs_file_pos_after_op_with_offset) {
MAKE_VALGRIND_HAPPY();
return 0;
}
+
+TEST_IMPL(fs_null_req) {
+ /* Verify that all fs functions return UV_EINVAL when the request is NULL. */
+ int r;
+
+ r = uv_fs_open(NULL, NULL, NULL, 0, 0, NULL);
+ ASSERT(r == UV_EINVAL);
+
+ r = uv_fs_close(NULL, NULL, 0, NULL);
+ ASSERT(r == UV_EINVAL);
+
+ r = uv_fs_read(NULL, NULL, 0, NULL, 0, -1, NULL);
+ ASSERT(r == UV_EINVAL);
+
+ r = uv_fs_write(NULL, NULL, 0, NULL, 0, -1, NULL);
+ ASSERT(r == UV_EINVAL);
+
+ r = uv_fs_unlink(NULL, NULL, NULL, NULL);
+ ASSERT(r == UV_EINVAL);
+
+ r = uv_fs_mkdir(NULL, NULL, NULL, 0, NULL);
+ ASSERT(r == UV_EINVAL);
+
+ r = uv_fs_mkdtemp(NULL, NULL, NULL, NULL);
+ ASSERT(r == UV_EINVAL);
+
+ r = uv_fs_rmdir(NULL, NULL, NULL, NULL);
+ ASSERT(r == UV_EINVAL);
+
+ r = uv_fs_scandir(NULL, NULL, NULL, 0, NULL);
+ ASSERT(r == UV_EINVAL);
+
+ r = uv_fs_link(NULL, NULL, NULL, NULL, NULL);
+ ASSERT(r == UV_EINVAL);
+
+ r = uv_fs_symlink(NULL, NULL, NULL, NULL, 0, NULL);
+ ASSERT(r == UV_EINVAL);
+
+ r = uv_fs_readlink(NULL, NULL, NULL, NULL);
+ ASSERT(r == UV_EINVAL);
+
+ r = uv_fs_realpath(NULL, NULL, NULL, NULL);
+ ASSERT(r == UV_EINVAL);
+
+ r = uv_fs_chown(NULL, NULL, NULL, 0, 0, NULL);
+ ASSERT(r == UV_EINVAL);
+
+ r = uv_fs_fchown(NULL, NULL, 0, 0, 0, NULL);
+ ASSERT(r == UV_EINVAL);
+
+ r = uv_fs_stat(NULL, NULL, NULL, NULL);
+ ASSERT(r == UV_EINVAL);
+
+ r = uv_fs_lstat(NULL, NULL, NULL, NULL);
+ ASSERT(r == UV_EINVAL);
+
+ r = uv_fs_fstat(NULL, NULL, 0, NULL);
+ ASSERT(r == UV_EINVAL);
+
+ r = uv_fs_rename(NULL, NULL, NULL, NULL, NULL);
+ ASSERT(r == UV_EINVAL);
+
+ r = uv_fs_fsync(NULL, NULL, 0, NULL);
+ ASSERT(r == UV_EINVAL);
+
+ r = uv_fs_fdatasync(NULL, NULL, 0, NULL);
+ ASSERT(r == UV_EINVAL);
+
+ r = uv_fs_ftruncate(NULL, NULL, 0, 0, NULL);
+ ASSERT(r == UV_EINVAL);
+
+ r = uv_fs_copyfile(NULL, NULL, NULL, NULL, 0, NULL);
+ ASSERT(r == UV_EINVAL);
+
+ r = uv_fs_sendfile(NULL, NULL, 0, 0, 0, 0, NULL);
+ ASSERT(r == UV_EINVAL);
+
+ r = uv_fs_access(NULL, NULL, NULL, 0, NULL);
+ ASSERT(r == UV_EINVAL);
+
+ r = uv_fs_chmod(NULL, NULL, NULL, 0, NULL);
+ ASSERT(r == UV_EINVAL);
+
+ r = uv_fs_fchmod(NULL, NULL, 0, 0, NULL);
+ ASSERT(r == UV_EINVAL);
+
+ r = uv_fs_utime(NULL, NULL, NULL, 0.0, 0.0, NULL);
+ ASSERT(r == UV_EINVAL);
+
+ r = uv_fs_futime(NULL, NULL, 0, 0.0, 0.0, NULL);
+ ASSERT(r == UV_EINVAL);
+
+ /* This should be a no-op. */
+ uv_fs_req_cleanup(NULL);
+
+ return 0;
+}
diff --git a/deps/uv/test/test-list.h b/deps/uv/test/test-list.h
index 0c32d84d20..6e84653e8b 100644
--- a/deps/uv/test/test-list.h
+++ b/deps/uv/test/test-list.h
@@ -81,6 +81,8 @@ TEST_DECLARE (tcp_try_write)
TEST_DECLARE (tcp_write_queue_order)
TEST_DECLARE (tcp_open)
TEST_DECLARE (tcp_open_twice)
+TEST_DECLARE (tcp_open_bound)
+TEST_DECLARE (tcp_open_connected)
TEST_DECLARE (tcp_connect_error_after_write)
TEST_DECLARE (tcp_shutdown_after_write)
TEST_DECLARE (tcp_bind_error_addrinuse)
@@ -256,6 +258,7 @@ TEST_DECLARE (spawn_auto_unref)
TEST_DECLARE (spawn_closed_process_io)
TEST_DECLARE (spawn_reads_child_path)
TEST_DECLARE (spawn_inherit_streams)
+TEST_DECLARE (spawn_quoted_path)
TEST_DECLARE (fs_poll)
TEST_DECLARE (fs_poll_getpath)
TEST_DECLARE (kill)
@@ -271,6 +274,7 @@ TEST_DECLARE (fs_mkdtemp)
TEST_DECLARE (fs_fstat)
TEST_DECLARE (fs_access)
TEST_DECLARE (fs_chmod)
+TEST_DECLARE (fs_copyfile)
TEST_DECLARE (fs_unlink_readonly)
TEST_DECLARE (fs_chown)
TEST_DECLARE (fs_link)
@@ -312,6 +316,7 @@ TEST_DECLARE (get_osfhandle_valid_handle)
TEST_DECLARE (fs_write_alotof_bufs)
TEST_DECLARE (fs_write_alotof_bufs_with_offset)
TEST_DECLARE (fs_file_pos_after_op_with_offset)
+TEST_DECLARE (fs_null_req)
TEST_DECLARE (threadpool_queue_work_simple)
TEST_DECLARE (threadpool_queue_work_einval)
TEST_DECLARE (threadpool_multiple_event_loops)
@@ -328,6 +333,10 @@ TEST_DECLARE (thread_rwlock_trylock)
TEST_DECLARE (thread_create)
TEST_DECLARE (thread_equal)
TEST_DECLARE (dlerror)
+#if (defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))) && \
+ !defined(__sun)
+TEST_DECLARE (poll_oob)
+#endif
TEST_DECLARE (poll_duplex)
TEST_DECLARE (poll_unidirectional)
TEST_DECLARE (poll_close)
@@ -486,6 +495,9 @@ TASK_LIST_START
TEST_ENTRY (tcp_open)
TEST_HELPER (tcp_open, tcp4_echo_server)
TEST_ENTRY (tcp_open_twice)
+ TEST_ENTRY (tcp_open_bound)
+ TEST_ENTRY (tcp_open_connected)
+ TEST_HELPER (tcp_open_connected, tcp4_echo_server)
TEST_ENTRY (tcp_shutdown_after_write)
TEST_HELPER (tcp_shutdown_after_write, tcp4_echo_server)
@@ -681,6 +693,11 @@ TASK_LIST_START
TEST_ENTRY (poll_unidirectional)
TEST_ENTRY (poll_close)
TEST_ENTRY (poll_bad_fdtype)
+#if (defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))) && \
+ !defined(__sun)
+ TEST_ENTRY (poll_oob)
+#endif
+
#ifdef __linux__
TEST_ENTRY (poll_nested_epoll)
#endif
@@ -714,6 +731,7 @@ TASK_LIST_START
TEST_ENTRY (spawn_closed_process_io)
TEST_ENTRY (spawn_reads_child_path)
TEST_ENTRY (spawn_inherit_streams)
+ TEST_ENTRY (spawn_quoted_path)
TEST_ENTRY (fs_poll)
TEST_ENTRY (fs_poll_getpath)
TEST_ENTRY (kill)
@@ -762,6 +780,7 @@ TASK_LIST_START
TEST_ENTRY (fs_fstat)
TEST_ENTRY (fs_access)
TEST_ENTRY (fs_chmod)
+ TEST_ENTRY (fs_copyfile)
TEST_ENTRY (fs_unlink_readonly)
TEST_ENTRY (fs_chown)
TEST_ENTRY (fs_utime)
@@ -801,6 +820,7 @@ TASK_LIST_START
TEST_ENTRY (fs_write_alotof_bufs_with_offset)
TEST_ENTRY (fs_read_write_null_arguments)
TEST_ENTRY (fs_file_pos_after_op_with_offset)
+ TEST_ENTRY (fs_null_req)
TEST_ENTRY (get_osfhandle_valid_handle)
TEST_ENTRY (threadpool_queue_work_simple)
TEST_ENTRY (threadpool_queue_work_einval)
diff --git a/deps/uv/test/test-poll-oob.c b/deps/uv/test/test-poll-oob.c
new file mode 100644
index 0000000000..2a6da843c6
--- /dev/null
+++ b/deps/uv/test/test-poll-oob.c
@@ -0,0 +1,205 @@
+/* Copyright libuv project 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.
+ */
+
+#if !defined(_WIN32)
+
+#include "uv.h"
+#include "task.h"
+
+#include <errno.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <unistd.h>
+#include <string.h>
+
+static uv_tcp_t server_handle;
+static uv_tcp_t client_handle;
+static uv_tcp_t peer_handle;
+static uv_poll_t poll_req[2];
+static uv_idle_t idle;
+static uv_os_fd_t client_fd;
+static uv_os_fd_t server_fd;
+static int ticks;
+static const int kMaxTicks = 10;
+static int cli_pr_check = 0;
+static int cli_rd_check = 0;
+static int srv_rd_check = 0;
+
+static int got_eagain(void) {
+ return errno == EAGAIN
+ || errno == EINPROGRESS
+#ifdef EWOULDBLOCK
+ || errno == EWOULDBLOCK
+#endif
+ ;
+}
+
+static void idle_cb(uv_idle_t* idle) {
+ uv_sleep(100);
+ if (++ticks < kMaxTicks)
+ return;
+
+ uv_poll_stop(&poll_req[0]);
+ uv_poll_stop(&poll_req[1]);
+ uv_close((uv_handle_t*) &server_handle, NULL);
+ uv_close((uv_handle_t*) &client_handle, NULL);
+ uv_close((uv_handle_t*) &peer_handle, NULL);
+ uv_close((uv_handle_t*) idle, NULL);
+}
+
+static void poll_cb(uv_poll_t* handle, int status, int events) {
+ char buffer[5];
+ int n;
+ int fd;
+
+ ASSERT(0 == uv_fileno((uv_handle_t*)handle, &fd));
+ memset(buffer, 0, 5);
+
+ if (events & UV_PRIORITIZED) {
+ do
+ n = recv(client_fd, &buffer, 5, MSG_OOB);
+ while (n == -1 && errno == EINTR);
+ ASSERT(n >= 0 || errno != EINVAL);
+ cli_pr_check = 1;
+ ASSERT(0 == uv_poll_stop(&poll_req[0]));
+ ASSERT(0 == uv_poll_start(&poll_req[0],
+ UV_READABLE | UV_WRITABLE,
+ poll_cb));
+ }
+ if (events & UV_READABLE) {
+ if (fd == client_fd) {
+ do
+ n = recv(client_fd, &buffer, 5, 0);
+ while (n == -1 && errno == EINTR);
+ ASSERT(n >= 0 || errno != EINVAL);
+ if (cli_rd_check == 1) {
+ ASSERT(strncmp(buffer, "world", n) == 0);
+ ASSERT(5 == n);
+ cli_rd_check = 2;
+ }
+ if (cli_rd_check == 0) {
+ ASSERT(n == 4);
+ ASSERT(strncmp(buffer, "hello", n) == 0);
+ cli_rd_check = 1;
+ do {
+ do
+ n = recv(server_fd, &buffer, 5, 0);
+ while (n == -1 && errno == EINTR);
+ if (n > 0) {
+ ASSERT(n == 5);
+ ASSERT(strncmp(buffer, "world", n) == 0);
+ cli_rd_check = 2;
+ }
+ } while (n > 0);
+
+ ASSERT(got_eagain());
+ }
+ }
+ if (fd == server_fd) {
+ do
+ n = recv(server_fd, &buffer, 3, 0);
+ while (n == -1 && errno == EINTR);
+ ASSERT(n >= 0 || errno != EINVAL);
+ ASSERT(3 == n);
+ ASSERT(strncmp(buffer, "foo", n) == 0);
+ srv_rd_check = 1;
+ uv_poll_stop(&poll_req[1]);
+ }
+ }
+ if (events & UV_WRITABLE) {
+ do {
+ n = send(client_fd, "foo", 3, 0);
+ } while (n < 0 && errno == EINTR);
+ ASSERT(3 == n);
+ }
+}
+
+static void connection_cb(uv_stream_t* handle, int status) {
+ int r;
+
+ ASSERT(0 == status);
+ ASSERT(0 == uv_accept(handle, (uv_stream_t*) &peer_handle));
+ ASSERT(0 == uv_fileno((uv_handle_t*) &peer_handle, &server_fd));
+ ASSERT(0 == uv_poll_init_socket(uv_default_loop(), &poll_req[0], client_fd));
+ ASSERT(0 == uv_poll_init_socket(uv_default_loop(), &poll_req[1], server_fd));
+ ASSERT(0 == uv_poll_start(&poll_req[0],
+ UV_PRIORITIZED | UV_READABLE | UV_WRITABLE,
+ poll_cb));
+ ASSERT(0 == uv_poll_start(&poll_req[1],
+ UV_READABLE,
+ poll_cb));
+ do {
+ r = send(server_fd, "hello", 5, MSG_OOB);
+ } while (r < 0 && errno == EINTR);
+ ASSERT(5 == r);
+
+ do {
+ r = send(server_fd, "world", 5, 0);
+ } while (r < 0 && errno == EINTR);
+ ASSERT(5 == r);
+
+ ASSERT(0 == uv_idle_start(&idle, idle_cb));
+}
+
+
+TEST_IMPL(poll_oob) {
+ struct sockaddr_in addr;
+ int r = 0;
+ uv_loop_t* loop;
+
+ ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr));
+ loop = uv_default_loop();
+
+ ASSERT(0 == uv_tcp_init(loop, &server_handle));
+ ASSERT(0 == uv_tcp_init(loop, &client_handle));
+ ASSERT(0 == uv_tcp_init(loop, &peer_handle));
+ ASSERT(0 == uv_idle_init(loop, &idle));
+ ASSERT(0 == uv_tcp_bind(&server_handle, (const struct sockaddr*) &addr, 0));
+ ASSERT(0 == uv_listen((uv_stream_t*) &server_handle, 1, connection_cb));
+
+ /* Ensure two separate packets */
+ ASSERT(0 == uv_tcp_nodelay(&client_handle, 1));
+
+ client_fd = socket(PF_INET, SOCK_STREAM, 0);
+ ASSERT(client_fd >= 0);
+ do {
+ errno = 0;
+ r = connect(client_fd, (const struct sockaddr*)&addr, sizeof(addr));
+ } while (r == -1 && errno == EINTR);
+ ASSERT(r == 0);
+
+ ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT));
+
+ ASSERT(ticks == kMaxTicks);
+
+ /* Did client receive the POLLPRI message */
+ ASSERT(cli_pr_check == 1);
+ /* Did client receive the POLLIN message */
+ ASSERT(cli_rd_check == 2);
+ /* Could we write with POLLOUT and did the server receive our POLLOUT message
+ * through POLLIN.
+ */
+ ASSERT(srv_rd_check == 1);
+
+ MAKE_VALGRIND_HAPPY();
+ return 0;
+}
+#endif
diff --git a/deps/uv/test/test-spawn.c b/deps/uv/test/test-spawn.c
index bb35e32b28..91d831e19b 100644
--- a/deps/uv/test/test-spawn.c
+++ b/deps/uv/test/test-spawn.c
@@ -1,3 +1,4 @@
+
/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1350,10 +1351,14 @@ TEST_IMPL(spawn_setgid_fails) {
init_process_options("spawn_helper1", fail_cb);
options.flags |= UV_PROCESS_SETGID;
+#if defined(__MVS__)
+ options.gid = -1;
+#else
options.gid = 0;
+#endif
r = uv_spawn(uv_default_loop(), &process, &options);
-#if defined(__CYGWIN__)
+#if defined(__CYGWIN__) || defined(__MVS__)
ASSERT(r == UV_EINVAL);
#else
ASSERT(r == UV_EPERM);
@@ -1711,6 +1716,31 @@ TEST_IMPL(spawn_inherit_streams) {
return 0;
}
+TEST_IMPL(spawn_quoted_path) {
+#ifndef _WIN32
+ RETURN_SKIP("Test for Windows");
+#else
+ char* quoted_path_env[2];
+ options.file = "not_existing";
+ args[0] = options.file;
+ args[1] = NULL;
+ options.args = args;
+ options.exit_cb = exit_cb;
+ options.flags = 0;
+ /* We test if search_path works correctly with semicolons in quoted path. */
+ /* We will use invalid drive, so we are sure no executable is spawned */
+ quoted_path_env[0] = "PATH=\"xyz:\\test;\";xyz:\\other";
+ quoted_path_env[1] = NULL;
+ options.env = quoted_path_env;
+
+ /* We test if libuv will not segfault. */
+ uv_spawn(uv_default_loop(), &process, &options);
+
+ MAKE_VALGRIND_HAPPY();
+ return 0;
+#endif
+}
+
/* Helper for child process of spawn_inherit_streams */
#ifndef _WIN32
int spawn_stdin_stdout(void) {
diff --git a/deps/uv/test/test-tcp-oob.c b/deps/uv/test/test-tcp-oob.c
index fc011ee495..4f1397a82f 100644
--- a/deps/uv/test/test-tcp-oob.c
+++ b/deps/uv/test/test-tcp-oob.c
@@ -56,8 +56,21 @@ static void idle_cb(uv_idle_t* idle) {
static void read_cb(uv_stream_t* handle, ssize_t nread, const uv_buf_t* buf) {
+#ifdef __MVS__
+ char lbuf[12];
+#endif
+ uv_os_fd_t fd;
+
ASSERT(nread > 0);
+ ASSERT(0 == uv_fileno((uv_handle_t*)handle, &fd));
ASSERT(0 == uv_idle_start(&idle, idle_cb));
+
+#ifdef __MVS__
+ /* Need to flush out the OOB data. Otherwise, this callback will get
+ * triggered on every poll with nread = 0.
+ */
+ ASSERT(-1 != recv(fd, lbuf, sizeof(lbuf), MSG_OOB));
+#endif
}
diff --git a/deps/uv/test/test-tcp-open.c b/deps/uv/test/test-tcp-open.c
index 6c8d43d000..cb74c50e2c 100644
--- a/deps/uv/test/test-tcp-open.c
+++ b/deps/uv/test/test-tcp-open.c
@@ -218,3 +218,60 @@ TEST_IMPL(tcp_open_twice) {
MAKE_VALGRIND_HAPPY();
return 0;
}
+
+
+TEST_IMPL(tcp_open_bound) {
+ struct sockaddr_in addr;
+ uv_tcp_t server;
+ uv_os_sock_t sock;
+
+ startup();
+ sock = create_tcp_socket();
+
+ ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr));
+
+ ASSERT(0 == uv_tcp_init(uv_default_loop(), &server));
+
+ ASSERT(0 == bind(sock, (struct sockaddr*) &addr, sizeof(addr)));
+
+ ASSERT(0 == uv_tcp_open(&server, sock));
+
+ ASSERT(0 == uv_listen((uv_stream_t*) &server, 128, NULL));
+
+ MAKE_VALGRIND_HAPPY();
+ return 0;
+}
+
+
+TEST_IMPL(tcp_open_connected) {
+ struct sockaddr_in addr;
+ uv_tcp_t client;
+ uv_os_sock_t sock;
+ uv_buf_t buf = uv_buf_init("PING", 4);
+
+ ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr));
+
+ startup();
+ sock = create_tcp_socket();
+
+ ASSERT(0 == connect(sock, (struct sockaddr*) &addr, sizeof(addr)));
+
+ ASSERT(0 == uv_tcp_init(uv_default_loop(), &client));
+
+ ASSERT(0 == uv_tcp_open(&client, sock));
+
+ ASSERT(0 == uv_write(&write_req, (uv_stream_t*) &client, &buf, 1, write_cb));
+
+ ASSERT(0 == uv_shutdown(&shutdown_req, (uv_stream_t*) &client, shutdown_cb));
+
+ ASSERT(0 == uv_read_start((uv_stream_t*) &client, alloc_cb, read_cb));
+
+ uv_run(uv_default_loop(), UV_RUN_DEFAULT);
+
+ ASSERT(shutdown_cb_called == 1);
+ ASSERT(write_cb_called == 1);
+ ASSERT(close_cb_called == 1);
+
+ MAKE_VALGRIND_HAPPY();
+ return 0;
+}