[tracker/wip/carlosg/tracker-3.0-api-breaks: 42/95] tests: Make test-bus-query-cancellation use in-process endpoint
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/tracker-3.0-api-breaks: 42/95] tests: Make test-bus-query-cancellation use in-process endpoint
- Date: Fri, 14 Feb 2020 13:34:09 +0000 (UTC)
commit b01cd33c65d73ca013895d28fddd9d9762b4d33f
Author: Carlos Garnacho <carlosg gnome org>
Date: Sat Dec 28 02:10:09 2019 +0100
tests: Make test-bus-query-cancellation use in-process endpoint
Create a local connection and endpoint in another thread, and use it
from the main thread through a bus connection.
.../ipc/test-bus-query-cancellation.c | 73 +++++++++++++++++++++-
1 file changed, 71 insertions(+), 2 deletions(-)
---
diff --git a/tests/functional-tests/ipc/test-bus-query-cancellation.c
b/tests/functional-tests/ipc/test-bus-query-cancellation.c
index 916b37481..44388b88d 100644
--- a/tests/functional-tests/ipc/test-bus-query-cancellation.c
+++ b/tests/functional-tests/ipc/test-bus-query-cancellation.c
@@ -26,6 +26,76 @@
#define MAX_TRIES 100
static int counter = 0;
+static gboolean started = FALSE;
+
+TrackerSparqlConnection *
+create_local_connection (GError **error)
+{
+ TrackerSparqlConnection *conn;
+ GFile *store, *ontology;
+ gchar *path;
+
+ path = g_build_filename (g_get_tmp_dir (), "libtracker-sparql-test-XXXXXX", NULL);
+ g_mkdtemp_full (path, 0700);
+ store = g_file_new_for_path (path);
+ g_free (path);
+
+ ontology = g_file_new_for_path (TEST_ONTOLOGIES_DIR);
+
+ conn = tracker_sparql_connection_new (0, store, ontology, NULL, error);
+ g_object_unref (store);
+ g_object_unref (ontology);
+
+ return conn;
+}
+
+static gpointer
+thread_func (gpointer user_data)
+{
+ GDBusConnection *dbus_conn = user_data;
+ TrackerSparqlConnection *direct;
+ TrackerEndpointDBus *endpoint;
+ GMainContext *context;
+ GMainLoop *main_loop;
+
+ context = g_main_context_new ();
+ g_main_context_push_thread_default (context);
+
+ main_loop = g_main_loop_new (context, FALSE);
+
+ direct = create_local_connection (NULL);
+ if (!direct)
+ return NULL;
+
+ endpoint = tracker_endpoint_dbus_new (direct, dbus_conn, NULL, NULL, NULL);
+ if (!endpoint)
+ return NULL;
+
+ started = TRUE;
+ g_main_loop_run (main_loop);
+
+ return NULL;
+}
+
+static TrackerSparqlConnection *
+create_dbus_connection (GError **error)
+{
+ TrackerSparqlConnection *dbus;
+ GDBusConnection *dbus_conn;
+
+ dbus_conn = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, error);
+ if (!dbus_conn)
+ return NULL;
+
+ g_thread_new (NULL, thread_func, dbus_conn);
+
+ while (!started)
+ g_usleep (100);
+
+ dbus = tracker_sparql_connection_bus_new (g_dbus_connection_get_unique_name (dbus_conn),
+ dbus_conn, error);
+ return dbus;
+}
static void
query_cb (GObject *source_object, GAsyncResult *res, gpointer user_data)
@@ -75,8 +145,7 @@ test_tracker_sparql_gb737023 (void)
g_test_bug_base ("https://bugzilla.gnome.org/show_bug.cgi?id=");
g_test_bug ("737023");
- g_setenv ("TRACKER_SPARQL_BACKEND", "bus", TRUE);
- conn = tracker_sparql_connection_get (NULL, &error);
+ conn = create_dbus_connection (&error);
g_assert_no_error (error);
loop = g_main_loop_new (NULL, FALSE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]