summaryrefslogtreecommitdiff
path: root/deps/uv/test
diff options
context:
space:
mode:
authorTimothy J Fontaine <tjfontaine@gmail.com>2013-10-29 16:33:17 -0700
committerTimothy J Fontaine <tjfontaine@gmail.com>2013-10-29 16:33:17 -0700
commita35a212f258812bd178f7f002660a0ddc0bf10b2 (patch)
tree32a27fca226d843207ccb93f08b5d12cd6b53ac6 /deps/uv/test
parent613d76ef6a00ec091367de1e63bc51e3ab672cbd (diff)
downloadandroid-node-v8-a35a212f258812bd178f7f002660a0ddc0bf10b2.tar.gz
android-node-v8-a35a212f258812bd178f7f002660a0ddc0bf10b2.tar.bz2
android-node-v8-a35a212f258812bd178f7f002660a0ddc0bf10b2.zip
uv: Upgrade to v0.11.14
Diffstat (limited to 'deps/uv/test')
-rw-r--r--deps/uv/test/benchmark-async.c4
-rw-r--r--deps/uv/test/benchmark-million-timers.c20
-rw-r--r--deps/uv/test/benchmark-ping-pongs.c4
-rw-r--r--deps/uv/test/benchmark-pound.c33
-rw-r--r--deps/uv/test/benchmark-pump.c22
-rw-r--r--deps/uv/test/benchmark-udp-pummel.c2
-rw-r--r--deps/uv/test/dns-server.c12
-rw-r--r--deps/uv/test/runner-win.c17
-rw-r--r--deps/uv/test/runner.c3
-rw-r--r--deps/uv/test/task.h2
-rw-r--r--deps/uv/test/test-active.c21
-rw-r--r--deps/uv/test/test-close-order.c80
-rw-r--r--deps/uv/test/test-fs-event.c92
-rw-r--r--deps/uv/test/test-fs-poll.c2
-rw-r--r--deps/uv/test/test-fs.c21
-rw-r--r--deps/uv/test/test-get-currentexe.c4
-rw-r--r--deps/uv/test/test-ipc-send-recv.c6
-rw-r--r--deps/uv/test/test-ipc.c12
-rw-r--r--deps/uv/test/test-list.h4
-rw-r--r--deps/uv/test/test-loop-stop.c2
-rw-r--r--deps/uv/test/test-ping-pong.c12
-rw-r--r--deps/uv/test/test-poll.c6
-rw-r--r--deps/uv/test/test-ref.c3
-rw-r--r--deps/uv/test/test-shutdown-close.c4
-rw-r--r--deps/uv/test/test-signal-multiple-loops.c57
-rw-r--r--deps/uv/test/test-spawn.c34
-rw-r--r--deps/uv/test/test-stdio-over-pipes.c1
-rw-r--r--deps/uv/test/test-tcp-bind-error.c3
-rw-r--r--deps/uv/test/test-tcp-bind6-error.c3
-rw-r--r--deps/uv/test/test-timer-again.c5
-rw-r--r--deps/uv/test/test-timer.c8
-rw-r--r--deps/uv/test/test-tty.c8
-rw-r--r--deps/uv/test/test-udp-send-and-recv.c2
33 files changed, 386 insertions, 123 deletions
diff --git a/deps/uv/test/benchmark-async.c b/deps/uv/test/benchmark-async.c
index 7d3c936d1d..33d9ab446a 100644
--- a/deps/uv/test/benchmark-async.c
+++ b/deps/uv/test/benchmark-async.c
@@ -86,7 +86,9 @@ static int test_async(int nthreads) {
ctx->loop = uv_loop_new();
ASSERT(ctx->loop != NULL);
ASSERT(0 == uv_async_init(ctx->loop, &ctx->worker_async, worker_async_cb));
- ASSERT(0 == uv_async_init(uv_default_loop(), &ctx->main_async, main_async_cb));
+ ASSERT(0 == uv_async_init(uv_default_loop(),
+ &ctx->main_async,
+ main_async_cb));
ASSERT(0 == uv_thread_create(&ctx->thread, worker, ctx));
}
diff --git a/deps/uv/test/benchmark-million-timers.c b/deps/uv/test/benchmark-million-timers.c
index fe887344bd..64f4a1038e 100644
--- a/deps/uv/test/benchmark-million-timers.c
+++ b/deps/uv/test/benchmark-million-timers.c
@@ -22,7 +22,7 @@
#include "task.h"
#include "uv.h"
-#define NUM_TIMERS (1000 * 1000)
+#define NUM_TIMERS (10 * 1000 * 1000)
static int timer_cb_called;
static int close_cb_called;
@@ -41,8 +41,10 @@ static void close_cb(uv_handle_t* handle) {
BENCHMARK_IMPL(million_timers) {
uv_timer_t* timers;
uv_loop_t* loop;
- uint64_t before;
- uint64_t after;
+ uint64_t before_all;
+ uint64_t before_run;
+ uint64_t after_run;
+ uint64_t after_all;
int timeout;
int i;
@@ -52,25 +54,31 @@ BENCHMARK_IMPL(million_timers) {
loop = uv_default_loop();
timeout = 0;
+ before_all = uv_hrtime();
for (i = 0; i < NUM_TIMERS; i++) {
if (i % 1000 == 0) timeout++;
ASSERT(0 == uv_timer_init(loop, timers + i));
ASSERT(0 == uv_timer_start(timers + i, timer_cb, timeout, 0));
}
- before = uv_hrtime();
+ before_run = uv_hrtime();
ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT));
- after = uv_hrtime();
+ after_run = uv_hrtime();
for (i = 0; i < NUM_TIMERS; i++)
uv_close((uv_handle_t*) (timers + i), close_cb);
ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT));
+ after_all = uv_hrtime();
+
ASSERT(timer_cb_called == NUM_TIMERS);
ASSERT(close_cb_called == NUM_TIMERS);
free(timers);
- LOGF("%.2f seconds\n", (after - before) / 1e9);
+ LOGF("%.2f seconds total\n", (after_all - before_all) / 1e9);
+ LOGF("%.2f seconds init\n", (before_run - before_all) / 1e9);
+ LOGF("%.2f seconds dispatch\n", (after_run - before_run) / 1e9);
+ LOGF("%.2f seconds cleanup\n", (after_all - after_run) / 1e9);
MAKE_VALGRIND_HAPPY();
return 0;
diff --git a/deps/uv/test/benchmark-ping-pongs.c b/deps/uv/test/benchmark-ping-pongs.c
index a6306e3291..d93e561ee0 100644
--- a/deps/uv/test/benchmark-ping-pongs.c
+++ b/deps/uv/test/benchmark-ping-pongs.c
@@ -148,7 +148,9 @@ static void pinger_read_cb(uv_stream_t* tcp,
if (pinger->state == 0) {
pinger->pongs++;
if (uv_now(loop) - start_time > TIME) {
- uv_shutdown(&pinger->shutdown_req, (uv_stream_t*) tcp, pinger_shutdown_cb);
+ uv_shutdown(&pinger->shutdown_req,
+ (uv_stream_t*) tcp,
+ pinger_shutdown_cb);
break;
} else {
pinger_write_ping(pinger);
diff --git a/deps/uv/test/benchmark-pound.c b/deps/uv/test/benchmark-pound.c
index e8d870556a..587928549e 100644
--- a/deps/uv/test/benchmark-pound.c
+++ b/deps/uv/test/benchmark-pound.c
@@ -229,7 +229,10 @@ static void pipe_make_connect(conn_rec* p) {
r = uv_pipe_init(loop, (uv_pipe_t*)&p->stream, 0);
ASSERT(r == 0);
- uv_pipe_connect(&((pipe_conn_rec*)p)->conn_req, (uv_pipe_t*)&p->stream, TEST_PIPENAME, connect_cb);
+ uv_pipe_connect(&((pipe_conn_rec*) p)->conn_req,
+ (uv_pipe_t*) &p->stream,
+ TEST_PIPENAME,
+ connect_cb);
#if DEBUG
printf("make connect %d\n", p->i);
@@ -308,20 +311,40 @@ static int pound_it(int concurrency,
BENCHMARK_IMPL(tcp4_pound_100) {
- return pound_it(100, "tcp", tcp_do_setup, tcp_do_connect, tcp_make_connect, NULL);
+ return pound_it(100,
+ "tcp",
+ tcp_do_setup,
+ tcp_do_connect,
+ tcp_make_connect,
+ NULL);
}
BENCHMARK_IMPL(tcp4_pound_1000) {
- return pound_it(1000, "tcp", tcp_do_setup, tcp_do_connect, tcp_make_connect, NULL);
+ return pound_it(1000,
+ "tcp",
+ tcp_do_setup,
+ tcp_do_connect,
+ tcp_make_connect,
+ NULL);
}
BENCHMARK_IMPL(pipe_pound_100) {
- return pound_it(100, "pipe", pipe_do_setup, pipe_do_connect, pipe_make_connect, NULL);
+ return pound_it(100,
+ "pipe",
+ pipe_do_setup,
+ pipe_do_connect,
+ pipe_make_connect,
+ NULL);
}
BENCHMARK_IMPL(pipe_pound_1000) {
- return pound_it(1000, "pipe", pipe_do_setup, pipe_do_connect, pipe_make_connect, NULL);
+ return pound_it(1000,
+ "pipe",
+ pipe_do_setup,
+ pipe_do_connect,
+ pipe_make_connect,
+ NULL);
}
diff --git a/deps/uv/test/benchmark-pump.c b/deps/uv/test/benchmark-pump.c
index eda3c142d7..b557cd4b81 100644
--- a/deps/uv/test/benchmark-pump.c
+++ b/deps/uv/test/benchmark-pump.c
@@ -101,11 +101,16 @@ static void show_stats(uv_timer_t* handle, int status) {
uv_update_time(loop);
diff = uv_now(loop) - start_time;
- LOGF("%s_pump%d_client: %.1f gbit/s\n", type == TCP ? "tcp" : "pipe", write_sockets,
- gbit(nsent_total, diff));
+ LOGF("%s_pump%d_client: %.1f gbit/s\n",
+ type == TCP ? "tcp" : "pipe",
+ write_sockets,
+ gbit(nsent_total, diff));
for (i = 0; i < write_sockets; i++) {
- uv_close(type == TCP ? (uv_handle_t*)&tcp_write_handles[i] : (uv_handle_t*)&pipe_write_handles[i], NULL);
+ if (type == TCP)
+ uv_close((uv_handle_t*) &tcp_write_handles[i], NULL);
+ else
+ uv_close((uv_handle_t*) &pipe_write_handles[i], NULL);
}
exit(0);
@@ -123,8 +128,10 @@ static void read_show_stats(void) {
uv_update_time(loop);
diff = uv_now(loop) - start_time;
- LOGF("%s_pump%d_server: %.1f gbit/s\n", type == TCP ? "tcp" : "pipe", max_read_sockets,
- gbit(nrecv_total, diff));
+ LOGF("%s_pump%d_server: %.1f gbit/s\n",
+ type == TCP ? "tcp" : "pipe",
+ max_read_sockets,
+ gbit(nrecv_total, diff));
}
@@ -219,7 +226,10 @@ static void connect_cb(uv_connect_t* req, int status) {
/* Yay! start writing */
for (i = 0; i < write_sockets; i++) {
- do_write(type == TCP ? (uv_stream_t*)&tcp_write_handles[i] : (uv_stream_t*)&pipe_write_handles[i]);
+ if (type == TCP)
+ do_write((uv_stream_t*) &tcp_write_handles[i]);
+ else
+ do_write((uv_stream_t*) &pipe_write_handles[i]);
}
}
}
diff --git a/deps/uv/test/benchmark-udp-pummel.c b/deps/uv/test/benchmark-udp-pummel.c
index f8f702c068..d99250affc 100644
--- a/deps/uv/test/benchmark-udp-pummel.c
+++ b/deps/uv/test/benchmark-udp-pummel.c
@@ -26,7 +26,7 @@
#include <stdlib.h>
#include <string.h>
-#define EXPECTED "RANG TANG DING DONG I AM THE JAPANESE SANDMAN" /* "Take eight!" */
+#define EXPECTED "RANG TANG DING DONG I AM THE JAPANESE SANDMAN"
#define TEST_DURATION 5000 /* ms */
diff --git a/deps/uv/test/dns-server.c b/deps/uv/test/dns-server.c
index 8ffe4e7b22..8c701221dc 100644
--- a/deps/uv/test/dns-server.c
+++ b/deps/uv/test/dns-server.c
@@ -159,12 +159,16 @@ static void process_req(uv_stream_t* handle,
/* process len and id */
if (readbuf_remaining < hdrbuf_remaining) {
/* too little to get request header. save for next buffer */
- memcpy(&hdrbuf[DNSREC_LEN - hdrbuf_remaining], dnsreq, readbuf_remaining);
+ memcpy(&hdrbuf[DNSREC_LEN - hdrbuf_remaining],
+ dnsreq,
+ readbuf_remaining);
hdrbuf_remaining = DNSREC_LEN - readbuf_remaining;
break;
} else {
/* save header */
- memcpy(&hdrbuf[DNSREC_LEN - hdrbuf_remaining], dnsreq, hdrbuf_remaining);
+ memcpy(&hdrbuf[DNSREC_LEN - hdrbuf_remaining],
+ dnsreq,
+ hdrbuf_remaining);
dnsreq += hdrbuf_remaining;
readbuf_remaining -= hdrbuf_remaining;
hdrbuf_remaining = 0;
@@ -192,7 +196,9 @@ static void process_req(uv_stream_t* handle,
}
}
- /* if we had to use bytes from prev buffer, start processing the current one */
+ /* If we had to use bytes from prev buffer, start processing the current
+ * one.
+ */
if (usingprev == 1) {
/* free previous buffer */
free(dns->state.prevbuf_ptr);
diff --git a/deps/uv/test/runner-win.c b/deps/uv/test/runner-win.c
index 5d23259437..83d76783f6 100644
--- a/deps/uv/test/runner-win.c
+++ b/deps/uv/test/runner-win.c
@@ -110,7 +110,9 @@ int process_start(char *name, char *part, process_info_t *p, int is_helper) {
if (!SetHandleInformation(nul, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT))
goto error;
- result = GetModuleFileNameW(NULL, (WCHAR*)&image, sizeof(image) / sizeof(WCHAR));
+ result = GetModuleFileNameW(NULL,
+ (WCHAR*) &image,
+ sizeof(image) / sizeof(WCHAR));
if (result == 0 || result == sizeof(image))
goto error;
@@ -214,8 +216,12 @@ int process_copy_output(process_info_t *p, int fd) {
char buf[1024];
char *line, *start;
- if (SetFilePointer(p->stdio_out, 0, 0, FILE_BEGIN) == INVALID_SET_FILE_POINTER)
+ if (SetFilePointer(p->stdio_out,
+ 0,
+ 0,
+ FILE_BEGIN) == INVALID_SET_FILE_POINTER) {
return -1;
+ }
if (tap_output)
write(fd, "#", 1);
@@ -337,8 +343,13 @@ static int clear_line() {
if (!SetConsoleCursorPosition(handle, coord))
return -1;
- if (!FillConsoleOutputCharacterW(handle, 0x20, info.dwSize.X, coord, &written))
+ if (!FillConsoleOutputCharacterW(handle,
+ 0x20,
+ info.dwSize.X,
+ coord,
+ &written)) {
return -1;
+ }
return 0;
}
diff --git a/deps/uv/test/runner.c b/deps/uv/test/runner.c
index d8e9ddeb01..f4d982c5b6 100644
--- a/deps/uv/test/runner.c
+++ b/deps/uv/test/runner.c
@@ -410,7 +410,8 @@ static int compare_task(const void* va, const void* vb) {
}
-static int find_helpers(const task_entry_t* task, const task_entry_t** helpers) {
+static int find_helpers(const task_entry_t* task,
+ const task_entry_t** helpers) {
const task_entry_t* helper;
int n_helpers;
diff --git a/deps/uv/test/task.h b/deps/uv/test/task.h
index e050dca0c6..8e7666ad00 100644
--- a/deps/uv/test/task.h
+++ b/deps/uv/test/task.h
@@ -153,7 +153,7 @@ enum test_status {
return TEST_SKIP; \
} while (0)
-#ifdef _WIN32
+#if defined _WIN32 && ! defined __GNUC__
#include <stdarg.h>
diff --git a/deps/uv/test/test-active.c b/deps/uv/test/test-active.c
index 1f3d5f1b15..0fae23cdb1 100644
--- a/deps/uv/test/test-active.c
+++ b/deps/uv/test/test-active.c
@@ -47,31 +47,32 @@ TEST_IMPL(active) {
r = uv_timer_init(uv_default_loop(), &timer);
ASSERT(r == 0);
- ASSERT(!uv_is_active((uv_handle_t*) &timer));
- ASSERT(!uv_is_closing((uv_handle_t*) &timer));
+ /* uv_is_active() and uv_is_closing() should always return either 0 or 1. */
+ ASSERT(0 == uv_is_active((uv_handle_t*) &timer));
+ ASSERT(0 == uv_is_closing((uv_handle_t*) &timer));
r = uv_timer_start(&timer, timer_cb, 1000, 0);
ASSERT(r == 0);
- ASSERT(uv_is_active((uv_handle_t*) &timer));
- ASSERT(!uv_is_closing((uv_handle_t*) &timer));
+ ASSERT(1 == uv_is_active((uv_handle_t*) &timer));
+ ASSERT(0 == uv_is_closing((uv_handle_t*) &timer));
r = uv_timer_stop(&timer);
ASSERT(r == 0);
- ASSERT(!uv_is_active((uv_handle_t*) &timer));
- ASSERT(!uv_is_closing((uv_handle_t*) &timer));
+ ASSERT(0 == uv_is_active((uv_handle_t*) &timer));
+ ASSERT(0 == uv_is_closing((uv_handle_t*) &timer));
r = uv_timer_start(&timer, timer_cb, 1000, 0);
ASSERT(r == 0);
- ASSERT(uv_is_active((uv_handle_t*) &timer));
- ASSERT(!uv_is_closing((uv_handle_t*) &timer));
+ ASSERT(1 == uv_is_active((uv_handle_t*) &timer));
+ ASSERT(0 == uv_is_closing((uv_handle_t*) &timer));
uv_close((uv_handle_t*) &timer, close_cb);
- ASSERT(!uv_is_active((uv_handle_t*) &timer));
- ASSERT(uv_is_closing((uv_handle_t*) &timer));
+ ASSERT(0 == uv_is_active((uv_handle_t*) &timer));
+ ASSERT(1 == uv_is_closing((uv_handle_t*) &timer));
r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(r == 0);
diff --git a/deps/uv/test/test-close-order.c b/deps/uv/test/test-close-order.c
new file mode 100644
index 0000000000..e2f25f987d
--- /dev/null
+++ b/deps/uv/test/test-close-order.c
@@ -0,0 +1,80 @@
+/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "uv.h"
+#include "task.h"
+
+static int check_cb_called;
+static int timer_cb_called;
+static int close_cb_called;
+
+static uv_check_t check_handle;
+static uv_timer_t timer_handle1;
+static uv_timer_t timer_handle2;
+
+
+static void close_cb(uv_handle_t* handle) {
+ ASSERT(handle != NULL);
+ close_cb_called++;
+}
+
+
+/* check_cb should run before any close_cb */
+static void check_cb(uv_check_t* handle, int status) {
+ ASSERT(check_cb_called == 0);
+ ASSERT(timer_cb_called == 1);
+ ASSERT(close_cb_called == 0);
+ uv_close((uv_handle_t*) handle, close_cb);
+ uv_close((uv_handle_t*) &timer_handle2, close_cb);
+ check_cb_called++;
+}
+
+
+static void timer_cb(uv_timer_t* handle, int status) {
+ uv_close((uv_handle_t*) handle, close_cb);
+ timer_cb_called++;
+}
+
+
+TEST_IMPL(close_order) {
+ uv_loop_t* loop;
+ loop = uv_default_loop();
+
+ uv_check_init(loop, &check_handle);
+ uv_check_start(&check_handle, check_cb);
+ uv_timer_init(loop, &timer_handle1);
+ uv_timer_start(&timer_handle1, timer_cb, 0, 0);
+ uv_timer_init(loop, &timer_handle2);
+ uv_timer_start(&timer_handle2, timer_cb, 100000, 0);
+
+ ASSERT(check_cb_called == 0);
+ ASSERT(close_cb_called == 0);
+ ASSERT(timer_cb_called == 0);
+
+ uv_run(loop, UV_RUN_DEFAULT);
+
+ ASSERT(check_cb_called == 1);
+ ASSERT(close_cb_called == 3);
+ ASSERT(timer_cb_called == 1);
+
+ MAKE_VALGRIND_HAPPY();
+ return 0;
+}
diff --git a/deps/uv/test/test-fs-event.c b/deps/uv/test/test-fs-event.c
index 1df2569d8b..66132e172f 100644
--- a/deps/uv/test/test-fs-event.c
+++ b/deps/uv/test/test-fs-event.c
@@ -103,6 +103,7 @@ static void fs_event_cb_dir(uv_fs_event_t* handle, const char* filename,
ASSERT(status == 0);
ASSERT(events == UV_RENAME);
ASSERT(filename == NULL || strcmp(filename, "file1") == 0);
+ ASSERT(0 == uv_fs_event_stop(handle));
uv_close((uv_handle_t*)handle, close_cb);
}
@@ -113,6 +114,7 @@ static void fs_event_cb_file(uv_fs_event_t* handle, const char* filename,
ASSERT(status == 0);
ASSERT(events == UV_CHANGE);
ASSERT(filename == NULL || strcmp(filename, "file2") == 0);
+ ASSERT(0 == uv_fs_event_stop(handle));
uv_close((uv_handle_t*)handle, close_cb);
}
@@ -187,7 +189,9 @@ TEST_IMPL(fs_event_watch_dir) {
remove("watch_dir/");
create_dir(loop, "watch_dir");
- r = uv_fs_event_init(loop, &fs_event, "watch_dir", fs_event_cb_dir, 0);
+ r = uv_fs_event_init(loop, &fs_event);
+ ASSERT(r == 0);
+ r = uv_fs_event_start(&fs_event, fs_event_cb_dir, "watch_dir", 0);
ASSERT(r == 0);
r = uv_timer_init(loop, &timer);
ASSERT(r == 0);
@@ -221,7 +225,9 @@ TEST_IMPL(fs_event_watch_file) {
create_file(loop, "watch_dir/file1");
create_file(loop, "watch_dir/file2");
- r = uv_fs_event_init(loop, &fs_event, "watch_dir/file2", fs_event_cb_file, 0);
+ r = uv_fs_event_init(loop, &fs_event);
+ ASSERT(r == 0);
+ r = uv_fs_event_start(&fs_event, fs_event_cb_file, "watch_dir/file2", 0);
ASSERT(r == 0);
r = uv_timer_init(loop, &timer);
ASSERT(r == 0);
@@ -252,8 +258,10 @@ TEST_IMPL(fs_event_watch_file_twice) {
loop = uv_default_loop();
timer.data = watchers;
- ASSERT(0 == uv_fs_event_init(loop, watchers + 0, path, fail_cb, 0));
- ASSERT(0 == uv_fs_event_init(loop, watchers + 1, path, fail_cb, 0));
+ ASSERT(0 == uv_fs_event_init(loop, watchers + 0));
+ ASSERT(0 == uv_fs_event_start(watchers + 0, fail_cb, path, 0));
+ ASSERT(0 == uv_fs_event_init(loop, watchers + 1));
+ ASSERT(0 == uv_fs_event_start(watchers + 1, fail_cb, path, 0));
ASSERT(0 == uv_timer_init(loop, &timer));
ASSERT(0 == uv_timer_start(&timer, timer_cb_watch_twice, 10, 0));
ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT));
@@ -273,10 +281,15 @@ TEST_IMPL(fs_event_watch_file_current_dir) {
remove("watch_file");
create_file(loop, "watch_file");
- r = uv_fs_event_init(loop, &fs_event, "watch_file",
- fs_event_cb_file_current_dir, 0);
+ r = uv_fs_event_init(loop, &fs_event);
+ ASSERT(r == 0);
+ r = uv_fs_event_start(&fs_event,
+ fs_event_cb_file_current_dir,
+ "watch_file",
+ 0);
ASSERT(r == 0);
+
r = uv_timer_init(loop, &timer);
ASSERT(r == 0);
@@ -310,13 +323,15 @@ TEST_IMPL(fs_event_no_callback_after_close) {
create_dir(loop, "watch_dir");
create_file(loop, "watch_dir/file1");
- r = uv_fs_event_init(loop,
- &fs_event,
- "watch_dir/file1",
- fs_event_cb_file,
- 0);
+ r = uv_fs_event_init(loop, &fs_event);
+ ASSERT(r == 0);
+ r = uv_fs_event_start(&fs_event,
+ fs_event_cb_file,
+ "watch_dir/file1",
+ 0);
ASSERT(r == 0);
+
uv_close((uv_handle_t*)&fs_event, close_cb);
touch_file(loop, "watch_dir/file1");
uv_run(loop, UV_RUN_DEFAULT);
@@ -342,11 +357,12 @@ TEST_IMPL(fs_event_no_callback_on_close) {
create_dir(loop, "watch_dir");
create_file(loop, "watch_dir/file1");
- r = uv_fs_event_init(loop,
- &fs_event,
- "watch_dir/file1",
- fs_event_cb_file,
- 0);
+ r = uv_fs_event_init(loop, &fs_event);
+ ASSERT(r == 0);
+ r = uv_fs_event_start(&fs_event,
+ fs_event_cb_file,
+ "watch_dir/file1",
+ 0);
ASSERT(r == 0);
uv_close((uv_handle_t*)&fs_event, close_cb);
@@ -376,7 +392,9 @@ static void timer_cb(uv_timer_t* handle, int status) {
ASSERT(status == 0);
- r = uv_fs_event_init(handle->loop, &fs_event, ".", fs_event_fail, 0);
+ r = uv_fs_event_init(handle->loop, &fs_event);
+ ASSERT(r == 0);
+ r = uv_fs_event_start(&fs_event, fs_event_fail, ".", 0);
ASSERT(r == 0);
uv_close((uv_handle_t*)&fs_event, close_cb);
@@ -415,7 +433,9 @@ TEST_IMPL(fs_event_close_with_pending_event) {
create_dir(loop, "watch_dir");
create_file(loop, "watch_dir/file");
- r = uv_fs_event_init(loop, &fs_event, "watch_dir", fs_event_fail, 0);
+ r = uv_fs_event_init(loop, &fs_event);
+ ASSERT(r == 0);
+ r = uv_fs_event_start(&fs_event, fs_event_fail, "watch_dir", 0);
ASSERT(r == 0);
/* Generate an fs event. */
@@ -474,7 +494,9 @@ TEST_IMPL(fs_event_close_in_callback) {
create_file(loop, "watch_dir/file4");
create_file(loop, "watch_dir/file5");
- r = uv_fs_event_init(loop, &fs_event, "watch_dir", fs_event_cb_close, 0);
+ r = uv_fs_event_init(loop, &fs_event);
+ ASSERT(r == 0);
+ r = uv_fs_event_start(&fs_event, fs_event_cb_close, "watch_dir", 0);
ASSERT(r == 0);
/* Generate a couple of fs events. */
@@ -502,3 +524,35 @@ TEST_IMPL(fs_event_close_in_callback) {
}
#endif /* HAVE_KQUEUE */
+
+TEST_IMPL(fs_event_start_and_close) {
+ uv_loop_t* loop;
+ uv_fs_event_t fs_event1;
+ uv_fs_event_t fs_event2;
+ int r;
+
+ loop = uv_default_loop();
+
+ create_dir(loop, "watch_dir");
+
+ r = uv_fs_event_init(loop, &fs_event1);
+ ASSERT(r == 0);
+ r = uv_fs_event_start(&fs_event1, fs_event_cb_dir, "watch_dir", 0);
+ ASSERT(r == 0);
+
+ r = uv_fs_event_init(loop, &fs_event2);
+ ASSERT(r == 0);
+ r = uv_fs_event_start(&fs_event2, fs_event_cb_dir, "watch_dir", 0);
+ ASSERT(r == 0);
+
+ uv_close((uv_handle_t*) &fs_event2, close_cb);
+ uv_close((uv_handle_t*) &fs_event1, close_cb);
+
+ uv_run(loop, UV_RUN_DEFAULT);
+
+ ASSERT(close_cb_called == 2);
+
+ remove("watch_dir/");
+ MAKE_VALGRIND_HAPPY();
+ return 0;
+}
diff --git a/deps/uv/test/test-fs-poll.c b/deps/uv/test/test-fs-poll.c
index 4a162ab475..9213f04b34 100644
--- a/deps/uv/test/test-fs-poll.c
+++ b/deps/uv/test/test-fs-poll.c
@@ -81,7 +81,7 @@ static void poll_cb(uv_fs_poll_t* handle,
memset(&zero_statbuf, 0, sizeof(zero_statbuf));
ASSERT(handle == &poll_handle);
- ASSERT(uv_is_active((uv_handle_t*)handle));
+ ASSERT(1 == uv_is_active((uv_handle_t*) handle));
ASSERT(prev != NULL);
ASSERT(curr != NULL);
diff --git a/deps/uv/test/test-fs.c b/deps/uv/test/test-fs.c
index 5e02237179..f0ff824f40 100644
--- a/deps/uv/test/test-fs.c
+++ b/deps/uv/test/test-fs.c
@@ -1333,7 +1333,12 @@ TEST_IMPL(fs_symlink) {
close(link);
- r = uv_fs_symlink(loop, &req, "test_file_symlink", "test_file_symlink_symlink", 0, NULL);
+ r = uv_fs_symlink(loop,
+ &req,
+ "test_file_symlink",
+ "test_file_symlink_symlink",
+ 0,
+ NULL);
ASSERT(r == 0);
uv_fs_req_cleanup(&req);
@@ -1343,7 +1348,12 @@ TEST_IMPL(fs_symlink) {
uv_fs_req_cleanup(&req);
/* async link */
- r = uv_fs_symlink(loop, &req, "test_file", "test_file_symlink2", 0, symlink_cb);
+ r = uv_fs_symlink(loop,
+ &req,
+ "test_file",
+ "test_file_symlink2",
+ 0,
+ symlink_cb);
ASSERT(r == 0);
uv_run(loop, UV_RUN_DEFAULT);
ASSERT(symlink_cb_count == 1);
@@ -1362,7 +1372,12 @@ TEST_IMPL(fs_symlink) {
close(link);
- r = uv_fs_symlink(loop, &req, "test_file_symlink2", "test_file_symlink2_symlink", 0, NULL);
+ r = uv_fs_symlink(loop,
+ &req,
+ "test_file_symlink2",
+ "test_file_symlink2_symlink",
+ 0,
+ NULL);
ASSERT(r == 0);
uv_fs_req_cleanup(&req);
diff --git a/deps/uv/test/test-get-currentexe.c b/deps/uv/test/test-get-currentexe.c
index 8882732eec..be578db75d 100644
--- a/deps/uv/test/test-get-currentexe.c
+++ b/deps/uv/test/test-get-currentexe.c
@@ -47,7 +47,9 @@ TEST_IMPL(get_currentexe) {
}
match = strstr(buffer, path);
- /* Verify that the path returned from uv_exepath is a subdirectory of executable_path */
+ /* Verify that the path returned from uv_exepath is a subdirectory of
+ * executable_path.
+ */
ASSERT(match && !strcmp(match, path));
ASSERT(size == strlen(buffer));
diff --git a/deps/uv/test/test-ipc-send-recv.c b/deps/uv/test/test-ipc-send-recv.c
index cbd6a95f6d..73013ebaba 100644
--- a/deps/uv/test/test-ipc-send-recv.c
+++ b/deps/uv/test/test-ipc-send-recv.c
@@ -211,9 +211,9 @@ int ipc_send_recv_helper(void) {
ASSERT(r == 0);
uv_pipe_open(&ctx.channel, 0);
- ASSERT(uv_is_readable((uv_stream_t*)&ctx.channel));
- ASSERT(uv_is_writable((uv_stream_t*)&ctx.channel));
- ASSERT(!uv_is_closing((uv_handle_t*)&ctx.channel));
+ ASSERT(1 == uv_is_readable((uv_stream_t*)&ctx.channel));
+ ASSERT(1 == uv_is_writable((uv_stream_t*)&ctx.channel));
+ ASSERT(0 == uv_is_closing((uv_handle_t*)&ctx.channel));
r = uv_read2_start((uv_stream_t*)&ctx.channel, alloc_cb, read2_cb);
ASSERT(r == 0);
diff --git a/deps/uv/test/test-ipc.c b/deps/uv/test/test-ipc.c
index d19affacd5..6826b041d0 100644
--- a/deps/uv/test/test-ipc.c
+++ b/deps/uv/test/test-ipc.c
@@ -559,9 +559,9 @@ int ipc_helper(int listen_after_write) {
uv_pipe_open(&channel, 0);
- ASSERT(uv_is_readable((uv_stream_t*) &channel));
- ASSERT(uv_is_writable((uv_stream_t*) &channel));
- ASSERT(!uv_is_closing((uv_handle_t*) &channel));
+ ASSERT(1 == uv_is_readable((uv_stream_t*) &channel));
+ ASSERT(1 == uv_is_writable((uv_stream_t*) &channel));
+ ASSERT(0 == uv_is_closing((uv_handle_t*) &channel));
r = uv_tcp_init(uv_default_loop(), &tcp_server);
ASSERT(r == 0);
@@ -609,9 +609,9 @@ int ipc_helper_tcp_connection(void) {
uv_pipe_open(&channel, 0);
- ASSERT(uv_is_readable((uv_stream_t*)&channel));
- ASSERT(uv_is_writable((uv_stream_t*)&channel));
- ASSERT(!uv_is_closing((uv_handle_t*)&channel));
+ ASSERT(1 == uv_is_readable((uv_stream_t*) &channel));
+ ASSERT(1 == uv_is_writable((uv_stream_t*) &channel));
+ ASSERT(0 == uv_is_closing((uv_handle_t*) &channel));
r = uv_tcp_init(uv_default_loop(), &tcp_server);
ASSERT(r == 0);
diff --git a/deps/uv/test/test-list.h b/deps/uv/test/test-list.h
index 334b48322a..d963f04cf3 100644
--- a/deps/uv/test/test-list.h
+++ b/deps/uv/test/test-list.h
@@ -21,6 +21,7 @@
TEST_DECLARE (platform_output)
TEST_DECLARE (callback_order)
+TEST_DECLARE (close_order)
TEST_DECLARE (run_once)
TEST_DECLARE (run_nowait)
TEST_DECLARE (loop_stop)
@@ -192,6 +193,7 @@ TEST_DECLARE (fs_event_no_callback_on_close)
TEST_DECLARE (fs_event_immediate_close)
TEST_DECLARE (fs_event_close_with_pending_event)
TEST_DECLARE (fs_event_close_in_callback)
+TEST_DECLARE (fs_event_start_and_close)
TEST_DECLARE (fs_readdir_empty_dir)
TEST_DECLARE (fs_readdir_file)
TEST_DECLARE (fs_open_dir)
@@ -242,6 +244,7 @@ TASK_LIST_START
#if 0
TEST_ENTRY (callback_order)
#endif
+ TEST_ENTRY (close_order)
TEST_ENTRY (run_once)
TEST_ENTRY (run_nowait)
TEST_ENTRY (loop_stop)
@@ -486,6 +489,7 @@ TASK_LIST_START
TEST_ENTRY (fs_event_immediate_close)
TEST_ENTRY (fs_event_close_with_pending_event)
TEST_ENTRY (fs_event_close_in_callback)
+ TEST_ENTRY (fs_event_start_and_close)
TEST_ENTRY (fs_readdir_empty_dir)
TEST_ENTRY (fs_readdir_file)
TEST_ENTRY (fs_open_dir)
diff --git a/deps/uv/test/test-loop-stop.c b/deps/uv/test/test-loop-stop.c
index db52a094e7..c519644ed2 100644
--- a/deps/uv/test/test-loop-stop.c
+++ b/deps/uv/test/test-loop-stop.c
@@ -62,7 +62,7 @@ TEST_IMPL(loop_stop) {
r = uv_run(uv_default_loop(), UV_RUN_NOWAIT);
ASSERT(r != 0);
- ASSERT(prepare_called == 3);
+ ASSERT(prepare_called > 1);
r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(r == 0);
diff --git a/deps/uv/test/test-ping-pong.c b/deps/uv/test/test-ping-pong.c
index fb8f5669dc..c579fdd668 100644
--- a/deps/uv/test/test-ping-pong.c
+++ b/deps/uv/test/test-ping-pong.c
@@ -78,7 +78,11 @@ static void pinger_write_ping(pinger_t* pinger) {
buf = uv_buf_init(PING, sizeof(PING) - 1);
req = malloc(sizeof(*req));
- if (uv_write(req, (uv_stream_t*)&pinger->stream.tcp, &buf, 1, pinger_after_write)) {
+ if (uv_write(req,
+ (uv_stream_t*) &pinger->stream.tcp,
+ &buf,
+ 1,
+ pinger_after_write)) {
FATAL("uv_write failed");
}
@@ -135,9 +139,9 @@ static void pinger_on_connect(uv_connect_t *req, int status) {
ASSERT(status == 0);
- ASSERT(uv_is_readable(req->handle));
- ASSERT(uv_is_writable(req->handle));
- ASSERT(!uv_is_closing((uv_handle_t *)req->handle));
+ ASSERT(1 == uv_is_readable(req->handle));
+ ASSERT(1 == uv_is_writable(req->handle));
+ ASSERT(0 == uv_is_closing((uv_handle_t *) req->handle));
pinger_write_ping(pinger);
diff --git a/deps/uv/test/test-poll.c b/deps/uv/test/test-poll.c
index 135c72974d..0736b9b0bf 100644
--- a/deps/uv/test/test-poll.c
+++ b/deps/uv/test/test-poll.c
@@ -406,9 +406,9 @@ static void connection_poll_cb(uv_poll_t* handle, int status, int events) {
/* Assert that uv_is_active works correctly for poll handles. */
if (context->events != 0) {
- ASSERT(uv_is_active((uv_handle_t*) handle));
+ ASSERT(1 == uv_is_active((uv_handle_t*) handle));
} else {
- ASSERT(!uv_is_active((uv_handle_t*) handle));
+ ASSERT(0 == uv_is_active((uv_handle_t*) handle));
}
}
@@ -418,7 +418,7 @@ static void delay_timer_cb(uv_timer_t* timer, int status) {
int r;
/* Timer should auto stop. */
- ASSERT(!uv_is_active((uv_handle_t*) timer));
+ ASSERT(0 == uv_is_active((uv_handle_t*) timer));
/* Add the requested events to the poll mask. */
ASSERT(context->delayed_events != 0);
diff --git a/deps/uv/test/test-ref.c b/deps/uv/test/test-ref.c
index ca44ec415b..7ff2e84e38 100644
--- a/deps/uv/test/test-ref.c
+++ b/deps/uv/test/test-ref.c
@@ -196,7 +196,8 @@ TEST_IMPL(timer_ref2) {
TEST_IMPL(fs_event_ref) {
uv_fs_event_t h;
- uv_fs_event_init(uv_default_loop(), &h, ".", (uv_fs_event_cb)fail_cb, 0);
+ uv_fs_event_init(uv_default_loop(), &h);
+ uv_fs_event_start(&h, (uv_fs_event_cb)fail_cb, ".", 0);
uv_unref((uv_handle_t*)&h);
uv_run(uv_default_loop(), UV_RUN_DEFAULT);
do_close(&h);
diff --git a/deps/uv/test/test-shutdown-close.c b/deps/uv/test/test-shutdown-close.c
index fd2d4b8ac4..78c369be2d 100644
--- a/deps/uv/test/test-shutdown-close.c
+++ b/deps/uv/test/test-shutdown-close.c
@@ -56,9 +56,9 @@ static void connect_cb(uv_connect_t* req, int status) {
r = uv_shutdown(&shutdown_req, req->handle, shutdown_cb);
ASSERT(r == 0);
- ASSERT(!uv_is_closing((uv_handle_t*) req->handle));
+ ASSERT(0 == uv_is_closing((uv_handle_t*) req->handle));
uv_close((uv_handle_t*) req->handle, close_cb);
- ASSERT(uv_is_closing((uv_handle_t*) req->handle));
+ ASSERT(1 == uv_is_closing((uv_handle_t*) req->handle));
connect_cb_called++;
}
diff --git a/deps/uv/test/test-signal-multiple-loops.c b/deps/uv/test/test-signal-multiple-loops.c
index c43e02b788..e80154e3e8 100644
--- a/deps/uv/test/test-signal-multiple-loops.c
+++ b/deps/uv/test/test-signal-multiple-loops.c
@@ -34,10 +34,20 @@
#include <string.h>
#include <unistd.h>
-
-#define NUM_SIGNAL_HANDLING_THREADS 25
+/* The value of NUM_SIGNAL_HANDLING_THREADS is not arbitrary; it needs to be a
+ * multiple of three for reasons that will become clear when you scroll down.
+ * We're basically creating three different thread groups. The total needs
+ * to be divisible by three in order for the numbers in the final check to
+ * match up.
+ */
+#define NUM_SIGNAL_HANDLING_THREADS 24
#define NUM_LOOP_CREATING_THREADS 10
+enum signal_action {
+ ONLY_SIGUSR1,
+ ONLY_SIGUSR2,
+ SIGUSR1_AND_SIGUSR2
+};
static uv_sem_t sem;
static uv_mutex_t counter_lock;
@@ -70,18 +80,20 @@ static void signal2_cb(uv_signal_t* handle, int signum) {
static void signal_handling_worker(void* context) {
- uintptr_t mask = (uintptr_t) context;
- uv_loop_t* loop;
+ enum signal_action action;
uv_signal_t signal1a;
uv_signal_t signal1b;
uv_signal_t signal2;
+ uv_loop_t* loop;
int r;
+ action = (enum signal_action) (uintptr_t) context;
+
loop = uv_loop_new();
ASSERT(loop != NULL);
/* Setup the signal watchers and start them. */
- if (mask & SIGUSR1) {
+ if (action == ONLY_SIGUSR1 || action == SIGUSR1_AND_SIGUSR2) {
r = uv_signal_init(loop, &signal1a);
ASSERT(r == 0);
r = uv_signal_start(&signal1a, signal1_cb, SIGUSR1);
@@ -91,7 +103,8 @@ static void signal_handling_worker(void* context) {
r = uv_signal_start(&signal1b, signal1_cb, SIGUSR1);
ASSERT(r == 0);
}
- if (mask & SIGUSR2) {
+
+ if (action == ONLY_SIGUSR2 || action == SIGUSR1_AND_SIGUSR2) {
r = uv_signal_init(loop, &signal2);
ASSERT(r == 0);
r = uv_signal_start(&signal2, signal2_cb, SIGUSR2);
@@ -108,13 +121,14 @@ static void signal_handling_worker(void* context) {
ASSERT(r == 0);
/* Restart the signal watchers. */
- if (mask & SIGUSR1) {
+ if (action == ONLY_SIGUSR1 || action == SIGUSR1_AND_SIGUSR2) {
r = uv_signal_start(&signal1a, signal1_cb, SIGUSR1);
ASSERT(r == 0);
r = uv_signal_start(&signal1b, signal1_cb, SIGUSR1);
ASSERT(r == 0);
}
- if (mask & SIGUSR2) {
+
+ if (action == ONLY_SIGUSR2 || action == SIGUSR1_AND_SIGUSR2) {
r = uv_signal_start(&signal2, signal2_cb, SIGUSR2);
ASSERT(r == 0);
}
@@ -126,11 +140,12 @@ static void signal_handling_worker(void* context) {
ASSERT(r == 0);
/* Close the watchers. */
- if (mask & SIGUSR1) {
+ if (action == ONLY_SIGUSR1 || action == SIGUSR1_AND_SIGUSR2) {
uv_close((uv_handle_t*) &signal1a, NULL);
uv_close((uv_handle_t*) &signal1b, NULL);
}
- if (mask & SIGUSR2) {
+
+ if (action == ONLY_SIGUSR2 || action == SIGUSR1_AND_SIGUSR2) {
uv_close((uv_handle_t*) &signal2, NULL);
}
@@ -177,10 +192,12 @@ static void loop_creating_worker(void* context) {
TEST_IMPL(signal_multiple_loops) {
- int i, r;
uv_thread_t loop_creating_threads[NUM_LOOP_CREATING_THREADS];
uv_thread_t signal_handling_threads[NUM_SIGNAL_HANDLING_THREADS];
+ enum signal_action action;
sigset_t sigset;
+ int i;
+ int r;
r = uv_sem_init(&sem, 0);
ASSERT(r == 0);
@@ -198,17 +215,15 @@ TEST_IMPL(signal_multiple_loops) {
/* Create a couple of threads that actually handle signals. */
for (i = 0; i < NUM_SIGNAL_HANDLING_THREADS; i++) {
- uintptr_t mask;
-
switch (i % 3) {
- case 0: mask = SIGUSR1; break;
- case 1: mask = SIGUSR2; break;
- case 2: mask = SIGUSR1 | SIGUSR2; break;
+ case 0: action = ONLY_SIGUSR1; break;
+ case 1: action = ONLY_SIGUSR2; break;
+ case 2: action = SIGUSR1_AND_SIGUSR2; break;
}
r = uv_thread_create(&signal_handling_threads[i],
signal_handling_worker,
- (void*) mask);
+ (void*) (uintptr_t) action);
ASSERT(r == 0);
}
@@ -256,8 +271,12 @@ TEST_IMPL(signal_multiple_loops) {
printf("signal2_cb calls: %d\n", signal2_cb_counter);
printf("loops created and destroyed: %d\n", loop_creation_counter);
- ASSERT(signal1_cb_counter == 4 * NUM_SIGNAL_HANDLING_THREADS);
- ASSERT(signal2_cb_counter == 2 * NUM_SIGNAL_HANDLING_THREADS);
+ /* The division by three reflects the fact that we spawn three different
+ * thread groups of (NUM_SIGNAL_HANDLING_THREADS / 3) threads each.
+ */
+ ASSERT(signal1_cb_counter == 8 * (NUM_SIGNAL_HANDLING_THREADS / 3));
+ ASSERT(signal2_cb_counter == 4 * (NUM_SIGNAL_HANDLING_THREADS / 3));
+
/* We don't know exactly how much loops will be created and destroyed, but at
* least there should be 1 for every loop creating thread.
*/
diff --git a/deps/uv/test/test-spawn.c b/deps/uv/test/test-spawn.c
index 97d08d5286..454c18169d 100644
--- a/deps/uv/test/test-spawn.c
+++ b/deps/uv/test/test-spawn.c
@@ -113,7 +113,9 @@ static void kill_cb(uv_process_t* process,
ASSERT(err == UV_ESRCH);
}
-static void detach_failure_cb(uv_process_t* process, int64_t exit_status, int term_signal) {
+static void detach_failure_cb(uv_process_t* process,
+ int64_t exit_status,
+ int term_signal) {
printf("detach_cb\n");
exit_cb_called++;
}
@@ -167,7 +169,7 @@ TEST_IMPL(spawn_fails) {
init_process_options("", exit_cb_expect_enoent);
options.file = options.args[0] = "program-that-had-better-not-exist";
ASSERT(0 == uv_spawn(uv_default_loop(), &process, &options));
- ASSERT(0 != uv_is_active((uv_handle_t*)&process));
+ ASSERT(1 == uv_is_active((uv_handle_t*) &process));
ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT));
ASSERT(1 == exit_cb_called);
@@ -630,7 +632,11 @@ TEST_IMPL(spawn_detect_pipe_name_collisions_on_windows) {
options.stdio_count = 2;
/* Create a pipe that'll cause a collision. */
- _snprintf(name, sizeof(name), "\\\\.\\pipe\\uv\\%p-%d", &out, GetCurrentProcessId());
+ _snprintf(name,
+ sizeof(name),
+ "\\\\.\\pipe\\uv\\%p-%d",
+ &out,
+ GetCurrentProcessId());
pipe_handle = CreateNamedPipeA(name,
PIPE_ACCESS_INBOUND | FILE_FLAG_OVERLAPPED,
PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT,
@@ -729,8 +735,12 @@ TEST_IMPL(argument_escaping) {
wprintf(L" verbatim_output: %s\n", verbatim_output);
wprintf(L"non_verbatim_output: %s\n", non_verbatim_output);
- ASSERT(wcscmp(verbatim_output, L"cmd.exe /c c:\\path\\to\\node.exe --eval \"require('c:\\\\path\\\\to\\\\test.js')\"") == 0);
- ASSERT(wcscmp(non_verbatim_output, L"cmd.exe /c \"c:\\path\\to\\node.exe --eval \\\"require('c:\\\\path\\\\to\\\\test.js')\\\"\"") == 0);
+ ASSERT(wcscmp(verbatim_output,
+ L"cmd.exe /c c:\\path\\to\\node.exe --eval "
+ L"\"require('c:\\\\path\\\\to\\\\test.js')\"") == 0);
+ ASSERT(wcscmp(non_verbatim_output,
+ L"cmd.exe /c \"c:\\path\\to\\node.exe --eval "
+ L"\\\"require('c:\\\\path\\\\to\\\\test.js')\\\"\"") == 0);
free(verbatim_output);
free(non_verbatim_output);
@@ -758,17 +768,23 @@ TEST_IMPL(environment_creation) {
WCHAR* env;
for (i = 0; i < sizeof(environment) / sizeof(environment[0]) - 1; i++) {
- ptr += uv_utf8_to_utf16(environment[i], ptr, expected + sizeof(expected) - ptr);
+ ptr += uv_utf8_to_utf16(environment[i],
+ ptr,
+ expected + sizeof(expected) - ptr);
}
memcpy(ptr, L"SYSTEMROOT=", sizeof(L"SYSTEMROOT="));
ptr += sizeof(L"SYSTEMROOT=")/sizeof(WCHAR) - 1;
- ptr += GetEnvironmentVariableW(L"SYSTEMROOT", ptr, expected + sizeof(expected) - ptr);
+ ptr += GetEnvironmentVariableW(L"SYSTEMROOT",
+ ptr,
+ expected + sizeof(expected) - ptr);
++ptr;
memcpy(ptr, L"SYSTEMDRIVE=", sizeof(L"SYSTEMDRIVE="));
ptr += sizeof(L"SYSTEMDRIVE=")/sizeof(WCHAR) - 1;
- ptr += GetEnvironmentVariableW(L"SYSTEMDRIVE", ptr, expected + sizeof(expected) - ptr);
+ ptr += GetEnvironmentVariableW(L"SYSTEMDRIVE",
+ ptr,
+ expected + sizeof(expected) - ptr);
++ptr;
*ptr = '\0';
@@ -946,7 +962,7 @@ TEST_IMPL(spawn_auto_unref) {
ASSERT(0 == uv_is_closing((uv_handle_t*) &process));
uv_close((uv_handle_t*) &process, NULL);
ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT));
- ASSERT(0 != uv_is_closing((uv_handle_t*) &process));
+ ASSERT(1 == uv_is_closing((uv_handle_t*) &process));
MAKE_VALGRIND_HAPPY();
return 0;
}
diff --git a/deps/uv/test/test-stdio-over-pipes.c b/deps/uv/test/test-stdio-over-pipes.c
index 5f2226cd08..1574476104 100644
--- a/deps/uv/test/test-stdio-over-pipes.c
+++ b/deps/uv/test/test-stdio-over-pipes.c
@@ -43,7 +43,6 @@ static int output_used;
static void close_cb(uv_handle_t* handle) {
- printf("close_cb\n");
close_cb_called++;
}
diff --git a/deps/uv/test/test-tcp-bind-error.c b/deps/uv/test/test-tcp-bind-error.c
index 0cecedede4..42c0106237 100644
--- a/deps/uv/test/test-tcp-bind-error.c
+++ b/deps/uv/test/test-tcp-bind-error.c
@@ -116,7 +116,8 @@ TEST_IMPL(tcp_bind_error_addrnotavail_2) {
TEST_IMPL(tcp_bind_error_fault) {
- char garbage[] = "blah blah blah blah blah blah blah blah blah blah blah blah";
+ char garbage[] =
+ "blah blah blah blah blah blah blah blah blah blah blah blah";
struct sockaddr_in* garbage_addr;
uv_tcp_t server;
int r;
diff --git a/deps/uv/test/test-tcp-bind6-error.c b/deps/uv/test/test-tcp-bind6-error.c
index 7eb2f05b37..08772190f2 100644
--- a/deps/uv/test/test-tcp-bind6-error.c
+++ b/deps/uv/test/test-tcp-bind6-error.c
@@ -92,7 +92,8 @@ TEST_IMPL(tcp_bind6_error_addrnotavail) {
TEST_IMPL(tcp_bind6_error_fault) {
- char garbage[] = "blah blah blah blah blah blah blah blah blah blah blah blah";
+ char garbage[] =
+ "blah blah blah blah blah blah blah blah blah blah blah blah";
struct sockaddr_in6* garbage_addr;
uv_tcp_t server;
int r;
diff --git a/deps/uv/test/test-timer-again.c b/deps/uv/test/test-timer-again.c
index 2616a13eb7..1638da2dfc 100644
--- a/deps/uv/test/test-timer-again.c
+++ b/deps/uv/test/test-timer-again.c
@@ -57,7 +57,7 @@ static void repeat_1_cb(uv_timer_t* handle, int status) {
r = uv_timer_again(&repeat_2);
ASSERT(r == 0);
- if (uv_now(uv_default_loop()) >= start_time + 500) {
+ 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. */
@@ -78,7 +78,7 @@ static void repeat_2_cb(uv_timer_t* handle, int status) {
repeat_2_cb_called++;
if (uv_timer_get_repeat(&repeat_2) == 0) {
- ASSERT(!uv_is_active((uv_handle_t*)handle));
+ ASSERT(0 == uv_is_active((uv_handle_t*) handle));
uv_close((uv_handle_t*)handle, close_cb);
return;
}
@@ -134,7 +134,6 @@ TEST_IMPL(timer_again) {
LOGF("Test took %ld ms (expected ~700 ms)\n",
(long int)(uv_now(uv_default_loop()) - start_time));
- ASSERT(700 <= uv_now(uv_default_loop()) - start_time);
MAKE_VALGRIND_HAPPY();
return 0;
diff --git a/deps/uv/test/test-timer.c b/deps/uv/test/test-timer.c
index 3954957295..bbe69f68be 100644
--- a/deps/uv/test/test-timer.c
+++ b/deps/uv/test/test-timer.c
@@ -38,7 +38,7 @@ static void once_close_cb(uv_handle_t* handle) {
printf("ONCE_CLOSE_CB\n");
ASSERT(handle != NULL);
- ASSERT(!uv_is_active(handle));
+ ASSERT(0 == uv_is_active(handle));
once_close_cb_called++;
}
@@ -49,7 +49,7 @@ static void once_cb(uv_timer_t* handle, int status) {
ASSERT(handle != NULL);
ASSERT(status == 0);
- ASSERT(!uv_is_active((uv_handle_t*)handle));
+ ASSERT(0 == uv_is_active((uv_handle_t*) handle));
once_cb_called++;
@@ -74,7 +74,7 @@ static void repeat_cb(uv_timer_t* handle, int status) {
ASSERT(handle != NULL);
ASSERT(status == 0);
- ASSERT(uv_is_active((uv_handle_t*)handle));
+ ASSERT(1 == uv_is_active((uv_handle_t*) handle));
repeat_cb_called++;
@@ -163,7 +163,7 @@ TEST_IMPL(timer_init) {
ASSERT(0 == uv_timer_init(uv_default_loop(), &handle));
ASSERT(0 == uv_timer_get_repeat(&handle));
- ASSERT(!uv_is_active((uv_handle_t*)&handle));
+ ASSERT(0 == uv_is_active((uv_handle_t*) &handle));
MAKE_VALGRIND_HAPPY();
return 0;
diff --git a/deps/uv/test/test-tty.c b/deps/uv/test/test-tty.c
index c26f7fa9bb..fb69910732 100644
--- a/deps/uv/test/test-tty.c
+++ b/deps/uv/test/test-tty.c
@@ -65,12 +65,16 @@ TEST_IMPL(tty) {
#else /* unix */
ttyin_fd = open("/dev/tty", O_RDONLY, 0);
- if (ttyin_fd < 0)
+ if (ttyin_fd < 0) {
LOGF("Cannot open /dev/tty as read-only: %s\n", strerror(errno));
+ return TEST_SKIP;
+ }
ttyout_fd = open("/dev/tty", O_WRONLY, 0);
- if (ttyout_fd < 0)
+ if (ttyout_fd < 0) {
LOGF("Cannot open /dev/tty as write-only: %s\n", strerror(errno));
+ return TEST_SKIP;
+ }
#endif
ASSERT(ttyin_fd >= 0);
diff --git a/deps/uv/test/test-udp-send-and-recv.c b/deps/uv/test/test-udp-send-and-recv.c
index aa9a31c3a9..3020ded7bf 100644
--- a/deps/uv/test/test-udp-send-and-recv.c
+++ b/deps/uv/test/test-udp-send-and-recv.c
@@ -54,7 +54,7 @@ static void alloc_cb(uv_handle_t* handle,
static void close_cb(uv_handle_t* handle) {
CHECK_HANDLE(handle);
- ASSERT(uv_is_closing(handle));
+ ASSERT(1 == uv_is_closing(handle));
close_cb_called++;
}