You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by da...@apache.org on 2007/06/30 15:30:24 UTC

svn commit: r552147 - /apr/apr/trunk/test/testsockets.c

Author: davi
Date: Sat Jun 30 06:30:24 2007
New Revision: 552147

URL: http://svn.apache.org/viewvc?view=rev&rev=552147
Log:
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.

The AI_ADDRCONFIG flag (and loopback addresses) issue has been reported
and fixed: http://sourceware.org/bugzilla/show_bug.cgi?id=4599

Modified:
    apr/apr/trunk/test/testsockets.c

Modified: apr/apr/trunk/test/testsockets.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/test/testsockets.c?view=diff&rev=552147&r1=552146&r2=552147
==============================================================================
--- apr/apr/trunk/test/testsockets.c (original)
+++ apr/apr/trunk/test/testsockets.c Sat Jun 30 06:30:24 2007
@@ -103,7 +103,7 @@
 #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 @@
     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);
@@ -147,12 +138,12 @@
     rv = apr_socket_bind(sock, to);
     APR_ASSERT_SUCCESS(tc, "Could not bind socket", rv);
     if (rv != APR_SUCCESS)
-      return;
+        return;
 
     rv = apr_socket_bind(sock2, from);
     APR_ASSERT_SUCCESS(tc, "Could not bind second socket", rv);
     if (rv != APR_SUCCESS)
-      return;
+        return;
 
     len = STRLEN;
     rv = apr_socket_sendto(sock2, to, 0, sendbuf, &len);
@@ -176,6 +167,14 @@
 
     apr_socket_close(sock);
     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)