[glib] various tests: do not provoke SIGTRAP with -m no-undefined
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] various tests: do not provoke SIGTRAP with -m no-undefined
- Date: Tue, 27 Dec 2011 22:56:31 +0000 (UTC)
commit fa4792c35e42107e0ded0f499bb86415a2b1faef
Author: Simon McVittie <simon mcvittie collabora co uk>
Date: Wed Dec 14 18:08:59 2011 +0000
various tests: do not provoke SIGTRAP with -m no-undefined
Some of the GLib tests deliberately provoke warnings (or even fatal
errors) in a forked child. Normally, this is fine, but under valgrind
it's somewhat undesirable. We do want to follow fork(), so we can check
for leaks in child processes that exit gracefully; but we don't want to
be told about "leaks" in processes that are crashing, because there'd
be no point in cleaning those up anyway.
https://bugzilla.gnome.org/show_bug.cgi?id=666116
gio/tests/actions.c | 83 +++++++++++++---------
gio/tests/gdbus-proxy.c | 30 +++++---
gio/tests/gsettings.c | 64 ++++++++++++-----
glib/tests/error.c | 3 +
glib/tests/gvariant.c | 32 +++++----
glib/tests/logging.c | 54 +++++++++------
glib/tests/markup-collect.c | 3 +
glib/tests/mem-overflow.c | 13 +++-
glib/tests/option-context.c | 6 ++
glib/tests/slice.c | 3 +
glib/tests/strfuncs.c | 146 +++++++++++++++++++++++---------------
glib/tests/testing.c | 34 ++++++---
gobject/tests/ifaceproperties.c | 3 +
13 files changed, 305 insertions(+), 169 deletions(-)
---
diff --git a/gio/tests/actions.c b/gio/tests/actions.c
index 57fec75..53a3a8d 100644
--- a/gio/tests/actions.c
+++ b/gio/tests/actions.c
@@ -62,12 +62,15 @@ test_basic (void)
g_action_activate (G_ACTION (action), NULL);
g_assert (!a.did_run);
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
+ if (g_test_undefined ())
{
- g_action_activate (G_ACTION (action), g_variant_new_string ("xxx"));
- exit (0);
+ if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
+ {
+ g_action_activate (G_ACTION (action), g_variant_new_string ("xxx"));
+ exit (0);
+ }
+ g_test_trap_assert_failed ();
}
- g_test_trap_assert_failed ();
g_object_unref (action);
g_assert (!a.did_run);
@@ -87,13 +90,16 @@ test_basic (void)
g_variant_unref (a.params);
a.did_run = FALSE;
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
+ if (g_test_undefined ())
{
- g_action_activate (G_ACTION (action), NULL);
- exit (0);
- }
+ if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
+ {
+ g_action_activate (G_ACTION (action), NULL);
+ exit (0);
+ }
- g_test_trap_assert_failed ();
+ g_test_trap_assert_failed ();
+ }
g_object_unref (action);
g_assert (!a.did_run);
@@ -250,12 +256,15 @@ test_stateful (void)
g_assert_cmpstr (g_variant_get_string (state, NULL), ==, "hihi");
g_variant_unref (state);
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
+ if (g_test_undefined ())
{
- g_simple_action_set_state (action, g_variant_new_int32 (123));
- exit (0);
+ if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
+ {
+ g_simple_action_set_state (action, g_variant_new_int32 (123));
+ exit (0);
+ }
+ g_test_trap_assert_failed ();
}
- g_test_trap_assert_failed ();
g_simple_action_set_state (action, g_variant_new_string ("hello"));
state = g_action_get_state (G_ACTION (action));
@@ -265,12 +274,17 @@ test_stateful (void)
g_object_unref (action);
action = g_simple_action_new ("foo", NULL);
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
+
+ if (g_test_undefined ())
{
- g_simple_action_set_state (action, g_variant_new_int32 (123));
- exit (0);
+ if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
+ {
+ g_simple_action_set_state (action, g_variant_new_int32 (123));
+ exit (0);
+ }
+ g_test_trap_assert_failed ();
}
- g_test_trap_assert_failed ();
+
g_object_unref (action);
}
@@ -339,27 +353,30 @@ test_entries (void)
g_assert (bar_activated);
g_assert (!foo_activated);
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
+ if (g_test_undefined ())
{
- const GActionEntry bad_type = {
- "bad-type", NULL, "ss"
- };
+ if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
+ {
+ const GActionEntry bad_type = {
+ "bad-type", NULL, "ss"
+ };
- g_simple_action_group_add_entries (actions, &bad_type, 1, NULL);
- exit (0);
- }
- g_test_trap_assert_failed ();
+ g_simple_action_group_add_entries (actions, &bad_type, 1, NULL);
+ exit (0);
+ }
+ g_test_trap_assert_failed ();
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
- {
- const GActionEntry bad_state = {
- "bad-state", NULL, NULL, "flse"
- };
+ if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
+ {
+ const GActionEntry bad_state = {
+ "bad-state", NULL, NULL, "flse"
+ };
- g_simple_action_group_add_entries (actions, &bad_state, 1, NULL);
- exit (0);
+ g_simple_action_group_add_entries (actions, &bad_state, 1, NULL);
+ exit (0);
+ }
+ g_test_trap_assert_failed ();
}
- g_test_trap_assert_failed ();
state = g_action_group_get_action_state (G_ACTION_GROUP (actions), "volume");
g_assert_cmpint (g_variant_get_int32 (state), ==, 0);
diff --git a/gio/tests/gdbus-proxy.c b/gio/tests/gdbus-proxy.c
index 2e280fc..0b2905c 100644
--- a/gio/tests/gdbus-proxy.c
+++ b/gio/tests/gdbus-proxy.c
@@ -572,26 +572,32 @@ test_expected_interface (GDBusProxy *proxy)
test_bogus_property (proxy);
*/
- /* Also check that we complain if setting a cached property of the wrong type */
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR))
+ if (g_test_undefined ())
{
- g_dbus_proxy_set_cached_property (proxy, "y", g_variant_new_string ("error_me_out!"));
+ /* Also check that we complain if setting a cached property of the wrong type */
+ if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR))
+ {
+ g_dbus_proxy_set_cached_property (proxy, "y", g_variant_new_string ("error_me_out!"));
+ }
+ g_test_trap_assert_stderr ("*Trying to set property y of type s but according to the expected interface the type is y*");
+ g_test_trap_assert_failed();
}
- g_test_trap_assert_stderr ("*Trying to set property y of type s but according to the expected interface the type is y*");
- g_test_trap_assert_failed();
/* this should work, however (since the type is correct) */
g_dbus_proxy_set_cached_property (proxy, "y", g_variant_new_byte (42));
- /* Try to get the value of a property where the type we expect is different from
- * what we have in our cache (e.g. what the service returned)
- */
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR))
+ if (g_test_undefined ())
{
- value = g_dbus_proxy_get_cached_property (proxy, "i");
+ /* Try to get the value of a property where the type we expect is different from
+ * what we have in our cache (e.g. what the service returned)
+ */
+ if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR))
+ {
+ value = g_dbus_proxy_get_cached_property (proxy, "i");
+ }
+ g_test_trap_assert_stderr ("*Trying to get property i with type i but according to the expected interface the type is u*");
+ g_test_trap_assert_failed();
}
- g_test_trap_assert_stderr ("*Trying to get property i with type i but according to the expected interface the type is u*");
- g_test_trap_assert_failed();
/* Even if a property does not exist in expected_interface, looking it
* up, or setting it, should never fail. Because it could be that the
diff --git a/gio/tests/gsettings.c b/gio/tests/gsettings.c
index 645d487..3c42c90 100644
--- a/gio/tests/gsettings.c
+++ b/gio/tests/gsettings.c
@@ -53,7 +53,7 @@ test_basic (void)
g_free (str);
str = NULL;
- if (!backend_set)
+ if (!backend_set && g_test_undefined ())
{
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
{
@@ -85,6 +85,9 @@ test_basic (void)
static void
test_unknown_key (void)
{
+ if (!g_test_undefined ())
+ return;
+
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
{
GSettings *settings;
@@ -107,6 +110,9 @@ test_unknown_key (void)
static void
test_no_schema (void)
{
+ if (!g_test_undefined ())
+ return;
+
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
{
GSettings *settings;
@@ -126,6 +132,9 @@ test_no_schema (void)
static void
test_wrong_type (void)
{
+ if (!g_test_undefined ())
+ return;
+
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
{
GSettings *settings;
@@ -156,6 +165,9 @@ test_wrong_type (void)
static void
test_wrong_path (void)
{
+ if (!g_test_undefined ())
+ return;
+
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
{
GSettings *settings G_GNUC_UNUSED;
@@ -170,6 +182,9 @@ test_wrong_path (void)
static void
test_no_path (void)
{
+ if (!g_test_undefined ())
+ return;
+
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
{
GSettings *settings G_GNUC_UNUSED;
@@ -1233,6 +1248,9 @@ test_directional_binding (void)
static void
test_typesafe_binding (void)
{
+ if (!g_test_undefined ())
+ return;
+
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
{
TestObject *obj;
@@ -1356,18 +1374,21 @@ test_no_change_binding (void)
static void
test_no_read_binding (void)
{
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
+ if (g_test_undefined ())
{
- TestObject *obj;
- GSettings *settings;
+ if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
+ {
+ TestObject *obj;
+ GSettings *settings;
- settings = g_settings_new ("org.gtk.test.binding");
- obj = test_object_new ();
+ settings = g_settings_new ("org.gtk.test.binding");
+ obj = test_object_new ();
- g_settings_bind (settings, "string", obj, "no-read", 0);
+ g_settings_bind (settings, "string", obj, "no-read", 0);
+ }
+ g_test_trap_assert_failed ();
+ g_test_trap_assert_stderr ("*property*is not readable*");
}
- g_test_trap_assert_failed ();
- g_test_trap_assert_stderr ("*property*is not readable*");
if (g_test_trap_fork (0, 0))
{
@@ -1390,18 +1411,21 @@ test_no_read_binding (void)
static void
test_no_write_binding (void)
{
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
+ if (g_test_undefined ())
{
- TestObject *obj;
- GSettings *settings;
+ if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
+ {
+ TestObject *obj;
+ GSettings *settings;
- settings = g_settings_new ("org.gtk.test.binding");
- obj = test_object_new ();
+ settings = g_settings_new ("org.gtk.test.binding");
+ obj = test_object_new ();
- g_settings_bind (settings, "string", obj, "no-write", 0);
+ g_settings_bind (settings, "string", obj, "no-write", 0);
+ }
+ g_test_trap_assert_failed ();
+ g_test_trap_assert_stderr ("*property*is not writable*");
}
- g_test_trap_assert_failed ();
- g_test_trap_assert_stderr ("*property*is not writable*");
if (g_test_trap_fork (0, 0))
{
@@ -1562,7 +1586,7 @@ test_enums (void)
settings = g_settings_new ("org.gtk.test.enums");
direct = g_settings_new ("org.gtk.test.enums.direct");
- if (!backend_set)
+ if (g_test_undefined () && !backend_set)
{
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
g_settings_get_enum (direct, "test");
@@ -1620,7 +1644,7 @@ test_flags (void)
settings = g_settings_new ("org.gtk.test.enums");
direct = g_settings_new ("org.gtk.test.enums.direct");
- if (!backend_set)
+ if (g_test_undefined () && !backend_set)
{
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
g_settings_get_flags (direct, "test");
@@ -1690,7 +1714,7 @@ test_range (void)
settings = g_settings_new ("org.gtk.test.range");
direct = g_settings_new ("org.gtk.test.range.direct");
- if (!backend_set)
+ if (g_test_undefined () && !backend_set)
{
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
g_settings_set_int (settings, "val", 45);
diff --git a/glib/tests/error.c b/glib/tests/error.c
index f483092..66ec6e0 100644
--- a/glib/tests/error.c
+++ b/glib/tests/error.c
@@ -3,6 +3,9 @@
static void
test_overwrite (void)
{
+ if (!g_test_undefined ())
+ return;
+
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
{
GError *error;
diff --git a/glib/tests/gvariant.c b/glib/tests/gvariant.c
index 18fe2fe..c328aa8 100644
--- a/glib/tests/gvariant.c
+++ b/glib/tests/gvariant.c
@@ -2831,6 +2831,9 @@ do_failed_test (const gchar *pattern)
static void
test_invalid_varargs (void)
{
+ if (!g_test_undefined ())
+ return;
+
if (do_failed_test ("*GVariant format string*"))
{
g_variant_new ("z");
@@ -3871,22 +3874,25 @@ test_parse_positional (void)
check_and_free (value, "[('one', 1), ('two', 2), ('three', 3)]");
check_and_free (g_variant_new_parsed ("{%s:%i}", "one", 1), "{'one': 1}");
- if (do_failed_test ("*GVariant format string*"))
+ if (g_test_undefined ())
{
- g_variant_new_parsed ("%z");
- abort ();
- }
+ if (do_failed_test ("*GVariant format string*"))
+ {
+ g_variant_new_parsed ("%z");
+ abort ();
+ }
- if (do_failed_test ("*can not parse as*"))
- {
- g_variant_new_parsed ("uint32 %i", 2);
- abort ();
- }
+ if (do_failed_test ("*can not parse as*"))
+ {
+ g_variant_new_parsed ("uint32 %i", 2);
+ abort ();
+ }
- if (do_failed_test ("*expected GVariant of type `i'*"))
- {
- g_variant_new_parsed ("% i", g_variant_new_uint32 (2));
- abort ();
+ if (do_failed_test ("*expected GVariant of type `i'*"))
+ {
+ g_variant_new_parsed ("% i", g_variant_new_uint32 (2));
+ abort ();
+ }
}
}
diff --git a/glib/tests/logging.c b/glib/tests/logging.c
index 9d69e6a..aece490 100644
--- a/glib/tests/logging.c
+++ b/glib/tests/logging.c
@@ -5,6 +5,9 @@
static void
test_warnings (void)
{
+ if (!g_test_undefined ())
+ return;
+
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
{
g_warn_if_reached ();
@@ -62,29 +65,32 @@ test_set_handler (void)
static void
test_default_handler (void)
{
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
- {
- g_error ("message1");
- exit (0);
- }
- g_test_trap_assert_failed ();
- g_test_trap_assert_stderr ("*ERROR*message1*");
-
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
- {
- g_critical ("message2");
- exit (0);
- }
- g_test_trap_assert_failed ();
- g_test_trap_assert_stderr ("*CRITICAL*message2*");
-
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
+ if (g_test_undefined ())
{
- g_warning ("message3");
- exit (0);
+ if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
+ {
+ g_error ("message1");
+ exit (0);
+ }
+ g_test_trap_assert_failed ();
+ g_test_trap_assert_stderr ("*ERROR*message1*");
+
+ if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
+ {
+ g_critical ("message2");
+ exit (0);
+ }
+ g_test_trap_assert_failed ();
+ g_test_trap_assert_stderr ("*CRITICAL*message2*");
+
+ if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
+ {
+ g_warning ("message3");
+ exit (0);
+ }
+ g_test_trap_assert_failed ();
+ g_test_trap_assert_stderr ("*WARNING*message3*");
}
- g_test_trap_assert_failed ();
- g_test_trap_assert_stderr ("*WARNING*message3*");
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
{
@@ -146,6 +152,9 @@ test_fatal_log_mask (void)
{
GLogLevelFlags flags;
+ if (!g_test_undefined ())
+ return;
+
flags = g_log_set_fatal_mask ("bu", G_LOG_LEVEL_INFO);
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT))
g_log ("bu", G_LOG_LEVEL_INFO, "fatal");
@@ -233,6 +242,9 @@ test_handler (const gchar *log_domain,
static void
bug653052 (void)
{
+ if (!g_test_undefined ())
+ return;
+
g_test_bug ("653052");
g_test_log_set_fatal_handler (good_failure_handler, fail_str);
diff --git a/glib/tests/markup-collect.c b/glib/tests/markup-collect.c
index 74ce2bf..3b2e2bd 100644
--- a/glib/tests/markup-collect.c
+++ b/glib/tests/markup-collect.c
@@ -197,6 +197,9 @@ static GMarkupParser cleanup_parser = {
static void
test_cleanup (void)
{
+ if (!g_test_undefined ())
+ return;
+
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
{
GMarkupParseContext *context;
diff --git a/glib/tests/mem-overflow.c b/glib/tests/mem-overflow.c
index 0d483fb..c7ea218 100644
--- a/glib/tests/mem-overflow.c
+++ b/glib/tests/mem-overflow.c
@@ -73,7 +73,18 @@ mem_overflow (void)
#undef CHECK_FAIL
#undef CHECK_PASS
-#define CHECK_FAIL(P) if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) { p = (P); exit (0); } g_test_trap_assert_failed();
+#define CHECK_FAIL(P) do { \
+ if (g_test_undefined ()) \
+ { \
+ if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) \
+ { \
+ p = (P); \
+ exit (0); \
+ } \
+ \
+ g_test_trap_assert_failed(); \
+ } \
+ } while (0)
#define CHECK_PASS(P) do { \
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) \
diff --git a/glib/tests/option-context.c b/glib/tests/option-context.c
index 20b1ee3..ba8fcf1 100644
--- a/glib/tests/option-context.c
+++ b/glib/tests/option-context.c
@@ -2077,6 +2077,9 @@ test_error_hook (void)
static void
flag_reverse_string (void)
{
+ if (!g_test_undefined ())
+ return;
+
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
{
GOptionContext *context;
@@ -2108,6 +2111,9 @@ flag_reverse_string (void)
static void
flag_optional_int (void)
{
+ if (!g_test_undefined ())
+ return;
+
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
{
GOptionContext *context;
diff --git a/glib/tests/slice.c b/glib/tests/slice.c
index 9f4670c..7976e51 100644
--- a/glib/tests/slice.c
+++ b/glib/tests/slice.c
@@ -3,6 +3,9 @@
static void
test_slice_config (void)
{
+ if (!g_test_undefined ())
+ return;
+
if (g_test_trap_fork (1000000, G_TEST_TRAP_SILENCE_STDERR))
g_slice_set_config (G_SLICE_CONFIG_ALWAYS_MALLOC, TRUE);
diff --git a/glib/tests/strfuncs.c b/glib/tests/strfuncs.c
index d5e4f4c..3387734 100644
--- a/glib/tests/strfuncs.c
+++ b/glib/tests/strfuncs.c
@@ -327,19 +327,22 @@ test_strcanon (void)
{
gchar *str;
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
+ if (g_test_undefined ())
{
- str = g_strcanon (NULL, "ab", 'y');
- }
- g_test_trap_assert_failed ();
+ if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
+ {
+ str = g_strcanon (NULL, "ab", 'y');
+ }
+ g_test_trap_assert_failed ();
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
- {
- str = g_strdup ("abxabxab");
- str = g_strcanon (str, NULL, 'y');
- g_free (str);
+ if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
+ {
+ str = g_strdup ("abxabxab");
+ str = g_strcanon (str, NULL, 'y');
+ g_free (str);
+ }
+ g_test_trap_assert_failed ();
}
- g_test_trap_assert_failed ();
str = g_strdup ("abxabxab");
str = g_strcanon (str, "ab", 'y');
@@ -355,18 +358,21 @@ test_strcompress_strescape (void)
gchar *tmp;
/* test compress */
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
+ if (g_test_undefined ())
{
- str = g_strcompress (NULL);
- }
- g_test_trap_assert_failed ();
+ if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
+ {
+ str = g_strcompress (NULL);
+ }
+ g_test_trap_assert_failed ();
- /* trailing slashes are not allowed */
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
- {
- str = g_strcompress ("abc\\");
+ /* trailing slashes are not allowed */
+ if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
+ {
+ str = g_strcompress ("abc\\");
+ }
+ g_test_trap_assert_failed ();
}
- g_test_trap_assert_failed ();
str = g_strcompress ("abc\\\\\\\"\\b\\f\\n\\r\\t\\003\\177\\234\\313\\12345z");
g_assert (str != NULL);
@@ -374,11 +380,14 @@ test_strcompress_strescape (void)
g_free (str);
/* test escape */
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
+ if (g_test_undefined ())
{
- str = g_strescape (NULL, NULL);
+ if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
+ {
+ str = g_strescape (NULL, NULL);
+ }
+ g_test_trap_assert_failed ();
}
- g_test_trap_assert_failed ();
str = g_strescape ("abc\\\"\b\f\n\r\t\003\177\234\313", NULL);
g_assert (str != NULL);
@@ -405,17 +414,20 @@ test_ascii_strcasecmp (void)
{
gboolean res;
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
+ if (g_test_undefined ())
{
- res = g_ascii_strcasecmp ("foo", NULL);
- }
- g_test_trap_assert_failed ();
+ if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
+ {
+ res = g_ascii_strcasecmp ("foo", NULL);
+ }
+ g_test_trap_assert_failed ();
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
- {
- res = g_ascii_strcasecmp (NULL, "foo");
+ if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
+ {
+ res = g_ascii_strcasecmp (NULL, "foo");
+ }
+ g_test_trap_assert_failed ();
}
- g_test_trap_assert_failed ();
res = g_ascii_strcasecmp ("FroboZZ", "frobozz");
g_assert_cmpint (res, ==, 0);
@@ -478,11 +490,14 @@ do_test_strchug (const gchar *str, const gchar *expected)
static void
test_strchug (void)
{
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
+ if (g_test_undefined ())
{
- g_strchug (NULL);
+ if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
+ {
+ g_strchug (NULL);
+ }
+ g_test_trap_assert_failed ();
}
- g_test_trap_assert_failed ();
do_test_strchug ("", "");
do_test_strchug (" ", "");
@@ -511,11 +526,14 @@ do_test_strchomp (const gchar *str, const gchar *expected)
static void
test_strchomp (void)
{
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
+ if (g_test_undefined ())
{
- g_strchomp (NULL);
+ if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
+ {
+ g_strchomp (NULL);
+ }
+ g_test_trap_assert_failed ();
}
- g_test_trap_assert_failed ();
do_test_strchomp ("", "");
do_test_strchomp (" ", "");
@@ -532,11 +550,14 @@ test_strreverse (void)
gchar *str;
gchar *p;
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
+ if (g_test_undefined ())
{
- str = g_strreverse (NULL);
+ if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
+ {
+ str = g_strreverse (NULL);
+ }
+ g_test_trap_assert_failed ();
}
- g_test_trap_assert_failed ();
str = p = g_strdup ("abcde");
str = g_strreverse (str);
@@ -626,17 +647,20 @@ test_has_prefix (void)
{
gboolean res;
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
+ if (g_test_undefined ())
{
- res = g_str_has_prefix ("foo", NULL);
- }
- g_test_trap_assert_failed ();
+ if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
+ {
+ res = g_str_has_prefix ("foo", NULL);
+ }
+ g_test_trap_assert_failed ();
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
- {
- res = g_str_has_prefix (NULL, "foo");
+ if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
+ {
+ res = g_str_has_prefix (NULL, "foo");
+ }
+ g_test_trap_assert_failed ();
}
- g_test_trap_assert_failed ();
res = g_str_has_prefix ("foo", "bar");
g_assert_cmpint (res, ==, FALSE);
@@ -665,17 +689,20 @@ test_has_suffix (void)
{
gboolean res;
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
+ if (g_test_undefined ())
{
- res = g_str_has_suffix ("foo", NULL);
- }
- g_test_trap_assert_failed ();
+ if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
+ {
+ res = g_str_has_suffix ("foo", NULL);
+ }
+ g_test_trap_assert_failed ();
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
- {
- res = g_str_has_suffix (NULL, "foo");
+ if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
+ {
+ res = g_str_has_suffix (NULL, "foo");
+ }
+ g_test_trap_assert_failed ();
}
- g_test_trap_assert_failed ();
res = g_str_has_suffix ("foo", "bar");
g_assert_cmpint (res, ==, FALSE);
@@ -844,11 +871,14 @@ test_strv_length (void)
gchar **strv;
guint l;
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
+ if (g_test_undefined ())
{
- l = g_strv_length (NULL);
+ if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
+ {
+ l = g_strv_length (NULL);
+ }
+ g_test_trap_assert_failed ();
}
- g_test_trap_assert_failed ();
strv = g_strsplit ("1,2,3,4", ",", -1);
l = g_strv_length (strv);
diff --git a/glib/tests/testing.c b/glib/tests/testing.c
index 2b257f2..d6e39ba 100644
--- a/glib/tests/testing.c
+++ b/glib/tests/testing.c
@@ -46,19 +46,22 @@ test_assertions (void)
g_assert_cmpstr ("fzz", >, "faa");
g_assert_cmpstr ("fzz", ==, "fzz");
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
+ if (g_test_undefined ())
{
- g_assert_cmpstr ("fzz", !=, "fzz");
- }
- g_test_trap_assert_failed ();
- g_test_trap_assert_stderr ("*assertion failed*");
+ if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
+ {
+ g_assert_cmpstr ("fzz", !=, "fzz");
+ }
+ g_test_trap_assert_failed ();
+ g_test_trap_assert_stderr ("*assertion failed*");
- if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
- {
- g_assert_cmpint (4, !=, 4);
+ if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
+ {
+ g_assert_cmpint (4, !=, 4);
+ }
+ g_test_trap_assert_failed ();
+ g_test_trap_assert_stderr ("*assertion failed*");
}
- g_test_trap_assert_failed ();
- g_test_trap_assert_stderr ("*assertion failed*");
}
/* test g_test_timer* API */
@@ -80,6 +83,9 @@ test_timer (void)
static void
test_fork_fail (void)
{
+ if (!g_test_undefined ())
+ return;
+
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
{
g_assert_not_reached();
@@ -107,6 +113,9 @@ test_fork_patterns (void)
static void
test_fork_timeout (void)
{
+ if (!g_test_undefined ())
+ return;
+
/* allow child to run for only a fraction of a second */
if (g_test_trap_fork (0.11 * 1000000, 0))
{
@@ -217,6 +226,9 @@ fatal_handler (const gchar *log_domain,
static void
test_fatal_log_handler (void)
{
+ if (!g_test_undefined ())
+ return;
+
g_test_log_set_fatal_handler (fatal_handler, NULL);
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
{
diff --git a/gobject/tests/ifaceproperties.c b/gobject/tests/ifaceproperties.c
index 5e3d220..f7a260c 100644
--- a/gobject/tests/ifaceproperties.c
+++ b/gobject/tests/ifaceproperties.c
@@ -615,6 +615,9 @@ base2_object_init (Base2Object *object)
static void
test_not_overridden (void)
{
+ if (!g_test_undefined ())
+ return;
+
g_test_bug ("637738");
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT|G_TEST_TRAP_SILENCE_STDERR))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]