test and bench: assert return values of *_init functions in tests
This commit is contained in:
parent
905fe71341
commit
533418d4da
@ -273,10 +273,12 @@ static void connection_cb(uv_stream_t* s, int status) {
|
|||||||
|
|
||||||
if (type == TCP) {
|
if (type == TCP) {
|
||||||
stream = (uv_stream_t*)malloc(sizeof(uv_tcp_t));
|
stream = (uv_stream_t*)malloc(sizeof(uv_tcp_t));
|
||||||
uv_tcp_init(loop, (uv_tcp_t*)stream);
|
r = uv_tcp_init(loop, (uv_tcp_t*)stream);
|
||||||
|
ASSERT(r == 0);
|
||||||
} else {
|
} else {
|
||||||
stream = (uv_stream_t*)malloc(sizeof(uv_pipe_t));
|
stream = (uv_stream_t*)malloc(sizeof(uv_pipe_t));
|
||||||
uv_pipe_init(loop, (uv_pipe_t*)stream);
|
r = uv_pipe_init(loop, (uv_pipe_t*)stream);
|
||||||
|
ASSERT(r == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
r = uv_accept(s, stream);
|
r = uv_accept(s, stream);
|
||||||
|
|||||||
@ -272,7 +272,8 @@ static void on_connection(uv_stream_t* server, int status) {
|
|||||||
handle->state.prevbuf_pos = 0;
|
handle->state.prevbuf_pos = 0;
|
||||||
handle->state.prevbuf_rem = 0;
|
handle->state.prevbuf_rem = 0;
|
||||||
|
|
||||||
uv_tcp_init(loop, (uv_tcp_t*)handle);
|
r = uv_tcp_init(loop, (uv_tcp_t*)handle);
|
||||||
|
ASSERT(r == 0);
|
||||||
|
|
||||||
r = uv_accept(server, (uv_stream_t*)handle);
|
r = uv_accept(server, (uv_stream_t*)handle);
|
||||||
ASSERT(r == 0);
|
ASSERT(r == 0);
|
||||||
|
|||||||
@ -144,13 +144,15 @@ static void on_connection(uv_stream_t* server, int status) {
|
|||||||
case TCP:
|
case TCP:
|
||||||
stream = malloc(sizeof(uv_tcp_t));
|
stream = malloc(sizeof(uv_tcp_t));
|
||||||
ASSERT(stream != NULL);
|
ASSERT(stream != NULL);
|
||||||
uv_tcp_init(loop, (uv_tcp_t*)stream);
|
r = uv_tcp_init(loop, (uv_tcp_t*)stream);
|
||||||
|
ASSERT(r == 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PIPE:
|
case PIPE:
|
||||||
stream = malloc(sizeof(uv_pipe_t));
|
stream = malloc(sizeof(uv_pipe_t));
|
||||||
ASSERT(stream != NULL);
|
ASSERT(stream != NULL);
|
||||||
uv_pipe_init(loop, (uv_pipe_t*)stream);
|
r = uv_pipe_init(loop, (uv_pipe_t*)stream);
|
||||||
|
ASSERT(r == 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
@ -134,7 +134,10 @@ TEST_IMPL(connection_fail) {
|
|||||||
* attempt.
|
* attempt.
|
||||||
*/
|
*/
|
||||||
TEST_IMPL(connection_fail_doesnt_auto_close) {
|
TEST_IMPL(connection_fail_doesnt_auto_close) {
|
||||||
uv_timer_init(uv_default_loop(), &timer);
|
int r;
|
||||||
|
|
||||||
|
r = uv_timer_init(uv_default_loop(), &timer);
|
||||||
|
ASSERT(r == 0);
|
||||||
|
|
||||||
connection_fail(on_connect_without_close);
|
connection_fail(on_connect_without_close);
|
||||||
|
|
||||||
|
|||||||
@ -57,7 +57,8 @@ static void do_accept(uv_timer_t* timer_handle, int status) {
|
|||||||
ASSERT(status == 0);
|
ASSERT(status == 0);
|
||||||
ASSERT(accepted_handle != NULL);
|
ASSERT(accepted_handle != NULL);
|
||||||
|
|
||||||
uv_tcp_init(uv_default_loop(), accepted_handle);
|
r = uv_tcp_init(uv_default_loop(), accepted_handle);
|
||||||
|
ASSERT(r == 0);
|
||||||
|
|
||||||
/* Test to that uv_default_loop()->counters.tcp_init does not increase across the uv_accept. */
|
/* Test to that uv_default_loop()->counters.tcp_init does not increase across the uv_accept. */
|
||||||
tcpcnt = uv_default_loop()->counters.tcp_init;
|
tcpcnt = uv_default_loop()->counters.tcp_init;
|
||||||
|
|||||||
@ -117,7 +117,8 @@ static void on_connection(uv_stream_t* server, int status) {
|
|||||||
handle = (uv_handle_t*) malloc(sizeof(uv_tcp_t));
|
handle = (uv_handle_t*) malloc(sizeof(uv_tcp_t));
|
||||||
ASSERT(handle != NULL);
|
ASSERT(handle != NULL);
|
||||||
|
|
||||||
uv_tcp_init(loop, (uv_tcp_t*)handle);
|
r = uv_tcp_init(loop, (uv_tcp_t*)handle);
|
||||||
|
ASSERT(r == 0);
|
||||||
|
|
||||||
/* associate server with stream */
|
/* associate server with stream */
|
||||||
handle->data = server;
|
handle->data = server;
|
||||||
|
|||||||
@ -156,7 +156,9 @@ TEST_IMPL(shutdown_eof) {
|
|||||||
qbuf.base = "Q";
|
qbuf.base = "Q";
|
||||||
qbuf.len = 1;
|
qbuf.len = 1;
|
||||||
|
|
||||||
uv_timer_init(uv_default_loop(), &timer);
|
r = uv_timer_init(uv_default_loop(), &timer);
|
||||||
|
ASSERT(r == 0);
|
||||||
|
|
||||||
uv_timer_start(&timer, timer_cb, 100, 0);
|
uv_timer_start(&timer, timer_cb, 100, 0);
|
||||||
|
|
||||||
server_addr = uv_ip4_addr("127.0.0.1", TEST_PORT);
|
server_addr = uv_ip4_addr("127.0.0.1", TEST_PORT);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user