diff --git a/test/echo-server.c b/test/echo-server.c index 4d572dde..ba8a912e 100644 --- a/test/echo-server.c +++ b/test/echo-server.c @@ -29,6 +29,8 @@ typedef struct { uv_buf_t buf; } write_req_t; +static uv_loop_t* loop; + static int server_closed; static stream_type serverType; static uv_tcp_t tcpServer; @@ -46,7 +48,7 @@ static void after_write(uv_write_t* req, int status) { write_req_t* wr; if (status) { - uv_err_t err = uv_last_error(uv_default_loop()); + uv_err_t err = uv_last_error(loop); fprintf(stderr, "uv_write error: %s\n", uv_strerror(err)); ASSERT(0); } @@ -72,7 +74,7 @@ static void after_read(uv_stream_t* handle, ssize_t nread, uv_buf_t buf) { if (nread < 0) { /* Error or EOF */ - ASSERT (uv_last_error(uv_default_loop()).code == UV_EOF); + ASSERT (uv_last_error(loop).code == UV_EOF); if (buf.base) { free(buf.base); @@ -134,7 +136,7 @@ static void on_connection(uv_stream_t* server, int status) { if (status != 0) { fprintf(stderr, "Connect error %d\n", - uv_last_error(uv_default_loop()).code); + uv_last_error(loop).code); } ASSERT(status == 0); @@ -142,13 +144,13 @@ static void on_connection(uv_stream_t* server, int status) { case TCP: stream = malloc(sizeof(uv_tcp_t)); ASSERT(stream != NULL); - uv_tcp_init(uv_default_loop(), (uv_tcp_t*)stream); + uv_tcp_init(loop, (uv_tcp_t*)stream); break; case PIPE: stream = malloc(sizeof(uv_pipe_t)); ASSERT(stream != NULL); - uv_pipe_init(uv_default_loop(), (uv_pipe_t*)stream); + uv_pipe_init(loop, (uv_pipe_t*)stream); break; default: @@ -179,7 +181,7 @@ static int tcp4_echo_start(int port) { server = (uv_handle_t*)&tcpServer; serverType = TCP; - r = uv_tcp_init(uv_default_loop(), &tcpServer); + r = uv_tcp_init(loop, &tcpServer); if (r) { /* TODO: Error codes */ fprintf(stderr, "Socket creation error\n"); @@ -197,7 +199,7 @@ static int tcp4_echo_start(int port) { if (r) { /* TODO: Error codes */ fprintf(stderr, "Listen error %s\n", - uv_err_name(uv_last_error(uv_default_loop()))); + uv_err_name(uv_last_error(loop))); return 1; } @@ -212,7 +214,7 @@ static int tcp6_echo_start(int port) { server = (uv_handle_t*)&tcpServer; serverType = TCP; - r = uv_tcp_init(uv_default_loop(), &tcpServer); + r = uv_tcp_init(loop, &tcpServer); if (r) { /* TODO: Error codes */ fprintf(stderr, "Socket creation error\n"); @@ -244,24 +246,24 @@ static int pipe_echo_start(char* pipeName) { server = (uv_handle_t*)&pipeServer; serverType = PIPE; - r = uv_pipe_init(uv_default_loop(), &pipeServer); + r = uv_pipe_init(loop, &pipeServer); if (r) { fprintf(stderr, "uv_pipe_init: %s\n", - uv_strerror(uv_last_error(uv_default_loop()))); + uv_strerror(uv_last_error(loop))); return 1; } r = uv_pipe_bind(&pipeServer, pipeName); if (r) { fprintf(stderr, "uv_pipe_bind: %s\n", - uv_strerror(uv_last_error(uv_default_loop()))); + uv_strerror(uv_last_error(loop))); return 1; } r = uv_listen((uv_stream_t*)&pipeServer, SOMAXCONN, on_connection); if (r) { fprintf(stderr, "uv_pipe_listen: %s\n", - uv_strerror(uv_last_error(uv_default_loop()))); + uv_strerror(uv_last_error(loop))); return 1; } @@ -271,7 +273,7 @@ static int pipe_echo_start(char* pipeName) { HELPER_IMPL(tcp4_echo_server) { uv_init(); - uv_loop_t* loop = uv_default_loop(); + loop = uv_default_loop(); if (tcp4_echo_start(TEST_PORT)) return 1; @@ -283,7 +285,7 @@ HELPER_IMPL(tcp4_echo_server) { HELPER_IMPL(tcp6_echo_server) { uv_init(); - uv_loop_t* loop = uv_default_loop(); + loop = uv_default_loop(); if (tcp6_echo_start(TEST_PORT)) return 1; @@ -295,7 +297,7 @@ HELPER_IMPL(tcp6_echo_server) { HELPER_IMPL(pipe_echo_server) { uv_init(); - uv_loop_t* loop = uv_default_loop(); + loop = uv_default_loop(); if (pipe_echo_start(TEST_PIPENAME)) return 1; diff --git a/test/test-fs.c b/test/test-fs.c index 7ad35ea8..4d72abd6 100644 --- a/test/test-fs.c +++ b/test/test-fs.c @@ -58,6 +58,8 @@ static int fdatasync_cb_count; static int ftruncate_cb_count; static int sendfile_cb_count; +static uv_loop_t* loop; + static uv_fs_t open_req1; static uv_fs_t open_req2; static uv_fs_t read_req; @@ -95,7 +97,7 @@ static void close_cb(uv_fs_t* req) { close_cb_count++; uv_fs_req_cleanup(req); if (close_cb_count == 3) { - r = uv_fs_unlink(&unlink_req, "test_file2", unlink_cb); + r = uv_fs_unlink(loop, &unlink_req, "test_file2", unlink_cb); } } @@ -107,7 +109,7 @@ static void ftruncate_cb(uv_fs_t* req) { ASSERT(req->result != -1); ftruncate_cb_count++; uv_fs_req_cleanup(req); - r = uv_fs_close(&close_req, open_req1.result, close_cb); + r = uv_fs_close(loop, &close_req, open_req1.result, close_cb); } @@ -120,10 +122,11 @@ static void read_cb(uv_fs_t* req) { uv_fs_req_cleanup(req); if (read_cb_count == 1) { ASSERT(strcmp(buf, test_buf) == 0); - r = uv_fs_ftruncate(&ftruncate_req, open_req1.result, 7, ftruncate_cb); + r = uv_fs_ftruncate(loop, &ftruncate_req, open_req1.result, 7, + ftruncate_cb); } else { ASSERT(strcmp(buf, "test-bu") == 0); - r = uv_fs_close(&close_req, open_req1.result, close_cb); + r = uv_fs_close(loop, &close_req, open_req1.result, close_cb); } } @@ -132,7 +135,7 @@ static void open_cb(uv_fs_t* req) { int r; ASSERT(req == &open_req1); ASSERT(req->fs_type == UV_FS_OPEN); - if (req->result < 0) { + if (req->result < 0) { /* TODO get error with uv_last_error() */ fprintf(stderr, "async open error: %d\n", req->errorno); ASSERT(0); @@ -140,7 +143,8 @@ static void open_cb(uv_fs_t* req) { open_cb_count++; uv_fs_req_cleanup(req); memset(buf, 0, sizeof(buf)); - r = uv_fs_read(&read_req, open_req1.result, buf, sizeof(buf), -1, read_cb); + r = uv_fs_read(loop, &read_req, open_req1.result, buf, sizeof(buf), -1, + read_cb); } @@ -151,7 +155,7 @@ static void fsync_cb(uv_fs_t* req) { ASSERT(req->result != -1); fsync_cb_count++; uv_fs_req_cleanup(req); - r = uv_fs_close(&close_req, open_req1.result, close_cb); + r = uv_fs_close(loop, &close_req, open_req1.result, close_cb); } @@ -162,7 +166,7 @@ static void fdatasync_cb(uv_fs_t* req) { ASSERT(req->result != -1); fdatasync_cb_count++; uv_fs_req_cleanup(req); - r = uv_fs_fsync(&fsync_req, open_req1.result, fsync_cb); + r = uv_fs_fsync(loop, &fsync_req, open_req1.result, fsync_cb); } @@ -173,7 +177,7 @@ static void write_cb(uv_fs_t* req) { ASSERT(req->result != -1); write_cb_count++; uv_fs_req_cleanup(req); - r = uv_fs_fdatasync(&fdatasync_req, open_req1.result, fdatasync_cb); + r = uv_fs_fdatasync(loop, &fdatasync_req, open_req1.result, fdatasync_cb); } @@ -184,8 +188,8 @@ static void create_cb(uv_fs_t* req) { ASSERT(req->result != -1); create_cb_count++; uv_fs_req_cleanup(req); - r = uv_fs_write(&write_req, req->result, test_buf, sizeof(test_buf), -1, - write_cb); + r = uv_fs_write(loop, &write_req, req->result, test_buf, sizeof(test_buf), + -1, write_cb); } @@ -222,7 +226,8 @@ static void readdir_cb(uv_fs_t* req) { ASSERT(req->result == 2); ASSERT(req->ptr); ASSERT(strcmp((const char*)req->ptr, "file1") == 0); - ASSERT(strcmp((char*)req->ptr + strlen((const char*)req->ptr) + 1, "file2") == 0); + ASSERT(strcmp((char*)req->ptr + strlen((const char*)req->ptr) + 1, + "file2") == 0); readdir_cb_count++; uv_fs_req_cleanup(req); ASSERT(!req->ptr); @@ -257,11 +262,12 @@ TEST_IMPL(fs_file_async) { unlink("test_file2"); uv_init(); + loop = uv_default_loop(); - r = uv_fs_open(&open_req1, "test_file", O_WRONLY | O_CREAT, + r = uv_fs_open(loop, &open_req1, "test_file", O_WRONLY | O_CREAT, S_IREAD | S_IWRITE, create_cb); ASSERT(r == 0); - uv_run(); + uv_run(loop); ASSERT(create_cb_count == 1); ASSERT(write_cb_count == 1); @@ -269,19 +275,19 @@ TEST_IMPL(fs_file_async) { ASSERT(fdatasync_cb_count == 1); ASSERT(close_cb_count == 1); - r = uv_fs_rename(&rename_req, "test_file", "test_file2", rename_cb); + r = uv_fs_rename(loop, &rename_req, "test_file", "test_file2", rename_cb); ASSERT(r == 0); - uv_run(); + uv_run(loop); ASSERT(create_cb_count == 1); ASSERT(write_cb_count == 1); ASSERT(close_cb_count == 1); ASSERT(rename_cb_count == 1); - r = uv_fs_open(&open_req1, "test_file2", O_RDWR, 0, open_cb); + r = uv_fs_open(loop, &open_req1, "test_file2", O_RDWR, 0, open_cb); ASSERT(r == 0); - uv_run(); + uv_run(loop); ASSERT(open_cb_count == 1); ASSERT(read_cb_count == 1); ASSERT(close_cb_count == 2); @@ -290,10 +296,10 @@ TEST_IMPL(fs_file_async) { ASSERT(write_cb_count == 1); ASSERT(ftruncate_cb_count == 1); - r = uv_fs_open(&open_req1, "test_file2", O_RDONLY, 0, open_cb); + r = uv_fs_open(loop, &open_req1, "test_file2", O_RDONLY, 0, open_cb); ASSERT(r == 0); - - uv_run(); + + uv_run(loop); ASSERT(open_cb_count == 2); ASSERT(read_cb_count == 2); ASSERT(close_cb_count == 3); @@ -319,68 +325,71 @@ TEST_IMPL(fs_file_sync) { unlink("test_file2"); uv_init(); - - r = uv_fs_open(&open_req1, "test_file", O_WRONLY | O_CREAT, + loop = uv_default_loop(); + + r = uv_fs_open(loop, &open_req1, "test_file", O_WRONLY | O_CREAT, S_IWRITE | S_IREAD, NULL); ASSERT(r == 0); ASSERT(open_req1.result != -1); uv_fs_req_cleanup(&open_req1); - - r = uv_fs_write(&write_req, open_req1.result, test_buf, sizeof(test_buf), -1, - NULL); + + r = uv_fs_write(loop, &write_req, open_req1.result, test_buf, + sizeof(test_buf), -1, NULL); ASSERT(r == 0); ASSERT(write_req.result != -1); uv_fs_req_cleanup(&write_req); - r = uv_fs_close(&close_req, open_req1.result, NULL); + r = uv_fs_close(loop, &close_req, open_req1.result, NULL); ASSERT(r == 0); ASSERT(close_req.result != -1); uv_fs_req_cleanup(&close_req); - r = uv_fs_open(&open_req1, "test_file", O_RDWR, 0, NULL); + r = uv_fs_open(loop, &open_req1, "test_file", O_RDWR, 0, NULL); ASSERT(r == 0); ASSERT(open_req1.result != -1); uv_fs_req_cleanup(&open_req1); - r = uv_fs_read(&read_req, open_req1.result, buf, sizeof(buf), -1, NULL); + r = uv_fs_read(loop, &read_req, open_req1.result, buf, sizeof(buf), -1, + NULL); ASSERT(r == 0); ASSERT(read_req.result != -1); ASSERT(strcmp(buf, test_buf) == 0); uv_fs_req_cleanup(&read_req); - r = uv_fs_ftruncate(&ftruncate_req, open_req1.result, 7, NULL); + r = uv_fs_ftruncate(loop, &ftruncate_req, open_req1.result, 7, NULL); ASSERT(r == 0); ASSERT(ftruncate_req.result != -1); uv_fs_req_cleanup(&ftruncate_req); - r = uv_fs_close(&close_req, open_req1.result, NULL); + r = uv_fs_close(loop, &close_req, open_req1.result, NULL); ASSERT(r == 0); ASSERT(close_req.result != -1); uv_fs_req_cleanup(&close_req); - r = uv_fs_rename(&rename_req, "test_file", "test_file2", NULL); + r = uv_fs_rename(loop, &rename_req, "test_file", "test_file2", NULL); ASSERT(r == 0); ASSERT(rename_req.result != -1); uv_fs_req_cleanup(&rename_req); - r = uv_fs_open(&open_req1, "test_file2", O_RDONLY, 0, NULL); + r = uv_fs_open(loop, &open_req1, "test_file2", O_RDONLY, 0, NULL); ASSERT(r == 0); ASSERT(open_req1.result != -1); uv_fs_req_cleanup(&open_req1); memset(buf, 0, sizeof(buf)); - r = uv_fs_read(&read_req, open_req1.result, buf, sizeof(buf), -1, NULL); + r = uv_fs_read(loop, &read_req, open_req1.result, buf, sizeof(buf), -1, + NULL); ASSERT(r == 0); ASSERT(read_req.result != -1); ASSERT(strcmp(buf, "test-bu") == 0); uv_fs_req_cleanup(&read_req); - r = uv_fs_close(&close_req, open_req1.result, NULL); + r = uv_fs_close(loop, &close_req, open_req1.result, NULL); ASSERT(r == 0); ASSERT(close_req.result != -1); uv_fs_req_cleanup(&close_req); - r = uv_fs_unlink(&unlink_req, "test_file2", NULL); + r = uv_fs_unlink(loop, &unlink_req, "test_file2", NULL); ASSERT(r == 0); ASSERT(unlink_req.result != -1); uv_fs_req_cleanup(&unlink_req); @@ -402,67 +411,68 @@ TEST_IMPL(fs_async_dir) { rmdir("test_dir"); uv_init(); + loop = uv_default_loop(); - r = uv_fs_mkdir(&mkdir_req, "test_dir", 0755, mkdir_cb); + r = uv_fs_mkdir(loop, &mkdir_req, "test_dir", 0755, mkdir_cb); ASSERT(r == 0); - uv_run(); + uv_run(loop); ASSERT(mkdir_cb_count == 1); /* Create 2 files synchronously. */ - r = uv_fs_open(&open_req1, "test_dir/file1", O_WRONLY | O_CREAT, + r = uv_fs_open(loop, &open_req1, "test_dir/file1", O_WRONLY | O_CREAT, S_IWRITE | S_IREAD, NULL); ASSERT(r == 0); uv_fs_req_cleanup(&open_req1); - r = uv_fs_close(&close_req, open_req1.result, NULL); + r = uv_fs_close(loop, &close_req, open_req1.result, NULL); ASSERT(r == 0); uv_fs_req_cleanup(&close_req); - r = uv_fs_open(&open_req1, "test_dir/file2", O_WRONLY | O_CREAT, + r = uv_fs_open(loop, &open_req1, "test_dir/file2", O_WRONLY | O_CREAT, S_IWRITE | S_IREAD, NULL); ASSERT(r == 0); uv_fs_req_cleanup(&open_req1); - r = uv_fs_close(&close_req, open_req1.result, NULL); + r = uv_fs_close(loop, &close_req, open_req1.result, NULL); ASSERT(r == 0); uv_fs_req_cleanup(&close_req); - r = uv_fs_readdir(&readdir_req, "test_dir", 0, readdir_cb); + r = uv_fs_readdir(loop, &readdir_req, "test_dir", 0, readdir_cb); ASSERT(r == 0); - uv_run(); + uv_run(loop); ASSERT(readdir_cb_count == 1); - r = uv_fs_stat(&stat_req, "test_dir", stat_cb); + r = uv_fs_stat(loop, &stat_req, "test_dir", stat_cb); ASSERT(r == 0); - uv_run(); + uv_run(loop); - r = uv_fs_stat(&stat_req, "test_dir\\", stat_cb); + r = uv_fs_stat(loop, &stat_req, "test_dir\\", stat_cb); ASSERT(r == 0); - uv_run(); + uv_run(loop); - r = uv_fs_lstat(&stat_req, "test_dir", stat_cb); + r = uv_fs_lstat(loop, &stat_req, "test_dir", stat_cb); ASSERT(r == 0); - uv_run(); + uv_run(loop); - r = uv_fs_lstat(&stat_req, "test_dir\\", stat_cb); + r = uv_fs_lstat(loop, &stat_req, "test_dir\\", stat_cb); ASSERT(r == 0); - uv_run(); + uv_run(loop); ASSERT(stat_cb_count == 4); - r = uv_fs_unlink(&unlink_req, "test_dir/file1", unlink_cb); + r = uv_fs_unlink(loop, &unlink_req, "test_dir/file1", unlink_cb); ASSERT(r == 0); - uv_run(); + uv_run(loop); ASSERT(unlink_cb_count == 1); - r = uv_fs_unlink(&unlink_req, "test_dir/file2", unlink_cb); + r = uv_fs_unlink(loop, &unlink_req, "test_dir/file2", unlink_cb); ASSERT(r == 0); - uv_run(); + uv_run(loop); ASSERT(unlink_cb_count == 2); - r = uv_fs_rmdir(&rmdir_req, "test_dir", rmdir_cb); + r = uv_fs_rmdir(loop, &rmdir_req, "test_dir", rmdir_cb); ASSERT(r == 0); - uv_run(); + uv_run(loop); ASSERT(rmdir_cb_count == 1); /* Cleanup */ @@ -485,7 +495,7 @@ TEST_IMPL(fs_async_sendfile) { f = open("test_file", O_WRONLY | O_CREAT, S_IWRITE | S_IREAD); ASSERT(f != -1); - + r = write(f, "begin\n", 6); ASSERT(r == 6); @@ -500,29 +510,30 @@ TEST_IMPL(fs_async_sendfile) { /* Test starts here. */ uv_init(); + loop = uv_default_loop(); - r = uv_fs_open(&open_req1, "test_file", O_RDWR, 0, NULL); + r = uv_fs_open(loop, &open_req1, "test_file", O_RDWR, 0, NULL); ASSERT(r == 0); ASSERT(open_req1.result != -1); uv_fs_req_cleanup(&open_req1); - r = uv_fs_open(&open_req2, "test_file2", O_WRONLY | O_CREAT, + r = uv_fs_open(loop, &open_req2, "test_file2", O_WRONLY | O_CREAT, S_IWRITE | S_IREAD, NULL); ASSERT(r == 0); ASSERT(open_req2.result != -1); uv_fs_req_cleanup(&open_req2); - r = uv_fs_sendfile(&sendfile_req, open_req2.result, open_req1.result, 0, - 131072, sendfile_cb); + r = uv_fs_sendfile(loop, &sendfile_req, open_req2.result, open_req1.result, + 0, 131072, sendfile_cb); ASSERT(r == 0); - uv_run(); + uv_run(loop); ASSERT(sendfile_cb_count == 1); - r = uv_fs_close(&close_req, open_req1.result, NULL); + r = uv_fs_close(loop, &close_req, open_req1.result, NULL); ASSERT(r == 0); uv_fs_req_cleanup(&close_req); - r = uv_fs_close(&close_req, open_req2.result, NULL); + r = uv_fs_close(loop, &close_req, open_req2.result, NULL); ASSERT(r == 0); uv_fs_req_cleanup(&close_req); diff --git a/test/test-getsockname.c b/test/test-getsockname.c index 2bdd76a9..cf0b933e 100644 --- a/test/test-getsockname.c +++ b/test/test-getsockname.c @@ -29,6 +29,7 @@ static int getsocknamecount = 0; +static uv_loop_t* loop; static uv_tcp_t tcp; static uv_udp_t udp; static uv_connect_t connect_req; @@ -79,14 +80,14 @@ static void on_connection(uv_stream_t* server, int status) { if (status != 0) { fprintf(stderr, "Connect error %d\n", - uv_last_error(uv_default_loop()).code); + uv_last_error(loop).code); } ASSERT(status == 0); handle = (uv_handle_t*) malloc(sizeof(uv_tcp_t)); ASSERT(handle != NULL); - uv_tcp_init(uv_default_loop(), (uv_tcp_t*)handle); + uv_tcp_init(loop, (uv_tcp_t*)handle); /* associate server with stream */ handle->data = server; @@ -97,7 +98,7 @@ static void on_connection(uv_stream_t* server, int status) { status = uv_getsockname(handle, &sockname, &namelen); if (status != 0) { fprintf(stderr, "uv_getsockname error (accepted) %d\n", - uv_last_error(uv_default_loop()).code); + uv_last_error(loop).code); } ASSERT(status == 0); @@ -118,7 +119,7 @@ static void on_connect(uv_connect_t* req, int status) { r = uv_getsockname((uv_handle_t*)&tcp, &sockname, &namelen); if (r != 0) { fprintf(stderr, "uv_getsockname error (connector) %d\n", - uv_last_error(uv_default_loop()).code); + uv_last_error(loop).code); } ASSERT(r == 0); @@ -135,7 +136,7 @@ static int tcp_listener(int port) { char ip[20]; int r; - r = uv_tcp_init(uv_default_loop(), &tcpServer); + r = uv_tcp_init(loop, &tcpServer); if (r) { fprintf(stderr, "Socket creation error\n"); return 1; @@ -158,7 +159,7 @@ static int tcp_listener(int port) { r = uv_getsockname((uv_handle_t*)&tcpServer, &sockname, &namelen); if (r != 0) { fprintf(stderr, "uv_getsockname error (listening) %d\n", - uv_last_error(uv_default_loop()).code); + uv_last_error(loop).code); } ASSERT(r == 0); @@ -179,7 +180,7 @@ static void tcp_connector() { int r; struct sockaddr_in server_addr = uv_ip4_addr("127.0.0.1", TEST_PORT); - r = uv_tcp_init(uv_default_loop(), &tcp); + r = uv_tcp_init(loop, &tcp); tcp.data = &connect_req; ASSERT(!r); @@ -201,7 +202,6 @@ static void udp_recv(uv_udp_t* handle, ASSERT(nread >= 0); if (nread == 0) { - uv_close((uv_handle_t*)handle, NULL); free(buf.base); return; } @@ -209,7 +209,7 @@ static void udp_recv(uv_udp_t* handle, namelen = sizeof(sockname); r = uv_getsockname((uv_handle_t*)&udp, &sockname, &namelen); if (r != 0) { - fprintf(stderr, "uv_getsockname error (connector) %d\n", uv_last_error().code); + fprintf(stderr, "uv_getsockname error (connector) %d\n", uv_last_error(loop).code); } ASSERT(r == 0); @@ -219,7 +219,8 @@ static void udp_recv(uv_udp_t* handle, getsocknamecount++; - uv_close((uv_handle_t*)&udp, NULL); + uv_close((uv_handle_t*) &udp, NULL); + uv_close((uv_handle_t*) handle, NULL); } @@ -235,7 +236,7 @@ static int udp_listener(int port) { char ip[20]; int r; - r = uv_udp_init(&udpServer); + r = uv_udp_init(loop, &udpServer); if (r) { fprintf(stderr, "Socket creation error\n"); return 1; @@ -251,7 +252,7 @@ static int udp_listener(int port) { r = uv_getsockname((uv_handle_t*)&udpServer, &sockname, &namelen); if (r != 0) { - fprintf(stderr, "uv_getsockname error (listening) %d\n", uv_last_error().code); + fprintf(stderr, "uv_getsockname error (listening) %d\n", uv_last_error(loop).code); } ASSERT(r == 0); @@ -276,7 +277,7 @@ static void udp_sender(void) { uv_buf_t buf; int r; - r = uv_udp_init(&udp); + r = uv_udp_init(loop, &udp); ASSERT(!r); buf = uv_buf_init("PING", 4); @@ -289,13 +290,14 @@ static void udp_sender(void) { TEST_IMPL(getsockname_tcp) { uv_init(); + loop = uv_default_loop(); if (tcp_listener(TEST_PORT)) return 1; tcp_connector(); - uv_run(uv_default_loop()); + uv_run(loop); ASSERT(getsocknamecount == 3); @@ -305,13 +307,14 @@ TEST_IMPL(getsockname_tcp) { TEST_IMPL(getsockname_udp) { uv_init(); + loop = uv_default_loop(); if (udp_listener(TEST_PORT)) return 1; udp_sender(); - uv_run(); + uv_run(loop); ASSERT(getsocknamecount == 2); diff --git a/test/test-spawn.c b/test/test-spawn.c index d86cd009..13987744 100644 --- a/test/test-spawn.c +++ b/test/test-spawn.c @@ -238,7 +238,7 @@ TEST_IMPL(spawn_detect_pipe_name_collisions_on_windows) { init_process_options("spawn_helper2", exit_cb); - uv_pipe_init(&out); + uv_pipe_init(uv_default_loop(), &out); options.stdout_stream = &out; /* Create a pipe that'll cause a collision. */ @@ -253,13 +253,13 @@ TEST_IMPL(spawn_detect_pipe_name_collisions_on_windows) { NULL); ASSERT(pipe_handle != INVALID_HANDLE_VALUE); - r = uv_spawn(&process, options); + r = uv_spawn(uv_default_loop(), &process, options); ASSERT(r == 0); r = uv_read_start((uv_stream_t*) &out, on_alloc, on_read); ASSERT(r == 0); - r = uv_run(); + r = uv_run(uv_default_loop()); ASSERT(r == 0); ASSERT(exit_cb_called == 1); diff --git a/test/test-threadpool.c b/test/test-threadpool.c index 19742f23..4f0be0cd 100644 --- a/test/test-threadpool.c +++ b/test/test-threadpool.c @@ -48,9 +48,9 @@ TEST_IMPL(threadpool_queue_work_simple) { uv_init(); work_req.data = &data; - r = uv_queue_work(&work_req, work_cb, after_work_cb); + r = uv_queue_work(uv_default_loop(), &work_req, work_cb, after_work_cb); ASSERT(r == 0); - uv_run(); + uv_run(uv_default_loop()); ASSERT(work_cb_count == 1); ASSERT(after_work_cb_count == 1);