From: Marc-André Lureau Date: Wed, 9 Feb 2022 08:32:23 +0000 (+0400) Subject: test: add test_check_af_unix_works() X-Git-Tag: dbus-1.15.0~26^2~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=58992c88bcb0d8d602b3272b8df2f7ce5a7757bd;p=thirdparty%2Fdbus.git test: add test_check_af_unix_works() Signed-off-by: Marc-André Lureau --- diff --git a/test/test-utils-glib.c b/test/test-utils-glib.c index 2aafb03e7..30b9836c5 100644 --- a/test/test-utils-glib.c +++ b/test/test-utils-glib.c @@ -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. diff --git a/test/test-utils-glib.h b/test/test-utils-glib.h index eda468b9e..bfc369411 100644 --- a/test/test-utils-glib.h +++ b/test/test-utils-glib.h @@ -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,