From f78931c4abf217fce0eca890da411c1c1c983d45 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Wed, 1 Aug 2012 09:49:10 -0400 Subject: [PATCH] glib/tests/testing, logging: don't use g_test_undefined() We are verifying the behavior of the test/logging functions here; this is not undefined behavior. https://bugzilla.gnome.org/show_bug.cgi?id=679556 --- glib/tests/logging.c | 54 +++++++++++++++++--------------------------- glib/tests/testing.c | 34 +++++++++------------------- 2 files changed, 32 insertions(+), 56 deletions(-) diff --git a/glib/tests/logging.c b/glib/tests/logging.c index 89005a8f8..f90dc74af 100644 --- a/glib/tests/logging.c +++ b/glib/tests/logging.c @@ -5,9 +5,6 @@ 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 (); @@ -65,32 +62,29 @@ test_set_handler (void) static void test_default_handler (void) { - if (g_test_undefined ()) + if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) { - 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_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*"); if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) { @@ -152,9 +146,6 @@ 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"); @@ -242,9 +233,6 @@ 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/testing.c b/glib/tests/testing.c index d6e39baf8..2b257f258 100644 --- a/glib/tests/testing.c +++ b/glib/tests/testing.c @@ -46,22 +46,19 @@ test_assertions (void) g_assert_cmpstr ("fzz", >, "faa"); g_assert_cmpstr ("fzz", ==, "fzz"); - if (g_test_undefined ()) + if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) { - 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); - } - g_test_trap_assert_failed (); - g_test_trap_assert_stderr ("*assertion failed*"); + 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); + } + g_test_trap_assert_failed (); + g_test_trap_assert_stderr ("*assertion failed*"); } /* test g_test_timer* API */ @@ -83,9 +80,6 @@ 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(); @@ -113,9 +107,6 @@ 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)) { @@ -226,9 +217,6 @@ 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)) {