tracker r1996 - in branches/indexer-split: . src/libtracker-common tests/libtracker-common
- From: ifrade svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r1996 - in branches/indexer-split: . src/libtracker-common tests/libtracker-common
- Date: Mon, 4 Aug 2008 15:54:00 +0000 (UTC)
Author: ifrade
Date: Mon Aug 4 15:54:00 2008
New Revision: 1996
URL: http://svn.gnome.org/viewvc/tracker?rev=1996&view=rev
Log:
tracker_dbus_request_failed now can log the errors setted by the indexer
Modified:
branches/indexer-split/ChangeLog
branches/indexer-split/src/libtracker-common/tracker-dbus.c
branches/indexer-split/tests/libtracker-common/tracker-dbus-test.c
Modified: branches/indexer-split/src/libtracker-common/tracker-dbus.c
==============================================================================
--- branches/indexer-split/src/libtracker-common/tracker-dbus.c (original)
+++ branches/indexer-split/src/libtracker-common/tracker-dbus.c Mon Aug 4 15:54:00 2008
@@ -294,11 +294,18 @@
request_handler_call_for_done (request_id);
- va_start (args, format);
- str = g_strdup_vprintf (format, args);
- va_end (args);
-
- g_set_error (error, TRACKER_DBUS_ERROR, 0, str);
+ if (format) {
+ va_start (args, format);
+ str = g_strdup_vprintf (format, args);
+ va_end (args);
+
+ g_set_error (error, TRACKER_DBUS_ERROR, 0, str);
+
+ } else if (*error != NULL) {
+ str = g_strdup ((*error)->message);
+ } else {
+ g_critical ("Unset error and no error message.");
+ }
g_message ("---> [%d] Failed, %s",
request_id,
Modified: branches/indexer-split/tests/libtracker-common/tracker-dbus-test.c
==============================================================================
--- branches/indexer-split/tests/libtracker-common/tracker-dbus-test.c (original)
+++ branches/indexer-split/tests/libtracker-common/tracker-dbus-test.c Mon Aug 4 15:54:00 2008
@@ -127,6 +127,41 @@
g_assert (array == NULL);
}
+static void
+test_dbus_request_failed (void)
+{
+ GError *error = NULL;
+
+ /* Default case: we set the error */
+ if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) {
+ tracker_dbus_request_failed (1, &error, "Test Error message");
+ }
+ g_test_trap_assert_stderr ("*Test Error message*");
+
+ /* Second common case: we have already the error and want only the log line */
+ error = g_error_new (1000, -1, "The indexer founded an error");
+ if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) {
+ tracker_dbus_request_failed (1, &error, NULL);
+ }
+ g_test_trap_assert_stderr ("*The indexer founded an error*");
+ g_error_free (error);
+
+
+ /* Wrong use: error set and we add a new message */
+ error = g_error_new (1000, -1, "The indexer founded an error");
+ if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) {
+ tracker_dbus_request_failed (1, &error, "Dont do this");
+ }
+ g_test_trap_assert_stderr ("*GError set over the top of a previous GError or uninitialized memory*");
+ g_error_free (error);
+
+ error = NULL;
+ /* Wrong use: no error, no message */
+ if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) {
+ tracker_dbus_request_failed (1, &error, NULL);
+ }
+ g_test_trap_assert_stderr ("*Unset error and no error message*");
+}
int
main (int argc, char **argv) {
@@ -142,6 +177,7 @@
g_test_add_func ("/libtracker-common/tracker-dbus/async_queue_to_strv_ok", test_async_queue_to_strv);
g_test_add_func ("/libtracker-common/tracker-dbus/async_queue_to_strv_nonutf8", test_async_queue_to_strv_nonutf8);
g_test_add_func ("/libtracker-common/tracker-dbus/free_ptr_array", test_results_ptr_array_free);
+ g_test_add_func ("/libtracker-common/tracker-dbus/dbus_request_failed", test_dbus_request_failed);
result = g_test_run ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]