summaryrefslogtreecommitdiff
path: root/deps/uv/test
diff options
context:
space:
mode:
Diffstat (limited to 'deps/uv/test')
-rw-r--r--deps/uv/test/runner-unix.c25
-rw-r--r--deps/uv/test/task.h22
-rw-r--r--deps/uv/test/test-cwd-and-chdir.c27
-rw-r--r--deps/uv/test/test-dlerror.c19
-rw-r--r--deps/uv/test/test-fs.c12
-rw-r--r--deps/uv/test/test-get-currentexe.c21
-rw-r--r--deps/uv/test/test-list.h6
-rw-r--r--deps/uv/test/test-loop-configure.c38
-rw-r--r--deps/uv/test/test-osx-select.c2
-rw-r--r--deps/uv/test/test-ping-pong.c3
-rw-r--r--deps/uv/test/test-pipe-close-stdout-read-stdin.c3
-rw-r--r--deps/uv/test/test-platform-output.c6
-rw-r--r--deps/uv/test/test-poll-close-doesnt-corrupt-stack.c114
-rw-r--r--deps/uv/test/test-spawn.c26
-rw-r--r--deps/uv/test/test-tcp-bind6-error.c15
-rw-r--r--deps/uv/test/test-udp-ipv6.c13
-rw-r--r--deps/uv/test/test-udp-multicast-interface6.c3
-rw-r--r--deps/uv/test/test-udp-multicast-join6.c3
-rw-r--r--deps/uv/test/test-udp-options.c26
19 files changed, 324 insertions, 60 deletions
diff --git a/deps/uv/test/runner-unix.c b/deps/uv/test/runner-unix.c
index 1f12c6f12d..5da720fad4 100644
--- a/deps/uv/test/runner-unix.c
+++ b/deps/uv/test/runner-unix.c
@@ -68,6 +68,7 @@ int process_start(char* name, char* part, process_info_t* p, int is_helper) {
const char* arg;
char* args[16];
int n;
+ pid_t pid;
stdout_file = tmpfile();
if (!stdout_file) {
@@ -78,7 +79,7 @@ int process_start(char* name, char* part, process_info_t* p, int is_helper) {
p->terminated = 0;
p->status = 0;
- pid_t pid = fork();
+ pid = fork();
if (pid < 0) {
perror("fork");
@@ -167,8 +168,14 @@ static void* dowait(void* data) {
/* Return 0 if all processes are terminated, -1 on error, -2 on timeout. */
int process_wait(process_info_t* vec, int n, int timeout) {
int i;
+ int r;
+ int retval;
process_info_t* p;
dowait_args args;
+ pthread_t tid;
+ struct timeval tv;
+ fd_set fds;
+
args.vec = vec;
args.n = n;
args.pipe[0] = -1;
@@ -186,10 +193,7 @@ int process_wait(process_info_t* vec, int n, int timeout) {
* we'd need to lock vec.
*/
- pthread_t tid;
- int retval;
-
- int r = pipe((int*)&(args.pipe));
+ r = pipe((int*)&(args.pipe));
if (r) {
perror("pipe()");
return -1;
@@ -202,11 +206,9 @@ int process_wait(process_info_t* vec, int n, int timeout) {
goto terminate;
}
- struct timeval tv;
tv.tv_sec = timeout / 1000;
tv.tv_usec = 0;
- fd_set fds;
FD_ZERO(&fds);
FD_SET(args.pipe[0], &fds);
@@ -259,15 +261,16 @@ long int process_output_size(process_info_t *p) {
/* Copy the contents of the stdio output buffer to `fd`. */
int process_copy_output(process_info_t *p, int fd) {
- int r = fseek(p->stdout_file, 0, SEEK_SET);
+ ssize_t nwritten;
+ char buf[1024];
+ int r;
+
+ r = fseek(p->stdout_file, 0, SEEK_SET);
if (r < 0) {
perror("fseek");
return -1;
}
- ssize_t nwritten;
- char buf[1024];
-
/* TODO: what if the line is longer than buf */
while (fgets(buf, sizeof(buf), p->stdout_file) != NULL) {
/* TODO: what if write doesn't write the whole buffer... */
diff --git a/deps/uv/test/task.h b/deps/uv/test/task.h
index e890c77fe1..07584c5299 100644
--- a/deps/uv/test/task.h
+++ b/deps/uv/test/task.h
@@ -39,6 +39,11 @@
# include <sys/resource.h> /* setrlimit() */
#endif
+#ifdef __clang__
+# pragma clang diagnostic ignored "-Wvariadic-macros"
+# pragma clang diagnostic ignored "-Wc99-extensions"
+#endif
+
#define TEST_PORT 9123
#define TEST_PORT_2 9124
@@ -229,4 +234,21 @@ UNUSED static void close_loop(uv_loop_t* loop) {
uv_run(loop, UV_RUN_DEFAULT);
}
+UNUSED static int can_ipv6(void) {
+ uv_interface_address_t* addr;
+ int supported;
+ int count;
+ int i;
+
+ if (uv_interface_addresses(&addr, &count))
+ return 1; /* Assume IPv6 support on failure. */
+
+ supported = 0;
+ for (i = 0; supported == 0 && i < count; i += 1)
+ supported = (AF_INET6 == addr[i].address.address6.sin6_family);
+
+ uv_free_interface_addresses(addr, count);
+ return supported;
+}
+
#endif /* TASK_H_ */
diff --git a/deps/uv/test/test-cwd-and-chdir.c b/deps/uv/test/test-cwd-and-chdir.c
index 6f6173192d..1e95043c17 100644
--- a/deps/uv/test/test-cwd-and-chdir.c
+++ b/deps/uv/test/test-cwd-and-chdir.c
@@ -29,35 +29,22 @@ extern char executable_path[];
TEST_IMPL(cwd_and_chdir) {
char buffer_orig[PATHMAX];
char buffer_new[PATHMAX];
- size_t size;
- char* last_slash;
+ size_t size1;
+ size_t size2;
int err;
- size = sizeof(buffer_orig);
- err = uv_cwd(buffer_orig, &size);
+ size1 = sizeof buffer_orig;
+ err = uv_cwd(buffer_orig, &size1);
ASSERT(err == 0);
- /* Remove trailing slash unless at a root directory. */
-#ifdef _WIN32
- last_slash = strrchr(buffer_orig, '\\');
- ASSERT(last_slash);
- if (last_slash > buffer_orig && *(last_slash - 1) != ':') {
- *last_slash = '\0';
- }
-#else /* Unix */
- last_slash = strrchr(buffer_orig, '/');
- ASSERT(last_slash);
- if (last_slash != buffer_orig) {
- *last_slash = '\0';
- }
-#endif
-
err = uv_chdir(buffer_orig);
ASSERT(err == 0);
- err = uv_cwd(buffer_new, &size);
+ size2 = sizeof buffer_new;
+ err = uv_cwd(buffer_new, &size2);
ASSERT(err == 0);
+ ASSERT(size1 == size2);
ASSERT(strcmp(buffer_orig, buffer_new) == 0);
return 0;
diff --git a/deps/uv/test/test-dlerror.c b/deps/uv/test/test-dlerror.c
index 877ebf3712..091200edbe 100644
--- a/deps/uv/test/test-dlerror.c
+++ b/deps/uv/test/test-dlerror.c
@@ -26,31 +26,28 @@
TEST_IMPL(dlerror) {
const char* path = "test/fixtures/load_error.node";
+ const char* dlerror_no_error = "no error";
const char* msg;
uv_lib_t lib;
int r;
-#ifdef __linux__
- const char* dlerror_desc = "file too short";
-#elif defined (__sun__)
- const char* dlerror_desc = "unknown file type";
-#elif defined (_WIN32)
- const char* dlerror_desc = "%1 is not a valid Win32 application";
-#else
- const char* dlerror_desc = "";
-#endif
+ lib.errmsg = NULL;
+ lib.handle = NULL;
+ msg = uv_dlerror(&lib);
+ ASSERT(msg != NULL);
+ ASSERT(strstr(msg, dlerror_no_error) != NULL);
r = uv_dlopen(path, &lib);
ASSERT(r == -1);
msg = uv_dlerror(&lib);
ASSERT(msg != NULL);
- ASSERT(strstr(msg, dlerror_desc) != 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, dlerror_desc) != NULL);
+ ASSERT(strstr(msg, dlerror_no_error) == NULL);
uv_dlclose(&lib);
diff --git a/deps/uv/test/test-fs.c b/deps/uv/test/test-fs.c
index 471860a76c..2c392251f0 100644
--- a/deps/uv/test/test-fs.c
+++ b/deps/uv/test/test-fs.c
@@ -568,7 +568,17 @@ TEST_IMPL(fs_file_loop) {
loop = uv_default_loop();
unlink("test_symlink");
- uv_fs_symlink(loop, &req, "test_symlink", "test_symlink", 0, NULL);
+ r = uv_fs_symlink(loop, &req, "test_symlink", "test_symlink", 0, NULL);
+#ifdef _WIN32
+ /*
+ * Windows XP and Server 2003 don't support symlinks; we'll get UV_ENOTSUP.
+ * Starting with vista they are supported, but only when elevated, otherwise
+ * we'll see UV_EPERM.
+ */
+ if (r == UV_ENOTSUP || r == UV_EPERM)
+ return 0;
+#endif
+ ASSERT(r == 0);
uv_fs_req_cleanup(&req);
r = uv_fs_open(loop, &req, "test_symlink", O_RDONLY, 0, NULL);
diff --git a/deps/uv/test/test-get-currentexe.c b/deps/uv/test/test-get-currentexe.c
index be578db75d..0e9d696540 100644
--- a/deps/uv/test/test-get-currentexe.c
+++ b/deps/uv/test/test-get-currentexe.c
@@ -61,5 +61,26 @@ TEST_IMPL(get_currentexe) {
r = uv_exepath(buffer, NULL);
ASSERT(r == UV_EINVAL);
+ size = 0;
+ r = uv_exepath(buffer, &size);
+ ASSERT(r == UV_EINVAL);
+
+ memset(buffer, -1, sizeof(buffer));
+
+ size = 1;
+ r = uv_exepath(buffer, &size);
+ ASSERT(r == 0);
+ ASSERT(size == 0);
+ ASSERT(buffer[0] == '\0');
+
+ memset(buffer, -1, sizeof(buffer));
+
+ size = 2;
+ r = uv_exepath(buffer, &size);
+ ASSERT(r == 0);
+ ASSERT(size == 1);
+ ASSERT(buffer[0] != '\0');
+ ASSERT(buffer[1] == '\0');
+
return 0;
}
diff --git a/deps/uv/test/test-list.h b/deps/uv/test/test-list.h
index 85ddac82ae..eb78a43cc7 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 (loop_configure)
TEST_DECLARE (default_loop_close)
TEST_DECLARE (barrier_1)
TEST_DECLARE (barrier_2)
@@ -103,6 +104,7 @@ TEST_DECLARE (udp_dgram_too_big)
TEST_DECLARE (udp_dual_stack)
TEST_DECLARE (udp_ipv6_only)
TEST_DECLARE (udp_options)
+TEST_DECLARE (udp_options6)
TEST_DECLARE (udp_no_autobind)
TEST_DECLARE (udp_open)
TEST_DECLARE (udp_try_send)
@@ -269,6 +271,7 @@ TEST_DECLARE (ip4_addr)
TEST_DECLARE (ip6_addr_link_local)
#ifdef _WIN32
+TEST_DECLARE (poll_close_doesnt_corrupt_stack)
TEST_DECLARE (poll_closesocket)
TEST_DECLARE (spawn_detect_pipe_name_collisions_on_windows)
TEST_DECLARE (argument_escaping)
@@ -312,6 +315,7 @@ TASK_LIST_START
TEST_ENTRY (loop_stop)
TEST_ENTRY (loop_update_time)
TEST_ENTRY (loop_backend_timeout)
+ TEST_ENTRY (loop_configure)
TEST_ENTRY (default_loop_close)
TEST_ENTRY (barrier_1)
TEST_ENTRY (barrier_2)
@@ -410,6 +414,7 @@ TASK_LIST_START
TEST_ENTRY (udp_dual_stack)
TEST_ENTRY (udp_ipv6_only)
TEST_ENTRY (udp_options)
+ TEST_ENTRY (udp_options6)
TEST_ENTRY (udp_no_autobind)
TEST_ENTRY (udp_multicast_interface)
TEST_ENTRY (udp_multicast_interface6)
@@ -558,6 +563,7 @@ TASK_LIST_START
TEST_ENTRY (kill)
#ifdef _WIN32
+ TEST_ENTRY (poll_close_doesnt_corrupt_stack)
TEST_ENTRY (poll_closesocket)
TEST_ENTRY (spawn_detect_pipe_name_collisions_on_windows)
TEST_ENTRY (argument_escaping)
diff --git a/deps/uv/test/test-loop-configure.c b/deps/uv/test/test-loop-configure.c
new file mode 100644
index 0000000000..d057c1ed8a
--- /dev/null
+++ b/deps/uv/test/test-loop-configure.c
@@ -0,0 +1,38 @@
+/* Copyright (c) 2014, 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"
+
+static void timer_cb(uv_timer_t* handle) {
+ uv_close((uv_handle_t*) handle, NULL);
+}
+
+
+TEST_IMPL(loop_configure) {
+ uv_timer_t timer_handle;
+ uv_loop_t loop;
+ ASSERT(0 == uv_loop_init(&loop));
+#ifdef _WIN32
+ ASSERT(UV_ENOSYS == uv_loop_configure(&loop, UV_LOOP_BLOCK_SIGNAL, 0));
+#else
+ ASSERT(0 == uv_loop_configure(&loop, UV_LOOP_BLOCK_SIGNAL, SIGPROF));
+#endif
+ ASSERT(0 == uv_timer_init(&loop, &timer_handle));
+ ASSERT(0 == uv_timer_start(&timer_handle, timer_cb, 10, 0));
+ ASSERT(0 == uv_run(&loop, UV_RUN_DEFAULT));
+ ASSERT(0 == uv_loop_close(&loop));
+ return 0;
+}
diff --git a/deps/uv/test/test-osx-select.c b/deps/uv/test/test-osx-select.c
index 49b1bb8229..ef551eaf2f 100644
--- a/deps/uv/test/test-osx-select.c
+++ b/deps/uv/test/test-osx-select.c
@@ -90,7 +90,7 @@ TEST_IMPL(osx_select_many_fds) {
uv_tty_t tty;
uv_tcp_t tcps[1500];
- TEST_FILE_LIMIT(ARRAY_SIZE(tcps) + 2);
+ TEST_FILE_LIMIT(ARRAY_SIZE(tcps) + 100);
r = uv_ip4_addr("127.0.0.1", 0, &addr);
ASSERT(r == 0);
diff --git a/deps/uv/test/test-ping-pong.c b/deps/uv/test/test-ping-pong.c
index 81941ab83d..c074178541 100644
--- a/deps/uv/test/test-ping-pong.c
+++ b/deps/uv/test/test-ping-pong.c
@@ -246,6 +246,9 @@ TEST_IMPL(tcp_ping_pong) {
TEST_IMPL(tcp_ping_pong_v6) {
+ if (!can_ipv6())
+ RETURN_SKIP("IPv6 not supported");
+
tcp_pinger_v6_new();
uv_run(uv_default_loop(), UV_RUN_DEFAULT);
diff --git a/deps/uv/test/test-pipe-close-stdout-read-stdin.c b/deps/uv/test/test-pipe-close-stdout-read-stdin.c
index 3064babf98..ee8bb2a9a8 100644
--- a/deps/uv/test/test-pipe-close-stdout-read-stdin.c
+++ b/deps/uv/test/test-pipe-close-stdout-read-stdin.c
@@ -53,6 +53,7 @@ TEST_IMPL(pipe_close_stdout_read_stdin) {
int pid;
int fd[2];
int status;
+ uv_pipe_t stdin_pipe;
r = pipe(fd);
ASSERT(r == 0);
@@ -68,8 +69,6 @@ TEST_IMPL(pipe_close_stdout_read_stdin) {
ASSERT(r != -1);
/* 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);
diff --git a/deps/uv/test/test-platform-output.c b/deps/uv/test/test-platform-output.c
index 931311985b..dc6fa32b0d 100644
--- a/deps/uv/test/test-platform-output.c
+++ b/deps/uv/test/test-platform-output.c
@@ -27,6 +27,7 @@
TEST_IMPL(platform_output) {
char buffer[512];
size_t rss;
+ size_t size;
double uptime;
uv_rusage_t rusage;
uv_cpu_info_t* cpus;
@@ -39,6 +40,11 @@ TEST_IMPL(platform_output) {
ASSERT(err == 0);
printf("uv_get_process_title: %s\n", buffer);
+ size = sizeof(buffer);
+ err = uv_cwd(buffer, &size);
+ ASSERT(err == 0);
+ printf("uv_cwd: %s\n", buffer);
+
err = uv_resident_set_memory(&rss);
ASSERT(err == 0);
printf("uv_resident_set_memory: %llu\n", (unsigned long long) rss);
diff --git a/deps/uv/test/test-poll-close-doesnt-corrupt-stack.c b/deps/uv/test/test-poll-close-doesnt-corrupt-stack.c
new file mode 100644
index 0000000000..fc2cc004f1
--- /dev/null
+++ b/deps/uv/test/test-poll-close-doesnt-corrupt-stack.c
@@ -0,0 +1,114 @@
+/* Copyright Bert Belder, and other libuv 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.
+ */
+
+#ifdef _WIN32
+
+#include <errno.h>
+#include <stdio.h>
+
+#include "uv.h"
+#include "task.h"
+
+#ifdef _MSC_VER /* msvc */
+# define NO_INLINE __declspec(noinline)
+#else /* gcc */
+# define NO_INLINE __attribute__ ((noinline))
+#endif
+
+
+uv_os_sock_t sock;
+uv_poll_t handle;
+
+static int close_cb_called = 0;
+
+
+static void close_cb(uv_handle_t* h) {
+ close_cb_called++;
+}
+
+
+static void poll_cb(uv_poll_t* h, int status, int events) {
+ ASSERT(0 && "should never get here");
+}
+
+
+static void NO_INLINE close_socket_and_verify_stack() {
+ const uint32_t MARKER = 0xDEADBEEF;
+ const int VERIFY_AFTER = 10; /* ms */
+ int r;
+
+ volatile uint32_t data[65536];
+ size_t i;
+
+ for (i = 0; i < ARRAY_SIZE(data); i++)
+ data[i] = MARKER;
+
+ r = closesocket(sock);
+ ASSERT(r == 0);
+
+ uv_sleep(VERIFY_AFTER);
+
+ for (i = 0; i < ARRAY_SIZE(data); i++)
+ ASSERT(data[i] == MARKER);
+}
+
+
+TEST_IMPL(poll_close_doesnt_corrupt_stack) {
+ struct WSAData wsa_data;
+ int r;
+ unsigned long on;
+ struct sockaddr_in addr;
+
+ r = WSAStartup(MAKEWORD(2, 2), &wsa_data);
+ ASSERT(r == 0);
+
+ sock = socket(AF_INET, SOCK_STREAM, 0);
+ ASSERT(sock != INVALID_SOCKET);
+ on = 1;
+ r = ioctlsocket(sock, FIONBIO, &on);
+ ASSERT(r == 0);
+
+ r = uv_ip4_addr("127.0.0.1", TEST_PORT, &addr);
+ ASSERT(r == 0);
+
+ r = connect(sock, (const struct sockaddr*) &addr, sizeof addr);
+ ASSERT(r != 0);
+ ASSERT(WSAGetLastError() == WSAEWOULDBLOCK);
+
+ r = uv_poll_init_socket(uv_default_loop(), &handle, sock);
+ ASSERT(r == 0);
+ r = uv_poll_start(&handle, UV_READABLE | UV_WRITABLE, poll_cb);
+ ASSERT(r == 0);
+
+ uv_close((uv_handle_t*) &handle, close_cb);
+
+ close_socket_and_verify_stack();
+
+ r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
+ ASSERT(r == 0);
+
+ ASSERT(close_cb_called == 1);
+
+ MAKE_VALGRIND_HAPPY();
+ return 0;
+}
+
+#endif /* _WIN32 */
diff --git a/deps/uv/test/test-spawn.c b/deps/uv/test/test-spawn.c
index 11f43bdf13..5c25f81926 100644
--- a/deps/uv/test/test-spawn.c
+++ b/deps/uv/test/test-spawn.c
@@ -1032,6 +1032,7 @@ TEST_IMPL(spawn_with_an_odd_path) {
#ifndef _WIN32
TEST_IMPL(spawn_setuid_setgid) {
int r;
+ struct passwd* pw;
/* if not root, then this will fail. */
uv_uid_t uid = getuid();
@@ -1043,7 +1044,6 @@ TEST_IMPL(spawn_setuid_setgid) {
init_process_options("spawn_helper1", exit_cb);
/* become the "nobody" user. */
- struct passwd* pw;
pw = getpwnam("nobody");
ASSERT(pw != NULL);
options.uid = pw->pw_uid;
@@ -1051,6 +1051,9 @@ TEST_IMPL(spawn_setuid_setgid) {
options.flags = UV_PROCESS_SETUID | UV_PROCESS_SETGID;
r = uv_spawn(uv_default_loop(), &process, &options);
+ if (r == UV_EACCES)
+ RETURN_SKIP("user 'nobody' cannot access the test runner");
+
ASSERT(r == 0);
r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
@@ -1297,7 +1300,16 @@ TEST_IMPL(spawn_reads_child_path) {
int len;
char file[64];
char path[1024];
- char *env[2] = {path, NULL};
+ char* env[3];
+
+ /* Need to carry over the dynamic linker path when the test runner is
+ * linked against libuv.so, see https://github.com/libuv/libuv/issues/85.
+ */
+#if defined(__APPLE__)
+ static const char dyld_path_var[] = "DYLD_LIBRARY_PATH";
+#else
+ static const char dyld_path_var[] = "LD_LIBRARY_PATH";
+#endif
/* Set up the process, but make sure that the file to run is relative and */
/* requires a lookup into PATH */
@@ -1312,6 +1324,16 @@ TEST_IMPL(spawn_reads_child_path) {
strcpy(path, "PATH=");
strcpy(path + 5, exepath);
+ env[0] = path;
+ env[1] = getenv(dyld_path_var);
+ env[2] = NULL;
+
+ if (env[1] != NULL) {
+ static char buf[1024 + sizeof(dyld_path_var)];
+ snprintf(buf, sizeof(buf), "%s=%s", dyld_path_var, env[1]);
+ env[1] = buf;
+ }
+
options.file = file;
options.args[0] = file;
options.env = env;
diff --git a/deps/uv/test/test-tcp-bind6-error.c b/deps/uv/test/test-tcp-bind6-error.c
index 1d65f3de3e..b762bcb3d1 100644
--- a/deps/uv/test/test-tcp-bind6-error.c
+++ b/deps/uv/test/test-tcp-bind6-error.c
@@ -39,6 +39,9 @@ TEST_IMPL(tcp_bind6_error_addrinuse) {
uv_tcp_t server1, server2;
int r;
+ if (!can_ipv6())
+ RETURN_SKIP("IPv6 not supported");
+
ASSERT(0 == uv_ip6_addr("::", TEST_PORT, &addr));
r = uv_tcp_init(uv_default_loop(), &server1);
@@ -73,6 +76,9 @@ TEST_IMPL(tcp_bind6_error_addrnotavail) {
uv_tcp_t server;
int r;
+ if (!can_ipv6())
+ RETURN_SKIP("IPv6 not supported");
+
ASSERT(0 == uv_ip6_addr("4:4:4:4:4:4:4:4", TEST_PORT, &addr));
r = uv_tcp_init(uv_default_loop(), &server);
@@ -98,6 +104,9 @@ TEST_IMPL(tcp_bind6_error_fault) {
uv_tcp_t server;
int r;
+ if (!can_ipv6())
+ RETURN_SKIP("IPv6 not supported");
+
garbage_addr = (struct sockaddr_in6*) &garbage;
r = uv_tcp_init(uv_default_loop(), &server);
@@ -123,6 +132,9 @@ TEST_IMPL(tcp_bind6_error_inval) {
uv_tcp_t server;
int r;
+ if (!can_ipv6())
+ RETURN_SKIP("IPv6 not supported");
+
ASSERT(0 == uv_ip6_addr("::", TEST_PORT, &addr1));
ASSERT(0 == uv_ip6_addr("::", TEST_PORT_2, &addr2));
@@ -149,6 +161,9 @@ TEST_IMPL(tcp_bind6_localhost_ok) {
uv_tcp_t server;
int r;
+ if (!can_ipv6())
+ RETURN_SKIP("IPv6 not supported");
+
ASSERT(0 == uv_ip6_addr("::1", TEST_PORT, &addr));
r = uv_tcp_init(uv_default_loop(), &server);
diff --git a/deps/uv/test/test-udp-ipv6.c b/deps/uv/test/test-udp-ipv6.c
index 0ca9f4dcff..1d5720ce73 100644
--- a/deps/uv/test/test-udp-ipv6.c
+++ b/deps/uv/test/test-udp-ipv6.c
@@ -147,23 +147,22 @@ 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
+ if (!can_ipv6())
+ RETURN_SKIP("IPv6 not supported");
+
do_test(ipv6_recv_ok, 0);
ASSERT(recv_cb_called == 1);
ASSERT(send_cb_called == 1);
return 0;
-#endif
}
TEST_IMPL(udp_ipv6_only) {
+ if (!can_ipv6())
+ RETURN_SKIP("IPv6 not supported");
+
do_test(ipv6_recv_fail, UV_UDP_IPV6ONLY);
ASSERT(recv_cb_called == 0);
diff --git a/deps/uv/test/test-udp-multicast-interface6.c b/deps/uv/test/test-udp-multicast-interface6.c
index e54e738b0b..d3881e83bb 100644
--- a/deps/uv/test/test-udp-multicast-interface6.c
+++ b/deps/uv/test/test-udp-multicast-interface6.c
@@ -60,6 +60,9 @@ TEST_IMPL(udp_multicast_interface6) {
struct sockaddr_in6 addr;
struct sockaddr_in6 baddr;
+ if (!can_ipv6())
+ RETURN_SKIP("IPv6 not supported");
+
ASSERT(0 == uv_ip6_addr("::1", TEST_PORT, &addr));
r = uv_udp_init(uv_default_loop(), &server);
diff --git a/deps/uv/test/test-udp-multicast-join6.c b/deps/uv/test/test-udp-multicast-join6.c
index babf61e2bf..9ba201ab9e 100644
--- a/deps/uv/test/test-udp-multicast-join6.c
+++ b/deps/uv/test/test-udp-multicast-join6.c
@@ -103,6 +103,9 @@ TEST_IMPL(udp_multicast_join6) {
uv_buf_t buf;
struct sockaddr_in6 addr;
+ if (!can_ipv6())
+ RETURN_SKIP("IPv6 not supported");
+
ASSERT(0 == uv_ip6_addr("::1", TEST_PORT, &addr));
r = uv_udp_init(uv_default_loop(), &server);
diff --git a/deps/uv/test/test-udp-options.c b/deps/uv/test/test-udp-options.c
index 19c45c2e31..0da1786f50 100644
--- a/deps/uv/test/test-udp-options.c
+++ b/deps/uv/test/test-udp-options.c
@@ -27,15 +27,12 @@
#include <string.h>
-TEST_IMPL(udp_options) {
+static int udp_options_test(const struct sockaddr* addr) {
static int invalid_ttls[] = { -1, 0, 256 };
- struct sockaddr_in addr;
uv_loop_t* loop;
uv_udp_t h;
int i, r;
- ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &addr));
-
loop = uv_default_loop();
r = uv_udp_init(loop, &h);
@@ -43,7 +40,7 @@ TEST_IMPL(udp_options) {
uv_unref((uv_handle_t*)&h); /* don't keep the loop alive */
- r = uv_udp_bind(&h, (const struct sockaddr*) &addr, 0);
+ r = uv_udp_bind(&h, addr, 0);
ASSERT(r == 0);
r = uv_udp_set_broadcast(&h, 1);
@@ -88,6 +85,25 @@ TEST_IMPL(udp_options) {
}
+TEST_IMPL(udp_options) {
+ struct sockaddr_in addr;
+
+ ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &addr));
+ return udp_options_test((const struct sockaddr*) &addr);
+}
+
+
+TEST_IMPL(udp_options6) {
+ struct sockaddr_in6 addr;
+
+ if (!can_ipv6())
+ RETURN_SKIP("IPv6 not supported");
+
+ ASSERT(0 == uv_ip6_addr("::", TEST_PORT, &addr));
+ return udp_options_test((const struct sockaddr*) &addr);
+}
+
+
TEST_IMPL(udp_no_autobind) {
uv_loop_t* loop;
uv_udp_t h;