summaryrefslogtreecommitdiff
path: root/gio/tests/gdbus-peer.c
diff options
context:
space:
mode:
authorSimon McVittie <smcv@collabora.com>2020-03-15 18:10:53 +0000
committerPhilip Withnall <withnall@endlessm.com>2020-05-07 14:19:16 +0100
commit05cb22908236da54ccf1fa8d04c5ec7860f4d08c (patch)
tree92c7addaedb582e1e7f5e98ae5cd6d7fdff36c9e /gio/tests/gdbus-peer.c
parenta9a7aa05dc3a13bf4321713abb397c466c2d92a5 (diff)
downloadglib-05cb22908236da54ccf1fa8d04c5ec7860f4d08c.tar.gz
GCredentials: Add the concept of credentials that lack the process ID
struct xucred on macOS doesn't have the process ID, only the user ID and groups. Signed-off-by: Simon McVittie <smcv@collabora.com>
Diffstat (limited to 'gio/tests/gdbus-peer.c')
-rw-r--r--gio/tests/gdbus-peer.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/gio/tests/gdbus-peer.c b/gio/tests/gdbus-peer.c
index d01bc9a7a..7ddfdfc7a 100644
--- a/gio/tests/gdbus-peer.c
+++ b/gio/tests/gdbus-peer.c
@@ -344,7 +344,7 @@ on_new_connection (GDBusServer *server,
gpointer user_data)
{
PeerData *data = user_data;
- GError *error;
+ GError *error = NULL;
guint reg_id;
//g_printerr ("Client connected.\n"
@@ -362,13 +362,19 @@ on_new_connection (GDBusServer *server,
g_assert (credentials != NULL);
g_assert_cmpuint (g_credentials_get_unix_user (credentials, NULL), ==,
getuid ());
- g_assert_cmpuint (g_credentials_get_unix_pid (credentials, NULL), ==,
- getpid ());
+#if G_CREDENTIALS_HAS_PID
+ g_assert_cmpint (g_credentials_get_unix_pid (credentials, &error), ==,
+ getpid ());
+ g_assert_no_error (error);
+#else
+ g_assert_cmpint (g_credentials_get_unix_pid (credentials, &error), ==, -1);
+ g_assert_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED);
+ g_clear_error (&error);
+#endif
}
#endif
/* export object on the newly established connection */
- error = NULL;
reg_id = g_dbus_connection_register_object (connection,
"/org/gtk/GDBus/PeerTestObject",
test_interface_introspection_data,
@@ -922,8 +928,15 @@ do_test_peer (void)
g_assert_cmpuint (g_credentials_get_unix_user (credentials, NULL), ==,
getuid ());
- g_assert_cmpuint (g_credentials_get_unix_pid (credentials, NULL), ==,
- getpid ());
+#if G_CREDENTIALS_HAS_PID
+ g_assert_cmpint (g_credentials_get_unix_pid (credentials, &error), ==,
+ getpid ());
+ g_assert_no_error (error);
+#else
+ g_assert_cmpint (g_credentials_get_unix_pid (credentials, &error), ==, -1);
+ g_assert_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED);
+ g_clear_error (&error);
+#endif
g_object_unref (credentials);
#else
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED);