]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
test: add test_check_af_unix_works()
authorMarc-André Lureau <marcandre.lureau@redhat.com>
Wed, 9 Feb 2022 08:32:23 +0000 (12:32 +0400)
committerSimon McVittie <smcv@collabora.com>
Fri, 15 Jul 2022 15:26:54 +0000 (16:26 +0100)
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
test/test-utils-glib.c
test/test-utils-glib.h

index 2aafb03e78fafbd73a1c389a5d3a110e91b3af3b..30b9836c520a5acac37e939572b117686b3edd5c 100644 (file)
@@ -899,6 +899,25 @@ test_check_tcp_works (void)
 #endif
 }
 
+gboolean
+test_check_af_unix_works (void)
+{
+#if defined(G_OS_WIN32) && !defined(HAVE_AFUNIX_H)
+  /* AFUNIX support is compiled out, skip system check */
+  return FALSE;
+#else
+#ifdef G_OS_WIN32
+  SOCKET fd = socket (AF_UNIX, SOCK_STREAM, 0);
+  closesocket (fd);
+  return fd != INVALID_SOCKET;
+#else
+  int fd = socket (AF_UNIX, SOCK_STREAM, 0);
+  close (fd);
+  return fd >= 0;
+#endif
+#endif
+}
+
 /*
  * Store the result of an async operation. @user_data is a pointer to a
  * variable that can store @result, initialized to %NULL.
index eda468b9ec1eac908dbd2b6fc786d13c22fcb055..bfc369411373b3e036d8d3b4d73c0ce2a6c03e24 100644 (file)
@@ -143,6 +143,7 @@ backported_g_steal_pointer (gpointer pointer_to_pointer)
 #endif
 
 gboolean test_check_tcp_works (void);
+gboolean test_check_af_unix_works (void);
 
 void test_store_result_cb (GObject *source_object,
                            GAsyncResult *result,