[glib] Make the logging test more robust
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Make the logging test more robust
- Date: Sat, 2 Feb 2013 23:26:44 +0000 (UTC)
commit 8455702a8d55436f2ca37b801052d41cfb0ee2c9
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Feb 2 16:23:03 2013 -0500
Make the logging test more robust
The default handler test was not unsetting the log handler that
gets installed by GTest, which causes the log messages to be duplicated
on stdout if --verbose or --tap are passed. This in turn can make some
of the non-match checks fail. Since we are already using g_test_trap_fork,
we can just unset the handler in the child.
glib/tests/logging.c | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
---
diff --git a/glib/tests/logging.c b/glib/tests/logging.c
index f90dc74..e2df2b5 100644
--- a/glib/tests/logging.c
+++ b/glib/tests/logging.c
@@ -64,6 +64,7 @@ test_default_handler (void)
{
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
{
+ g_log_set_default_handler (g_log_default_handler, NULL);
g_error ("message1");
exit (0);
}
@@ -72,6 +73,7 @@ test_default_handler (void)
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
{
+ g_log_set_default_handler (g_log_default_handler, NULL);
g_critical ("message2");
exit (0);
}
@@ -80,6 +82,7 @@ test_default_handler (void)
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
{
+ g_log_set_default_handler (g_log_default_handler, NULL);
g_warning ("message3");
exit (0);
}
@@ -88,6 +91,7 @@ test_default_handler (void)
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
{
+ g_log_set_default_handler (g_log_default_handler, NULL);
g_message ("message4");
exit (0);
}
@@ -96,6 +100,7 @@ test_default_handler (void)
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT))
{
+ g_log_set_default_handler (g_log_default_handler, NULL);
g_log (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, "message5");
exit (0);
}
@@ -105,6 +110,7 @@ test_default_handler (void)
g_setenv ("G_MESSAGES_DEBUG", "foo bar baz", TRUE);
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT))
{
+ g_log_set_default_handler (g_log_default_handler, NULL);
g_log ("bar", G_LOG_LEVEL_INFO, "message5");
exit (0);
}
@@ -113,6 +119,7 @@ test_default_handler (void)
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT))
{
+ g_log_set_default_handler (g_log_default_handler, NULL);
g_log ("baz", G_LOG_LEVEL_DEBUG, "message6");
exit (0);
}
@@ -122,6 +129,7 @@ test_default_handler (void)
g_setenv ("G_MESSAGES_DEBUG", "all", TRUE);
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT))
{
+ g_log_set_default_handler (g_log_default_handler, NULL);
g_log ("foo", G_LOG_LEVEL_DEBUG, "6");
g_log ("bar", G_LOG_LEVEL_DEBUG, "6");
g_log ("baz", G_LOG_LEVEL_DEBUG, "6");
@@ -133,6 +141,7 @@ test_default_handler (void)
g_unsetenv ("G_MESSAGES_DEBUG");
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT))
{
+ g_log_set_default_handler (g_log_default_handler, NULL);
g_log (G_LOG_DOMAIN, 1<<10, "message7");
exit (0);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]