Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
test and bench: assert return values of *_init functions in tests
  • Loading branch information
erickt authored and bnoordhuis committed Sep 15, 2011
1 parent 905fe71 commit 533418d
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 9 deletions.
6 changes: 4 additions & 2 deletions test/benchmark-pump.c
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion test/dns-server.c
Expand Up @@ -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);
Expand Down
6 changes: 4 additions & 2 deletions test/echo-server.c
Expand Up @@ -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:
Expand Down
5 changes: 4 additions & 1 deletion test/test-connection-fail.c
Expand Up @@ -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);

Expand Down
3 changes: 2 additions & 1 deletion test/test-delayed-accept.c
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion test/test-getsockname.c
Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion test/test-shutdown-eof.c
Expand Up @@ -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);
Expand Down

0 comments on commit 533418d

Please sign in to comment.