mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 06:56:14 +01:00
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:
parent
d9f6314f57
commit
f78931c4ab
@ -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);
|
||||
|
@ -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))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user