diff options
| author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2022-02-09 12:32:23 +0400 |
|---|---|---|
| committer | Simon McVittie <smcv@collabora.com> | 2022-07-15 16:26:54 +0100 |
| commit | 58992c88bcb0d8d602b3272b8df2f7ce5a7757bd (patch) | |
| tree | 79c4ab502b8fc7d005898749e26ddc011a3a4a3d /test | |
| parent | 95f4cf53fe5e156f0144dbd68badb1ed3a32934b (diff) | |
| download | dbus-58992c88bcb0d8d602b3272b8df2f7ce5a7757bd.tar.gz | |
test: add test_check_af_unix_works()
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Diffstat (limited to 'test')
| -rw-r--r-- | test/test-utils-glib.c | 19 | ||||
| -rw-r--r-- | test/test-utils-glib.h | 1 |
2 files changed, 20 insertions, 0 deletions
diff --git a/test/test-utils-glib.c b/test/test-utils-glib.c index 2aafb03e..30b9836c 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 eda468b9..bfc36941 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, |
