From b3d6946c2783bbca0603863f5e6cc4ba5b27589c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Fri, 4 Feb 2022 12:38:43 +0400 Subject: [PATCH] tests/socket: skip a test if AF_UNIX is not supported on win32 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marc-André Lureau --- gio/tests/socket.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/gio/tests/socket.c b/gio/tests/socket.c index 250ec648a..a8bab16df 100644 --- a/gio/tests/socket.c +++ b/gio/tests/socket.c @@ -1358,6 +1358,13 @@ test_unix_from_fd (void) GSocket *s; fd = socket (AF_UNIX, SOCK_STREAM, 0); +#ifdef G_OS_WIN32 + if (fd == -1) + { + g_test_skip ("AF_UNIX not supported on this Windows system."); + return; + } +#endif g_assert_cmpint (fd, !=, -1); bind_win32_unixfd (fd); @@ -1380,6 +1387,13 @@ test_unix_connection (void) GSocketConnection *c; fd = socket (AF_UNIX, SOCK_STREAM, 0); +#ifdef G_OS_WIN32 + if (fd == -1) + { + g_test_skip ("AF_UNIX not supported on this Windows system."); + return; + } +#endif g_assert_cmpint (fd, !=, -1); bind_win32_unixfd (fd); @@ -1518,6 +1532,14 @@ test_source_postmortem (void) gboolean callback_visited = FALSE; socket = g_socket_new (G_SOCKET_FAMILY_UNIX, G_SOCKET_TYPE_STREAM, G_SOCKET_PROTOCOL_DEFAULT, &error); +#ifdef G_OS_WIN32 + if (error) + { + g_test_skip_printf ("AF_UNIX not supported on this Windows system: %s", error->message); + g_clear_error (&error); + return; + } +#endif g_assert_no_error (error); context = g_main_context_new (); @@ -2225,6 +2247,11 @@ test_credentials_unix_socketpair (void) #ifdef G_OS_WIN32 status = _g_win32_socketpair (PF_UNIX, SOCK_STREAM, 0, fds); + if (status != 0) + { + g_test_skip ("AF_UNIX not supported on this Windows system."); + return; + } #else status = socketpair (PF_UNIX, SOCK_STREAM, 0, fds); #endif