Check whether the system actually does support IPv6 in 'sws --version' and
'sockfilt --version'. Don't waste time trying to start the ftp-ipv6 or
http-ipv6 server if they're not available.

---
 tests/runtests.pl       |    6 ++++++
 tests/server/sockfilt.c |    8 +-------
 tests/server/sws.c      |    9 +--------
 tests/server/util.c     |   20 ++++++++++++++++++++
 tests/server/util.h     |    3 +++
 5 files changed, 31 insertions(+), 15 deletions(-)

--- tests/server/sws.c.orig
+++ tests/server/sws.c
@@ -801,14 +801,7 @@ int main(int argc, char *argv[])
 #ifdef CURL_SWS_FORK_ENABLED
              " FORK"
 #endif
-             "\n"
-             ,
-#ifdef ENABLE_IPV6
-             "/IPv6"
-#else
-             ""
-#endif
-             );
+             "\n", has_ipv6() ? "/IPv6" : "");
       return 0;
     }
     else if(!strcmp("--pidfile", argv[arg])) {
--- tests/server/util.c.orig
+++ tests/server/util.c
@@ -190,4 +190,24 @@ void go_sleep(long ms)
 #endif
 }
 
+int has_ipv6(void)
+{
+#ifdef ENABLE_IPV6
+	static int res = -1;
+
+	if (res == -1) {
+		int sock = socket(AF_INET6, SOCK_STREAM, 0);
+		if (sock < 0) {
+			res = 0;
+		} else {
+			close(sock);
+			res = 1;
+		}
+	}
+	return res;
+#else
+	return 0;
+#endif
+}
+
 
--- tests/server/sockfilt.c.orig
+++ tests/server/sockfilt.c
@@ -526,13 +526,7 @@ int main(int argc, char *argv[])
 
   while(argc>arg) {
     if(!strcmp("--version", argv[arg])) {
-      printf("sockfilt IPv4%s\n",
-#ifdef ENABLE_IPV6
-             "/IPv6"
-#else
-             ""
-#endif
-             );
+      printf("sockfilt IPv4%s\n", has_ipv6() ? "/IPv6" : "");
       return 0;
     }
     else if(!strcmp("--pidfile", argv[arg])) {
--- tests/server/util.h.orig
+++ tests/server/util.h
@@ -51,4 +51,7 @@ char *test2file(long testno);
 
 void go_sleep(long ms);
 
+/* returns 1 if the system supports IPv6 */
+int has_ipv6(void);
+
 #endif  /* __SERVER_UTIL_H */
--- tests/runtests.pl.orig
+++ tests/runtests.pl
@@ -2203,6 +2203,9 @@ sub startservers {
             }
         }
         elsif($what eq "ftp-ipv6") {
+            if (!$ftp_ipv6) {
+                return "FTP server has no IPv6 support";
+            }
             if(!$run{'ftp-ipv6'}) {
                 ($pid, $pid2) = runftpserver("", $verbose, "ipv6");
                 if($pid <= 0) {
@@ -2224,6 +2227,9 @@ sub startservers {
             }
         }
         elsif($what eq "http-ipv6") {
+            if (!$http_ipv6) {
+                return "HTTP server has no IPv6 support";
+            }
             if(!$run{'http-ipv6'}) {
                 ($pid, $pid2) = runhttpserver($verbose, "IPv6");
                 if($pid <= 0) {

