[glib/glib-2-40] gio/tests/socket: skip IPv6 tests on IPv6-less machines



commit 187af7ba1d77750878133956fb86fa7b82c1530f
Author: Dan Winship <danw gnome org>
Date:   Sat Feb 1 18:13:50 2014 +0100

    gio/tests/socket: skip IPv6 tests on IPv6-less machines
    
    https://bugzilla.gnome.org/show_bug.cgi?id=667468

 gio/tests/socket.c |   32 ++++++++++++++++++++++++++++++++
 1 files changed, 32 insertions(+), 0 deletions(-)
---
diff --git a/gio/tests/socket.c b/gio/tests/socket.c
index 4066563..362a1f2 100644
--- a/gio/tests/socket.c
+++ b/gio/tests/socket.c
@@ -29,6 +29,8 @@
 
 #include "gnetworkingprivate.h"
 
+static gboolean ipv6_supported;
+
 typedef struct {
   GSocket *server;
   GSocket *client;
@@ -338,6 +340,12 @@ test_ipv4_async (void)
 static void
 test_ipv6_async (void)
 {
+  if (!ipv6_supported)
+    {
+      g_test_skip ("No support for IPv6");
+      return;
+    }
+
   test_ip_async (G_SOCKET_FAMILY_IPV6);
 }
 
@@ -420,6 +428,12 @@ test_ipv4_sync (void)
 static void
 test_ipv6_sync (void)
 {
+  if (!ipv6_supported)
+    {
+      g_test_skip ("No support for IPv6");
+      return;
+    }
+
   test_ip_sync (G_SOCKET_FAMILY_IPV6);
 }
 
@@ -546,6 +560,12 @@ test_ipv6_v4mapped (void)
   GSocketAddress *addr, *v4addr;
   GInetAddress *iaddr;
 
+  if (!ipv6_supported)
+    {
+      g_test_skip ("No support for IPv6");
+      return;
+    }
+
   data = create_server (G_SOCKET_FAMILY_IPV6, v4mapped_server_thread, TRUE);
 
   if (data == NULL)
@@ -1032,8 +1052,20 @@ int
 main (int   argc,
       char *argv[])
 {
+  GSocket *sock;
+
   g_test_init (&argc, &argv, NULL);
 
+  sock = g_socket_new (G_SOCKET_FAMILY_IPV6,
+                       G_SOCKET_TYPE_STREAM,
+                       G_SOCKET_PROTOCOL_DEFAULT,
+                       NULL);
+  if (sock != NULL)
+    {
+      ipv6_supported = TRUE;
+      g_object_unref (sock);
+    }
+
   g_test_add_func ("/socket/ipv4_sync", test_ipv4_sync);
   g_test_add_func ("/socket/ipv4_async", test_ipv4_async);
   g_test_add_func ("/socket/ipv6_sync", test_ipv6_sync);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]