From 9468c6570a5181b7ff50024b26ac63feb5689cbc Mon Sep 17 00:00:00 2001 From: Alan Gutierrez Date: Thu, 21 Apr 2011 17:24:50 +0800 Subject: [PATCH] Check oio_err in connection_fail test. * Renamed test_connection_fail to connection_fail following the conventions. * Mapped Windows error ERROR_CONNECTION_REFUSED to OIO_ECONNREFUSED. * Asserting that the oio_err in connection_fail is OIO_ECONNREFUSED. --- oio-win.c | 1 + test/test-connection-fail.c | 4 ++-- test/test-list.h | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/oio-win.c b/oio-win.c index 64923909..f307f8d3 100644 --- a/oio-win.c +++ b/oio-win.c @@ -230,6 +230,7 @@ static oio_err_code oio_translate_sys_error(int sys_errno) { case WSAEINVAL: return OIO_EINVAL; case WSAEALREADY: return OIO_EALREADY; case ERROR_OUTOFMEMORY: return OIO_ENOMEM; + case ERROR_CONNECTION_REFUSED: return OIO_ECONNREFUSED; default: return OIO_UNKNOWN; } } diff --git a/test/test-connection-fail.c b/test/test-connection-fail.c index 3a268c59..a9ebe30a 100644 --- a/test/test-connection-fail.c +++ b/test/test-connection-fail.c @@ -40,13 +40,13 @@ static void on_close(oio_handle* handle, int status) { static void on_connect(oio_req *req, int status) { ASSERT(status == -1); + ASSERT(oio_last_error().code == OIO_ECONNREFUSED); connect_cb_calls++; - oio_close(req->handle); } -TEST_IMPL(test_connection_fail) { +TEST_IMPL(connection_fail) { struct sockaddr_in client_addr, server_addr; int r; diff --git a/test/test-list.h b/test/test-list.h index 4451e2d9..20fffc3f 100644 --- a/test/test-list.h +++ b/test/test-list.h @@ -24,7 +24,7 @@ TEST_DECLARE (close_cb_stack) TEST_DECLARE (timeout) TEST_DECLARE (fail_always) TEST_DECLARE (pass_always) -TEST_DECLARE (test_connection_fail) +TEST_DECLARE (connection_fail) HELPER_DECLARE (echo_server) TASK_LIST_START @@ -39,5 +39,5 @@ TASK_LIST_START TEST_ENTRY (fail_always) TEST_ENTRY (pass_always) - TEST_ENTRY (test_connection_fail) + TEST_ENTRY (connection_fail) TASK_LIST_END