Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

update tests for multiplicity

  • Loading branch information...
piscisaureus committed Aug 31, 2011
1 parent 78debf9 commit 8e3a8602addfa1f7689f8fc151b6516632ffd4c8
Showing with 117 additions and 101 deletions.
  1. +17 −15 test/echo-server.c
  2. +77 −66 test/test-fs.c
  3. +18 −15 test/test-getsockname.c
  4. +3 −3 test/test-spawn.c
  5. +2 −2 test/test-threadpool.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,21 +136,21 @@ 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);

switch (serverType) {
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;

0 comments on commit 8e3a860

Please sign in to comment.
You can’t perform that action at this time.