diff options
Diffstat (limited to 'tests/socket-test.c')
-rw-r--r-- | tests/socket-test.c | 73 |
1 files changed, 43 insertions, 30 deletions
diff --git a/tests/socket-test.c b/tests/socket-test.c index 42ab6c8b..5bcc3b0c 100644 --- a/tests/socket-test.c +++ b/tests/socket-test.c @@ -18,81 +18,90 @@ do_unconnected_socket_test (void) guint res; struct sockaddr_in in_localhost; + g_test_bug ("673083"); + in_localhost.sin_family = AF_INET; in_localhost.sin_port = 0; in_localhost.sin_addr.s_addr = htonl (INADDR_LOOPBACK); localhost = soup_address_new_from_sockaddr ( (struct sockaddr *) &in_localhost, sizeof (in_localhost)); - g_assert (localhost != NULL); + g_assert_true (localhost != NULL); res = soup_address_resolve_sync (localhost, NULL); g_assert_cmpuint (res, ==, SOUP_STATUS_OK); - sock = soup_socket_new ( - SOUP_SOCKET_LOCAL_ADDRESS, localhost, - NULL); - g_assert (sock != NULL); + sock = soup_socket_new (SOUP_SOCKET_LOCAL_ADDRESS, localhost, + NULL); + g_assert_true (sock != NULL); addr = soup_socket_get_local_address (sock); - g_assert (addr != NULL); + g_assert_true (addr != NULL); g_assert_cmpstr (soup_address_get_physical (addr), ==, "127.0.0.1"); g_assert_cmpuint (soup_address_get_port (addr), ==, 0); /* fails with ENOTCONN */ - expect_warning++; + g_test_expect_message ("libsoup", G_LOG_LEVEL_WARNING, + "*socket not connected*"); addr = soup_socket_get_remote_address (sock); - g_assert (addr == NULL); + g_test_assert_expected_messages (); + g_assert_null (addr); res = soup_socket_listen (sock); - g_assert_cmpuint (res, ==, TRUE); + g_assert_true (res); addr = soup_socket_get_local_address (sock); - g_assert (addr != NULL); + g_assert_true (addr != NULL); g_assert_cmpstr (soup_address_get_physical (addr), ==, "127.0.0.1"); g_assert_cmpuint (soup_address_get_port (addr), >, 0); - client = soup_socket_new ( - SOUP_SOCKET_REMOTE_ADDRESS, - soup_socket_get_local_address (sock), - NULL); + client = soup_socket_new (SOUP_SOCKET_REMOTE_ADDRESS, + soup_socket_get_local_address (sock), + NULL); res = soup_socket_connect_sync (client, NULL); g_assert_cmpuint (res, ==, SOUP_STATUS_OK); addr = soup_socket_get_local_address (client); - g_assert (addr != NULL); + g_assert_true (addr != NULL); addr = soup_socket_get_remote_address (client); - g_assert (addr != NULL); + g_assert_true (addr != NULL); g_assert_cmpstr (soup_address_get_physical (addr), ==, "127.0.0.1"); g_assert_cmpuint (soup_address_get_port (addr), >, 0); g_object_unref (client); - client = soup_socket_new ( - SOUP_SOCKET_REMOTE_ADDRESS, - soup_socket_get_local_address (sock), - NULL); + client = soup_socket_new (SOUP_SOCKET_REMOTE_ADDRESS, + soup_socket_get_local_address (sock), + NULL); /* save it for later */ /* listening socket fails with ENOTCONN */ - expect_warning++; + g_test_expect_message ("libsoup", G_LOG_LEVEL_WARNING, + "*endpoint is not connected*"); addr = soup_socket_get_remote_address (sock); - g_assert (addr == NULL); + g_test_assert_expected_messages (); + g_assert_null (addr); soup_socket_disconnect (sock); - expect_warning++; + g_test_expect_message ("libsoup", G_LOG_LEVEL_WARNING, + "*socket not connected*"); addr = soup_socket_get_remote_address (sock); - g_assert (addr == NULL); + g_test_assert_expected_messages (); + g_assert_null (addr); /* has never been connected */ - expect_warning++; + g_test_expect_message ("libsoup", G_LOG_LEVEL_WARNING, + "*socket not connected*"); addr = soup_socket_get_local_address (client); - g_assert (addr == NULL); + g_test_assert_expected_messages (); + g_assert_null (addr); res = soup_socket_connect_sync (client, NULL); g_assert_cmpuint (res, ==, SOUP_STATUS_CANT_CONNECT); - expect_warning++; + g_test_expect_message ("libsoup", G_LOG_LEVEL_WARNING, + "*socket not connected*"); addr = soup_socket_get_local_address (client); - g_assert (addr == NULL); + g_test_assert_expected_messages (); + g_assert_null (addr); g_object_unref (localhost); g_object_unref (client); @@ -102,10 +111,14 @@ do_unconnected_socket_test (void) int main (int argc, char **argv) { + int ret; + test_init (argc, argv, NULL); - do_unconnected_socket_test (); + g_test_add_func ("/sockets/unconnected", do_unconnected_socket_test); + + ret = g_test_run (); test_cleanup (); - return errors != 0; + return ret; } |