[glib/glib-2-30] Pass correct data to fatal log handlers
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/glib-2-30] Pass correct data to fatal log handlers
- Date: Fri, 11 Nov 2011 21:22:15 +0000 (UTC)
commit 81c07947291c691fd7b897509cc00771ac21f943
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Oct 16 16:23:18 2011 -0400
Pass correct data to fatal log handlers
This was pointed out by John Ralls in bug 653052.
He also provided the test case.
glib/gmessages.c | 2 +-
glib/tests/logging.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 59 insertions(+), 1 deletions(-)
---
diff --git a/glib/gmessages.c b/glib/gmessages.c
index 9860875..a3b223e 100644
--- a/glib/gmessages.c
+++ b/glib/gmessages.c
@@ -548,7 +548,7 @@ g_logv (const gchar *log_domain,
&& !(test_level & G_LOG_LEVEL_ERROR))
{
masquerade_fatal = fatal_log_func
- && !fatal_log_func (log_domain, test_level, msg, data);
+ && !fatal_log_func (log_domain, test_level, msg, fatal_log_data);
}
g_free (msg);
diff --git a/glib/tests/logging.c b/glib/tests/logging.c
index 0c83b80..9d13b8f 100644
--- a/glib/tests/logging.c
+++ b/glib/tests/logging.c
@@ -169,10 +169,67 @@ test_printerr_handler (void)
g_set_printerr_handler (NULL);
}
+static char *fail_str = "foo";
+static char *log_str = "bar";
+
+gboolean
+good_failure_handler (const gchar *log_domain,
+ GLogLevelFlags log_level,
+ const gchar *msg,
+ gpointer user_data)
+{
+ g_test_message ("The Good Fail Message Handler\n");
+ g_assert ((char *)user_data != log_str);
+ g_assert ((char *)user_data == fail_str);
+
+ return FALSE;
+}
+
+gboolean
+bad_failure_handler (const gchar *log_domain,
+ GLogLevelFlags log_level,
+ const gchar *msg,
+ gpointer user_data)
+{
+ g_test_message ("The Bad Fail Message Handler\n");
+ g_assert ((char *)user_data == log_str);
+ g_assert ((char *)user_data != fail_str);
+
+ return FALSE;
+}
+
+void
+test_handler (const gchar *log_domain,
+ GLogLevelFlags log_level,
+ const gchar *msg,
+ gpointer user_data)
+{
+ g_test_message ("The Log Message Handler\n");
+ g_assert ((char *)user_data != fail_str);
+ g_assert ((char *)user_data == log_str);
+}
+
+void
+bug653052 (void)
+{
+ g_test_bug ("653052");
+
+ g_test_log_set_fatal_handler (good_failure_handler, fail_str);
+ g_log_set_default_handler (test_handler, log_str);
+
+ g_return_if_fail (0);
+
+ g_test_log_set_fatal_handler (bad_failure_handler, fail_str);
+ g_log_set_default_handler (test_handler, log_str);
+
+ g_return_if_fail (0);
+}
+
int
main (int argc, char *argv[])
{
g_test_init (&argc, &argv, NULL);
+ g_test_bug_base ("http://bugzilla.gnome.org/");
g_test_add_func ("/logging/default-handler", test_default_handler);
g_test_add_func ("/logging/warnings", test_warnings);
@@ -180,6 +237,7 @@ main (int argc, char *argv[])
g_test_add_func ("/logging/set-handler", test_set_handler);
g_test_add_func ("/logging/print-handler", test_print_handler);
g_test_add_func ("/logging/printerr-handler", test_printerr_handler);
+ g_test_add_func ("/logging/653052", bug653052);
return g_test_run ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]