mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-07-29 21:33:30 +02:00
Merge branch 'test-failure-gdbus-proxy' into 'main'
tests: Wait for gdbus-testserver to die when killing it See merge request GNOME/glib!2341
This commit is contained in:
@@ -733,6 +733,16 @@ test_basic (GDBusProxy *proxy)
|
|||||||
g_object_unref (connection);
|
g_object_unref (connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
name_disappeared_cb (GDBusConnection *connection,
|
||||||
|
const gchar *name,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
gboolean *name_disappeared = user_data;
|
||||||
|
*name_disappeared = TRUE;
|
||||||
|
g_main_context_wakeup (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
kill_test_service (GDBusConnection *connection)
|
kill_test_service (GDBusConnection *connection)
|
||||||
{
|
{
|
||||||
@@ -741,6 +751,8 @@ kill_test_service (GDBusConnection *connection)
|
|||||||
GVariant *ret;
|
GVariant *ret;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
const gchar *name = "com.example.TestService";
|
const gchar *name = "com.example.TestService";
|
||||||
|
guint watch_id;
|
||||||
|
gboolean name_disappeared = FALSE;
|
||||||
|
|
||||||
ret = g_dbus_connection_call_sync (connection,
|
ret = g_dbus_connection_call_sync (connection,
|
||||||
"org.freedesktop.DBus",
|
"org.freedesktop.DBus",
|
||||||
@@ -755,7 +767,18 @@ kill_test_service (GDBusConnection *connection)
|
|||||||
&error);
|
&error);
|
||||||
g_variant_get (ret, "(u)", &pid);
|
g_variant_get (ret, "(u)", &pid);
|
||||||
g_variant_unref (ret);
|
g_variant_unref (ret);
|
||||||
|
|
||||||
|
/* Watch the name and wait until it’s disappeared. */
|
||||||
|
watch_id = g_bus_watch_name_on_connection (connection, name,
|
||||||
|
G_BUS_NAME_WATCHER_FLAGS_NONE,
|
||||||
|
NULL, name_disappeared_cb,
|
||||||
|
&name_disappeared, NULL);
|
||||||
kill (pid, SIGTERM);
|
kill (pid, SIGTERM);
|
||||||
|
|
||||||
|
while (!name_disappeared)
|
||||||
|
g_main_context_iteration (NULL, TRUE);
|
||||||
|
|
||||||
|
g_bus_unwatch_name (watch_id);
|
||||||
#else
|
#else
|
||||||
g_warning ("Can't kill com.example.TestService");
|
g_warning ("Can't kill com.example.TestService");
|
||||||
#endif
|
#endif
|
||||||
@@ -798,8 +821,6 @@ test_proxy_with_flags (GDBusProxyFlags flags)
|
|||||||
|
|
||||||
kill_test_service (connection);
|
kill_test_service (connection);
|
||||||
|
|
||||||
_g_assert_property_notify (proxy, "g-name-owner");
|
|
||||||
|
|
||||||
owner = g_dbus_proxy_get_name_owner (proxy);
|
owner = g_dbus_proxy_get_name_owner (proxy);
|
||||||
g_assert_null (owner);
|
g_assert_null (owner);
|
||||||
g_free (owner);
|
g_free (owner);
|
||||||
|
Reference in New Issue
Block a user