forked from cory/tildefriends
libuv 1.47.0.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4615 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
42
deps/libuv/test/test-tcp-try-write.c
vendored
42
deps/libuv/test/test-tcp-try-write.c
vendored
@@ -46,7 +46,7 @@ static void close_cb(uv_handle_t* handle) {
|
||||
static void connect_cb(uv_connect_t* req, int status) {
|
||||
int r;
|
||||
uv_buf_t buf;
|
||||
ASSERT(status == 0);
|
||||
ASSERT_OK(status);
|
||||
connect_cb_called++;
|
||||
|
||||
do {
|
||||
@@ -87,24 +87,24 @@ static void read_cb(uv_stream_t* tcp, ssize_t nread, const uv_buf_t* buf) {
|
||||
|
||||
|
||||
static void connection_cb(uv_stream_t* tcp, int status) {
|
||||
ASSERT(status == 0);
|
||||
ASSERT_OK(status);
|
||||
|
||||
ASSERT(0 == uv_tcp_init(tcp->loop, &incoming));
|
||||
ASSERT(0 == uv_accept(tcp, (uv_stream_t*) &incoming));
|
||||
ASSERT_OK(uv_tcp_init(tcp->loop, &incoming));
|
||||
ASSERT_OK(uv_accept(tcp, (uv_stream_t*) &incoming));
|
||||
|
||||
connection_cb_called++;
|
||||
ASSERT(0 == uv_read_start((uv_stream_t*) &incoming, alloc_cb, read_cb));
|
||||
ASSERT_OK(uv_read_start((uv_stream_t*) &incoming, alloc_cb, read_cb));
|
||||
}
|
||||
|
||||
|
||||
static void start_server(void) {
|
||||
struct sockaddr_in addr;
|
||||
|
||||
ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &addr));
|
||||
ASSERT_OK(uv_ip4_addr("0.0.0.0", TEST_PORT, &addr));
|
||||
|
||||
ASSERT(0 == uv_tcp_init(uv_default_loop(), &server));
|
||||
ASSERT(0 == uv_tcp_bind(&server, (struct sockaddr*) &addr, 0));
|
||||
ASSERT(0 == uv_listen((uv_stream_t*) &server, 128, connection_cb));
|
||||
ASSERT_OK(uv_tcp_init(uv_default_loop(), &server));
|
||||
ASSERT_OK(uv_tcp_bind(&server, (struct sockaddr*) &addr, 0));
|
||||
ASSERT_OK(uv_listen((uv_stream_t*) &server, 128, connection_cb));
|
||||
}
|
||||
|
||||
|
||||
@@ -114,21 +114,21 @@ TEST_IMPL(tcp_try_write) {
|
||||
|
||||
start_server();
|
||||
|
||||
ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr));
|
||||
ASSERT_OK(uv_ip4_addr("127.0.0.1", TEST_PORT, &addr));
|
||||
|
||||
ASSERT(0 == uv_tcp_init(uv_default_loop(), &client));
|
||||
ASSERT(0 == uv_tcp_connect(&connect_req,
|
||||
&client,
|
||||
(struct sockaddr*) &addr,
|
||||
connect_cb));
|
||||
ASSERT_OK(uv_tcp_init(uv_default_loop(), &client));
|
||||
ASSERT_OK(uv_tcp_connect(&connect_req,
|
||||
&client,
|
||||
(struct sockaddr*) &addr,
|
||||
connect_cb));
|
||||
|
||||
ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT));
|
||||
ASSERT_OK(uv_run(uv_default_loop(), UV_RUN_DEFAULT));
|
||||
|
||||
ASSERT(connect_cb_called == 1);
|
||||
ASSERT(close_cb_called == 3);
|
||||
ASSERT(connection_cb_called == 1);
|
||||
ASSERT(bytes_read == bytes_written);
|
||||
ASSERT(bytes_written > 0);
|
||||
ASSERT_EQ(1, connect_cb_called);
|
||||
ASSERT_EQ(3, close_cb_called);
|
||||
ASSERT_EQ(1, connection_cb_called);
|
||||
ASSERT_EQ(bytes_read, bytes_written);
|
||||
ASSERT_GT(bytes_written, 0);
|
||||
|
||||
MAKE_VALGRIND_HAPPY(uv_default_loop());
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user