[tracker/deprecated-g-test-trap-fork] tests: Removed all cases of g_test_trap_fork() which has been deprecated.
- From: Martyn James Russell <mr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/deprecated-g-test-trap-fork] tests: Removed all cases of g_test_trap_fork() which has been deprecated.
- Date: Fri, 17 Jan 2014 18:54:37 +0000 (UTC)
commit 4d206f76aae4a543057124c98793d0e815cdb6d7
Author: Martyn Russell <martyn lanedo com>
Date: Fri Jan 17 18:17:05 2014 +0000
tests: Removed all cases of g_test_trap_fork() which has been deprecated.
Now we're using g_test_trap_subprocess() instead and that requires GLib 2.38.
Tracker now depends on GLib 2.38.
configure.ac | 2 +-
tests/libtracker-common/tracker-date-time-test.c | 23 ++-
tests/libtracker-common/tracker-dbus-test.c | 286 +++++----------------
tests/libtracker-common/tracker-type-utils-test.c | 125 ++++++----
tests/libtracker-extract/tracker-test-utils.c | 29 ++-
tests/libtracker-extract/tracker-test-xmp.c | 29 ++-
tests/libtracker-sparql/tracker-test.c | 63 ++++-
tests/tracker-steroids/tracker-test.c | 27 ++-
8 files changed, 282 insertions(+), 302 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 5c3730b..a8d3175 100644
--- a/configure.ac
+++ b/configure.ac
@@ -162,7 +162,7 @@ PYTHON_REQUIRED=2.6
# Library required versions
DBUS_REQUIRED=1.3.1
-GLIB_REQUIRED=2.35.1
+GLIB_REQUIRED=2.38.0
PANGO_REQUIRED=1.0.0
GTK_REQUIRED=3.0.0
LIBXML2_REQUIRED=2.6
diff --git a/tests/libtracker-common/tracker-date-time-test.c
b/tests/libtracker-common/tracker-date-time-test.c
index d1b34b2..81ae1d7 100644
--- a/tests/libtracker-common/tracker-date-time-test.c
+++ b/tests/libtracker-common/tracker-date-time-test.c
@@ -33,6 +33,20 @@
#endif
static void
+test_string_to_date_failures_subprocess ()
+{
+ tracker_string_to_date (NULL, NULL, NULL);
+}
+
+static void
+test_string_to_date_failures ()
+{
+ g_test_trap_subprocess ("/libtracker-common/date-time/string_to_date_failures/subprocess", 0, 0);
+ g_test_trap_assert_failed ();
+ g_test_trap_assert_stderr ("*'date_string' failed*");
+}
+
+static void
test_string_to_date (void)
{
GDate *expected;
@@ -69,11 +83,6 @@ test_string_to_date (void)
g_assert_cmpint (g_date_get_day (expected), ==, g_date_get_day (result));
g_assert_cmpint (g_date_get_month (expected), ==, g_date_get_month (result));
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) {
- result_time_t = tracker_string_to_date (NULL, NULL, NULL);
- }
- g_test_trap_assert_failed ();
-
result_time_t = tracker_string_to_date ("", NULL, &error);
g_assert_cmpint (result_time_t, ==, -1);
g_assert_error (error, TRACKER_DATE_ERROR, TRACKER_DATE_ERROR_INVALID_ISO8601);
@@ -231,6 +240,10 @@ main (gint argc, gchar **argv)
test_date_to_string);
g_test_add_func ("/libtracker-common/date-time/string_to_date",
test_string_to_date);
+ g_test_add_func ("/libtracker-common/date-time/string_to_date_failures",
+ test_string_to_date_failures);
+ g_test_add_func ("/libtracker-common/date-time/string_to_date_failures/subprocess",
+ test_string_to_date_failures_subprocess);
g_test_add_func ("/libtracker-common/date-time/get_set",
test_date_time_get_set);
g_test_add_func ("/libtracker-common/date-time/from_string",
diff --git a/tests/libtracker-common/tracker-dbus-test.c b/tests/libtracker-common/tracker-dbus-test.c
index 8a6299a..e9f2535 100644
--- a/tests/libtracker-common/tracker-dbus-test.c
+++ b/tests/libtracker-common/tracker-dbus-test.c
@@ -43,13 +43,12 @@ log_handler (const gchar *domain,
g_print ("%s\n", message);
}
-static void
-slist_to_strv (gboolean utf8)
+static inline GSList *
+slist_to_strv_get_source (gint strings,
+ gboolean utf8)
{
GSList *input = NULL;
- gint i;
- gchar **input_as_strv;
- gint strings = 5;
+ gint i;
for (i = 0; i < strings; i++) {
if (utf8) {
@@ -58,261 +57,105 @@ slist_to_strv (gboolean utf8)
input = g_slist_prepend (input, g_strdup (tracker_test_helpers_get_nonutf8 ()));
}
}
- g_assert_cmpint (g_slist_length (input), ==, strings);
-
- if (utf8) {
- input_as_strv = tracker_dbus_slist_to_strv (input);
-
- g_assert_cmpint (g_strv_length (input_as_strv), ==, (utf8 ? strings : 0));
- g_strfreev (input_as_strv);
- } else {
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) {
- g_log_set_default_handler (log_handler, NULL);
- input_as_strv = tracker_dbus_slist_to_strv (input);
- g_strfreev (input_as_strv);
- }
- /* Error message:
- * Could not add string:'/invalid/file/\xe4\xf6\xe590808.' to GStrv, invalid UTF-8
- */
- g_test_trap_assert_stderr ("*Could not add string:*");
- }
- g_slist_foreach (input, (GFunc) g_free, NULL);
- g_slist_free (input);
+ return input;
}
static void
-test_slist_to_strv (void)
+test_slist_to_strv_failures_subprocess (void)
{
- slist_to_strv (TRUE);
-}
-
-#if 0
+ GSList *input;
+ gchar **input_as_strv;
-static void
-test_slist_to_strv_nonutf8 (void)
-{
- slist_to_strv (FALSE);
-}
+ input = slist_to_strv_get_source (5, FALSE);
-#endif
+ g_log_set_default_handler (log_handler, NULL);
+ input_as_strv = tracker_dbus_slist_to_strv (input);
+ g_assert_cmpint (g_strv_length (input_as_strv), ==, 0);
+ g_strfreev (input_as_strv);
-#if 0
+ g_slist_foreach (input, (GFunc) g_free, NULL);
+ g_slist_free (input);
+}
static void
-test_async_queue_to_strv_nonutf8 (void)
+test_slist_to_strv_failures (void)
{
- async_queue_to_strv (FALSE);
-}
+ g_test_trap_subprocess ("/libtracker-common/tracker-dbus/slist_to_strv_failures/subprocess", 0, 0);
-#endif
+ /* Error message:
+ * Could not add string:'/invalid/file/\xe4\xf6\xe590808.' to GStrv, invalid UTF-8
+ */
+ g_test_trap_assert_passed ();
+ g_test_trap_assert_stderr ("*Could not add string:*");
+}
static void
-test_dbus_request_failed (void)
+test_slist_to_strv (void)
{
- TrackerDBusRequest *request;
- GError *error = NULL;
+ GSList *input;
+ gchar **input_as_strv;
+ gint strings = 5;
- /* For some (unknown) reason, this calls don't appear in the
- * coverage evaluation. */
+ input = slist_to_strv_get_source (strings, TRUE);
+ g_assert_cmpint (g_slist_length (input), ==, strings);
- request = tracker_dbus_request_begin ("tracker-dbus-test.c",
- "%s()",
- __PRETTY_FUNCTION__);
+ input_as_strv = tracker_dbus_slist_to_strv (input);
- /* 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)) {
- g_log_set_default_handler (log_handler, NULL);
- tracker_dbus_request_end (request, error);
- }
+ g_assert_cmpint (g_strv_length (input_as_strv), ==, strings);
+ g_strfreev (input_as_strv);
- g_test_trap_assert_stderr ("*The indexer founded an error*");
- g_error_free (error);
+ g_slist_foreach (input, (GFunc) g_free, NULL);
+ g_slist_free (input);
}
static void
-test_dbus_request ()
+test_dbus_request_subprocess (void)
{
TrackerDBusRequest *request;
+ GError *error = NULL;
tracker_dbus_enable_client_lookup (FALSE);
- /* Checking the logging output */
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT)) {
- g_log_set_default_handler (log_handler, NULL);
- request = tracker_dbus_request_begin ("tracker-dbus-test.c",
- "Test request (%s))",
- "--TestNewOK--");
- exit (0);
- }
-
- g_test_trap_assert_passed ();
- g_test_trap_assert_stdout ("*TestNewOK*");
+ g_log_set_default_handler (log_handler, NULL);
+ /* New request case */
request = tracker_dbus_request_begin ("tracker-dbus-test.c",
"Test request (%s))",
"--TestNewOK--");
+ tracker_dbus_request_end (request, NULL);
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) {
- g_log_set_default_handler (log_handler, NULL);
- tracker_dbus_request_comment (request,
- "Well (%s)",
- "--TestCommentOK--");
- exit (0);
- }
-
- g_test_trap_assert_passed ();
- g_test_trap_assert_stderr ("*TestCommentOK*");
-
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT)) {
- g_log_set_default_handler (log_handler, NULL);
- tracker_dbus_request_end (request, NULL);
- exit (0);
- }
-
- g_test_trap_assert_passed ();
- g_test_trap_assert_stdout ("*Success*");
-}
-#if 0
-static void
-test_dbus_request_client_lookup ()
-{
- TrackerDBusRequest *request;
-
- tracker_dbus_enable_client_lookup (TRUE);
-
-
- /* Checking the logging output */
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT)) {
- g_log_set_default_handler (log_handler, NULL);
- request = tracker_dbus_request_begin ("tracker-dbus-test.c",
- "Test request (%s))",
- "--TestNewOK--");
- exit (0);
- }
-
- g_test_trap_assert_passed ();
- g_test_trap_assert_stdout ("*TestNewOK*");
- g_test_trap_assert_stdout ("*lt-tracker-dbus*");
-
+ /* Comment and success case */
request = tracker_dbus_request_begin ("tracker-dbus-test.c",
"Test request (%s))",
"--TestNewOK--");
+ tracker_dbus_request_comment (request,
+ "Well (%s)",
+ "--TestCommentOK--");
+ tracker_dbus_request_end (request, NULL);
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) {
- g_log_set_default_handler (log_handler, NULL);
- tracker_dbus_request_comment (request,
- "Well (%s)",
- "--TestCommentOK--");
- exit (0);
- }
-
- g_test_trap_assert_passed ();
- g_test_trap_assert_stderr ("*TestCommentOK*");
-
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT)) {
- g_log_set_default_handler (log_handler, NULL);
- tracker_dbus_request_info (request,
- "Test info %s",
- "--TestInfoOK--");
- exit (0);
- }
-
- g_test_trap_assert_passed ();
- g_test_trap_assert_stdout ("*TestInfoOK*");
-
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT)) {
- g_log_set_default_handler (log_handler, NULL);
- tracker_dbus_request_debug (request,
- "Test debug %s",
- "--TestDebugOK--");
- exit (0);
- }
-
- g_test_trap_assert_passed ();
- g_test_trap_assert_stdout ("*TestDebugOK*");
-
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT)) {
- g_log_set_default_handler (log_handler, NULL);
- tracker_dbus_request_end (request, NULL);
- exit (0);
- }
-
- g_test_trap_assert_passed ();
- g_test_trap_assert_stdout ("*Success*");
-
- /* Force client shutdown */
- tracker_dbus_enable_client_lookup (FALSE);
-}
-
-static void
-test_dbus_request_client_lookup_monothread ()
-{
- /* Run everything in the same fork to check the clients_shutdown code */
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR)) {
- TrackerDBusRequest *request;
-
- g_log_set_default_handler (log_handler, NULL);
-
- tracker_dbus_enable_client_lookup (TRUE);
- request = tracker_dbus_request_begin ("tracker-dbus-test.c",
- "Test request (%s))",
- "--TestNewOK--");
- tracker_dbus_request_comment (request,
- "Well (%s)",
- "--TestCommentOK--");
-/*
- tracker_dbus_request_end (request, NULL,
- "--TestFailedOK--");
- tracker_quark = tracker_dbus_error_quark ();
- error = g_error_new (tracker_quark, -1, "test_using_g_error");
- tracker_dbus_request_end (tracker_quark, error);
-*/
-
- tracker_dbus_request_end (request, NULL);
- /* Force client shutdown */
- tracker_dbus_enable_client_lookup (FALSE);
- exit (0);
- }
+ /* Error case */
+ request = tracker_dbus_request_begin ("tracker-dbus-test.c",
+ "%s()",
+ __PRETTY_FUNCTION__);
- g_test_trap_assert_passed ();
+ error = g_error_new (1000, -1, "The indexer founded an error");
+ tracker_dbus_request_end (request, error);
+ g_error_free (error);
}
static void
-test_dbus_request_failed_coverage ()
+test_dbus_request (void)
{
- /* Repeat the failed test case in one thread to get coverage */
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR)) {
- GQuark tracker_quark;
- GError *error = NULL;
- TrackerDBusRequest *request;
-
- g_log_set_default_handler (log_handler, NULL);
-
- tracker_dbus_enable_client_lookup (TRUE);
-
- /* Using GError */
- request = tracker_dbus_request_begin ("tracker-dbus-test.c",
- "Test request (%s))",
- "--TestNewOK--");
- tracker_quark = tracker_dbus_error_quark ();
- error = g_error_new (tracker_quark, -1, "test_using_g_error");
- tracker_dbus_request_end (request, error);
-
- request = tracker_dbus_request_begin ("tracker-dbus-test.c",
- "Test request (%s))",
- "--TestNewOK--");
- tracker_dbus_request_end (request, NULL);
-
- /* Force client shutdown */
- tracker_dbus_enable_client_lookup (FALSE);
- exit (0);
- }
+ /* Checking the logging output */
+ g_test_trap_subprocess ("/libtracker-common/tracker-dbus/request/subprocess", 0, 0);
g_test_trap_assert_passed ();
+ g_test_trap_assert_stdout ("*TestNewOK*");
+ g_test_trap_assert_stderr ("*TestCommentOK*");
+ g_test_trap_assert_stdout ("*Success*");
+ g_test_trap_assert_stderr ("*The indexer founded an error*");
}
-#endif
int
main (int argc, char **argv) {
@@ -332,18 +175,21 @@ main (int argc, char **argv) {
g_test_add_func ("/libtracker-common/tracker-dbus/slist_to_strv_ok",
test_slist_to_strv);
+ g_test_add_func ("/libtracker-common/tracker-dbus/slist_to_strv_failures",
+ test_slist_to_strv_failures);
+ g_test_add_func ("/libtracker-common/tracker-dbus/slist_to_strv_failures/subprocess",
+ test_slist_to_strv_failures_subprocess);
g_test_add_func ("/libtracker-common/tracker-dbus/request",
test_dbus_request);
+ g_test_add_func ("/libtracker-common/tracker-dbus/request/subprocess",
+ test_dbus_request_subprocess);
/* port to gdbus first
g_test_add_func ("/libtracker-common/tracker-dbus/request-client-lookup",
test_dbus_request_client_lookup);
g_test_add_func ("/libtracker-common/tracker-dbus/request-client-lookup",
test_dbus_request_client_lookup_monothread);
-*/
- g_test_add_func ("/libtracker-common/tracker-dbus/request_failed",
- test_dbus_request_failed);
-/* g_test_add_func ("/libtracker-common/tracker-dbus/request_failed_coverage",
+ g_test_add_func ("/libtracker-common/tracker-dbus/request_failed_coverage",
test_dbus_request_failed_coverage);
*/
result = g_test_run ();
diff --git a/tests/libtracker-common/tracker-type-utils-test.c
b/tests/libtracker-common/tracker-type-utils-test.c
index 4eef837..1f9559b 100644
--- a/tests/libtracker-common/tracker-type-utils-test.c
+++ b/tests/libtracker-common/tracker-type-utils-test.c
@@ -103,6 +103,32 @@ test_guint32_to_string (void)
}
static void
+test_string_to_uint_failures_subprocess_1 (void)
+{
+ guint num = 10;
+
+ tracker_string_to_uint (NULL, &num);
+}
+
+static void
+test_string_to_uint_failures_subprocess_2 (void)
+{
+ tracker_string_to_uint ("199", NULL);
+}
+
+static void
+test_string_to_uint_failures (void)
+{
+ g_test_trap_subprocess ("/libtracker-common/tracker-type-utils/string_to_uint_failures/subprocess/1",
0, 0);
+ g_test_trap_assert_failed ();
+ g_test_trap_assert_stderr ("*assertion 's != NULL' failed*");
+
+ g_test_trap_subprocess ("/libtracker-common/tracker-type-utils/string_to_uint_failures/subprocess/2",
0, 0);
+ g_test_trap_assert_failed ();
+ g_test_trap_assert_stderr ("*assertion 'value != NULL' failed*");
+}
+
+static void
test_string_to_uint (void)
{
guint num_result, rc;
@@ -112,28 +138,31 @@ test_string_to_uint (void)
g_assert (rc);
g_assert_cmpint (num_result, ==, 10);
+ rc = tracker_string_to_uint ("i am not a number", &num_result);
+ g_assert (!rc);
+ g_assert_cmpint (rc, ==, 0);
+}
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) {
- rc = tracker_string_to_uint (NULL, &num_result);
- }
- g_test_trap_assert_failed ();
+static void
+test_string_in_string_list_failures_subprocess (void)
+{
+ const gchar *complete = "This is an extract of text with different terms an props like Audio:Title
...";
+ gchar **pieces;
- /* ???? FIXME */
- rc = tracker_string_to_uint ("-20", &num_result);
+ pieces = g_strsplit (complete, " ", -1);
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) {
- tracker_string_to_uint (NULL, &num_result);
- }
- g_test_trap_assert_failed ();
+ g_assert_cmpint (tracker_string_in_string_list (NULL, pieces), ==, -1);
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) {
- tracker_string_to_uint ("199", NULL);
- }
- g_test_trap_assert_failed ();
+ g_strfreev (pieces);
+}
- rc = tracker_string_to_uint ("i am not a number", &num_result);
- g_assert (!rc);
- g_assert_cmpint (rc, ==, 0);
+static void
+test_string_in_string_list_failures (void)
+{
+
+ g_test_trap_subprocess
("/libtracker-common/tracker-type-utils/string_in_string_list_failures/subprocess", 0, 0);
+ g_test_trap_assert_failed ();
+ g_test_trap_assert_stderr ("*assertion 'str != NULL' failed*");
}
static void
@@ -147,15 +176,7 @@ test_string_in_string_list (void)
g_assert_cmpint (tracker_string_in_string_list ("is", pieces), ==, 1);
g_assert_cmpint (tracker_string_in_string_list ("Audio:Title", pieces), ==, 12);
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) {
- g_assert_cmpint (tracker_string_in_string_list (NULL, pieces), ==, -1);
- }
- g_test_trap_assert_failed ();
-
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) {
- g_assert_cmpint (tracker_string_in_string_list ("terms", NULL), ==, -1);
- }
- g_test_trap_assert_failed ();
+ g_assert_cmpint (tracker_string_in_string_list ("terms", NULL), ==, -1);
}
static void
@@ -198,12 +219,9 @@ test_gslist_to_string_list (void)
g_strfreev (result);
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) {
- result = tracker_gslist_to_string_list (NULL);
- g_strfreev (result);
- }
-
- g_test_trap_assert_failed ();
+ result = tracker_gslist_to_string_list (NULL);
+ g_assert (result != NULL);
+ g_strfreev (result);
}
static void
@@ -253,12 +271,8 @@ test_string_list_to_string (void)
g_assert_cmpstr ("one_two_three", ==, result);
g_free (result);
-
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) {
- result = tracker_string_list_to_string (NULL, 6, 'x');
- g_free (result);
- }
- g_test_trap_assert_failed ();
+ result = tracker_string_list_to_string (NULL, 6, 'x');
+ g_assert (result == NULL);
result = tracker_string_list_to_string (pieces, -1, ' ');
g_assert_cmpstr (input, ==, result);
@@ -283,6 +297,20 @@ test_string_to_string_list (void)
}
static void
+test_boolean_as_text_to_number_failures_subprocess (void)
+{
+ tracker_string_boolean_to_string_gint (NULL);
+}
+
+static void
+test_boolean_as_text_to_number_failures (void)
+{
+ g_test_trap_subprocess
("/libtracker-common/tracker-type-utils/boolean_as_text_to_number_failures/subprocess", 0, 0);
+ g_test_trap_assert_failed ();
+ g_test_trap_assert_stderr ("*assertion 'value != NULL' failed*");
+}
+
+static void
test_boolean_as_text_to_number (void)
{
gchar *result;
@@ -326,13 +354,6 @@ test_boolean_as_text_to_number (void)
result = tracker_string_boolean_to_string_gint ("Other invalid value");
g_assert_cmpstr (result, ==, "Other invalid value");
g_free (result);
-
-
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) {
- result = tracker_string_boolean_to_string_gint (NULL);
- g_free (result);
- }
- g_test_trap_assert_failed ();
}
static void
@@ -401,6 +422,10 @@ main (int argc, char **argv)
g_test_add_func ("/libtracker-common/tracker-type-utils/boolean_as_text_to_number",
test_boolean_as_text_to_number);
+ g_test_add_func ("/libtracker-common/tracker-type-utils/boolean_as_text_to_number_failures",
+ test_boolean_as_text_to_number_failures);
+ g_test_add_func
("/libtracker-common/tracker-type-utils/boolean_as_text_to_number_failures/subprocess",
+ test_boolean_as_text_to_number_failures_subprocess);
g_test_add_func ("/libtracker-common/tracker-type-utils/string_list_as_list",
test_string_list_to_string);
g_test_add_func ("/libtracker-common/tracker-type-utils/string_list_as_list",
@@ -409,12 +434,22 @@ main (int argc, char **argv)
test_gslist_to_string_list);
g_test_add_func ("/libtracker-common/tracker-type-utils/string_in_string_list",
test_string_in_string_list);
+ g_test_add_func ("/libtracker-common/tracker-type-utils/string_in_string_list_failures",
+ test_string_in_string_list_failures);
+ g_test_add_func ("/libtracker-common/tracker-type-utils/string_in_string_list_failures/subprocess",
+ test_string_in_string_list_failures_subprocess);
g_test_add_func ("/libtracker-common/tracker-type-utils/string_in_gslist",
test_string_in_gslist);
g_test_add_func ("/libtracker-common/tracker-type-utils/string_list_to_gslist",
test_string_list_to_gslist);
g_test_add_func ("/libtracker-common/tracker-type-utils/string_to_uint",
test_string_to_uint);
+ g_test_add_func ("/libtracker-common/tracker-type-utils/string_to_uint_failures",
+ test_string_to_uint_failures);
+ g_test_add_func ("/libtracker-common/tracker-type-utils/string_to_uint_failures/subprocess/1",
+ test_string_to_uint_failures_subprocess_1);
+ g_test_add_func ("/libtracker-common/tracker-type-utils/string_to_uint_failures/subprocess/2",
+ test_string_to_uint_failures_subprocess_2);
g_test_add_func ("/libtracker-common/tracker-type-utils/guint32_to_string",
test_guint32_to_string);
g_test_add_func ("/libtracker-common/tracker-type-utils/gint32_to_string",
diff --git a/tests/libtracker-extract/tracker-test-utils.c b/tests/libtracker-extract/tracker-test-utils.c
index 0839ab9..fce4643 100644
--- a/tests/libtracker-extract/tracker-test-utils.c
+++ b/tests/libtracker-extract/tracker-test-utils.c
@@ -29,6 +29,24 @@
#include <libtracker-extract/tracker-extract.h>
static void
+test_guess_date_failures_subprocess ()
+{
+ gchar *result;
+
+ result = tracker_date_guess (NULL);
+ g_free (result);
+}
+
+static void
+test_guess_date_failures ()
+{
+ g_test_trap_subprocess ("/libtracker-extract/tracker-utils/guess_date_failures/subprocess", 0,
G_TEST_SUBPROCESS_INHERIT_STDERR);
+ g_test_trap_assert_passed ();
+
+ /* Should be NO output when using NULL with tracker_date_guess() */
+}
+
+static void
test_guess_date (void)
{
gchar *result;
@@ -83,13 +101,6 @@ test_guess_date (void)
result = tracker_date_guess ("2010-03-18T01:02:03.100");
g_assert_cmpstr (result, ==, "2010-03-18T01:02:03.100");
g_free (result);
-
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) {
- result = tracker_date_guess (NULL);
- g_free (result);
- }
-
- g_test_trap_assert_failed ();
}
static void
@@ -274,6 +285,10 @@ main (int argc, char **argv)
g_test_add_func ("/libtracker-extract/tracker-utils/guess_date",
test_guess_date);
+ g_test_add_func ("/libtracker-extract/tracker-utils/guess_date_failures",
+ test_guess_date_failures);
+ g_test_add_func ("/libtracker-extract/tracker-utils/guess_date_failures/subprocess",
+ test_guess_date_failures_subprocess);
g_test_add_func ("/libtracker-extract/tracker-utils/text-validate-utf8",
test_text_validate_utf8);
g_test_add_func ("/libtracker-extract/tracker-utils/date_to_iso8601",
diff --git a/tests/libtracker-extract/tracker-test-xmp.c b/tests/libtracker-extract/tracker-test-xmp.c
index 89148fb..d8a2708 100644
--- a/tests/libtracker-extract/tracker-test-xmp.c
+++ b/tests/libtracker-extract/tracker-test-xmp.c
@@ -180,19 +180,29 @@ get_example_expected (void)
};
static void
-test_parsing_xmp (void)
+test_parsing_xmp_invalid_file_subprocess (void)
{
TrackerXmpData *data;
- TrackerXmpData *expected;
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) {
- data = tracker_xmp_new (BROKEN_XMP, strlen (BROKEN_XMP), "test://file");
- g_assert (data != NULL);
+ data = tracker_xmp_new (BROKEN_XMP, strlen (BROKEN_XMP), "test://file");
+ g_assert (data != NULL);
- tracker_xmp_free (data);
- }
+ tracker_xmp_free (data);
+}
+static void
+test_parsing_xmp_invalid_file (void)
+{
+ g_test_trap_subprocess ("/libtracker-extract/tracker-xmp/parsing_xmp_invalid_file/subprocess", 0, 0);
+ g_test_trap_assert_passed ();
g_test_trap_assert_stderr ("*parsing failure*");
+}
+
+static void
+test_parsing_xmp (void)
+{
+ TrackerXmpData *data;
+ TrackerXmpData *expected;
data = tracker_xmp_new (EXAMPLE_XMP, strlen (EXAMPLE_XMP), "test://file");
expected = get_example_expected ();
@@ -606,6 +616,11 @@ main (int argc,
g_test_add_func ("/libtracker-extract/tracker-xmp/parsing_xmp",
test_parsing_xmp);
+ g_test_add_func ("/libtracker-extract/tracker-xmp/parsing_xmp_invalid_file",
+ test_parsing_xmp_invalid_file);
+ g_test_add_func ("/libtracker-extract/tracker-xmp/parsing_xmp_invalid_file/subprocess",
+ test_parsing_xmp_invalid_file_subprocess);
+
g_test_add_func ("/libtracker-extract/tracker-xmp/metering-mode",
test_xmp_metering_mode);
diff --git a/tests/libtracker-sparql/tracker-test.c b/tests/libtracker-sparql/tracker-test.c
index ee0dbad..5784fb4 100644
--- a/tests/libtracker-sparql/tracker-test.c
+++ b/tests/libtracker-sparql/tracker-test.c
@@ -21,6 +21,8 @@
#include <locale.h>
+#include <glib-object.h>
+
#include <libtracker-sparql/tracker-sparql.h>
typedef struct {
@@ -295,31 +297,64 @@ test_tracker_sparql_nb237150_cb (GObject *source_object,
GAsyncResult *result,
gpointer user_data)
{
+ TrackerSparqlConnection *connection;
+ GError *error = NULL;
+ static gboolean had_1 = FALSE;
+ static gboolean had_2 = FALSE;
+
+ connection = tracker_sparql_connection_get_finish (result, &error);
+ g_assert_no_error (error);
+ g_assert (connection != NULL);
+
/* Not actually worried about this being called */
g_print ("Called back for #%d\n", GPOINTER_TO_INT(user_data));
+
+ if (GPOINTER_TO_INT(user_data) == 1)
+ had_1 = TRUE;
+ if (GPOINTER_TO_INT(user_data) == 2)
+ had_2 = TRUE;
+
+ if (had_1 && had_2) {
+ g_print ("Called back ALL\n");
+ g_main_loop_quit (main_loop);
+ }
}
static void
-test_tracker_sparql_nb237150 (void)
+test_tracker_sparql_nb237150_subprocess (void)
{
- /* Test NB#237150 - Second tracker_sparql_connection_get_async never returns */
- if (g_test_trap_fork (G_USEC_PER_SEC * 2, G_TEST_TRAP_SILENCE_STDOUT)) {
- g_print ("\n");
- g_print ("Calling #1 - tracker_sparql_connection_get_async()\n");
- tracker_sparql_connection_get_async (NULL, test_tracker_sparql_nb237150_cb,
GINT_TO_POINTER(1));
+ g_print ("\n");
+ g_print ("Calling #1 - tracker_sparql_connection_get_async()\n");
+ tracker_sparql_connection_get_async (NULL, test_tracker_sparql_nb237150_cb, GINT_TO_POINTER(1));
- g_print ("Calling #2 - tracker_sparql_connection_get_async()\n");
- tracker_sparql_connection_get_async (NULL, test_tracker_sparql_nb237150_cb,
GINT_TO_POINTER(2));
+ g_print ("Calling #2 - tracker_sparql_connection_get_async()\n");
+ tracker_sparql_connection_get_async (NULL, test_tracker_sparql_nb237150_cb, GINT_TO_POINTER(2));
- g_print ("Calling both finished\n");
+ g_print ("Calling both finished\n");
+}
- exit (0); /* successful test run */
- }
+static void
+test_tracker_sparql_nb237150 (void)
+{
+ /* Test NB#237150 - Second tracker_sparql_connection_get_async
+ * never returns
+ */
+ g_test_trap_subprocess ("/libtracker-sparql/tracker/nb237150/subprocess",
+ G_USEC_PER_SEC * 2,
+ G_TEST_SUBPROCESS_INHERIT_STDOUT);
g_test_trap_assert_passed ();
+
+ /* Check we called the functions in the test */
g_test_trap_assert_stdout ("*Calling #1*");
g_test_trap_assert_stdout ("*Calling #2*");
g_test_trap_assert_stdout ("*Calling both finished*");
+
+ /* Check the callbacks from the functions we called were
+ * called in the test */
+ g_test_trap_assert_stdout ("*Called back for #1*");
+ g_test_trap_assert_stdout ("*Called back for #2*");
+ g_test_trap_assert_stdout ("*Called back ALL*");
}
static void
@@ -371,9 +406,11 @@ main (gint argc, gchar **argv)
/* NOTE: this first test must come BEFORE any others because
* connections are cached by libtracker-sparql.
*/
- g_test_add_func ("/libtracker-sparql/tracker/test_tracker_sparql_nb237150",
+ g_test_add_func ("/libtracker-sparql/tracker/nb237150",
test_tracker_sparql_nb237150);
- g_test_add_func ("/libtracker-sparql/tracker/tracker_sparql_escape_string",
+ g_test_add_func ("/libtracker-sparql/tracker/nb237150/subprocess",
+ test_tracker_sparql_nb237150_subprocess);
+ g_test_add_func ("/libtracker-sparql/tracker/tracker_sparql_escape_string",
test_tracker_sparql_escape_string);
g_test_add_func ("/libtracker-sparql/tracker/tracker_sparql_escape_uri_vprintf",
test_tracker_sparql_escape_uri_vprintf);
diff --git a/tests/tracker-steroids/tracker-test.c b/tests/tracker-steroids/tracker-test.c
index b246c4a..8eada53 100644
--- a/tests/tracker-steroids/tracker-test.c
+++ b/tests/tracker-steroids/tracker-test.c
@@ -209,6 +209,26 @@ test_tracker_sparql_query_iterate_error ()
/* Runs a query returning an empty set */
static void
+test_tracker_sparql_query_iterate_empty_subprocess ()
+{
+ TrackerSparqlCursor *cursor;
+ GError *error = NULL;
+ const gchar *query = "SELECT ?r WHERE {?r a nfo:FileDataObject; nao:identifier
\"thisannotationdoesnotexist\"}";
+
+ cursor = tracker_sparql_connection_query (connection, query, NULL, &error);
+
+ tracker_sparql_cursor_next (cursor, NULL, NULL);
+
+ /* Testing we fail with this error:
+ *
+ * Tracker-CRITICAL **:
+ * tracker_bus_fd_cursor_real_get_string: assertion '(_tmp0_
+ * < _tmp2_) && (_tmp3_ != NULL)' failed
+ */
+ tracker_sparql_cursor_get_string (cursor, 0, NULL);
+}
+
+static void
test_tracker_sparql_query_iterate_empty ()
{
TrackerSparqlCursor *cursor;
@@ -224,10 +244,8 @@ test_tracker_sparql_query_iterate_empty ()
/* This should be 1, the original test had it wrong: there's one column,
* no matter if there are no results*/
g_assert (tracker_sparql_cursor_get_n_columns (cursor) == 1);
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR)) {
- tracker_sparql_cursor_get_string (cursor, 0, NULL);
- exit (0);
- }
+
+ g_test_trap_subprocess ("/steroids/tracker/tracker_sparql_query_iterate_empty/subprocess", 0, 0);
g_test_trap_assert_failed ();
g_object_unref (cursor);
@@ -675,6 +693,7 @@ main (gint argc, gchar **argv)
g_test_add_func ("/steroids/tracker/tracker_sparql_query_iterate_largerow",
test_tracker_sparql_query_iterate_largerow);
g_test_add_func ("/steroids/tracker/tracker_sparql_query_iterate_error",
test_tracker_sparql_query_iterate_error);
g_test_add_func ("/steroids/tracker/tracker_sparql_query_iterate_empty",
test_tracker_sparql_query_iterate_empty);
+ g_test_add_func ("/steroids/tracker/tracker_sparql_query_iterate_empty/subprocess",
test_tracker_sparql_query_iterate_empty_subprocess);
g_test_add_func ("/steroids/tracker/tracker_sparql_query_iterate_sigpipe",
test_tracker_sparql_query_iterate_sigpipe);
g_test_add_func ("/steroids/tracker/tracker_sparql_update_fast_small",
test_tracker_sparql_update_fast_small);
g_test_add_func ("/steroids/tracker/tracker_sparql_update_fast_large",
test_tracker_sparql_update_fast_large);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]