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
This commit is contained in:
Dan Winship 2012-08-01 09:49:10 -04:00
parent d9f6314f57
commit f78931c4ab
2 changed files with 32 additions and 56 deletions

View File

@ -5,9 +5,6 @@
static void static void
test_warnings (void) test_warnings (void)
{ {
if (!g_test_undefined ())
return;
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
{ {
g_warn_if_reached (); g_warn_if_reached ();
@ -64,8 +61,6 @@ test_set_handler (void)
static void static void
test_default_handler (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))
{ {
@ -90,7 +85,6 @@ test_default_handler (void)
} }
g_test_trap_assert_failed (); g_test_trap_assert_failed ();
g_test_trap_assert_stderr ("*WARNING*message3*"); g_test_trap_assert_stderr ("*WARNING*message3*");
}
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
{ {
@ -152,9 +146,6 @@ test_fatal_log_mask (void)
{ {
GLogLevelFlags flags; GLogLevelFlags flags;
if (!g_test_undefined ())
return;
flags = g_log_set_fatal_mask ("bu", G_LOG_LEVEL_INFO); flags = g_log_set_fatal_mask ("bu", G_LOG_LEVEL_INFO);
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT)) if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT))
g_log ("bu", G_LOG_LEVEL_INFO, "fatal"); g_log ("bu", G_LOG_LEVEL_INFO, "fatal");
@ -242,9 +233,6 @@ test_handler (const gchar *log_domain,
static void static void
bug653052 (void) bug653052 (void)
{ {
if (!g_test_undefined ())
return;
g_test_bug ("653052"); g_test_bug ("653052");
g_test_log_set_fatal_handler (good_failure_handler, fail_str); g_test_log_set_fatal_handler (good_failure_handler, fail_str);

View File

@ -46,8 +46,6 @@ test_assertions (void)
g_assert_cmpstr ("fzz", >, "faa"); g_assert_cmpstr ("fzz", >, "faa");
g_assert_cmpstr ("fzz", ==, "fzz"); 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_assert_cmpstr ("fzz", !=, "fzz");
@ -62,7 +60,6 @@ test_assertions (void)
g_test_trap_assert_failed (); g_test_trap_assert_failed ();
g_test_trap_assert_stderr ("*assertion failed*"); g_test_trap_assert_stderr ("*assertion failed*");
} }
}
/* test g_test_timer* API */ /* test g_test_timer* API */
static void static void
@ -83,9 +80,6 @@ test_timer (void)
static void static void
test_fork_fail (void) test_fork_fail (void)
{ {
if (!g_test_undefined ())
return;
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
{ {
g_assert_not_reached(); g_assert_not_reached();
@ -113,9 +107,6 @@ test_fork_patterns (void)
static void static void
test_fork_timeout (void) test_fork_timeout (void)
{ {
if (!g_test_undefined ())
return;
/* allow child to run for only a fraction of a second */ /* allow child to run for only a fraction of a second */
if (g_test_trap_fork (0.11 * 1000000, 0)) if (g_test_trap_fork (0.11 * 1000000, 0))
{ {
@ -226,9 +217,6 @@ fatal_handler (const gchar *log_domain,
static void static void
test_fatal_log_handler (void) test_fatal_log_handler (void)
{ {
if (!g_test_undefined ())
return;
g_test_log_set_fatal_handler (fatal_handler, NULL); g_test_log_set_fatal_handler (fatal_handler, NULL);
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
{ {