diff options
author | davi <davi@13f79535-47bb-0310-9956-ffa450edef68> | 2007-06-30 14:01:49 +0000 |
---|---|---|
committer | davi <davi@13f79535-47bb-0310-9956-ffa450edef68> | 2007-06-30 14:01:49 +0000 |
commit | f597d5ccc902ff4b4c0cca22a3b93092b877980b (patch) | |
tree | 910a3bc3471385b662a5313c2d6522d809d00610 | |
parent | 235c068ea95a30e83bb2cb9c76501fbbe10d0c96 (diff) | |
download | libapr-f597d5ccc902ff4b4c0cca22a3b93092b877980b.tar.gz |
Backport 552147 from trunk with more failure checks:
Split the sendto_receivefrom test into two tests, one for IPv6 and one
for IPv4, and allow the tests to fail. Previously the test would fail
or succeed depending on the host IPv6 connectivity (non-localhost IPv6
address) and resolver bugs (AI_ADDRCONFIG flag), which would cause the
test to core dump.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/1.2.x@552149 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | CHANGES | 3 | ||||
-rw-r--r-- | test/testsockets.c | 40 |
2 files changed, 25 insertions, 18 deletions
@@ -1,5 +1,8 @@ Changes for APR 1.2.10 + *) Allow IPv6 connectivity test to fail, avoiding a potentially fatal + error. [Davi Arnaut] + *) The MinGW Windows headers effectively redefines WINADVAPI from __stdcall to empty which results in a link failure when wincrypt.h is placed after an include to apr_private.h. diff --git a/test/testsockets.c b/test/testsockets.c index 6328af8d9..934cd4109 100644 --- a/test/testsockets.c +++ b/test/testsockets.c @@ -103,7 +103,7 @@ static void udp6_socket(abts_case *tc, void *data) #endif } -static void sendto_receivefrom(abts_case *tc, void *data) +static void sendto_receivefrom_helper(abts_case *tc, const char *addr, int family) { apr_status_t rv; apr_socket_t *sock = NULL; @@ -115,28 +115,19 @@ static void sendto_receivefrom(abts_case *tc, void *data) apr_sockaddr_t *from; apr_sockaddr_t *to; apr_size_t len = 30; - int family; - const char *addr; -#if APR_HAVE_IPV6 - family = APR_INET6; - addr = "::1"; rv = apr_socket_create(&sock, family, SOCK_DGRAM, 0, p); - if (V6_NOT_ENABLED(rv)) { -#endif - family = APR_INET; - addr = "127.0.0.1"; - rv = apr_socket_create(&sock, family, SOCK_DGRAM, 0, p); -#if APR_HAVE_IPV6 - } -#endif ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); + if (rv != APR_SUCCESS) + return; rv = apr_socket_create(&sock2, family, SOCK_DGRAM, 0, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); + if (rv != APR_SUCCESS) + return; - rv = apr_sockaddr_info_get(&to, addr, APR_UNSPEC, 7772, 0, p); + rv = apr_sockaddr_info_get(&to, addr, family, 7772, 0, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_sockaddr_info_get(&from, addr, APR_UNSPEC, 7771, 0, p); + rv = apr_sockaddr_info_get(&from, addr, family, 7771, 0, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); rv = apr_socket_opt_set(sock, APR_SO_REUSEADDR, 1); @@ -145,9 +136,14 @@ static void sendto_receivefrom(abts_case *tc, void *data) APR_ASSERT_SUCCESS(tc, "Could not set REUSEADDR on socket2", rv); rv = apr_socket_bind(sock, to); - ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); + APR_ASSERT_SUCCESS(tc, "Could not bind socket", rv); + if (rv != APR_SUCCESS) + return; + rv = apr_socket_bind(sock2, from); - ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); + APR_ASSERT_SUCCESS(tc, "Could not bind second socket", rv); + if (rv != APR_SUCCESS) + return; len = STRLEN; rv = apr_socket_sendto(sock2, to, 0, sendbuf, &len); @@ -169,6 +165,14 @@ static void sendto_receivefrom(abts_case *tc, void *data) apr_socket_close(sock2); } +static void sendto_receivefrom(abts_case *tc, void *data) +{ +#if APR_HAVE_IPV6 + sendto_receivefrom_helper(tc, "::1", APR_INET6); +#endif + sendto_receivefrom_helper(tc, "127.0.0.1", APR_INET); +} + static void socket_userdata(abts_case *tc, void *data) { apr_socket_t *sock1, *sock2; |