[gtk/matthiasc/for-master] reftest: get backtraces
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/for-master] reftest: get backtraces
- Date: Sun, 12 Apr 2020 15:18:38 +0000 (UTC)
commit fc9e00d4f6b1861470cc2d566642ab31bfd84c79
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Apr 12 10:40:07 2020 -0400
reftest: get backtraces
In the hope of making ci-only failures less of a black hole,
add a backtrace to the messsage for criticals.
This could eventually go into GLib (pass backtrace symbols along
as a log field for criticals), but for now this will do.
testsuite/reftests/gtk-reftest.c | 50 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
---
diff --git a/testsuite/reftests/gtk-reftest.c b/testsuite/reftests/gtk-reftest.c
index c09147a6cc..b3482e8c22 100644
--- a/testsuite/reftests/gtk-reftest.c
+++ b/testsuite/reftests/gtk-reftest.c
@@ -24,6 +24,7 @@
#include "reftest-module.h"
#include "reftest-snapshot.h"
+#include <execinfo.h>
#include <string.h>
#include <glib/gstdio.h>
#include <gtk/gtk.h>
@@ -285,6 +286,8 @@ test_ui_file (GFile *file)
ui_file = g_file_get_path (file);
+ g_critical ("Oops in %s", ui_file);
+
provider = add_extra_css (ui_file, ".css");
ui_image = reftest_snapshot_ui_file (ui_file);
@@ -384,6 +387,51 @@ add_test_for_file (GFile *file)
g_list_free_full (files, g_object_unref);
}
+static GLogWriterOutput
+log_writer (GLogLevelFlags log_level,
+ const GLogField *fields,
+ gsize n_fields,
+ gpointer user_data)
+{
+ if (log_level & G_LOG_LEVEL_CRITICAL)
+ {
+ void *buffer[1024];
+ int size, i;
+ char **symbols;
+ GString *s;
+ GLogField *my_fields;
+
+ my_fields = g_alloca (sizeof (GLogField) * n_fields);
+
+ s = g_string_new ("");
+
+ size = backtrace (buffer, 1024);
+ symbols = backtrace_symbols (buffer, size);
+ for (i = 0; i < size; i++)
+ {
+ g_string_append (s, symbols[i]);
+ g_string_append_c (s, '\n');
+ }
+ free (symbols);
+
+ for (i = 0; i < n_fields; i++)
+ {
+ my_fields[i] = fields[i];
+
+ if (strcmp (fields[i].key, "MESSAGE") == 0)
+ {
+ my_fields[i].value = g_strconcat (fields[i].value, "\nBacktrace:\n", s->str, NULL);
+ my_fields[i].length = strlen (my_fields[i].value);
+ }
+ }
+ g_string_free (s, TRUE);
+
+ fields = my_fields;
+ }
+
+ return g_log_writer_standard_streams (log_level, fields, n_fields, user_data);
+}
+
int
main (int argc, char **argv)
{
@@ -434,6 +482,8 @@ main (int argc, char **argv)
*/
chdir (basedir);
+ g_log_set_writer_func (log_writer, NULL, NULL);
+
result = g_test_run ();
if (using_tap)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]