aboutsummaryrefslogtreecommitdiff
path: root/deps/uv/test
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2011-05-19 10:37:51 -0700
committerRyan Dahl <ry@tinyclouds.org>2011-05-19 10:37:51 -0700
commit4b60e87afec10e7e051e37cd5d00d0fbe3568a7d (patch)
tree146d940fb18ad305fa1887f223805a7da41bc7da /deps/uv/test
parent3ac0ada758004ffe141d79c282e16ed8c8f4cc83 (diff)
downloadandroid-node-v8-4b60e87afec10e7e051e37cd5d00d0fbe3568a7d.tar.gz
android-node-v8-4b60e87afec10e7e051e37cd5d00d0fbe3568a7d.tar.bz2
android-node-v8-4b60e87afec10e7e051e37cd5d00d0fbe3568a7d.zip
Upgrade libuv to 9c2dd6bea970b2376696aba070bdfc2873843cfb
Diffstat (limited to 'deps/uv/test')
-rw-r--r--deps/uv/test/benchmark-ping-pongs.c20
-rw-r--r--deps/uv/test/benchmark-pump.c68
-rw-r--r--deps/uv/test/echo-server.c10
-rw-r--r--deps/uv/test/task.h4
-rw-r--r--deps/uv/test/test-async.c4
-rw-r--r--deps/uv/test/test-bind-error.c4
-rw-r--r--deps/uv/test/test-callback-stack.c40
-rw-r--r--deps/uv/test/test-connection-fail.c4
-rw-r--r--deps/uv/test/test-delayed-accept.c37
-rw-r--r--deps/uv/test/test-list.h7
-rw-r--r--deps/uv/test/test-loop-handles.c35
-rw-r--r--deps/uv/test/test-ping-pong.c8
-rw-r--r--deps/uv/test/test-tcp-writealot.c10
-rw-r--r--deps/uv/test/test-timeout.c105
14 files changed, 136 insertions, 220 deletions
diff --git a/deps/uv/test/benchmark-ping-pongs.c b/deps/uv/test/benchmark-ping-pongs.c
index 7731c3305d..1bda337779 100644
--- a/deps/uv/test/benchmark-ping-pongs.c
+++ b/deps/uv/test/benchmark-ping-pongs.c
@@ -39,7 +39,7 @@ typedef struct {
} pinger_t;
typedef struct buf_s {
- uv_buf uv_buf;
+ uv_buf_t uv_buf_t;
struct buf_s* next;
} buf_t;
@@ -52,26 +52,26 @@ static int completed_pingers = 0;
static int64_t start_time;
-static uv_buf buf_alloc(uv_handle_t* handle, size_t size) {
+static uv_buf_t buf_alloc(uv_handle_t* handle, size_t size) {
buf_t* ab;
ab = buf_freelist;
if (ab != NULL) {
buf_freelist = ab->next;
- return ab->uv_buf;
+ return ab->uv_buf_t;
}
ab = (buf_t*) malloc(size + sizeof *ab);
- ab->uv_buf.len = size;
- ab->uv_buf.base = ((char*) ab) + sizeof *ab;
+ ab->uv_buf_t.len = size;
+ ab->uv_buf_t.base = ((char*) ab) + sizeof *ab;
- return ab->uv_buf;
+ return ab->uv_buf_t;
}
-static void buf_free(uv_buf uv_buf) {
- buf_t* ab = (buf_t*) (uv_buf.base - sizeof *ab);
+static void buf_free(uv_buf_t uv_buf_t) {
+ buf_t* ab = (buf_t*) (uv_buf_t.base - sizeof *ab);
ab->next = buf_freelist;
buf_freelist = ab;
@@ -101,7 +101,7 @@ static void pinger_write_cb(uv_req_t *req, int status) {
static void pinger_write_ping(pinger_t* pinger) {
uv_req_t *req;
- uv_buf buf;
+ uv_buf_t buf;
buf.base = (char*)&PING;
buf.len = strlen(PING);
@@ -120,7 +120,7 @@ static void pinger_shutdown_cb(uv_handle_t* handle, int status) {
}
-static void pinger_read_cb(uv_handle_t* handle, int nread, uv_buf buf) {
+static void pinger_read_cb(uv_handle_t* handle, int nread, uv_buf_t buf) {
unsigned int i;
pinger_t* pinger;
diff --git a/deps/uv/test/benchmark-pump.c b/deps/uv/test/benchmark-pump.c
index 69773e1313..e9b3031ca0 100644
--- a/deps/uv/test/benchmark-pump.c
+++ b/deps/uv/test/benchmark-pump.c
@@ -41,11 +41,12 @@ static void maybe_connect_some();
static uv_req_t* req_alloc();
static void req_free(uv_req_t* uv_req);
-static uv_buf buf_alloc(uv_handle_t* handle, size_t size);
-static void buf_free(uv_buf uv_buf);
+static uv_buf_t buf_alloc(uv_handle_t* handle, size_t size);
+static void buf_free(uv_buf_t uv_buf_t);
-static struct sockaddr_in server_addr;
+static struct sockaddr_in listen_addr;
+static struct sockaddr_in connect_addr;
static int64_t start_time;
@@ -65,6 +66,8 @@ static char write_buffer[WRITE_BUFFER_SIZE];
static uv_handle_t read_handles[TARGET_CONNECTIONS];
static uv_handle_t write_handles[TARGET_CONNECTIONS];
+static uv_handle_t timer_handle;
+
static double gbit(int64_t bytes, int64_t passed_ms) {
double gbits = ((double)bytes / (1024 * 1024 * 1024)) * 8;
@@ -72,21 +75,21 @@ static double gbit(int64_t bytes, int64_t passed_ms) {
}
-static void show_stats(uv_req_t *req, int64_t skew, int status) {
- int64_t msec = STATS_INTERVAL + skew;
+static void show_stats(uv_handle_t *handle, int status) {
+ int64_t diff;
#if PRINT_STATS
LOGF("connections: %d, read: %.1f gbit/s, write: %.1f gbit/s\n",
read_sockets,
- gbit(nrecv, msec),
- gbit(nsent, msec));
+ gbit(nrecv, STATS_INTERVAL),
+ gbit(nsent, STATS_INTERVAL));
#endif
/* Exit if the show is over */
if (!--stats_left) {
uv_update_time();
- int64_t diff = uv_now() - start_time;
+ diff = uv_now() - start_time;
LOGF("pump_%d: %.1f gbit/s\n", read_sockets,
gbit(nrecv_total, diff));
@@ -97,10 +100,11 @@ static void show_stats(uv_req_t *req, int64_t skew, int status) {
/* Reset read and write counters */
nrecv = 0;
nsent = 0;
+}
+
- uv_timeout(req, (STATS_INTERVAL - skew > 0)
- ? STATS_INTERVAL - skew
- : 0);
+void close_cb(uv_handle_t* handle, int status) {
+ ASSERT(status == 0);
}
@@ -108,20 +112,16 @@ static void start_stats_collection() {
uv_req_t* req = req_alloc();
int r;
- /* Show-stats timeout */
+ /* Show-stats timer */
stats_left = STATS_COUNT;
- uv_req_init(req, NULL, (void*)show_stats);
- r = uv_timeout(req, STATS_INTERVAL);
+ r = uv_timer_init(&timer_handle, close_cb, NULL);
+ ASSERT(r == 0);
+ r = uv_timer_start(&timer_handle, show_stats, STATS_INTERVAL, STATS_INTERVAL);
ASSERT(r == 0);
}
-void close_cb(uv_handle_t* handle, int status) {
- ASSERT(status == 0);
-}
-
-
-static void read_cb(uv_handle_t* handle, int bytes, uv_buf buf) {
+static void read_cb(uv_handle_t* handle, int bytes, uv_buf_t buf) {
ASSERT(bytes >= 0);
buf_free(buf);
@@ -132,7 +132,7 @@ static void read_cb(uv_handle_t* handle, int bytes, uv_buf buf) {
static void write_cb(uv_req_t *req, int status) {
- uv_buf* buf = (uv_buf*) req->data;
+ uv_buf_t* buf = (uv_buf_t*) req->data;
ASSERT(status == 0);
@@ -147,7 +147,7 @@ static void write_cb(uv_req_t *req, int status) {
static void do_write(uv_handle_t* handle) {
uv_req_t* req;
- uv_buf buf;
+ uv_buf_t buf;
int r;
buf.base = (char*) &write_buffer;
@@ -207,7 +207,7 @@ static void maybe_connect_some() {
while (max_connect_socket < TARGET_CONNECTIONS &&
max_connect_socket < write_sockets + MAX_SIMULTANEOUS_CONNECTS) {
do_connect(&write_handles[max_connect_socket++],
- (struct sockaddr*) &server_addr);
+ (struct sockaddr*) &connect_addr);
}
}
@@ -237,11 +237,13 @@ BENCHMARK_IMPL(pump) {
uv_init(buf_alloc);
+ listen_addr = uv_ip4_addr("0.0.0.0", TEST_PORT);
+ connect_addr = uv_ip4_addr("127.0.0.1", TEST_PORT);
+
/* Server */
- server_addr = uv_ip4_addr("127.0.0.1", TEST_PORT);
r = uv_tcp_init(&server, close_cb, NULL);
ASSERT(r == 0);
- r = uv_bind(&server, (struct sockaddr*) &server_addr);
+ r = uv_bind(&server, (struct sockaddr*) &listen_addr);
ASSERT(r == 0);
r = uv_listen(&server, TARGET_CONNECTIONS, accept_cb);
ASSERT(r == 0);
@@ -298,7 +300,7 @@ static void req_free(uv_req_t* uv_req) {
*/
typedef struct buf_list_s {
- uv_buf uv_buf;
+ uv_buf_t uv_buf_t;
struct buf_list_s* next;
} buf_list_t;
@@ -306,25 +308,25 @@ typedef struct buf_list_s {
static buf_list_t* buf_freelist = NULL;
-static uv_buf buf_alloc(uv_handle_t* handle, size_t size) {
+static uv_buf_t buf_alloc(uv_handle_t* handle, size_t size) {
buf_list_t* buf;
buf = buf_freelist;
if (buf != NULL) {
buf_freelist = buf->next;
- return buf->uv_buf;
+ return buf->uv_buf_t;
}
buf = (buf_list_t*) malloc(size + sizeof *buf);
- buf->uv_buf.len = (unsigned int)size;
- buf->uv_buf.base = ((char*) buf) + sizeof *buf;
+ buf->uv_buf_t.len = (unsigned int)size;
+ buf->uv_buf_t.base = ((char*) buf) + sizeof *buf;
- return buf->uv_buf;
+ return buf->uv_buf_t;
}
-static void buf_free(uv_buf uv_buf) {
- buf_list_t* buf = (buf_list_t*) (uv_buf.base - sizeof *buf);
+static void buf_free(uv_buf_t uv_buf_t) {
+ buf_list_t* buf = (buf_list_t*) (uv_buf_t.base - sizeof *buf);
buf->next = buf_freelist;
buf_freelist = buf;
diff --git a/deps/uv/test/echo-server.c b/deps/uv/test/echo-server.c
index 32a415c8c9..0fcc935f36 100644
--- a/deps/uv/test/echo-server.c
+++ b/deps/uv/test/echo-server.c
@@ -27,7 +27,7 @@
typedef struct {
uv_req_t req;
- uv_buf buf;
+ uv_buf_t buf;
} write_req_t;
@@ -35,7 +35,7 @@ static uv_handle_t server;
static void after_write(uv_req_t* req, int status);
-static void after_read(uv_handle_t* handle, int nread, uv_buf buf);
+static void after_read(uv_handle_t* handle, int nread, uv_buf_t buf);
static void on_close(uv_handle_t* peer, int status);
static void on_accept(uv_handle_t* handle);
@@ -62,7 +62,7 @@ static void after_shutdown(uv_req_t* req, int status) {
}
-static void after_read(uv_handle_t* handle, int nread, uv_buf buf) {
+static void after_read(uv_handle_t* handle, int nread, uv_buf_t buf) {
write_req_t *wr;
uv_req_t* req;
@@ -156,8 +156,8 @@ static int echo_stop() {
}
-static uv_buf echo_alloc(uv_handle_t* handle, size_t suggested_size) {
- uv_buf buf;
+static uv_buf_t echo_alloc(uv_handle_t* handle, size_t suggested_size) {
+ uv_buf_t buf;
buf.base = (char*) malloc(suggested_size);
buf.len = suggested_size;
return buf;
diff --git a/deps/uv/test/task.h b/deps/uv/test/task.h
index 50c3784032..8d9a1e8e0d 100644
--- a/deps/uv/test/task.h
+++ b/deps/uv/test/task.h
@@ -27,8 +27,8 @@
#include <stdio.h>
#include <stdlib.h>
-#define TEST_PORT 8123
-#define TEST_PORT_2 8124
+#define TEST_PORT 9123
+#define TEST_PORT_2 9124
/* Log to stderr. */
diff --git a/deps/uv/test/test-async.c b/deps/uv/test/test-async.c
index d43fdcca21..7bedcf4a95 100644
--- a/deps/uv/test/test-async.c
+++ b/deps/uv/test/test-async.c
@@ -120,8 +120,8 @@ static void close_cb(uv_handle_t* handle, int status) {
}
-static uv_buf alloc_cb(uv_handle_t* handle, size_t size) {
- uv_buf buf = {0, 0};
+static uv_buf_t alloc_cb(uv_handle_t* handle, size_t size) {
+ uv_buf_t buf = {0, 0};
FATAL("alloc should not be called");
return buf;
}
diff --git a/deps/uv/test/test-bind-error.c b/deps/uv/test/test-bind-error.c
index a29914a9aa..ca9ccc5885 100644
--- a/deps/uv/test/test-bind-error.c
+++ b/deps/uv/test/test-bind-error.c
@@ -36,8 +36,8 @@ static void close_cb(uv_handle_t* handle, int status) {
}
-static uv_buf alloc_cb(uv_handle_t* handle, size_t size) {
- uv_buf buf = {0, 0};
+static uv_buf_t alloc_cb(uv_handle_t* handle, size_t size) {
+ uv_buf_t buf = {0, 0};
FATAL("alloc should not be called");
return buf;
}
diff --git a/deps/uv/test/test-callback-stack.c b/deps/uv/test/test-callback-stack.c
index 986f863dc3..d136c9a764 100644
--- a/deps/uv/test/test-callback-stack.c
+++ b/deps/uv/test/test-callback-stack.c
@@ -30,14 +30,14 @@
static const char MESSAGE[] = "Failure is for the weak. Everyone dies alone.";
-static uv_handle_t client;
-static uv_req_t connect_req, write_req, timeout_req, shutdown_req;
+static uv_handle_t client, timer;
+static uv_req_t connect_req, write_req, shutdown_req;
static int nested = 0;
static int close_cb_called = 0;
static int connect_cb_called = 0;
static int write_cb_called = 0;
-static int timeout_cb_called = 0;
+static int timer_cb_called = 0;
static int bytes_received = 0;
static int shutdown_cb_called = 0;
@@ -58,7 +58,7 @@ static void shutdown_cb(uv_req_t* req, int status) {
}
-static void read_cb(uv_handle_t* handle, int nread, uv_buf buf) {
+static void read_cb(uv_handle_t* handle, int nread, uv_buf_t buf) {
ASSERT(nested == 0 && "read_cb must be called from a fresh stack");
printf("Read. nread == %d\n", nread);
@@ -100,9 +100,12 @@ static void read_cb(uv_handle_t* handle, int nread, uv_buf buf) {
}
-static void timeout_cb(uv_req_t* req, int64_t skew, int status) {
+static void timer_cb(uv_handle_t* handle, int status) {
+ int r;
+
+ ASSERT(handle == &timer);
ASSERT(status == 0);
- ASSERT(nested == 0 && "timeout_cb must be called from a fresh stack");
+ ASSERT(nested == 0 && "timer_cb must be called from a fresh stack");
puts("Timeout complete. Now read data...");
@@ -112,11 +115,16 @@ static void timeout_cb(uv_req_t* req, int64_t skew, int status) {
}
nested--;
- timeout_cb_called++;
+ timer_cb_called++;
+
+ r = uv_close(handle);
+ ASSERT(r == 0);
}
static void write_cb(uv_req_t* req, int status) {
+ int r;
+
ASSERT(status == 0);
ASSERT(nested == 0 && "write_cb must be called from a fresh stack");
@@ -127,10 +135,10 @@ static void write_cb(uv_req_t* req, int status) {
/* back to our receive buffer when we start reading. This maximizes the */
/* tempation for the backend to use dirty stack for calling read_cb. */
nested++;
- uv_req_init(&timeout_req, NULL, timeout_cb);
- if (uv_timeout(&timeout_req, 500)) {
- FATAL("uv_timeout failed");
- }
+ r = uv_timer_init(&timer, close_cb, NULL);
+ ASSERT(r == 0);
+ r = uv_timer_start(&timer, timer_cb, 500, 0);
+ ASSERT(r == 0);
nested--;
write_cb_called++;
@@ -138,7 +146,7 @@ static void write_cb(uv_req_t* req, int status) {
static void connect_cb(uv_req_t* req, int status) {
- uv_buf buf;
+ uv_buf_t buf;
puts("Connected. Write some data to echo server...");
@@ -162,8 +170,8 @@ static void connect_cb(uv_req_t* req, int status) {
}
-static uv_buf alloc_cb(uv_handle_t* handle, size_t size) {
- uv_buf buf;
+static uv_buf_t alloc_cb(uv_handle_t* handle, size_t size) {
+ uv_buf_t buf;
buf.len = size;
buf.base = (char*) malloc(size);
ASSERT(buf.base);
@@ -194,10 +202,10 @@ TEST_IMPL(callback_stack) {
ASSERT(nested == 0);
ASSERT(connect_cb_called == 1 && "connect_cb must be called exactly once");
ASSERT(write_cb_called == 1 && "write_cb must be called exactly once");
- ASSERT(timeout_cb_called == 1 && "timeout_cb must be called exactly once");
+ ASSERT(timer_cb_called == 1 && "timer_cb must be called exactly once");
ASSERT(bytes_received == sizeof MESSAGE);
ASSERT(shutdown_cb_called == 1 && "shutdown_cb must be called exactly once");
- ASSERT(close_cb_called == 1 && "close_cb must be called exactly once");
+ ASSERT(close_cb_called == 2 && "close_cb must be called exactly twice");
return 0;
}
diff --git a/deps/uv/test/test-connection-fail.c b/deps/uv/test/test-connection-fail.c
index ef060d1d25..e28c7c36e6 100644
--- a/deps/uv/test/test-connection-fail.c
+++ b/deps/uv/test/test-connection-fail.c
@@ -46,8 +46,8 @@ static void on_connect(uv_req_t *req, int status) {
}
-static uv_buf alloc_cb(uv_handle_t* handle, size_t size) {
- uv_buf buf = {0, 0};
+static uv_buf_t alloc_cb(uv_handle_t* handle, size_t size) {
+ uv_buf_t buf = {0, 0};
FATAL("alloc should not be called");
return buf;
}
diff --git a/deps/uv/test/test-delayed-accept.c b/deps/uv/test/test-delayed-accept.c
index 3c8a55f4ba..e372b955c4 100644
--- a/deps/uv/test/test-delayed-accept.c
+++ b/deps/uv/test/test-delayed-accept.c
@@ -43,42 +43,49 @@ static void close_cb(uv_handle_t* handle, int status) {
}
-static void do_accept(uv_req_t* req, int64_t skew, int status) {
+static void do_accept(uv_handle_t* timer_handle, int status) {
uv_handle_t* server;
uv_handle_t* accepted_handle = (uv_handle_t*)malloc(sizeof *accepted_handle);
int r;
- ASSERT(req != NULL);
+ ASSERT(timer_handle != NULL);
ASSERT(status == 0);
ASSERT(accepted_handle != NULL);
- server = (uv_handle_t*)req->data;
+ server = (uv_handle_t*)timer_handle->data;
r = uv_accept(server, accepted_handle, close_cb, NULL);
ASSERT(r == 0);
do_accept_called++;
/* Immediately close the accepted handle. */
- uv_close(accepted_handle);
+ r = uv_close(accepted_handle);
+ ASSERT(r == 0);
/* After accepting the two clients close the server handle */
if (do_accept_called == 2) {
- uv_close(server);
+ r = uv_close(server);
+ ASSERT(r == 0);
}
- free(req);
+ /* Dispose the timer. */
+ r = uv_close(timer_handle);
+ ASSERT(r == 0);
}
static void accept_cb(uv_handle_t* handle) {
- uv_req_t* timeout_req = (uv_req_t*)malloc(sizeof *timeout_req);
+ int r;
+ uv_handle_t* timer_handle;
- ASSERT(timeout_req != NULL);
+ timer_handle = (uv_handle_t*)malloc(sizeof *timer_handle);
+ ASSERT(timer_handle != NULL);
/* Accept the client after 1 second */
- uv_req_init(timeout_req, NULL, &do_accept);
- timeout_req->data = (void*)handle;
- uv_timeout(timeout_req, 1000);
+ r = uv_timer_init(timer_handle, close_cb, (void*)handle);
+ ASSERT(r == 0);
+ r = uv_timer_start(timer_handle, do_accept, 1000, 0);
+ ASSERT(r == 0);
accept_cb_called++;
}
@@ -102,7 +109,7 @@ static void start_server() {
}
-static void read_cb(uv_handle_t* handle, int nread, uv_buf buf) {
+static void read_cb(uv_handle_t* handle, int nread, uv_buf_t buf) {
/* The server will not send anything, it should close gracefully. */
ASSERT(handle != NULL);
ASSERT(nread == -1);
@@ -151,8 +158,8 @@ static void client_connect() {
}
-static uv_buf alloc_cb(uv_handle_t* handle, size_t size) {
- uv_buf buf;
+static uv_buf_t alloc_cb(uv_handle_t* handle, size_t size) {
+ uv_buf_t buf;
buf.base = (char*)malloc(size);
buf.len = size;
return buf;
@@ -173,7 +180,7 @@ TEST_IMPL(delayed_accept) {
ASSERT(accept_cb_called == 2);
ASSERT(do_accept_called == 2);
ASSERT(connect_cb_called == 2);
- ASSERT(close_cb_called == 5);
+ ASSERT(close_cb_called == 7);
return 0;
}
diff --git a/deps/uv/test/test-list.h b/deps/uv/test/test-list.h
index 0cf3518b5b..fb85295b5b 100644
--- a/deps/uv/test/test-list.h
+++ b/deps/uv/test/test-list.h
@@ -29,7 +29,8 @@ TEST_DECLARE (bind_error_fault)
TEST_DECLARE (bind_error_inval)
TEST_DECLARE (connection_fail)
TEST_DECLARE (callback_stack)
-TEST_DECLARE (timeout)
+TEST_DECLARE (timer)
+TEST_DECLARE (timer_again)
TEST_DECLARE (loop_handles)
TEST_DECLARE (async)
TEST_DECLARE (fail_always)
@@ -60,7 +61,9 @@ TASK_LIST_START
TEST_ENTRY (callback_stack)
TEST_HELPER (callback_stack, echo_server)
- TEST_ENTRY (timeout)
+ TEST_ENTRY (timer)
+
+ TEST_ENTRY (timer_again)
TEST_ENTRY (loop_handles)
diff --git a/deps/uv/test/test-loop-handles.c b/deps/uv/test/test-loop-handles.c
index 65c84b1b75..7b2c27c785 100644
--- a/deps/uv/test/test-loop-handles.c
+++ b/deps/uv/test/test-loop-handles.c
@@ -58,9 +58,9 @@
* being started by a check_1 watcher. It verifies that a watcher is
* implicitly stopped when closed, and that a watcher can close itself
* safely.
- * - There is a timeout request that reposts itself after every timeout. It
- * does not keep te event loop alive (ev_unref) but makes sure that the loop
- * keeps polling the system for events.
+ * - There is a repeating timer. It does not keep te event loop alive
+ * (ev_unref) but makes sure that the loop keeps polling the system for
+ * events.
*/
@@ -83,7 +83,7 @@ static uv_handle_t check_handle;
static uv_handle_t idle_1_handles[IDLE_COUNT];
static uv_handle_t idle_2_handle;
-static uv_req_t timeout_req;
+static uv_handle_t timer_handle;
static int loop_iteration = 0;
@@ -106,19 +106,19 @@ static int idle_2_close_cb_called = 0;
static int idle_2_cb_started = 0;
static int idle_2_is_active = 0;
-static int timeout_cb_called = 0;
+static int timer_cb_called = 0;
-static void timeout_cb(uv_req_t *req, int64_t skew, int status) {
- int r;
-
- ASSERT(req == &timeout_req);
+static void timer_cb(uv_handle_t* handle, int status) {
+ ASSERT(handle == &timer_handle);
ASSERT(status == 0);
- timeout_cb_called++;
+ timer_cb_called++;
+}
+
- r = uv_timeout(req, TIMEOUT);
- ASSERT(r == 0);
+static void timer_close_cb(uv_handle_t* handle, int status) {
+ FATAL("timer_close_cb should not be called");
}
@@ -313,8 +313,8 @@ static void prepare_1_close_cb(uv_handle_t* handle, int status){
}
-static uv_buf alloc_cb(uv_handle_t* handle, size_t size) {
- uv_buf rv = { 0, 0 };
+static uv_buf_t alloc_cb(uv_handle_t* handle, size_t size) {
+ uv_buf_t rv = { 0, 0 };
FATAL("alloc_cb should never be called in this test");
return rv;
}
@@ -350,8 +350,9 @@ TEST_IMPL(loop_handles) {
/* the timer callback is there to keep the event loop polling */
/* unref it as it is not supposed to keep the loop alive */
- uv_req_init(&timeout_req, NULL, timeout_cb);
- r = uv_timeout(&timeout_req, TIMEOUT);
+ r = uv_timer_init(&timer_handle, timer_close_cb, NULL);
+ ASSERT(r == 0);
+ r = uv_timer_start(&timer_handle, timer_cb, TIMEOUT, TIMEOUT);
ASSERT(r == 0);
uv_unref();
@@ -379,7 +380,7 @@ TEST_IMPL(loop_handles) {
ASSERT(idle_2_close_cb_called == idle_2_cb_started);
ASSERT(idle_2_is_active == 0);
- ASSERT(timeout_cb_called > 0);
+ ASSERT(timer_cb_called > 0);
return 0;
}
diff --git a/deps/uv/test/test-ping-pong.c b/deps/uv/test/test-ping-pong.c
index 56ea1db18c..13d114e32d 100644
--- a/deps/uv/test/test-ping-pong.c
+++ b/deps/uv/test/test-ping-pong.c
@@ -69,7 +69,7 @@ static void pinger_after_write(uv_req_t *req, int status) {
static void pinger_write_ping(pinger_t* pinger) {
uv_req_t *req;
- uv_buf buf;
+ uv_buf_t buf;
buf.base = (char*)&PING;
buf.len = strlen(PING);
@@ -85,7 +85,7 @@ static void pinger_write_ping(pinger_t* pinger) {
}
-static void pinger_read_cb(uv_handle_t* handle, int nread, uv_buf buf) {
+static void pinger_read_cb(uv_handle_t* handle, int nread, uv_buf_t buf) {
unsigned int i;
pinger_t* pinger;
@@ -156,8 +156,8 @@ static void pinger_new() {
}
-static uv_buf alloc_cb(uv_handle_t* handle, size_t size) {
- uv_buf buf;
+static uv_buf_t alloc_cb(uv_handle_t* handle, size_t size) {
+ uv_buf_t buf;
buf.base = (char*)malloc(size);
buf.len = size;
return buf;
diff --git a/deps/uv/test/test-tcp-writealot.c b/deps/uv/test/test-tcp-writealot.c
index 996599972a..15cc2d5b6f 100644
--- a/deps/uv/test/test-tcp-writealot.c
+++ b/deps/uv/test/test-tcp-writealot.c
@@ -72,7 +72,7 @@ static void shutdown_cb(uv_req_t* req, int status) {
}
-static void read_cb(uv_handle_t* handle, int nread, uv_buf buf) {
+static void read_cb(uv_handle_t* handle, int nread, uv_buf_t buf) {
ASSERT(handle != NULL);
if (nread < 0) {
@@ -110,7 +110,7 @@ static void write_cb(uv_req_t* req, int status) {
static void connect_cb(uv_req_t* req, int status) {
- uv_buf send_bufs[CHUNKS_PER_WRITE];
+ uv_buf_t send_bufs[CHUNKS_PER_WRITE];
uv_handle_t* handle;
int i, j, r;
@@ -134,7 +134,7 @@ static void connect_cb(uv_req_t* req, int status) {
ASSERT(req != NULL);
uv_req_init(req, handle, write_cb);
- r = uv_write(req, (uv_buf*)&send_bufs, CHUNKS_PER_WRITE);
+ r = uv_write(req, (uv_buf_t*)&send_bufs, CHUNKS_PER_WRITE);
ASSERT(r == 0);
}
@@ -155,8 +155,8 @@ static void connect_cb(uv_req_t* req, int status) {
}
-static uv_buf alloc_cb(uv_handle_t* handle, size_t size) {
- uv_buf buf;
+static uv_buf_t alloc_cb(uv_handle_t* handle, size_t size) {
+ uv_buf_t buf;
buf.base = (char*)malloc(size);
buf.len = size;
return buf;
diff --git a/deps/uv/test/test-timeout.c b/deps/uv/test/test-timeout.c
deleted file mode 100644
index ea984eb6fd..0000000000
--- a/deps/uv/test/test-timeout.c
+++ /dev/null
@@ -1,105 +0,0 @@
-/* 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 expected = 0;
-static int timeouts = 0;
-
-static int64_t start_time;
-
-static void timeout_cb(uv_req_t *req, int64_t skew, int status) {
- ASSERT(req != NULL);
- ASSERT(status == 0);
-
- free(req);
- timeouts++;
-
- /* Just call this randomly for the code coverage. */
- uv_update_time();
-}
-
-static void exit_timeout_cb(uv_req_t *req, int64_t skew, int status) {
- int64_t now = uv_now();
- ASSERT(req != NULL);
- ASSERT(status == 0);
- ASSERT(timeouts == expected);
- ASSERT(start_time < now);
- exit(0);
-}
-
-static void dummy_timeout_cb(uv_req_t *req, int64_t skew, int status) {
- /* Should never be called */
- FATAL("dummy_timer_cb should never be called");
-}
-
-
-static uv_buf alloc_cb(uv_handle_t* handle, size_t size) {
- uv_buf buf = {0, 0};
- FATAL("alloc should not be called");
- return buf;
-}
-
-
-TEST_IMPL(timeout) {
- uv_req_t *req;
- uv_req_t exit_req;
- uv_req_t dummy_req;
- int i;
-
- uv_init(alloc_cb);
-
- start_time = uv_now();
- ASSERT(0 < start_time);
-
- /* Let 10 timers time out in 500 ms total. */
- for (i = 0; i < 10; i++) {
- req = (uv_req_t*)malloc(sizeof(*req));
- ASSERT(req != NULL);
-
- uv_req_init(req, NULL, timeout_cb);
-
- if (uv_timeout(req, i * 50) < 0) {
- FATAL("uv_timeout failed");
- }
-
- expected++;
- }
-
- /* The 11th timer exits the test and runs after 1 s. */
- uv_req_init(&exit_req, NULL, exit_timeout_cb);
- if (uv_timeout(&exit_req, 1000) < 0) {
- FATAL("uv_timeout failed");
- }
-
- /* The 12th timer should never run. */
- uv_req_init(&dummy_req, NULL, dummy_timeout_cb);
- if (uv_timeout(&dummy_req, 2000)) {
- FATAL("uv_timeout failed");
- }
-
- uv_run();
-
- FATAL("should never get here");
- return 2;
-}