test and bench: assert return values of *_init functions in tests

This commit is contained in:
Erick Tryzelaar 2011-09-09 21:44:03 -07:00 committed by Ben Noordhuis
parent 905fe71341
commit 533418d4da
7 changed files with 21 additions and 9 deletions

View File

@ -273,10 +273,12 @@ static void connection_cb(uv_stream_t* s, int status) {
if (type == TCP) {
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 {
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);

View File

@ -272,7 +272,8 @@ static void on_connection(uv_stream_t* server, int status) {
handle->state.prevbuf_pos = 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);
ASSERT(r == 0);

View File

@ -144,13 +144,15 @@ static void on_connection(uv_stream_t* server, int status) {
case TCP:
stream = malloc(sizeof(uv_tcp_t));
ASSERT(stream != NULL);
uv_tcp_init(loop, (uv_tcp_t*)stream);
r = uv_tcp_init(loop, (uv_tcp_t*)stream);
ASSERT(r == 0);
break;
case PIPE:
stream = malloc(sizeof(uv_pipe_t));
ASSERT(stream != NULL);
uv_pipe_init(loop, (uv_pipe_t*)stream);
r = uv_pipe_init(loop, (uv_pipe_t*)stream);
ASSERT(r == 0);
break;
default:

View File

@ -134,7 +134,10 @@ TEST_IMPL(connection_fail) {
* attempt.
*/
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);

View File

@ -57,7 +57,8 @@ static void do_accept(uv_timer_t* timer_handle, int status) {
ASSERT(status == 0);
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. */
tcpcnt = uv_default_loop()->counters.tcp_init;

View File

@ -117,7 +117,8 @@ static void on_connection(uv_stream_t* server, int status) {
handle = (uv_handle_t*) malloc(sizeof(uv_tcp_t));
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 */
handle->data = server;

View File

@ -156,7 +156,9 @@ TEST_IMPL(shutdown_eof) {
qbuf.base = "Q";
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);
server_addr = uv_ip4_addr("127.0.0.1", TEST_PORT);