diff options
author | Sam Thursfield <sam@afuera.me.uk> | 2019-03-27 23:53:02 +0000 |
---|---|---|
committer | Sam Thursfield <sam@afuera.me.uk> | 2019-03-27 23:53:02 +0000 |
commit | 98611c1a2b7c3e6cafc77012dc44b6663b682992 (patch) | |
tree | 1a9d7f9fb941fc84d6623691b2fca357102ef1c3 | |
parent | 8c1cbf7f8485a136dac46b7823f18fde164a91ac (diff) | |
parent | 3155f39d36715e3425e4f13fb5f9174b8bddff91 (diff) | |
download | tracker-98611c1a2b7c3e6cafc77012dc44b6663b682992.tar.gz |
Merge branch 'sam/functional-tests-removal' into 'master'
tests: Remove some functional tests
See merge request GNOME/tracker!72
-rw-r--r-- | tests/functional-tests/ipc/meson.build | 52 | ||||
-rw-r--r-- | tests/functional-tests/ipc/test-bus-query.vala | 15 | ||||
-rw-r--r-- | tests/functional-tests/ipc/test-bus-update.vala | 15 | ||||
-rw-r--r-- | tests/functional-tests/ipc/test-busy-handling.vala | 165 | ||||
-rw-r--r-- | tests/functional-tests/ipc/test-class-signal-performance-batch.vala | 115 | ||||
-rw-r--r-- | tests/functional-tests/ipc/test-class-signal-performance.vala | 159 | ||||
-rw-r--r-- | tests/functional-tests/ipc/test-class-signal.vala | 178 | ||||
-rw-r--r-- | tests/functional-tests/ipc/test-default-update.vala | 70 | ||||
-rw-r--r-- | tests/functional-tests/ipc/test-direct-query.vala | 70 | ||||
-rw-r--r-- | tests/functional-tests/ipc/test-shared-query.vala | 139 | ||||
-rw-r--r-- | tests/functional-tests/ipc/test-shared-update.vala | 137 | ||||
-rw-r--r-- | tests/functional-tests/ipc/test-update-array-performance.c | 277 |
12 files changed, 0 insertions, 1392 deletions
diff --git a/tests/functional-tests/ipc/meson.build b/tests/functional-tests/ipc/meson.build index b789faca7..bd4c3250e 100644 --- a/tests/functional-tests/ipc/meson.build +++ b/tests/functional-tests/ipc/meson.build @@ -9,58 +9,6 @@ insert_or_replace_test = executable('test-insert-or-replace', test('functional-ipc-insert-or-replace', insert_or_replace_test, env: test_env) -busy_handling_test = executable('test-busy-handling', - 'test-busy-handling.vala', - dependencies: [tracker_common_dep, tracker_sparql_dep]) - -direct_query_test = executable('test-direct-query', - 'test-direct-query.vala', - 'test-shared-query.vala', - dependencies: [tracker_common_dep, tracker_sparql_dep]) -test('functional-ipc-direct-query', direct_query_test, - env: test_env) - -bus_query_test = executable('test-bus-query', - 'test-bus-query.vala', - 'test-shared-query.vala', - link_with: [libtracker_bus], - dependencies: [tracker_common_dep, tracker_sparql_dep, tracker_sparql_bus_dep]) -test('functional-ipc-bus-query', bus_query_test, - env: test_env) - -default_update_test = executable('test-default-update', - 'test-default-update.vala', - 'test-shared-update.vala', - dependencies: [tracker_common_dep, tracker_sparql_dep]) -test('functional-ipc-default-update', default_update_test, - env: test_env) - -bus_update_test = executable('test-bus-update', - 'test-bus-update.vala', - 'test-shared-update.vala', - link_with: [libtracker_bus], - dependencies: [tracker_common_dep, tracker_sparql_dep, tracker_sparql_bus_dep]) -test('functional-ipc-bus-update', bus_update_test, - env: test_env) - -class_signal_test = executable('test-class-signal', - 'test-class-signal.vala', - dependencies: [tracker_common_dep, tracker_sparql_dep]) - -class_signal_performance_test = executable('test-class-signal-performance', - 'test-class-signal-performance.vala', - dependencies: [tracker_common_dep, tracker_sparql_dep]) - -class_signal_performance_batch_test = executable('test-class-signal-performance-batch', - 'test-class-signal-performance-batch.vala', - dependencies: [tracker_common_dep, tracker_sparql_dep]) - -update_array_performance_test = executable('test-update-array-performance', - 'test-update-array-performance.c', - dependencies: [tracker_common_dep, tracker_sparql_dep]) -test('functional-ipc-update-array-performance', update_array_performance_test, - env: test_env) - bus_query_cancellation_test = executable('test-bus-query-cancellation', 'test-bus-query-cancellation.c', c_args: functional_ipc_test_c_args, diff --git a/tests/functional-tests/ipc/test-bus-query.vala b/tests/functional-tests/ipc/test-bus-query.vala deleted file mode 100644 index 4e51a2b07..000000000 --- a/tests/functional-tests/ipc/test-bus-query.vala +++ /dev/null @@ -1,15 +0,0 @@ -using Tracker; -using Tracker.Sparql; - -int -main( string[] args ) -{ - try { - TestApp app = new TestApp (new Tracker.Bus.Connection ("org.freedesktop.Tracker1", null, true)); - - return app.run (); - } catch (GLib.Error e) { - warning ("Couldn't perform test: %s", e.message); - return 1; - } -} diff --git a/tests/functional-tests/ipc/test-bus-update.vala b/tests/functional-tests/ipc/test-bus-update.vala deleted file mode 100644 index 4e51a2b07..000000000 --- a/tests/functional-tests/ipc/test-bus-update.vala +++ /dev/null @@ -1,15 +0,0 @@ -using Tracker; -using Tracker.Sparql; - -int -main( string[] args ) -{ - try { - TestApp app = new TestApp (new Tracker.Bus.Connection ("org.freedesktop.Tracker1", null, true)); - - return app.run (); - } catch (GLib.Error e) { - warning ("Couldn't perform test: %s", e.message); - return 1; - } -} diff --git a/tests/functional-tests/ipc/test-busy-handling.vala b/tests/functional-tests/ipc/test-busy-handling.vala deleted file mode 100644 index 27ecdfa15..000000000 --- a/tests/functional-tests/ipc/test-busy-handling.vala +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright (C) 2008, Nokia <ivan.frade@nokia.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -// To run this test: -// -===------------- -// -// tracker daemon -k -// rm ~/.cache/tracker/meta.db -// export TRACKER_DEBUG_MAKE_JOURNAL_READER_GO_VERY_SLOW=yes -// tracker-store -// ./busy-handling-test - -[DBus (name = "org.freedesktop.Tracker1.Resources")] -private interface Resources : DBusProxy { - [DBus (name = "SparqlQuery", timeout = 99999999999)] - public abstract async string[,] sparql_query (string query) throws GLib.Error, DBusError; -} - -[DBus (name = "org.freedesktop.Tracker1.Status")] -private interface Status: DBusProxy { - public signal void progress (string status, double progress); - public abstract double get_progress () throws GLib.Error, DBusError; - public abstract string get_status () throws GLib.Error, DBusError; -} - -public class TestApp { - static Resources resources_object; - static Status status_object; - int res = -1; - int users = 0; - MainLoop loop; - bool initialized = false; - bool ready = false; - - public TestApp () - requires (!initialized) { - try { - double progress; - string status; - - resources_object = GLib.Bus.get_proxy_sync (BusType.SESSION, - "org.freedesktop.Tracker1", - "/org/freedesktop/Tracker1/Resources", - DBusProxyFlags.DO_NOT_LOAD_PROPERTIES | DBusProxyFlags.DO_NOT_CONNECT_SIGNALS); - - status_object = GLib.Bus.get_proxy_sync (BusType.SESSION, - "org.freedesktop.Tracker1", - "/org/freedesktop/Tracker1/Status", - DBusProxyFlags.DO_NOT_LOAD_PROPERTIES | DBusProxyFlags.DO_NOT_CONNECT_SIGNALS); - - status_object.progress.connect (on_status_cb); - progress = status_object.get_progress (); - status = status_object.get_status (); - - ready = (progress == 1.0 && status == "Idle"); - - } catch (GLib.Error e) { - warning ("Could not connect to D-Bus service: %s", e.message); - initialized = false; - res = -1; - return; - } - initialized = true; - } - - void on_status_cb (string status, double progress) { - print ("%s: %f\n", status, progress); - // Don't use status here, it'll be "Journal replaying" when progress = 1 - if (progress == 1.0) { - ready = true; - } - } - - async void do_query_tests_async (string test_name) { - try { - int cnt = 0; - string[,] results = yield resources_object.sparql_query ("SELECT ?u { ?u a rdfs:Resource }"); - foreach (string res in results) { - cnt++; - } - print ("%s: Saw %d strings in result\n", test_name, cnt); - } catch (GLib.Error e) { - print ("Fail: %s\n", e.message); - res = -1; - } - } - - void check_shutdown () { - users--; - if (users == 0) { - print ("Async tests done, now I can quit the mainloop\n"); - loop.quit (); - } - } - - async void do_async_query_tests () { - print ("Test 1: Just launch the query and let it wait\nTest 1: query launches immediately\n"); - users++; - yield do_query_tests_async ("Test 1"); - - check_shutdown (); - } - - async void jumper_async () { - yield do_query_tests_async ("Test 2"); - check_shutdown (); - } - - bool test_ready () { - - if (ready) { - print ("Test 2: query launches now\n"); - jumper_async.begin (); - } - - return !ready; - } - - bool in_mainloop () { - do_async_query_tests.begin (); - - print ("Test 2: Wait for the status signal to indicate readyness\n"); - users++; - - if (!ready) { - Timeout.add (1, test_ready); - } else { - test_ready (); - } - - return false; - } - - public int run () { - loop = new MainLoop (null, false); - - Idle.add (in_mainloop); - - loop.run (); - - return res; - } -} - -int main (string[] args) { - TestApp app = new TestApp (); - - return app.run (); -} diff --git a/tests/functional-tests/ipc/test-class-signal-performance-batch.vala b/tests/functional-tests/ipc/test-class-signal-performance-batch.vala deleted file mode 100644 index c3185e2a5..000000000 --- a/tests/functional-tests/ipc/test-class-signal-performance-batch.vala +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (C) 2008, Nokia <ivan.frade@nokia.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -using Tracker; -using Tracker.Sparql; - -const int max_signals = 1000; -const string title_data = "title"; - -public struct Event { - int graph_id; - int subject_id; - int pred_id; - int object_id; -} - -[DBus (name = "org.freedesktop.Tracker1.Resources")] -private interface Resources : DBusProxy { - [DBus (name = "GraphUpdated")] - public signal void graph_updated (string class_name, Event[] deletes, Event[] inserts); - [DBus (name = "BatchSparqlUpdate")] - public abstract async void batch_sparql_update_async (string query) throws GLib.Error, Sparql.Error, DBusError; - [DBus (name = "SparqlUpdate")] - public abstract async void sparql_update_async (string query) throws GLib.Error, Sparql.Error, DBusError; -} - -public class TestApp { - static Resources resources_object; - MainLoop loop; - bool initialized = false; - Sparql.Connection con; - int count = 0; - GLib.Timer t; - - public TestApp () - requires (!initialized) { - try { - con = Tracker.Sparql.Connection.get(); - - resources_object = GLib.Bus.get_proxy_sync (BusType.SESSION, - "org.freedesktop.Tracker1", - "/org/freedesktop/Tracker1/Resources", - DBusProxyFlags.DO_NOT_LOAD_PROPERTIES | DBusProxyFlags.DO_NOT_CONNECT_SIGNALS); - - - resources_object.graph_updated.connect (on_graph_updated_received); - t = new GLib.Timer (); - - } catch (GLib.Error e) { - warning ("Could not connect to D-Bus service: %s", e.message); - initialized = false; - return; - } - initialized = true; - } - - private void on_graph_updated_received (string class_name, Event[] deletes, Event[] inserts) { - foreach (Event insert in inserts) - count++; - print ("New class signal count=%d time=%lf\n", count, t.elapsed ()); - } - - private void insert_data () { - int i; - for (i = 0; i <= max_signals; i++) { - string upqry = "DELETE { <%d> a rdfs:Resource }".printf(i); - resources_object.sparql_update_async.begin (upqry); - } - - t.start(); - for (i = 0; i <= max_signals; i++) { - string upqry = "INSERT { <%d> a nmm:MusicPiece ; nie:title '%s %d' }".printf(i, title_data, i); - - if (i == max_signals / 2) { - resources_object.sparql_update_async.begin (upqry); - } else { - resources_object.batch_sparql_update_async.begin (upqry); - } - } - } - - private bool in_mainloop () { - insert_data (); - return false; - } - - public int run () { - loop = new MainLoop (null, false); - Idle.add (in_mainloop); - loop.run (); - return 0; - } -} - -int main (string[] args) { - TestApp app = new TestApp (); - - return app.run (); -} diff --git a/tests/functional-tests/ipc/test-class-signal-performance.vala b/tests/functional-tests/ipc/test-class-signal-performance.vala deleted file mode 100644 index e97671c95..000000000 --- a/tests/functional-tests/ipc/test-class-signal-performance.vala +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright (C) 2008, Nokia <ivan.frade@nokia.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -using Tracker; -using Tracker.Sparql; - -const int max_signals = 1000; -// const int max_signals = 10000; -const string title_data = "title"; - -// Always start this test AFTER DOING tracker-control -r. The test IS NOT -// deleting existing resources, so you CAN'T RUN IT TWICE unless you clear -// the database before starting it the second time. - -// Testreport of Aug 25, 2010 by Philip -// ------------------------------------ -// On Aug 25 the difference between using tracker-store on master and the -// tracker-store of class-signal, and then letting this wait until all 10000 -// (in case of max_signals = 10000) insert queries' signals arrived (you'll -// have in total 20002 events in the signals in both tracker-store versions) -// was: 20s for class-signals (new class signal) and 23s for master (old class -// signals). Measured using this performance test. -// -// Memory usage of class-signal (new class signal)'s tracker-store: -// Low: VmRSS: 8860 Kb -- Max: VmRSS: 14116 kB -// -// Memory usage of master (old class signal)'s tracker-store: -// Low: VmRSS: 8868 Kb -- Max: VmRSS: 14060 kB - - -public struct Event { - int graph_id; - int subject_id; - int pred_id; - int object_id; -} - -[DBus (name = "org.freedesktop.Tracker1.Resources")] -private interface Resources : DBusProxy { - [DBus (name = "GraphUpdated")] - public signal void graph_updated (string class_name, Event[] deletes, Event[] inserts); - - [DBus (name = "SparqlUpdate")] - public abstract async void sparql_update_async (string query) throws GLib.Error, Sparql.Error, DBusError; -} - -[DBus (name = "org.freedesktop.Tracker1.Resources.Class")] -private interface ResourcesClass : DBusProxy { - [DBus (name = "SubjectsAdded")] - public signal void subjects_added (string [] subjects); - [DBus (name = "SubjectsChanged")] - public signal void subjects_changed (string [] subjects, string [] preds); -} - -public class TestApp { - static Resources resources_object; - static ResourcesClass class_object; - MainLoop loop; - bool initialized = false; - Sparql.Connection con; - int count = 0; - GLib.Timer t; - - public TestApp () - requires (!initialized) { - try { - con = Tracker.Sparql.Connection.get(); - - resources_object = GLib.Bus.get_proxy_sync (BusType.SESSION, - "org.freedesktop.Tracker1", - "/org/freedesktop/Tracker1/Resources", - DBusProxyFlags.DO_NOT_LOAD_PROPERTIES | DBusProxyFlags.DO_NOT_CONNECT_SIGNALS); - - class_object = GLib.Bus.get_proxy_sync (BusType.SESSION, - "org.freedesktop.Tracker1", - "/org/freedesktop/Tracker1/Resources/Classes/nmm/MusicPiece", - DBusProxyFlags.DO_NOT_LOAD_PROPERTIES | DBusProxyFlags.DO_NOT_CONNECT_SIGNALS); - - class_object.subjects_added.connect (on_subjects_added); - class_object.subjects_changed.connect (on_subjects_changed); - - resources_object.graph_updated.connect (on_graph_updated_received); - t = new GLib.Timer (); - - } catch (GLib.Error e) { - warning ("Could not connect to D-Bus service: %s", e.message); - initialized = false; - return; - } - initialized = true; - } - - private void on_subjects_changed (string [] subjects, string [] preds) { - foreach (string s in subjects) - count++; - - //if (count == 20002) - print ("Old class signal count=%d time=%lf\n", count, t.elapsed ()); - } - - private void on_subjects_added (string [] subjects) { - foreach (string s in subjects) - count++; - - //if (count == 20002) - print ("Old class signal count=%d time=%lf\n", count, t.elapsed ()); - } - - private void on_graph_updated_received (string class_name, Event[] deletes, Event[] inserts) { - foreach (Event insert in inserts) - count++; - //if (count == 20002) - print ("New class signal count=%d time=%lf\n", count, t.elapsed ()); - } - - private void insert_data () { - int i; - - t.start(); - for (i = 0; i <= max_signals; i++) { - string upqry = "INSERT { <%d> a nmm:MusicPiece ; nie:title '%s %d' }".printf(i, title_data, i); - resources_object.sparql_update_async.begin (upqry); - } - } - - private bool in_mainloop () { - insert_data (); - return false; - } - - public int run () { - loop = new MainLoop (null, false); - Idle.add (in_mainloop); - loop.run (); - return 0; - } -} - -int main (string[] args) { - TestApp app = new TestApp (); - - return app.run (); -} diff --git a/tests/functional-tests/ipc/test-class-signal.vala b/tests/functional-tests/ipc/test-class-signal.vala deleted file mode 100644 index 0b0f8bb1b..000000000 --- a/tests/functional-tests/ipc/test-class-signal.vala +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Copyright (C) 2008, Nokia <ivan.frade@nokia.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -using Tracker; -using Tracker.Sparql; - -const int max_signals = 10; -const string title_data = "title"; - - -public struct Event { - int graph_id; - int subject_id; - int pred_id; - int object_id; -} - -[DBus (name = "org.freedesktop.Tracker1.Resources")] -private interface Resources : DBusProxy { - [DBus (name = "GraphUpdated")] - public signal void graph_updated (string class_name, Event[] deletes, Event[] inserts); - - [DBus (name = "SparqlUpdate")] - public abstract async void sparql_update_async (string query) throws GLib.Error, Sparql.Error, DBusError; -} - -public class TestApp { - static Resources resources_object; - int res = -1; - MainLoop loop; - bool initialized = false; - Sparql.Connection signal_con; - Sparql.Connection con; - int total_signals_seen = 0; - - public TestApp () - requires (!initialized) { - try { - con = Tracker.Sparql.Connection.get(); - - // Switch between kinds of query connections here: - signal_con = con; - - resources_object = GLib.Bus.get_proxy_sync (BusType.SESSION, - "org.freedesktop.Tracker1", - "/org/freedesktop/Tracker1/Resources", - DBusProxyFlags.DO_NOT_LOAD_PROPERTIES | DBusProxyFlags.DO_NOT_CONNECT_SIGNALS); - - resources_object.graph_updated.connect (on_graph_updated_received); - - } catch (GLib.Error e) { - warning ("Could not connect to D-Bus service: %s", e.message); - initialized = false; - res = -1; - return; - } - initialized = true; - } - - // Query looks like this: - // SELECT ?r ?t { ?r a nmm:MusicPiece; nie:title ?t . - // FILTER (tracker:id (?r) IN (id1, id2, id3)) - // } - - private StringBuilder build_title_query (string class_name, Event[] ids) { - bool first = true; - StringBuilder builder = new StringBuilder ("SELECT ?r ?t { ?r a <"); - builder.append (class_name); - builder.append (">; nie:title ?t . FILTER (tracker:id (?r) IN ("); - foreach (Event event in ids) { - if (first) - builder.append_printf ("%d", event.subject_id); - else - builder.append_printf (" , %d", event.subject_id); - first = false; - } - builder.append (")) }"); - return builder; - } - - private int iter_cursor (string kind, Cursor cursor) { - try { - while (cursor.next()) { - string resource = cursor.get_string (0); - - print ("%s <%s> nie:title '%s'\n", - kind, - resource, - cursor.get_string (1)); - total_signals_seen++; - - // We'll see ~ max_signals*2 things, (insert and delete, plus the - // resource creates too - so a little bit more) - if (total_signals_seen >= (max_signals*2)) { - loop.quit(); - } - } - } catch (GLib.Error e) { - warning ("Couldn't iterate query results: %s", e.message); - res = -1; - return -1; - } - return (0); - } - - private async void on_graph_updated_received_async (string dels_query, string ins_query) { - try { - Sparql.Cursor cursor1, cursor2; - - cursor1 = yield signal_con.query_async (dels_query); - cursor2 = yield signal_con.query_async (ins_query); - - res = iter_cursor ("delete of: ", cursor1); - if (res != -1) - res = iter_cursor ("insert of: ", cursor2); - - } catch (GLib.Error e) { - warning ("Couldn't iterate query results: %s", e.message); - res = -1; - } - } - - private void on_graph_updated_received (string class_name, Event[] deletes, Event[] inserts) { - string dels_qry = build_title_query (class_name, deletes).str; - string ins_qry = build_title_query (class_name, deletes).str; - - on_graph_updated_received_async.begin (dels_qry, ins_qry); - } - - private void insert_data () { - int i; - - for (i = 0; i <= max_signals; i++) { - string upqry = "DELETE { <%d> a rdfs:Resource } INSERT { <%d> a nmm:MusicPiece ; nie:title '%s %d' }".printf(i, i, title_data, i); - - resources_object.sparql_update_async.begin (upqry); - - // Once the FD passing bug is fixed (running out of FDs), replace - // above with this: - // con.update_async (upqry); - } - } - - private bool in_mainloop () { - insert_data (); - - return false; - } - - public int run () { - loop = new MainLoop (null, false); - Idle.add (in_mainloop); - loop.run (); - return res; - } -} - -int main (string[] args) { - TestApp app = new TestApp (); - - return app.run (); -} diff --git a/tests/functional-tests/ipc/test-default-update.vala b/tests/functional-tests/ipc/test-default-update.vala deleted file mode 100644 index e62c63aec..000000000 --- a/tests/functional-tests/ipc/test-default-update.vala +++ /dev/null @@ -1,70 +0,0 @@ -using Tracker.Sparql; - -private static int res; -private static MainLoop loop; - -private void test_async () { - Connection c = null; - - // Test async - print ("Getting connection async\n"); - loop = new MainLoop (null, false); - Connection.get_async.begin (null, (o, res) => { - try { - c = Connection.get_async.end (res); - loop.quit (); - } catch (GLib.Error e) { - warning ("Couldn't perform test: %s", e.message); - } - }); - loop.run (); - - print ("Got it %p\n", c); - - print ("Creating app with connection\n"); - TestApp app = new TestApp (c); - - print ("Running app\n"); - res = app.run(); - - print ("\n"); -} - -private void test_sync () { - try { - Connection c; - - // Test async - print ("Getting connection\n"); - c = Connection.get (); - - print ("Got it %p\n", c); - - print ("Creating app with connection\n"); - TestApp app = new TestApp (c); - - print ("Running app\n"); - res = app.run(); - } catch (GLib.Error e) { - warning ("Couldn't perform test: %s", e.message); - } - - print ("\n"); -} - -int -main( string[] args ) -{ - print ("Starting...\n"); - - test_sync (); - - if (res < 0) { - return res; - } - - // Do async second - test_async (); - - return res; -} diff --git a/tests/functional-tests/ipc/test-direct-query.vala b/tests/functional-tests/ipc/test-direct-query.vala deleted file mode 100644 index 2d051616e..000000000 --- a/tests/functional-tests/ipc/test-direct-query.vala +++ /dev/null @@ -1,70 +0,0 @@ -using Tracker; -using Tracker.Sparql; - -private static int res; -private static MainLoop loop; - -private void test_async () { - Connection c = null; - - // Test async - print ("Getting connection asynchronously\n"); - loop = new MainLoop (null, false); - Connection.get_async.begin (null, (o, res) => { - try { - c = Connection.get_async.end (res); - } catch (GLib.Error e) { - warning ("Couldn't perform test: %s", e.message); - } - loop.quit (); - }); - loop.run (); - - print ("Got it %p\n", c); - - print ("Creating app with connection\n"); - TestApp app = new TestApp (c); - - print ("Running app\n"); - res = app.run(); - - print ("\n"); -} - -private void test_sync () { - try { - Connection c; - - // Test async - print ("Getting connection synchronously\n"); - c = Connection.get (); - - print ("Got it %p\n", c); - - print ("Creating app with connection\n"); - TestApp app = new TestApp (c); - - print ("Running app\n"); - res = app.run(); - } catch (GLib.Error e) { - warning ("Couldn't perform test: %s", e.message); - } - - print ("\n"); -} - -int -main( string[] args ) -{ - print ("Starting...\n"); - - test_sync (); - - if (res < 0) { - return res; - } - - test_async (); - - return res; -} diff --git a/tests/functional-tests/ipc/test-shared-query.vala b/tests/functional-tests/ipc/test-shared-query.vala deleted file mode 100644 index 133fec890..000000000 --- a/tests/functional-tests/ipc/test-shared-query.vala +++ /dev/null @@ -1,139 +0,0 @@ -using Tracker; -using Tracker.Sparql; - -public class TestApp : GLib.Object { - MainLoop loop; - Sparql.Connection con; - int res = 0; - - public TestApp (Sparql.Connection connection) { - con = connection; - } - - string type_to_string (Sparql.ValueType type) { - switch (type) { - case Sparql.ValueType.UNBOUND: - return "unbound"; - case Sparql.ValueType.URI: - return "uri"; - case Sparql.ValueType.STRING: - return "string"; - case Sparql.ValueType.INTEGER: - return "integer"; - case Sparql.ValueType.DOUBLE: - return "double"; - case Sparql.ValueType.DATETIME: - return "datetime"; - case Sparql.ValueType.BLANK_NODE: - return "blank-node"; - case Sparql.ValueType.BOOLEAN: - return "boolean"; - default: - break; - } - return "unknown"; - } - - int iter_cursor (Cursor cursor) { - int i; - - try { - for (i = 0; i < cursor.n_columns; i++) { - print ("| %s ", cursor.get_variable_name (i)); - } - print ("| -> %d columns\n", cursor.n_columns); - - while (cursor.next()) { - for (i = 0; i < cursor.n_columns; i++) { - print ("%s%s a %s", i != 0 ? ",":"", - cursor.get_string (i), - type_to_string (cursor.get_value_type (i))); - } - - print ("\n"); - } - } catch (GLib.Error e) { - warning ("Couldn't iterate query results: %s", e.message); - return -1; - } - - return (0); - } - - private void test_query () { - Cursor cursor; - - print ("Sync test\n"); - try { - cursor = con.query ("SELECT ?u WHERE { ?u a rdfs:Class }"); - } catch (GLib.Error e) { - warning ("Couldn't perform query: %s", e.message); - res = -1; - return; - } - - res = iter_cursor (cursor); - - if (res == -1) - return; - - print ("\nRewinding\n"); - cursor.rewind (); - - print ("\nSecond run\n"); - res = iter_cursor (cursor); - } - - private async void test_query_async () { - Cursor cursor; - - print ("Async test\n"); - try { - cursor = yield con.query_async ("SELECT ?u WHERE { ?u a rdfs:Class }"); - } catch (GLib.Error e) { - warning ("Couldn't perform query: %s", e.message); - res = -1; - return; - } - - res = iter_cursor (cursor); - - if (res == -1) - return; - - print ("\nRewinding\n"); - cursor.rewind (); - - print ("\nSecond run\n"); - res = iter_cursor (cursor); - } - - void do_sync_tests () { - test_query (); - } - - async void do_async_tests () { - yield test_query_async (); - - print ("Async tests done, now I can quit the mainloop\n"); - loop.quit (); - } - - bool in_mainloop () { - - do_sync_tests (); - do_async_tests.begin (); - - return false; - } - - public int run () { - loop = new MainLoop (null, false); - - Idle.add (in_mainloop); - - loop.run (); - - return res; - } -} diff --git a/tests/functional-tests/ipc/test-shared-update.vala b/tests/functional-tests/ipc/test-shared-update.vala deleted file mode 100644 index f2a54a7e6..000000000 --- a/tests/functional-tests/ipc/test-shared-update.vala +++ /dev/null @@ -1,137 +0,0 @@ -using Tracker; -using Tracker.Sparql; - - -public class TestApp : GLib.Object { - MainLoop loop; - Sparql.Connection con; - private int res = 0; - - public TestApp (Sparql.Connection connection) { - con = connection; - } - - int iter_cursor (Cursor cursor) { - try { - while (cursor.next()) { - int i; - - for (i = 0; i < cursor.n_columns; i++) { - print ("%s%s", i != 0 ? ",":"", cursor.get_string (i)); - } - - print ("\n"); - } - } catch (GLib.Error e) { - warning ("Couldn't iterate query results: %s", e.message); - return -1; - } - - return (0); - } - - int iter_variant (GLib.Variant variant) { - - // TODO: Rest the return value, also check tracker_bus_message_to_variant - // in libtracker-bus/tracker-bus-shared.c - - return 0; - } - - void update_query () { - Cursor cursor; - int a; - - try { - con.update ("INSERT { <test01> a nie:InformationElement ; nie:title 'test01' }"); - } catch (GLib.Error e) { - warning ("Couldn't update: %s", e.message); - res = -1; - } - - try { - cursor = con.query ("SELECT ?title WHERE { <test01> nie:title ?title }"); - a = iter_cursor (cursor); - } catch (GLib.Error e) { - warning ("Couldn't query: %s", e.message); - res = -1; - } - } - - async void update_query_async () { - Cursor cursor; - int a; - - try { - yield con.update_async ("INSERT { <test02> a nie:InformationElement ; nie:title 'test01' }"); - } catch (GLib.Error ea) { - warning ("Couldn't update: %s", ea.message); - res = -1; - } - - try { - cursor = con.query ("SELECT ?title WHERE { <test02> nie:title ?title }"); - a = iter_cursor (cursor); - } catch (GLib.Error eb) { - warning ("Couldn't query: %s", eb.message); - res = -1; - } - } - - void update_blank_query () { - GLib.Variant variant; - int a; - - try { - variant = con.update_blank ("INSERT { _:a1 a nie:InformationElement . _:b1 a nie:InformationElement . _:c1 a nie:InformationElement }"); - a = iter_variant (variant); - } catch (GLib.Error e) { - warning ("Couldn't update: %s", e.message); - res = -1; - } - } - - async void update_blank_query_async () { - GLib.Variant variant; - int a; - - try { - variant = yield con.update_blank_async ("INSERT { _:a2 a nie:InformationElement . _:b2 a nie:InformationElement . _:c2 a nie:InformationElement }"); - a = iter_variant (variant); - } catch (GLib.Error e) { - warning ("Couldn't update: %s", e.message); - res = -1; - } - } - - void do_sync_tests () { - update_query (); - update_blank_query (); - } - - async void do_async_tests () { - yield update_query_async (); - yield update_blank_query_async (); - - print ("Async tests done, now I can quit the mainloop\n"); - loop.quit (); - } - - bool in_mainloop () { - - do_sync_tests (); - do_async_tests.begin (); - - return false; - } - - public int run () { - loop = new MainLoop (null, false); - - Idle.add (in_mainloop); - - loop.run (); - - return res; - } -} diff --git a/tests/functional-tests/ipc/test-update-array-performance.c b/tests/functional-tests/ipc/test-update-array-performance.c deleted file mode 100644 index 8c6f35d10..000000000 --- a/tests/functional-tests/ipc/test-update-array-performance.c +++ /dev/null @@ -1,277 +0,0 @@ -/* - * Copyright (C) 2010, Codeminded BVBA <abustany@gnome.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - * Copied from ../tracker-steroids/tracker-test.c - */ - -#include <stdlib.h> -#include <string.h> - -#include <libtracker-sparql/tracker-sparql.h> - -typedef struct { - GMainLoop *main_loop; - const gchar *query; - guint len, cur; -} AsyncData; - -static TrackerSparqlConnection *connection; -#define MSIZE 90 -#define TEST_STR "Brrr0092323" - -static const gchar *queries[90] = { - "INSERT { _:a0 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:a9 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:a11 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:b0 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:b9 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:b11 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:c0 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:c9 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:c12 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:d0 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:d9 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:d12 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:e0 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:e9 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:e11 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:f0 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:f9 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:f11 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:b1 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:b8 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:b13 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:c1 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:c8 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:c13 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:d1 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:d8 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:d14 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:e1 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:e8 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:e14 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:f1 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:f8 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:f15 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:b2 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:b7 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:b15 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:c2 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:c7 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:c15 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:d2 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:d7 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:d16 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:e2 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:e7 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:e16 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:f2 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:f7 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:f17 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:b3 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:b6 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:b16 a nmo:Message; nie:title '" TEST_STR "'}", - "INSERT { _:c3 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:c6 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:c18 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:d3 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:d6 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:d19 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:e3 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:e6 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:e20 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:f3 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:f6 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:f21 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:b4 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:b5 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:b22 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:c4 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:c5 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:c23 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:d4 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:d5 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:d24 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:e4 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:e5 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:e24 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:f4 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:f5 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:f25 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:c5 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:c2 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:c26 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:d5 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:d2 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:d28 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:e5 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:e2 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:e29 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:f5 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:f2 a nmo:Message; nie:title '" TEST_STR "' }", - "INSERT { _:f33 a nmo:Message; nie:title '" TEST_STR "' }" }; - -static void -async_update_array_callback (GObject *source_object, - GAsyncResult *result, - gpointer user_data) -{ - AsyncData *data = user_data; - GError *error = NULL; - GPtrArray *errors; - - errors = tracker_sparql_connection_update_array_finish (connection, result, &error); - g_assert_no_error (error); - g_ptr_array_unref (errors); - g_main_loop_quit (data->main_loop); -} - - -static void -test_tracker_sparql_update_array_async () -{ - GMainLoop *main_loop; - AsyncData *data; - - main_loop = g_main_loop_new (NULL, FALSE); - - data = g_slice_new (AsyncData); - data->main_loop = main_loop; - - /* Cast here is because vala doesn't make const-char-** possible :( */ - tracker_sparql_connection_update_array_async (connection, - (char**) queries, MSIZE, - 0, NULL, - async_update_array_callback, - data); - - g_main_loop_run (main_loop); - - g_slice_free (AsyncData, data); - g_main_loop_unref (main_loop); - -} - -static void -async_update_callback (GObject *source_object, - GAsyncResult *result, - gpointer user_data) -{ - AsyncData *data = user_data; - GError *error = NULL; - - data->cur++; - - tracker_sparql_connection_update_finish (connection, result, &error); - if (error) - g_error_free (error); - - if (data->cur == data->len) - g_main_loop_quit (data->main_loop); -} - -static void -test_tracker_sparql_update_async () -{ - guint i; - GMainLoop *main_loop; - AsyncData *data; - - main_loop = g_main_loop_new (NULL, FALSE); - - data = g_slice_new (AsyncData); - data->len = MSIZE; - data->main_loop = main_loop; - data->cur = 0; - - for (i = 0; i < data->len; i++) { - tracker_sparql_connection_update_async (connection, - queries[i], - 0, NULL, - async_update_callback, - data); - } - - g_main_loop_run (main_loop); - - g_slice_free (AsyncData, data); - g_main_loop_unref (main_loop); - -} - - -gint -main (gint argc, gchar **argv) -{ - GTimer *array_t, *update_t; - - connection = tracker_sparql_connection_get (NULL, NULL); - - g_print ("First run (first update then array)\n"); - - tracker_sparql_connection_update (connection, - "DELETE { ?r a rdfs:Resource } WHERE { ?r nie:title '" TEST_STR "' }", - 0, NULL, NULL); - - update_t = g_timer_new (); - test_tracker_sparql_update_async (); - g_timer_stop (update_t); - - tracker_sparql_connection_update (connection, - "DELETE { ?r a rdfs:Resource } WHERE { ?r nie:title '" TEST_STR "' }", - 0, NULL, NULL); - - array_t = g_timer_new (); - test_tracker_sparql_update_array_async (); - g_timer_stop (array_t); - - tracker_sparql_connection_update (connection, - "DELETE { ?r a rdfs:Resource } WHERE { ?r nie:title '" TEST_STR "' }", - 0, NULL, NULL); - - g_print ("Array: %f, Update: %f\n", g_timer_elapsed (array_t, NULL), g_timer_elapsed (update_t, NULL)); - - g_print ("Reversing run (first array then update)\n"); - - g_timer_destroy (array_t); - g_timer_destroy (update_t); - - array_t = g_timer_new (); - test_tracker_sparql_update_array_async (); - g_timer_stop (array_t); - - tracker_sparql_connection_update (connection, - "DELETE { ?r a rdfs:Resource } WHERE { ?r nie:title '" TEST_STR "' }", - 0, NULL, NULL); - - update_t = g_timer_new (); - test_tracker_sparql_update_async (); - g_timer_stop (update_t); - - tracker_sparql_connection_update (connection, - "DELETE { ?r a rdfs:Resource } WHERE { ?r nie:title '" TEST_STR "' }", - 0, NULL, NULL); - - g_print ("Array: %f, Update: %f\n", g_timer_elapsed (array_t, NULL), g_timer_elapsed (update_t, NULL)); - - g_timer_destroy (array_t); - g_timer_destroy (update_t); - g_object_unref (connection); - - return 0; -} |