summaryrefslogtreecommitdiff
path: root/tests/libtracker-sparql
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2022-05-01 17:51:17 +0200
committerCarlos Garnacho <carlosg@gnome.org>2022-05-01 19:44:47 +0200
commitb84baa135e27478372a16dbecea22d04d31c84db (patch)
tree9ab1223e4bdcd6876cec1fdc51b8af3ea36dbe76 /tests/libtracker-sparql
parentc3ab249c093a672b42571cdf97f3dfb8fcdf0221 (diff)
downloadtracker-b84baa135e27478372a16dbecea22d04d31c84db.tar.gz
tests: Test both JSON and XML cursors
There is no exposed mechanism to decide what cursor format do an endpoint/cursor negotiate between themselves, as a result we are currently only testing the JSON cursor format. Add a test-only environment variable so that TrackerEndpointHttp prefers a given TrackerSerializerFormat, and run cursor tests twice to ensure we test all cursor paths on HTTP connections. This additionally also exercises the XML serializer on the HTTP endpoint side.
Diffstat (limited to 'tests/libtracker-sparql')
-rw-r--r--tests/libtracker-sparql/meson.build10
-rw-r--r--tests/libtracker-sparql/tracker-cursor-test.c12
2 files changed, 19 insertions, 3 deletions
diff --git a/tests/libtracker-sparql/meson.build b/tests/libtracker-sparql/meson.build
index c3e1e097c..a7cf6c3ae 100644
--- a/tests/libtracker-sparql/meson.build
+++ b/tests/libtracker-sparql/meson.build
@@ -47,9 +47,17 @@ tracker_cursor_test = executable('tracker-cursor-test',
c_args: libtracker_sparql_test_c_args)
tests += {
- 'name': 'cursor',
+ 'name': 'cursor+json',
'exe': tracker_cursor_test,
'suite': ['sparql'],
+ 'env': { 'TRACKER_TEST_PREFERRED_CURSOR_FORMAT': '0' },
+}
+
+tests += {
+ 'name': 'cursor+xml',
+ 'exe': tracker_cursor_test,
+ 'suite': ['sparql'],
+ 'env': { 'TRACKER_TEST_PREFERRED_CURSOR_FORMAT': '1' },
}
test_gresources = gnome.compile_resources('test_gresources', 'statement-queries.gresource.xml')
diff --git a/tests/libtracker-sparql/tracker-cursor-test.c b/tests/libtracker-sparql/tracker-cursor-test.c
index 994424bc6..38fa701e6 100644
--- a/tests/libtracker-sparql/tracker-cursor-test.c
+++ b/tests/libtracker-sparql/tracker-cursor-test.c
@@ -33,6 +33,8 @@ typedef struct {
const gchar *query;
} AsyncData;
+static int http_port;
+
static TrackerSparqlConnection *direct;
static TrackerSparqlConnection *dbus;
static TrackerSparqlConnection *http;
@@ -375,7 +377,7 @@ thread_func (gpointer user_data)
endpoint_bus = tracker_endpoint_dbus_new (direct, dbus_conn, NULL, NULL, &error);
g_assert_no_error (error);
- endpoint_http = tracker_endpoint_http_new (direct, 54320, NULL, NULL, &error);
+ endpoint_http = tracker_endpoint_http_new (direct, http_port, NULL, NULL, &error);
g_assert_no_error (error);
started = TRUE;
@@ -390,6 +392,9 @@ create_connections (void)
GDBusConnection *dbus_conn;
GThread *thread;
GError *error = NULL;
+ gchar *host;
+
+ http_port = g_test_rand_int_range (30000, 60000);
dbus_conn = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
g_assert_no_error (error);
@@ -399,7 +404,10 @@ create_connections (void)
while (!started)
g_usleep (100);
- http = tracker_sparql_connection_remote_new ("http://127.0.0.1:54320/sparql");
+ host = g_strdup_printf ("http://127.0.0.1:%d/sparql", http_port);
+ http = tracker_sparql_connection_remote_new (host);
+ g_free (host);
+
dbus = tracker_sparql_connection_bus_new (g_dbus_connection_get_unique_name (dbus_conn),
NULL, dbus_conn, &error);
g_assert_no_error (error);