diff options
author | cjihrig <cjihrig@gmail.com> | 2018-06-22 11:28:11 -0400 |
---|---|---|
committer | cjihrig <cjihrig@gmail.com> | 2018-06-24 20:54:34 -0400 |
commit | 537a4baa443daea9850a8e324b5b4d7c21dd2717 (patch) | |
tree | f36565e62794a56adfa99a8511c6d2a90c466fbc /deps/uv/test | |
parent | 49e5f0a10fc3784b318842b06854b38475fc884b (diff) | |
download | android-node-v8-537a4baa443daea9850a8e324b5b4d7c21dd2717.tar.gz android-node-v8-537a4baa443daea9850a8e324b5b4d7c21dd2717.tar.bz2 android-node-v8-537a4baa443daea9850a8e324b5b4d7c21dd2717.zip |
deps: upgrade to libuv 1.21.0
Notable changes:
- Building via cmake is now supported.
PR-URL: https://github.com/libuv/libuv/pull/1850
- Stricter checks have been added to prevent watching the same
file descriptor multiple times.
PR-URL: https://github.com/libuv/libuv/pull/1851
Refs: https://github.com/nodejs/node/issues/3604
- An IPC deadlock on Windows has been fixed.
PR-URL: https://github.com/libuv/libuv/pull/1843
Fixes: https://github.com/nodejs/node/issues/9706
Fixes: https://github.com/nodejs/node/issues/7657
- uv_fs_lchown() has been added.
PR-URL: https://github.com/libuv/libuv/pull/1826
Refs: https://github.com/nodejs/node/issues/19868
- uv_fs_copyfile() sets errno on error.
PR-URL: https://github.com/libuv/libuv/pull/1881
Fixes: https://github.com/nodejs/node/issues/21329
- uv_fs_fchmod() supports -A files on Windows.
PR-URL: https://github.com/libuv/libuv/pull/1819
Refs: https://github.com/nodejs/node/issues/12803
PR-URL: https://github.com/nodejs/node/pull/21466
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'deps/uv/test')
33 files changed, 532 insertions, 116 deletions
diff --git a/deps/uv/test/benchmark-async-pummel.c b/deps/uv/test/benchmark-async-pummel.c index cca3de1062..119ae5eee5 100644 --- a/deps/uv/test/benchmark-async-pummel.c +++ b/deps/uv/test/benchmark-async-pummel.c @@ -41,7 +41,7 @@ static void async_cb(uv_async_t* handle) { /* Tell the pummel thread to stop. */ ACCESS_ONCE(const char*, handle->data) = stop; - /* Wait for for the pummel thread to acknowledge that it has stoppped. */ + /* Wait for the pummel thread to acknowledge that it has stoppped. */ while (ACCESS_ONCE(const char*, handle->data) != stopped) uv_sleep(0); diff --git a/deps/uv/test/run-tests.c b/deps/uv/test/run-tests.c index da4ac82e43..9b8af04608 100644 --- a/deps/uv/test/run-tests.c +++ b/deps/uv/test/run-tests.c @@ -37,6 +37,7 @@ #include "test-list.h" int ipc_helper(int listen_after_write); +int ipc_helper_heavy_traffic_deadlock_bug(void); int ipc_helper_tcp_connection(void); int ipc_helper_closed_handle(void); int ipc_send_recv_helper(void); @@ -83,6 +84,10 @@ static int maybe_run_test(int argc, char **argv) { return ipc_helper(1); } + if (strcmp(argv[1], "ipc_helper_heavy_traffic_deadlock_bug") == 0) { + return ipc_helper_heavy_traffic_deadlock_bug(); + } + if (strcmp(argv[1], "ipc_send_recv_helper") == 0) { return ipc_send_recv_helper(); } diff --git a/deps/uv/test/runner-unix.c b/deps/uv/test/runner-unix.c index 3167ed44bf..de0db0cc48 100644 --- a/deps/uv/test/runner-unix.c +++ b/deps/uv/test/runner-unix.c @@ -57,8 +57,8 @@ int platform_init(int argc, char **argv) { } -/* Invoke "argv[0] test-name [test-part]". Store process info in *p. */ -/* Make sure that all stdio output of the processes is buffered up. */ +/* Invoke "argv[0] test-name [test-part]". Store process info in *p. Make sure + * that all stdio output of the processes is buffered up. */ int process_start(char* name, char* part, process_info_t* p, int is_helper) { FILE* stdout_file; int stdout_fd; @@ -161,9 +161,9 @@ static void* dowait(void* data) { } -/* Wait for all `n` processes in `vec` to terminate. */ -/* Time out after `timeout` msec, or never if timeout == -1 */ -/* Return 0 if all processes are terminated, -1 on error, -2 on timeout. */ +/* Wait for all `n` processes in `vec` to terminate. Time out after `timeout` + * msec, or never if timeout == -1. 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; @@ -358,8 +358,7 @@ int process_terminate(process_info_t *p) { } -/* Return the exit code of process p. */ -/* On error, return -1. */ +/* Return the exit code of process p. On error, return -1. */ int process_reap(process_info_t *p) { if (WIFEXITED(p->status)) { return WEXITSTATUS(p->status); diff --git a/deps/uv/test/runner-win.c b/deps/uv/test/runner-win.c index d86fda3c5d..ce97270547 100644 --- a/deps/uv/test/runner-win.c +++ b/deps/uv/test/runner-win.c @@ -165,8 +165,8 @@ error: } -/* Timeout is is msecs. Set timeout < 0 to never time out. */ -/* Returns 0 when all processes are terminated, -2 on timeout. */ +/* Timeout is in msecs. Set timeout < 0 to never time out. Returns 0 when all + * processes are terminated, -2 on timeout. */ int process_wait(process_info_t *vec, int n, int timeout) { int i; HANDLE handles[MAXIMUM_WAIT_OBJECTS]; diff --git a/deps/uv/test/runner.h b/deps/uv/test/runner.h index 555f2f8eb7..1a33950852 100644 --- a/deps/uv/test/runner.h +++ b/deps/uv/test/runner.h @@ -138,13 +138,13 @@ void print_lines(const char* buffer, size_t size, FILE* stream); /* Do platform-specific initialization. */ int platform_init(int argc, char** argv); -/* Invoke "argv[0] test-name [test-part]". Store process info in *p. */ -/* Make sure that all stdio output of the processes is buffered up. */ +/* Invoke "argv[0] test-name [test-part]". Store process info in *p. Make sure + * that all stdio output of the processes is buffered up. */ int process_start(char *name, char* part, process_info_t *p, int is_helper); -/* Wait for all `n` processes in `vec` to terminate. */ -/* Time out after `timeout` msec, or never if timeout == -1 */ -/* Return 0 if all processes are terminated, -1 on error, -2 on timeout. */ +/* Wait for all `n` processes in `vec` to terminate. Time out after `timeout` + * msec, or never if timeout == -1. Return 0 if all processes are terminated, + * -1 on error, -2 on timeout. */ int process_wait(process_info_t *vec, int n, int timeout); /* Returns the number of bytes in the stdio output buffer for process `p`. */ @@ -164,8 +164,7 @@ char* process_get_name(process_info_t *p); /* Terminate process `p`. */ int process_terminate(process_info_t *p); -/* Return the exit code of process p. */ -/* On error, return -1. */ +/* Return the exit code of process p. On error, return -1. */ int process_reap(process_info_t *p); /* Clean up after terminating process `p` (e.g. free the output buffer etc.). */ diff --git a/deps/uv/test/task.h b/deps/uv/test/task.h index af99d92fb4..92a90a540b 100644 --- a/deps/uv/test/task.h +++ b/deps/uv/test/task.h @@ -29,7 +29,7 @@ #include <stdlib.h> #if defined(_MSC_VER) && _MSC_VER < 1600 -# include "stdint-msvc2008.h" +# include "uv/stdint-msvc2008.h" #else # include <stdint.h> #endif diff --git a/deps/uv/test/test-callback-stack.c b/deps/uv/test/test-callback-stack.c index 8855c0841b..1871e7e981 100644 --- a/deps/uv/test/test-callback-stack.c +++ b/deps/uv/test/test-callback-stack.c @@ -88,10 +88,9 @@ static void read_cb(uv_stream_t* tcp, ssize_t nread, const uv_buf_t* buf) { bytes_received += nread; - /* We call shutdown here because when bytes_received == sizeof MESSAGE */ - /* there will be no more data sent nor received, so here it would be */ - /* possible for a backend to to call shutdown_cb immediately and *not* */ - /* from a fresh stack. */ + /* We call shutdown here because when bytes_received == sizeof MESSAGE there + * will be no more data sent nor received, so here it would be possible for a + * backend to call shutdown_cb immediately and *not* from a fresh stack. */ if (bytes_received == sizeof MESSAGE) { nested++; @@ -131,10 +130,10 @@ static void write_cb(uv_write_t* req, int status) { puts("Data written. 500ms timeout..."); - /* After the data has been sent, we're going to wait for a while, then */ - /* start reading. This makes us certain that the message has been echoed */ - /* back to our receive buffer when we start reading. This maximizes the */ - /* temptation for the backend to use dirty stack for calling read_cb. */ + /* After the data has been sent, we're going to wait for a while, then start + * reading. This makes us certain that the message has been echoed back to + * our receive buffer when we start reading. This maximizes the temptation + * for the backend to use dirty stack for calling read_cb. */ nested++; r = uv_timer_init(uv_default_loop(), &timer); ASSERT(r == 0); diff --git a/deps/uv/test/test-connection-fail.c b/deps/uv/test/test-connection-fail.c index 328bff46e7..8338cacdec 100644 --- a/deps/uv/test/test-connection-fail.c +++ b/deps/uv/test/test-connection-fail.c @@ -98,8 +98,8 @@ static void connection_fail(uv_connect_cb connect_cb) { r = uv_tcp_init(uv_default_loop(), &tcp); ASSERT(!r); - /* We are never doing multiple reads/connects at a time anyway. */ - /* so these handles can be pre-initialized. */ + /* We are never doing multiple reads/connects at a time anyway. so these + * handles can be pre-initialized. */ ASSERT(0 == uv_tcp_bind(&tcp, (const struct sockaddr*) &client_addr, 0)); r = uv_tcp_connect(&req, diff --git a/deps/uv/test/test-delayed-accept.c b/deps/uv/test/test-delayed-accept.c index 4a7998909c..513e69bd5b 100644 --- a/deps/uv/test/test-delayed-accept.c +++ b/deps/uv/test/test-delayed-accept.c @@ -138,8 +138,8 @@ static void connect_cb(uv_connect_t* req, int status) { ASSERT(req != NULL); ASSERT(status == 0); - /* Not that the server will send anything, but otherwise we'll never know */ - /* when the server closes the connection. */ + /* Not that the server will send anything, but otherwise we'll never know + * when the server closes the connection. */ r = uv_read_start((uv_stream_t*)(req->handle), alloc_cb, read_cb); ASSERT(r == 0); diff --git a/deps/uv/test/test-fork.c b/deps/uv/test/test-fork.c index 39b59c8f20..2a1ddc497a 100644 --- a/deps/uv/test/test-fork.c +++ b/deps/uv/test/test-fork.c @@ -317,8 +317,7 @@ TEST_IMPL(fork_signal_to_child_closed) { printf("Waiting for child in parent\n"); assert_wait_child(child_pid); } else { - /* child */ - /* Our signal handler should still be installed. */ + /* Child. Our signal handler should still be installed. */ ASSERT(0 == uv_loop_fork(uv_default_loop())); printf("Checking loop in child\n"); ASSERT(0 != uv_loop_alive(uv_default_loop())); @@ -652,13 +651,11 @@ TEST_IMPL(fork_threadpool_queue_work_simple) { ASSERT(child_pid != -1); if (child_pid != 0) { - /* parent */ - /* We can still run work. */ + /* Parent. We can still run work. */ assert_run_work(uv_default_loop()); assert_wait_child(child_pid); } else { - /* child */ - /* We can work in a new loop. */ + /* Child. We can work in a new loop. */ printf("Running child in %d\n", getpid()); uv_loop_init(&loop); printf("Child first watch\n"); diff --git a/deps/uv/test/test-fs-copyfile.c b/deps/uv/test/test-fs-copyfile.c index 6cd43b4502..eadff542bc 100644 --- a/deps/uv/test/test-fs-copyfile.c +++ b/deps/uv/test/test-fs-copyfile.c @@ -179,7 +179,7 @@ TEST_IMPL(fs_copyfile) { unlink(dst); r = uv_fs_copyfile(NULL, &req, fixture, dst, UV_FS_COPYFILE_FICLONE_FORCE, NULL); - ASSERT(r == 0 || r == UV_ENOSYS || r == UV_ENOTSUP || r == UV_ENOTTY); + ASSERT(r == 0 || r == UV_ENOSYS || r == UV_ENOTSUP); if (r == 0) handle_result(&req); diff --git a/deps/uv/test/test-fs.c b/deps/uv/test/test-fs.c index 000a151a64..57da39891a 100644 --- a/deps/uv/test/test-fs.c +++ b/deps/uv/test/test-fs.c @@ -84,6 +84,7 @@ static int chmod_cb_count; static int fchmod_cb_count; static int chown_cb_count; static int fchown_cb_count; +static int lchown_cb_count; static int link_cb_count; static int symlink_cb_count; static int readlink_cb_count; @@ -253,6 +254,13 @@ static void chown_cb(uv_fs_t* req) { uv_fs_req_cleanup(req); } +static void lchown_cb(uv_fs_t* req) { + ASSERT(req->fs_type == UV_FS_LCHOWN); + ASSERT(req->result == 0); + lchown_cb_count++; + uv_fs_req_cleanup(req); +} + static void chown_root_cb(uv_fs_t* req) { ASSERT(req->fs_type == UV_FS_CHOWN); #if defined(_WIN32) || defined(__MSYS__) @@ -1540,6 +1548,7 @@ TEST_IMPL(fs_chown) { /* Setup. */ unlink("test_file"); + unlink("test_file_link"); loop = uv_default_loop(); @@ -1583,7 +1592,29 @@ TEST_IMPL(fs_chown) { uv_run(loop, UV_RUN_DEFAULT); ASSERT(fchown_cb_count == 1); - close(file); + /* sync link */ + r = uv_fs_link(NULL, &req, "test_file", "test_file_link", NULL); + ASSERT(r == 0); + ASSERT(req.result == 0); + uv_fs_req_cleanup(&req); + + /* sync lchown */ + r = uv_fs_lchown(NULL, &req, "test_file_link", -1, -1, NULL); + ASSERT(r == 0); + ASSERT(req.result == 0); + uv_fs_req_cleanup(&req); + + /* async lchown */ + r = uv_fs_lchown(loop, &req, "test_file_link", -1, -1, lchown_cb); + ASSERT(r == 0); + uv_run(loop, UV_RUN_DEFAULT); + ASSERT(lchown_cb_count == 1); + + /* Close file */ + r = uv_fs_close(NULL, &req, file, NULL); + ASSERT(r == 0); + ASSERT(req.result == 0); + uv_fs_req_cleanup(&req); /* * Run the loop just to check we don't have make any extraneous uv_ref() @@ -1593,6 +1624,7 @@ TEST_IMPL(fs_chown) { /* Cleanup. */ unlink("test_file"); + unlink("test_file_link"); MAKE_VALGRIND_HAPPY(); return 0; @@ -3230,3 +3262,138 @@ TEST_IMPL(fs_exclusive_sharing_mode) { return 0; } #endif + +#ifdef _WIN32 +int call_icacls(const char* command, ...) { + char icacls_command[1024]; + va_list args; + + va_start(args, command); + vsnprintf(icacls_command, ARRAYSIZE(icacls_command), command, args); + va_end(args); + return system(icacls_command); +} + +TEST_IMPL(fs_open_readonly_acl) { + uv_passwd_t pwd; + uv_fs_t req; + int r; + + /* + Based on Node.js test from + https://github.com/nodejs/node/commit/3ba81e34e86a5c32658e218cb6e65b13e8326bc5 + + If anything goes wrong, you can delte the test_fle_icacls with: + + icacls test_file_icacls /remove "%USERNAME%" /inheritance:e + attrib -r test_file_icacls + del test_file_icacls + */ + + /* Setup - clear the ACL and remove the file */ + loop = uv_default_loop(); + r = uv_os_get_passwd(&pwd); + ASSERT(r == 0); + call_icacls("icacls test_file_icacls /remove \"%s\" /inheritance:e", + pwd.username); + uv_fs_chmod(loop, &req, "test_file_icacls", S_IWUSR, NULL); + unlink("test_file_icacls"); + + /* Create the file */ + r = uv_fs_open(loop, + &open_req1, + "test_file_icacls", + O_RDONLY | O_CREAT, + S_IRUSR, + NULL); + ASSERT(r >= 0); + ASSERT(open_req1.result >= 0); + uv_fs_req_cleanup(&open_req1); + r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); + ASSERT(r == 0); + ASSERT(close_req.result == 0); + uv_fs_req_cleanup(&close_req); + + /* Set up ACL */ + r = call_icacls("icacls test_file_icacls /inheritance:r /remove \"%s\"", + pwd.username); + if (r != 0) { + goto acl_cleanup; + } + r = call_icacls("icacls test_file_icacls /grant \"%s\":RX", pwd.username); + if (r != 0) { + goto acl_cleanup; + } + + /* Try opening the file */ + r = uv_fs_open(NULL, &open_req1, "test_file_icacls", O_RDONLY, 0, NULL); + if (r < 0) { + goto acl_cleanup; + } + uv_fs_req_cleanup(&open_req1); + r = uv_fs_close(NULL, &close_req, open_req1.result, NULL); + if (r != 0) { + goto acl_cleanup; + } + uv_fs_req_cleanup(&close_req); + + acl_cleanup: + /* Cleanup */ + call_icacls("icacls test_file_icacls /remove \"%s\" /inheritance:e", + pwd.username); + unlink("test_file_icacls"); + uv_os_free_passwd(&pwd); + ASSERT(r == 0); + MAKE_VALGRIND_HAPPY(); + return 0; +} +#endif + +#ifdef _WIN32 +TEST_IMPL(fs_fchmod_archive_readonly) { + uv_fs_t req; + uv_file file; + int r; + /* Test clearing read-only flag from files with Archive flag cleared */ + + /* Setup*/ + unlink("test_file"); + r = uv_fs_open(NULL, + &req, + "test_file", + O_WRONLY | O_CREAT, + S_IWUSR | S_IRUSR, + NULL); + ASSERT(r >= 0); + ASSERT(req.result >= 0); + file = req.result; + uv_fs_req_cleanup(&req); + r = uv_fs_close(NULL, &req, file, NULL); + ASSERT(r == 0); + uv_fs_req_cleanup(&req); + /* Make the file read-only and clear archive flag */ + r = SetFileAttributes("test_file", FILE_ATTRIBUTE_READONLY); + ASSERT(r != 0); + check_permission("test_file", 0400); + /* Try fchmod */ + r = uv_fs_open(NULL, &req, "test_file", O_RDONLY, 0, NULL); + ASSERT(r >= 0); + ASSERT(req.result >= 0); + file = req.result; + uv_fs_req_cleanup(&req); + r = uv_fs_fchmod(NULL, &req, file, S_IWUSR, NULL); + ASSERT(r == 0); + ASSERT(req.result == 0); + uv_fs_req_cleanup(&req); + r = uv_fs_close(NULL, &req, file, NULL); + ASSERT(r == 0); + uv_fs_req_cleanup(&req); + check_permission("test_file", S_IWUSR); + + /* Restore Archive flag for rest of the tests */ + r = SetFileAttributes("test_file", FILE_ATTRIBUTE_ARCHIVE); + ASSERT(r != 0); + + return 0; +} +#endif diff --git a/deps/uv/test/test-hrtime.c b/deps/uv/test/test-hrtime.c index 72a4d4b181..fbe9a68bfc 100644 --- a/deps/uv/test/test-hrtime.c +++ b/deps/uv/test/test-hrtime.c @@ -43,9 +43,9 @@ TEST_IMPL(hrtime) { /* printf("i= %d diff = %llu\n", i, (unsigned long long int) diff); */ - /* The windows Sleep() function has only a resolution of 10-20 ms. */ - /* Check that the difference between the two hrtime values is somewhat in */ - /* the range we expect it to be. */ + /* The windows Sleep() function has only a resolution of 10-20 ms. Check + * that the difference between the two hrtime values is somewhat in the + * range we expect it to be. */ ASSERT(diff > (uint64_t) 25 * NANOSEC / MILLISEC); ASSERT(diff < (uint64_t) 80 * NANOSEC / MILLISEC); --i; diff --git a/deps/uv/test/test-ipc-heavy-traffic-deadlock-bug.c b/deps/uv/test/test-ipc-heavy-traffic-deadlock-bug.c new file mode 100644 index 0000000000..240fc64588 --- /dev/null +++ b/deps/uv/test/test-ipc-heavy-traffic-deadlock-bug.c @@ -0,0 +1,158 @@ +/* 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 "task.h" +#include "uv.h" + +#include <string.h> + +/* See test-ipc.c */ +void spawn_helper(uv_pipe_t* channel, + uv_process_t* process, + const char* helper); + +#define NUM_WRITES 256 +#define BUFFERS_PER_WRITE 3 +#define BUFFER_SIZE 0x2000 /* 8 kb. */ +#define BUFFER_CONTENT 42 + +#define XFER_SIZE (NUM_WRITES * BUFFERS_PER_WRITE * BUFFER_SIZE) + +struct write_info { + uv_write_t write_req; + char buffers[BUFFER_SIZE][BUFFERS_PER_WRITE]; +}; + +static uv_shutdown_t shutdown_req; + +static size_t bytes_written; +static size_t bytes_read; + +static void write_cb(uv_write_t* req, int status) { + struct write_info* write_info = + container_of(req, struct write_info, write_req); + ASSERT(status == 0); + bytes_written += BUFFERS_PER_WRITE * BUFFER_SIZE; + free(write_info); +} + +static void shutdown_cb(uv_shutdown_t* req, int status) { + ASSERT(status == 0); + uv_close((uv_handle_t*) req->handle, NULL); +} + +static void do_write(uv_stream_t* handle) { + struct write_info* write_info; + uv_buf_t bufs[BUFFERS_PER_WRITE]; + size_t i; + int r; + + write_info = malloc(sizeof *write_info); + ASSERT(write_info != NULL); + + for (i = 0; i < BUFFERS_PER_WRITE; i++) { + memset(&write_info->buffers[i], BUFFER_CONTENT, BUFFER_SIZE); + bufs[i] = uv_buf_init(write_info->buffers[i], BUFFER_SIZE); + } + + r = uv_write( + &write_info->write_req, handle, bufs, BUFFERS_PER_WRITE, write_cb); + ASSERT(r == 0); +} + +static void alloc_cb(uv_handle_t* handle, + size_t suggested_size, + uv_buf_t* buf) { + buf->base = malloc(suggested_size); + buf->len = (int) suggested_size; +} + +#ifndef _WIN32 +#include <sys/types.h> +#include <unistd.h> +#endif + +static void read_cb(uv_stream_t* handle, ssize_t nread, const uv_buf_t* buf) { + ssize_t i; + int r; + + ASSERT(nread >= 0); + bytes_read += nread; + + for (i = 0; i < nread; i++) + ASSERT(buf->base[i] == BUFFER_CONTENT); + free(buf->base); + + if (bytes_read >= XFER_SIZE) { + r = uv_read_stop(handle); + ASSERT(r == 0); + r = uv_shutdown(&shutdown_req, handle, shutdown_cb); + ASSERT(r == 0); + } +} + +static void do_writes_and_reads(uv_stream_t* handle) { + size_t i; + int r; + + bytes_written = 0; + bytes_read = 0; + + for (i = 0; i < NUM_WRITES; i++) { + do_write(handle); + } + + r = uv_read_start(handle, alloc_cb, read_cb); + ASSERT(r == 0); + + r = uv_run(handle->loop, UV_RUN_DEFAULT); + ASSERT(r == 0); + + ASSERT(bytes_written == XFER_SIZE); + ASSERT(bytes_read == XFER_SIZE); +} + +TEST_IMPL(ipc_heavy_traffic_deadlock_bug) { + uv_pipe_t pipe; + uv_process_t process; + + spawn_helper(&pipe, &process, "ipc_helper_heavy_traffic_deadlock_bug"); + do_writes_and_reads((uv_stream_t*) &pipe); + + MAKE_VALGRIND_HAPPY(); + return 0; +} + +int ipc_helper_heavy_traffic_deadlock_bug(void) { + uv_pipe_t pipe; + int r; + + r = uv_pipe_init(uv_default_loop(), &pipe, 1); + ASSERT(r == 0); + r = uv_pipe_open(&pipe, 0); + ASSERT(r == 0); + + do_writes_and_reads((uv_stream_t*) &pipe); + uv_sleep(100); + + MAKE_VALGRIND_HAPPY(); + return 0; +} diff --git a/deps/uv/test/test-ipc-send-recv.c b/deps/uv/test/test-ipc-send-recv.c index 917744cbae..3dedc86b8b 100644 --- a/deps/uv/test/test-ipc-send-recv.c +++ b/deps/uv/test/test-ipc-send-recv.c @@ -25,7 +25,7 @@ #include <stdio.h> #include <string.h> -/* See test-ipc.ctx */ +/* See test-ipc.c */ void spawn_helper(uv_pipe_t* channel, uv_process_t* process, const char* helper); @@ -149,6 +149,7 @@ static void connect_cb(uv_connect_t* req, int status) { &ctx.send.stream, NULL); ASSERT(r == 0); + ASSERT(ctx.write_req.send_handle == &ctx.send.stream); /* Perform two writes to the same pipe to make sure that on Windows we are * not running into issue 505: @@ -160,6 +161,7 @@ static void connect_cb(uv_connect_t* req, int status) { &ctx.send2.stream, NULL); ASSERT(r == 0); + ASSERT(ctx.write_req2.send_handle == &ctx.send2.stream); r = uv_read_start((uv_stream_t*)&ctx.channel, alloc_cb, recv_cb); ASSERT(r == 0); @@ -344,6 +346,7 @@ static void read_cb(uv_stream_t* handle, &recv->stream, write2_cb); ASSERT(r == 0); + ASSERT(write_req->send_handle == &recv->stream); } while (uv_pipe_pending_count(pipe) > 0); } diff --git a/deps/uv/test/test-ipc.c b/deps/uv/test/test-ipc.c index 88d63d4dc6..200f68d600 100644 --- a/deps/uv/test/test-ipc.c +++ b/deps/uv/test/test-ipc.c @@ -281,7 +281,7 @@ void spawn_helper(uv_pipe_t* channel, char exepath[1024]; char* args[3]; int r; - uv_stdio_container_t stdio[1]; + uv_stdio_container_t stdio[3]; r = uv_pipe_init(uv_default_loop(), channel, 1); ASSERT(r == 0); @@ -300,12 +300,15 @@ void spawn_helper(uv_pipe_t* channel, options.file = exepath; options.args = args; options.exit_cb = exit_cb; - 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; + options.stdio_count = ARRAY_SIZE(stdio); + + stdio[0].flags = UV_CREATE_PIPE | UV_READABLE_PIPE | UV_WRITABLE_PIPE; + stdio[0].data.stream = (uv_stream_t*) channel; + stdio[1].flags = UV_INHERIT_FD; + stdio[1].data.fd = 1; + stdio[2].flags = UV_INHERIT_FD; + stdio[2].data.fd = 2; r = uv_spawn(uv_default_loop(), process, &options); ASSERT(r == 0); diff --git a/deps/uv/test/test-list.h b/deps/uv/test/test-list.h index b89930d709..e59c6b6551 100644 --- a/deps/uv/test/test-list.h +++ b/deps/uv/test/test-list.h @@ -57,6 +57,7 @@ TEST_DECLARE (tty_pty) TEST_DECLARE (stdio_over_pipes) TEST_DECLARE (ip6_pton) TEST_DECLARE (connect_unspecified) +TEST_DECLARE (ipc_heavy_traffic_deadlock_bug) TEST_DECLARE (ipc_listen_before_write) TEST_DECLARE (ipc_listen_after_write) #ifndef _WIN32 @@ -71,8 +72,11 @@ TEST_DECLARE (ipc_closed_handle) #endif TEST_DECLARE (tcp_alloc_cb_fail) TEST_DECLARE (tcp_ping_pong) -TEST_DECLARE (tcp_ping_pong_v6) +TEST_DECLARE (tcp_ping_pong_vec) +TEST_DECLARE (tcp6_ping_pong) +TEST_DECLARE (tcp6_ping_pong_vec) TEST_DECLARE (pipe_ping_pong) +TEST_DECLARE (pipe_ping_pong_vec) TEST_DECLARE (delayed_accept) TEST_DECLARE (multiple_listen) #ifndef _WIN32 @@ -337,6 +341,8 @@ TEST_DECLARE (fs_file_pos_after_op_with_offset) TEST_DECLARE (fs_null_req) #ifdef _WIN32 TEST_DECLARE (fs_exclusive_sharing_mode) +TEST_DECLARE (fs_open_readonly_acl) +TEST_DECLARE (fs_fchmod_archive_readonly) #endif TEST_DECLARE (threadpool_queue_work_simple) TEST_DECLARE (threadpool_queue_work_einval) @@ -479,6 +485,7 @@ TASK_LIST_START TEST_ENTRY (stdio_over_pipes) TEST_ENTRY (ip6_pton) TEST_ENTRY (connect_unspecified) + TEST_ENTRY (ipc_heavy_traffic_deadlock_bug) TEST_ENTRY (ipc_listen_before_write) TEST_ENTRY (ipc_listen_after_write) #ifndef _WIN32 @@ -497,12 +504,21 @@ TASK_LIST_START TEST_ENTRY (tcp_ping_pong) TEST_HELPER (tcp_ping_pong, tcp4_echo_server) - TEST_ENTRY (tcp_ping_pong_v6) - TEST_HELPER (tcp_ping_pong_v6, tcp6_echo_server) + TEST_ENTRY (tcp_ping_pong_vec) + TEST_HELPER (tcp_ping_pong_vec, tcp4_echo_server) + + TEST_ENTRY (tcp6_ping_pong) + TEST_HELPER (tcp6_ping_pong, tcp6_echo_server) + + TEST_ENTRY (tcp6_ping_pong_vec) + TEST_HELPER (tcp6_ping_pong_vec, tcp6_echo_server) TEST_ENTRY (pipe_ping_pong) TEST_HELPER (pipe_ping_pong, pipe_echo_server) + TEST_ENTRY (pipe_ping_pong_vec) + TEST_HELPER (pipe_ping_pong_vec, pipe_echo_server) + TEST_ENTRY (delayed_accept) TEST_ENTRY (multiple_listen) @@ -708,7 +724,7 @@ TASK_LIST_START TEST_ENTRY (hrtime) TEST_ENTRY_CUSTOM (getaddrinfo_fail, 0, 0, 10000) - TEST_ENTRY (getaddrinfo_fail_sync) + TEST_ENTRY_CUSTOM (getaddrinfo_fail_sync, 0, 0, 10000) TEST_ENTRY (getaddrinfo_basic) TEST_ENTRY (getaddrinfo_basic_sync) @@ -869,6 +885,8 @@ TASK_LIST_START TEST_ENTRY (fs_null_req) #ifdef _WIN32 TEST_ENTRY (fs_exclusive_sharing_mode) + TEST_ENTRY (fs_open_readonly_acl) + TEST_ENTRY (fs_fchmod_archive_readonly) #endif TEST_ENTRY (get_osfhandle_valid_handle) TEST_ENTRY (threadpool_queue_work_simple) diff --git a/deps/uv/test/test-loop-handles.c b/deps/uv/test/test-loop-handles.c index c3e8498ae9..6471cd08b3 100644 --- a/deps/uv/test/test-loop-handles.c +++ b/deps/uv/test/test-loop-handles.c @@ -228,8 +228,8 @@ static void check_cb(uv_check_t* handle) { uv_close((uv_handle_t*)&idle_1_handles[i], idle_1_close_cb); } - /* This handle is closed/recreated every time, close it only if it is */ - /* active.*/ + /* This handle is closed/recreated every time, close it only if it is + * active. */ if (idle_2_is_active) { uv_close((uv_handle_t*)&idle_2_handle, idle_2_close_cb); } @@ -246,10 +246,10 @@ static void prepare_2_cb(uv_prepare_t* handle) { fflush(stderr); ASSERT(handle == &prepare_2_handle); - /* prepare_2 gets started by prepare_1 when (loop_iteration % 2 == 0), */ - /* and it stops itself immediately. A started watcher is not queued */ - /* until the next round, so when this callback is made */ - /* (loop_iteration % 2 == 0) cannot be true. */ + /* Prepare_2 gets started by prepare_1 when (loop_iteration % 2 == 0), and it + * stops itself immediately. A started watcher is not queued until the next + * round, so when this callback is made (loop_iteration % 2 == 0) cannot be + * true. */ ASSERT(loop_iteration % 2 != 0); r = uv_prepare_stop((uv_prepare_t*)handle); @@ -304,8 +304,8 @@ TEST_IMPL(loop_handles) { /* don't init or start idle_2, both is done by idle_1_cb */ - /* the timer callback is there to keep the event loop polling */ - /* unref it as it is not supposed to keep the loop alive */ + /* The timer callback is there to keep the event loop polling unref it as it + * is not supposed to keep the loop alive */ r = uv_timer_init(uv_default_loop(), &timer_handle); ASSERT(r == 0); r = uv_timer_start(&timer_handle, timer_cb, TIMEOUT, TIMEOUT); diff --git a/deps/uv/test/test-ping-pong.c b/deps/uv/test/test-ping-pong.c index 508f0db67b..c86a3f4a66 100644 --- a/deps/uv/test/test-ping-pong.c +++ b/deps/uv/test/test-ping-pong.c @@ -22,8 +22,8 @@ #include "uv.h" #include "task.h" -#include <stdlib.h> #include <stdio.h> +#include <stdlib.h> static int completed_pingers = 0; @@ -41,6 +41,7 @@ static int pinger_on_connect_count; typedef struct { + int vectored_writes; int pongs; int state; union { @@ -77,15 +78,26 @@ static void pinger_after_write(uv_write_t *req, int status) { static void pinger_write_ping(pinger_t* pinger) { uv_write_t *req; - uv_buf_t buf; - - buf = uv_buf_init(PING, sizeof(PING) - 1); + uv_buf_t bufs[sizeof PING - 1]; + int i, nbufs; + + if (!pinger->vectored_writes) { + /* Write a single buffer. */ + nbufs = 1; + bufs[0] = uv_buf_init(PING, sizeof PING - 1); + } else { + /* Write multiple buffers, each with one byte in them. */ + nbufs = sizeof PING - 1; + for (i = 0; i < nbufs; i++) { + bufs[i] = uv_buf_init(&PING[i], 1); + } + } req = malloc(sizeof(*req)); if (uv_write(req, (uv_stream_t*) &pinger->stream.tcp, - &buf, - 1, + bufs, + nbufs, pinger_after_write)) { FATAL("uv_write failed"); } @@ -154,7 +166,7 @@ static void pinger_on_connect(uv_connect_t *req, int status) { /* same ping-pong test, but using IPv6 connection */ -static void tcp_pinger_v6_new(void) { +static void tcp_pinger_v6_new(int vectored_writes) { int r; struct sockaddr_in6 server_addr; pinger_t *pinger; @@ -163,6 +175,7 @@ static void tcp_pinger_v6_new(void) { ASSERT(0 ==uv_ip6_addr("::1", TEST_PORT, &server_addr)); pinger = malloc(sizeof(*pinger)); ASSERT(pinger != NULL); + pinger->vectored_writes = vectored_writes; pinger->state = 0; pinger->pongs = 0; @@ -171,8 +184,8 @@ static void tcp_pinger_v6_new(void) { pinger->stream.tcp.data = pinger; ASSERT(!r); - /* We are never doing multiple reads/connects at a time anyway. */ - /* so these handles can be pre-initialized. */ + /* We are never doing multiple reads/connects at a time anyway, so these + * handles can be pre-initialized. */ r = uv_tcp_connect(&pinger->connect_req, &pinger->stream.tcp, (const struct sockaddr*) &server_addr, @@ -184,7 +197,7 @@ static void tcp_pinger_v6_new(void) { } -static void tcp_pinger_new(void) { +static void tcp_pinger_new(int vectored_writes) { int r; struct sockaddr_in server_addr; pinger_t *pinger; @@ -192,6 +205,7 @@ static void tcp_pinger_new(void) { ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &server_addr)); pinger = malloc(sizeof(*pinger)); ASSERT(pinger != NULL); + pinger->vectored_writes = vectored_writes; pinger->state = 0; pinger->pongs = 0; @@ -200,8 +214,8 @@ static void tcp_pinger_new(void) { pinger->stream.tcp.data = pinger; ASSERT(!r); - /* We are never doing multiple reads/connects at a time anyway. */ - /* so these handles can be pre-initialized. */ + /* We are never doing multiple reads/connects at a time anyway, so these + * handles can be pre-initialized. */ r = uv_tcp_connect(&pinger->connect_req, &pinger->stream.tcp, (const struct sockaddr*) &server_addr, @@ -213,12 +227,13 @@ static void tcp_pinger_new(void) { } -static void pipe_pinger_new(void) { +static void pipe_pinger_new(int vectored_writes) { int r; pinger_t *pinger; pinger = (pinger_t*)malloc(sizeof(*pinger)); ASSERT(pinger != NULL); + pinger->vectored_writes = vectored_writes; pinger->state = 0; pinger->pongs = 0; @@ -227,9 +242,8 @@ static void pipe_pinger_new(void) { pinger->stream.pipe.data = pinger; ASSERT(!r); - /* We are never doing multiple reads/connects at a time anyway. */ - /* so these handles can be pre-initialized. */ - + /* We are never doing multiple reads/connects at a time anyway, so these + * handles can be pre-initialized. */ uv_pipe_connect(&pinger->connect_req, &pinger->stream.pipe, TEST_PIPENAME, pinger_on_connect); @@ -238,10 +252,8 @@ static void pipe_pinger_new(void) { } -TEST_IMPL(tcp_ping_pong) { - tcp_pinger_new(); +static int run_ping_pong_test(void) { uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(completed_pingers == 1); MAKE_VALGRIND_HAPPY(); @@ -249,26 +261,41 @@ TEST_IMPL(tcp_ping_pong) { } -TEST_IMPL(tcp_ping_pong_v6) { +TEST_IMPL(tcp_ping_pong) { + tcp_pinger_new(0); + return run_ping_pong_test(); +} + + +TEST_IMPL(tcp_ping_pong_vec) { + tcp_pinger_new(1); + return run_ping_pong_test(); +} + + +TEST_IMPL(tcp6_ping_pong) { if (!can_ipv6()) RETURN_SKIP("IPv6 not supported"); + tcp_pinger_v6_new(0); + return run_ping_pong_test(); +} - tcp_pinger_v6_new(); - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - ASSERT(completed_pingers == 1); - - MAKE_VALGRIND_HAPPY(); - return 0; +TEST_IMPL(tcp6_ping_pong_vec) { + if (!can_ipv6()) + RETURN_SKIP("IPv6 not supported"); + tcp_pinger_v6_new(1); + return run_ping_pong_test(); } TEST_IMPL(pipe_ping_pong) { - pipe_pinger_new(); - uv_run(uv_default_loop(), UV_RUN_DEFAULT); + pipe_pinger_new(0); + return run_ping_pong_test(); +} - ASSERT(completed_pingers == 1); - MAKE_VALGRIND_HAPPY(); - return 0; +TEST_IMPL(pipe_ping_pong_vec) { + pipe_pinger_new(1); + return run_ping_pong_test(); } diff --git a/deps/uv/test/test-pipe-set-fchmod.c b/deps/uv/test/test-pipe-set-fchmod.c index de4932dc1a..91e476652e 100644 --- a/deps/uv/test/test-pipe-set-fchmod.c +++ b/deps/uv/test/test-pipe-set-fchmod.c @@ -39,8 +39,8 @@ TEST_IMPL(pipe_set_chmod) { r = uv_pipe_bind(&pipe_handle, TEST_PIPENAME); ASSERT(r == 0); - /* No easy way to test if this works, we will only make sure that */ - /* the call is successful. */ + /* No easy way to test if this works, we will only make sure that the call is + * successful. */ r = uv_pipe_chmod(&pipe_handle, UV_READABLE); if (r == UV_EPERM) { MAKE_VALGRIND_HAPPY(); diff --git a/deps/uv/test/test-process-title-threadsafe.c b/deps/uv/test/test-process-title-threadsafe.c index d986576ed9..cc3fd41a13 100644 --- a/deps/uv/test/test-process-title-threadsafe.c +++ b/deps/uv/test/test-process-title-threadsafe.c @@ -26,7 +26,7 @@ #include <string.h> #ifdef __APPLE__ -# define NUM_ITERATIONS 20 +# define NUM_ITERATIONS 10 #else # define NUM_ITERATIONS 50 #endif diff --git a/deps/uv/test/test-signal-multiple-loops.c b/deps/uv/test/test-signal-multiple-loops.c index 1272d4576f..79242fc9fa 100644 --- a/deps/uv/test/test-signal-multiple-loops.c +++ b/deps/uv/test/test-signal-multiple-loops.c @@ -249,7 +249,7 @@ TEST_IMPL(signal_multiple_loops) { uv_sem_wait(&sem); /* Block all signals to this thread, so we are sure that from here the signal - * handler runs in another thread. This is is more likely to catch thread and + * handler runs in another thread. This is more likely to catch thread and * signal safety issues if there are any. */ sigfillset(&sigset); diff --git a/deps/uv/test/test-spawn.c b/deps/uv/test/test-spawn.c index 4a2869a18a..1ab6e78807 100644 --- a/deps/uv/test/test-spawn.c +++ b/deps/uv/test/test-spawn.c @@ -1637,8 +1637,8 @@ TEST_IMPL(spawn_reads_child_path) { 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 */ + /* 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); /* Set up the PATH env variable */ @@ -1805,8 +1805,8 @@ TEST_IMPL(spawn_quoted_path) { 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 */ + /* We test if search_path works correctly with semicolons in quoted path. We + * will use an 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; diff --git a/deps/uv/test/test-tcp-open.c b/deps/uv/test/test-tcp-open.c index cb74c50e2c..f5d8f136b1 100644 --- a/deps/uv/test/test-tcp-open.c +++ b/deps/uv/test/test-tcp-open.c @@ -181,6 +181,20 @@ TEST_IMPL(tcp_open) { connect_cb); ASSERT(r == 0); +#ifndef _WIN32 + { + uv_tcp_t client2; + + r = uv_tcp_init(uv_default_loop(), &client2); + ASSERT(r == 0); + + r = uv_tcp_open(&client2, sock); + ASSERT(r == UV_EEXIST); + + uv_close((uv_handle_t*) &client2, NULL); + } +#endif /* !_WIN32 */ + uv_run(uv_default_loop(), UV_RUN_DEFAULT); ASSERT(shutdown_cb_called == 1); diff --git a/deps/uv/test/test-timer-again.c b/deps/uv/test/test-timer-again.c index f93c509be5..e87d2edf18 100644 --- a/deps/uv/test/test-timer-again.c +++ b/deps/uv/test/test-timer-again.c @@ -58,8 +58,8 @@ static void repeat_1_cb(uv_timer_t* handle) { if (repeat_1_cb_called == 10) { uv_close((uv_handle_t*)handle, close_cb); - /* We're not calling uv_timer_again on repeat_2 any more, so after this */ - /* timer_2_cb is expected. */ + /* We're not calling uv_timer_again on repeat_2 any more, so after this + * timer_2_cb is expected. */ repeat_2_cb_allowed = 1; return; } diff --git a/deps/uv/test/test-udp-alloc-cb-fail.c b/deps/uv/test/test-udp-alloc-cb-fail.c index 05b871e921..0cee09c942 100644 --- a/deps/uv/test/test-udp-alloc-cb-fail.c +++ b/deps/uv/test/test-udp-alloc-cb-fail.c @@ -120,8 +120,7 @@ static void sv_recv_cb(uv_udp_t* handle, } if (nread == 0) { - /* Returning unused buffer */ - /* Don't count towards sv_recv_cb_called */ + /* Returning unused buffer. Don't count towards sv_recv_cb_called */ ASSERT(addr == NULL); return; } diff --git a/deps/uv/test/test-udp-multicast-join.c b/deps/uv/test/test-udp-multicast-join.c index 6110a8d922..053d2f7914 100644 --- a/deps/uv/test/test-udp-multicast-join.c +++ b/deps/uv/test/test-udp-multicast-join.c @@ -81,8 +81,7 @@ static void cl_recv_cb(uv_udp_t* handle, } if (nread == 0) { - /* Returning unused buffer */ - /* Don't count towards cl_recv_cb_called */ + /* Returning unused buffer. Don't count towards cl_recv_cb_called */ ASSERT(addr == NULL); return; } diff --git a/deps/uv/test/test-udp-multicast-join6.c b/deps/uv/test/test-udp-multicast-join6.c index cf316e107a..bda5e20ea7 100644 --- a/deps/uv/test/test-udp-multicast-join6.c +++ b/deps/uv/test/test-udp-multicast-join6.c @@ -82,8 +82,7 @@ static void cl_recv_cb(uv_udp_t* handle, } if (nread == 0) { - /* Returning unused buffer */ - /* Don't count towards cl_recv_cb_called */ + /* Returning unused buffer. Don't count towards cl_recv_cb_called */ ASSERT(addr == NULL); return; } diff --git a/deps/uv/test/test-udp-open.c b/deps/uv/test/test-udp-open.c index 4d77f45d36..ee04c99f61 100644 --- a/deps/uv/test/test-udp-open.c +++ b/deps/uv/test/test-udp-open.c @@ -106,8 +106,7 @@ static void recv_cb(uv_udp_t* handle, } if (nread == 0) { - /* Returning unused buffer */ - /* Don't count towards sv_recv_cb_called */ + /* Returning unused buffer. Don't count towards sv_recv_cb_called */ ASSERT(addr == NULL); return; } @@ -165,6 +164,20 @@ TEST_IMPL(udp_open) { send_cb); ASSERT(r == 0); +#ifndef _WIN32 + { + uv_udp_t client2; + + r = uv_udp_init(uv_default_loop(), &client2); + ASSERT(r == 0); + + r = uv_udp_open(&client2, sock); + ASSERT(r == UV_EEXIST); + + uv_close((uv_handle_t*) &client2, NULL); + } +#endif /* !_WIN32 */ + uv_run(uv_default_loop(), UV_RUN_DEFAULT); ASSERT(send_cb_called == 1); diff --git a/deps/uv/test/test-udp-options.c b/deps/uv/test/test-udp-options.c index 8f91367590..d8c9d68d81 100644 --- a/deps/uv/test/test-udp-options.c +++ b/deps/uv/test/test-udp-options.c @@ -114,9 +114,11 @@ TEST_IMPL(udp_options6) { TEST_IMPL(udp_no_autobind) { uv_loop_t* loop; uv_udp_t h; + uv_udp_t h2; loop = uv_default_loop(); + /* Test a lazy initialized socket. */ ASSERT(0 == uv_udp_init(loop, &h)); ASSERT(UV_EBADF == uv_udp_set_multicast_ttl(&h, 32)); ASSERT(UV_EBADF == uv_udp_set_broadcast(&h, 1)); @@ -130,6 +132,23 @@ TEST_IMPL(udp_no_autobind) { uv_close((uv_handle_t*) &h, NULL); + /* Test a non-lazily initialized socket. */ + ASSERT(0 == uv_udp_init_ex(loop, &h2, AF_INET)); + ASSERT(0 == uv_udp_set_multicast_ttl(&h2, 32)); + ASSERT(0 == uv_udp_set_broadcast(&h2, 1)); + +#if defined(__MVS__) + /* zOS only supports setting ttl for IPv6 sockets. */ + ASSERT(UV_ENOTSUP == uv_udp_set_ttl(&h2, 1)); +#else + ASSERT(0 == uv_udp_set_ttl(&h2, 1)); +#endif + + ASSERT(0 == uv_udp_set_multicast_loop(&h2, 1)); + ASSERT(0 == uv_udp_set_multicast_interface(&h2, "0.0.0.0")); + + uv_close((uv_handle_t*) &h2, NULL); + ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT)); MAKE_VALGRIND_HAPPY(); diff --git a/deps/uv/test/test-udp-send-and-recv.c b/deps/uv/test/test-udp-send-and-recv.c index 633a16727b..1f01188b27 100644 --- a/deps/uv/test/test-udp-send-and-recv.c +++ b/deps/uv/test/test-udp-send-and-recv.c @@ -72,8 +72,7 @@ static void cl_recv_cb(uv_udp_t* handle, } if (nread == 0) { - /* Returning unused buffer */ - /* Don't count towards cl_recv_cb_called */ + /* Returning unused buffer. Don't count towards cl_recv_cb_called */ ASSERT(addr == NULL); return; } @@ -128,8 +127,7 @@ static void sv_recv_cb(uv_udp_t* handle, } if (nread == 0) { - /* Returning unused buffer */ - /* Don't count towards sv_recv_cb_called */ + /* Returning unused buffer. Don't count towards sv_recv_cb_called */ ASSERT(addr == NULL); return; } diff --git a/deps/uv/test/test-udp-send-immediate.c b/deps/uv/test/test-udp-send-immediate.c index 215f722572..1011aa467e 100644 --- a/deps/uv/test/test-udp-send-immediate.c +++ b/deps/uv/test/test-udp-send-immediate.c @@ -74,8 +74,7 @@ static void sv_recv_cb(uv_udp_t* handle, } if (nread == 0) { - /* Returning unused buffer */ - /* Don't count towards sv_recv_cb_called */ + /* Returning unused buffer. Don't count towards sv_recv_cb_called */ ASSERT(addr == NULL); return; } diff --git a/deps/uv/test/test.gyp b/deps/uv/test/test.gyp index 480e5a26c4..917533618b 100644 --- a/deps/uv/test/test.gyp +++ b/deps/uv/test/test.gyp @@ -47,8 +47,9 @@ 'test-hrtime.c', 'test-idle.c', 'test-ip6-addr.c', - 'test-ipc.c', + 'test-ipc-heavy-traffic-deadlock-bug.c', 'test-ipc-send-recv.c', + 'test-ipc.c', 'test-list.h', 'test-loop-handles.c', 'test-loop-alive.c', |