|
Matej Habrnal |
5c8df3 |
From d18e0f667d33527c1c5e54f448f6aa2ba59dabdb Mon Sep 17 00:00:00 2001
|
|
Matej Habrnal |
5c8df3 |
From: Jakub Filak <jfilak@redhat.com>
|
|
Matej Habrnal |
5c8df3 |
Date: Thu, 4 Dec 2014 08:43:17 +0100
|
|
Matej Habrnal |
5c8df3 |
Subject: [PATCH 127/136] lib: add Problem Format API
|
|
Matej Habrnal |
5c8df3 |
|
|
Matej Habrnal |
5c8df3 |
Related to #303
|
|
Matej Habrnal |
5c8df3 |
|
|
Matej Habrnal |
5c8df3 |
Signed-off-by: Jakub Filak <jfilak@redhat.com>
|
|
Matej Habrnal |
5c8df3 |
---
|
|
Matej Habrnal |
5c8df3 |
po/POTFILES.in | 1 +
|
|
Matej Habrnal |
5c8df3 |
src/include/Makefile.am | 1 +
|
|
Matej Habrnal |
5c8df3 |
src/include/problem_report.h | 225 ++++++++
|
|
Matej Habrnal |
5c8df3 |
src/lib/Makefile.am | 5 +-
|
|
Matej Habrnal |
5c8df3 |
src/lib/problem_report.c | 1209 ++++++++++++++++++++++++++++++++++++++++++
|
|
Matej Habrnal |
5c8df3 |
tests/Makefile.am | 3 +-
|
|
Matej Habrnal |
5c8df3 |
tests/problem_report.at | 690 ++++++++++++++++++++++++
|
|
Matej Habrnal |
5c8df3 |
tests/testsuite.at | 1 +
|
|
Matej Habrnal |
5c8df3 |
8 files changed, 2133 insertions(+), 2 deletions(-)
|
|
Matej Habrnal |
5c8df3 |
create mode 100644 src/include/problem_report.h
|
|
Matej Habrnal |
5c8df3 |
create mode 100644 src/lib/problem_report.c
|
|
Matej Habrnal |
5c8df3 |
create mode 100644 tests/problem_report.at
|
|
Matej Habrnal |
5c8df3 |
|
|
Matej Habrnal |
5c8df3 |
diff --git a/po/POTFILES.in b/po/POTFILES.in
|
|
Matej Habrnal |
5c8df3 |
index 00046e2..c597b11 100644
|
|
Matej Habrnal |
5c8df3 |
--- a/po/POTFILES.in
|
|
Matej Habrnal |
5c8df3 |
+++ b/po/POTFILES.in
|
|
Matej Habrnal |
5c8df3 |
@@ -23,6 +23,7 @@ src/lib/ureport.c
|
|
Matej Habrnal |
5c8df3 |
src/lib/make_descr.c
|
|
Matej Habrnal |
5c8df3 |
src/lib/parse_options.c
|
|
Matej Habrnal |
5c8df3 |
src/lib/problem_data.c
|
|
Matej Habrnal |
5c8df3 |
+src/lib/problem_report.c
|
|
Matej Habrnal |
5c8df3 |
src/lib/run_event.c
|
|
Matej Habrnal |
5c8df3 |
src/plugins/abrt_rh_support.c
|
|
Matej Habrnal |
5c8df3 |
src/plugins/report_Bugzilla.xml.in
|
|
Matej Habrnal |
5c8df3 |
diff --git a/src/include/Makefile.am b/src/include/Makefile.am
|
|
Matej Habrnal |
5c8df3 |
index de44cda..47ba399 100644
|
|
Matej Habrnal |
5c8df3 |
--- a/src/include/Makefile.am
|
|
Matej Habrnal |
5c8df3 |
+++ b/src/include/Makefile.am
|
|
Matej Habrnal |
5c8df3 |
@@ -5,6 +5,7 @@ libreport_include_HEADERS = \
|
|
Matej Habrnal |
5c8df3 |
dump_dir.h \
|
|
Matej Habrnal |
5c8df3 |
event_config.h \
|
|
Matej Habrnal |
5c8df3 |
problem_data.h \
|
|
Matej Habrnal |
5c8df3 |
+ problem_report.h \
|
|
Matej Habrnal |
5c8df3 |
report.h \
|
|
Matej Habrnal |
5c8df3 |
run_event.h \
|
|
Matej Habrnal |
5c8df3 |
libreport_curl.h \
|
|
Matej Habrnal |
5c8df3 |
diff --git a/src/include/problem_report.h b/src/include/problem_report.h
|
|
Matej Habrnal |
5c8df3 |
new file mode 100644
|
|
Matej Habrnal |
5c8df3 |
index 0000000..30781e6
|
|
Matej Habrnal |
5c8df3 |
--- /dev/null
|
|
Matej Habrnal |
5c8df3 |
+++ b/src/include/problem_report.h
|
|
Matej Habrnal |
5c8df3 |
@@ -0,0 +1,225 @@
|
|
Matej Habrnal |
5c8df3 |
+/*
|
|
Matej Habrnal |
5c8df3 |
+ Copyright (C) 2014 ABRT team
|
|
Matej Habrnal |
5c8df3 |
+ Copyright (C) 2014 RedHat Inc
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ This program is free software; you can redistribute it and/or modify
|
|
Matej Habrnal |
5c8df3 |
+ it under the terms of the GNU General Public License as published by
|
|
Matej Habrnal |
5c8df3 |
+ the Free Software Foundation; either version 2 of the License, or
|
|
Matej Habrnal |
5c8df3 |
+ (at your option) any later version.
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ This program is distributed in the hope that it will be useful,
|
|
Matej Habrnal |
5c8df3 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Matej Habrnal |
5c8df3 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Matej Habrnal |
5c8df3 |
+ GNU General Public License for more details.
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ You should have received a copy of the GNU General Public License along
|
|
Matej Habrnal |
5c8df3 |
+ with this program; if not, write to the Free Software Foundation, Inc.,
|
|
Matej Habrnal |
5c8df3 |
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
Matej Habrnal |
5c8df3 |
+*/
|
|
Matej Habrnal |
5c8df3 |
+#ifndef LIBREPORT_PROBLEM_REPORT_H
|
|
Matej Habrnal |
5c8df3 |
+#define LIBREPORT_PROBLEM_REPORT_H
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+#include <glib.h>
|
|
Matej Habrnal |
5c8df3 |
+#include <stdio.h>
|
|
Matej Habrnal |
5c8df3 |
+#include "problem_data.h"
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+#ifdef __cplusplus
|
|
Matej Habrnal |
5c8df3 |
+extern "C" {
|
|
Matej Habrnal |
5c8df3 |
+#endif
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+#define PR_SEC_SUMMARY "summary"
|
|
Matej Habrnal |
5c8df3 |
+#define PR_SEC_DESCRIPTION "description"
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+/*
|
|
Matej Habrnal |
5c8df3 |
+ * The problem report structure represents a problem data formatted according
|
|
Matej Habrnal |
5c8df3 |
+ * to a format string.
|
|
Matej Habrnal |
5c8df3 |
+ *
|
|
Matej Habrnal |
5c8df3 |
+ * A problem report is composed of well-known sections:
|
|
Matej Habrnal |
5c8df3 |
+ * - summary
|
|
Matej Habrnal |
5c8df3 |
+ * - descritpion
|
|
Matej Habrnal |
5c8df3 |
+ * - attach
|
|
Matej Habrnal |
5c8df3 |
+ *
|
|
Matej Habrnal |
5c8df3 |
+ * and custom sections accessed by:
|
|
Matej Habrnal |
5c8df3 |
+ * problem_report_get_section();
|
|
Matej Habrnal |
5c8df3 |
+ */
|
|
Matej Habrnal |
5c8df3 |
+struct problem_report;
|
|
Matej Habrnal |
5c8df3 |
+typedef struct problem_report problem_report_t;
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+/*
|
|
Matej Habrnal |
5c8df3 |
+ * Helpers for easily switching between FILE and struct strbuf
|
|
Matej Habrnal |
5c8df3 |
+ */
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+/*
|
|
Matej Habrnal |
5c8df3 |
+ * Type of buffer used by Problem report
|
|
Matej Habrnal |
5c8df3 |
+ */
|
|
Matej Habrnal |
5c8df3 |
+typedef FILE problem_report_buffer;
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+/*
|
|
Matej Habrnal |
5c8df3 |
+ * Wrapper for the proble buffer's formated output function.
|
|
Matej Habrnal |
5c8df3 |
+ */
|
|
Matej Habrnal |
5c8df3 |
+#define problem_report_buffer_printf(buf, fmt, ...)\
|
|
Matej Habrnal |
5c8df3 |
+ fprintf((buf), (fmt), ##__VA_ARGS__)
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+/*
|
|
Matej Habrnal |
5c8df3 |
+ * Get a section buffer
|
|
Matej Habrnal |
5c8df3 |
+ *
|
|
Matej Habrnal |
5c8df3 |
+ * Use this function if you need to amend something to a formatted section.
|
|
Matej Habrnal |
5c8df3 |
+ *
|
|
Matej Habrnal |
5c8df3 |
+ * @param self Problem report
|
|
Matej Habrnal |
5c8df3 |
+ * @param section_name Name of required section
|
|
Matej Habrnal |
5c8df3 |
+ * @return Always valid pointer to a section buffer
|
|
Matej Habrnal |
5c8df3 |
+ */
|
|
Matej Habrnal |
5c8df3 |
+problem_report_buffer *problem_report_get_buffer(const problem_report_t *self,
|
|
Matej Habrnal |
5c8df3 |
+ const char *section_name);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+/*
|
|
Matej Habrnal |
5c8df3 |
+ * Get Summary string
|
|
Matej Habrnal |
5c8df3 |
+ *
|
|
Matej Habrnal |
5c8df3 |
+ * The returned pointer is valid as long as you perform no further output to
|
|
Matej Habrnal |
5c8df3 |
+ * the summary buffer.
|
|
Matej Habrnal |
5c8df3 |
+ *
|
|
Matej Habrnal |
5c8df3 |
+ * @param self Problem report
|
|
Matej Habrnal |
5c8df3 |
+ * @return Non-NULL pointer to summary data
|
|
Matej Habrnal |
5c8df3 |
+ */
|
|
Matej Habrnal |
5c8df3 |
+const char *problem_report_get_summary(const problem_report_t *self);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+/*
|
|
Matej Habrnal |
5c8df3 |
+ * Get Description string
|
|
Matej Habrnal |
5c8df3 |
+ *
|
|
Matej Habrnal |
5c8df3 |
+ * The returned pointer is valid as long as you perform no further output to
|
|
Matej Habrnal |
5c8df3 |
+ * the description buffer.
|
|
Matej Habrnal |
5c8df3 |
+ *
|
|
Matej Habrnal |
5c8df3 |
+ * @param self Problem report
|
|
Matej Habrnal |
5c8df3 |
+ * @return Non-NULL pointer to description data
|
|
Matej Habrnal |
5c8df3 |
+ */
|
|
Matej Habrnal |
5c8df3 |
+const char *problem_report_get_description(const problem_report_t *self);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+/*
|
|
Matej Habrnal |
5c8df3 |
+ * Get Section's string
|
|
Matej Habrnal |
5c8df3 |
+ *
|
|
Matej Habrnal |
5c8df3 |
+ * The returned pointer is valid as long as you perform no further output to
|
|
Matej Habrnal |
5c8df3 |
+ * the section's buffer.
|
|
Matej Habrnal |
5c8df3 |
+ *
|
|
Matej Habrnal |
5c8df3 |
+ * @param self Problem report
|
|
Matej Habrnal |
5c8df3 |
+ * @param section_name Name of the required section
|
|
Matej Habrnal |
5c8df3 |
+ * @return Non-NULL pointer to description data
|
|
Matej Habrnal |
5c8df3 |
+ */
|
|
Matej Habrnal |
5c8df3 |
+const char *problem_report_get_section(const problem_report_t *self,
|
|
Matej Habrnal |
5c8df3 |
+ const char *section_name);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+/*
|
|
Matej Habrnal |
5c8df3 |
+ * Get GList of the problem data items that are to be attached
|
|
Matej Habrnal |
5c8df3 |
+ *
|
|
Matej Habrnal |
5c8df3 |
+ * @param self Problem report
|
|
Matej Habrnal |
5c8df3 |
+ * @return A pointer to GList (NULL means empty list)
|
|
Matej Habrnal |
5c8df3 |
+ */
|
|
Matej Habrnal |
5c8df3 |
+GList *problem_report_get_attachments(const problem_report_t *self);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+/*
|
|
Matej Habrnal |
5c8df3 |
+ * Releases all resources allocated by a problem report
|
|
Matej Habrnal |
5c8df3 |
+ *
|
|
Matej Habrnal |
5c8df3 |
+ * @param self Problem report
|
|
Matej Habrnal |
5c8df3 |
+ */
|
|
Matej Habrnal |
5c8df3 |
+void problem_report_free(problem_report_t *self);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+/*
|
|
Matej Habrnal |
5c8df3 |
+ * An enum of Extra section flags
|
|
Matej Habrnal |
5c8df3 |
+ */
|
|
Matej Habrnal |
5c8df3 |
+enum problem_formatter_section_flags {
|
|
Matej Habrnal |
5c8df3 |
+ PFFF_REQUIRED = 1 << 0, ///< section must be present in the format spec
|
|
Matej Habrnal |
5c8df3 |
+};
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+/*
|
|
Matej Habrnal |
5c8df3 |
+ * The problem formatter structure formats a problem data according to a format
|
|
Matej Habrnal |
5c8df3 |
+ * string and stores result a problem report.
|
|
Matej Habrnal |
5c8df3 |
+ *
|
|
Matej Habrnal |
5c8df3 |
+ * The problem formatter uses '%reason%' as %summary section format string, if
|
|
Matej Habrnal |
5c8df3 |
+ * %summary is not provided by a format string.
|
|
Matej Habrnal |
5c8df3 |
+ */
|
|
Matej Habrnal |
5c8df3 |
+struct problem_formatter;
|
|
Matej Habrnal |
5c8df3 |
+typedef struct problem_formatter problem_formatter_t;
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+/*
|
|
Matej Habrnal |
5c8df3 |
+ * Constructs a new problem formatter.
|
|
Matej Habrnal |
5c8df3 |
+ *
|
|
Matej Habrnal |
5c8df3 |
+ * @return Non-NULL pointer to the new problem formatter
|
|
Matej Habrnal |
5c8df3 |
+ */
|
|
Matej Habrnal |
5c8df3 |
+problem_formatter_t *problem_formatter_new(void);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+/*
|
|
Matej Habrnal |
5c8df3 |
+ * Releases all resources allocated by a problem formatter
|
|
Matej Habrnal |
5c8df3 |
+ *
|
|
Matej Habrnal |
5c8df3 |
+ * @param self Problem formatter
|
|
Matej Habrnal |
5c8df3 |
+ */
|
|
Matej Habrnal |
5c8df3 |
+void problem_formatter_free(problem_formatter_t *self);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+/*
|
|
Matej Habrnal |
5c8df3 |
+ * Adds a new recognized section
|
|
Matej Habrnal |
5c8df3 |
+ *
|
|
Matej Habrnal |
5c8df3 |
+ * The problem formatter ignores a section in the format spec if the section is
|
|
Matej Habrnal |
5c8df3 |
+ * not one of the default nor added by this function.
|
|
Matej Habrnal |
5c8df3 |
+ *
|
|
Matej Habrnal |
5c8df3 |
+ * How the problem formatter handles these extra sections:
|
|
Matej Habrnal |
5c8df3 |
+ *
|
|
Matej Habrnal |
5c8df3 |
+ * A custom section is something like %description section. %description is the
|
|
Matej Habrnal |
5c8df3 |
+ * default section where all text (sub)sections are stored. If the formatter
|
|
Matej Habrnal |
5c8df3 |
+ * finds the custom section in format string, then starts storing text
|
|
Matej Habrnal |
5c8df3 |
+ * (sub)sections in the custom section.
|
|
Matej Habrnal |
5c8df3 |
+ *
|
|
Matej Habrnal |
5c8df3 |
+ * (%description) |:: comment
|
|
Matej Habrnal |
5c8df3 |
+ * (%description) |
|
|
Matej Habrnal |
5c8df3 |
+ * (%description) |Package:: package
|
|
Matej Habrnal |
5c8df3 |
+ * (%description) |
|
|
Matej Habrnal |
5c8df3 |
+ * (%additiona_info) |%additional_info::
|
|
Matej Habrnal |
5c8df3 |
+ * (%additiona_info) |%reporter%
|
|
Matej Habrnal |
5c8df3 |
+ * (%additiona_info) |User:: user_name,uid
|
|
Matej Habrnal |
5c8df3 |
+ * (%additiona_info) |
|
|
Matej Habrnal |
5c8df3 |
+ * (%additiona_info) |Directories:: root,cwd
|
|
Matej Habrnal |
5c8df3 |
+ *
|
|
Matej Habrnal |
5c8df3 |
+ *
|
|
Matej Habrnal |
5c8df3 |
+ * @param self Problem formatter
|
|
Matej Habrnal |
5c8df3 |
+ * @param name Name of the added section
|
|
Matej Habrnal |
5c8df3 |
+ * @param flags Info about the added section
|
|
Matej Habrnal |
5c8df3 |
+ * @return Zero on success. -EEXIST if the name is already known by the formatter
|
|
Matej Habrnal |
5c8df3 |
+ */
|
|
Matej Habrnal |
5c8df3 |
+int problem_formatter_add_section(problem_formatter_t *self, const char *name, int flags);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+/*
|
|
Matej Habrnal |
5c8df3 |
+ * Loads a problem format from a string.
|
|
Matej Habrnal |
5c8df3 |
+ *
|
|
Matej Habrnal |
5c8df3 |
+ * @param self Problem formatter
|
|
Matej Habrnal |
5c8df3 |
+ * @param fmt Format
|
|
Matej Habrnal |
5c8df3 |
+ * @return Zero on success or number of warnings (e.g. missing section,
|
|
Matej Habrnal |
5c8df3 |
+ * unrecognized section).
|
|
Matej Habrnal |
5c8df3 |
+ */
|
|
Matej Habrnal |
5c8df3 |
+int problem_formatter_load_string(problem_formatter_t* self, const char *fmt);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+/*
|
|
Matej Habrnal |
5c8df3 |
+ * Loads a problem format from a file.
|
|
Matej Habrnal |
5c8df3 |
+ *
|
|
Matej Habrnal |
5c8df3 |
+ * @param self Problem formatter
|
|
Matej Habrnal |
5c8df3 |
+ * @param pat Path to the format file
|
|
Matej Habrnal |
5c8df3 |
+ * @return Zero on success or number of warnings (e.g. missing section,
|
|
Matej Habrnal |
5c8df3 |
+ * unrecognized section).
|
|
Matej Habrnal |
5c8df3 |
+ */
|
|
Matej Habrnal |
5c8df3 |
+int problem_formatter_load_file(problem_formatter_t* self, const char *path);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+/*
|
|
Matej Habrnal |
5c8df3 |
+ * Creates a new problem report, formats the data according to the loaded
|
|
Matej Habrnal |
5c8df3 |
+ * format string and stores output in the report.
|
|
Matej Habrnal |
5c8df3 |
+ *
|
|
Matej Habrnal |
5c8df3 |
+ * @param self Problem formatter
|
|
Matej Habrnal |
5c8df3 |
+ * @param data Problem data to format
|
|
Matej Habrnal |
5c8df3 |
+ * @param report Pointer where the created problem report is to be stored
|
|
Matej Habrnal |
5c8df3 |
+ * @return Zero on success, otherwise non-zero value.
|
|
Matej Habrnal |
5c8df3 |
+ */
|
|
Matej Habrnal |
5c8df3 |
+int problem_formatter_generate_report(const problem_formatter_t *self, problem_data_t *data, problem_report_t **report);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+#ifdef __cplusplus
|
|
Matej Habrnal |
5c8df3 |
+}
|
|
Matej Habrnal |
5c8df3 |
+#endif
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+#endif // LIBREPORT_PROBLEM_REPORT_H
|
|
Matej Habrnal |
5c8df3 |
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
|
|
Matej Habrnal |
5c8df3 |
index 7d9722a..a0001ef 100644
|
|
Matej Habrnal |
5c8df3 |
--- a/src/lib/Makefile.am
|
|
Matej Habrnal |
5c8df3 |
+++ b/src/lib/Makefile.am
|
|
Matej Habrnal |
5c8df3 |
@@ -38,6 +38,7 @@ libreport_la_SOURCES = \
|
|
Matej Habrnal |
5c8df3 |
make_descr.c \
|
|
Matej Habrnal |
5c8df3 |
run_event.c \
|
|
Matej Habrnal |
5c8df3 |
problem_data.c \
|
|
Matej Habrnal |
5c8df3 |
+ problem_report.c \
|
|
Matej Habrnal |
5c8df3 |
create_dump_dir.c \
|
|
Matej Habrnal |
5c8df3 |
abrt_types.c \
|
|
Matej Habrnal |
5c8df3 |
parse_release.c \
|
|
Matej Habrnal |
5c8df3 |
@@ -76,6 +77,7 @@ libreport_la_CPPFLAGS = \
|
|
Matej Habrnal |
5c8df3 |
$(GLIB_CFLAGS) \
|
|
Matej Habrnal |
5c8df3 |
$(GOBJECT_CFLAGS) \
|
|
Matej Habrnal |
5c8df3 |
$(AUGEAS_CFLAGS) \
|
|
Matej Habrnal |
5c8df3 |
+ $(SATYR_CFLAGS) \
|
|
Matej Habrnal |
5c8df3 |
-D_GNU_SOURCE
|
|
Matej Habrnal |
5c8df3 |
libreport_la_LDFLAGS = \
|
|
Matej Habrnal |
5c8df3 |
-version-info 0:1:0
|
|
Matej Habrnal |
5c8df3 |
@@ -84,7 +86,8 @@ libreport_la_LIBADD = \
|
|
Matej Habrnal |
5c8df3 |
$(GLIB_LIBS) \
|
|
Matej Habrnal |
5c8df3 |
$(JOURNAL_LIBS) \
|
|
Matej Habrnal |
5c8df3 |
$(GOBJECT_LIBS) \
|
|
Matej Habrnal |
5c8df3 |
- $(AUGEAS_LIBS)
|
|
Matej Habrnal |
5c8df3 |
+ $(AUGEAS_LIBS) \
|
|
Matej Habrnal |
5c8df3 |
+ $(SATYR_LIBS)
|
|
Matej Habrnal |
5c8df3 |
|
|
Matej Habrnal |
5c8df3 |
libreportconfdir = $(CONF_DIR)
|
|
Matej Habrnal |
5c8df3 |
dist_libreportconf_DATA = \
|
|
Matej Habrnal |
5c8df3 |
diff --git a/src/lib/problem_report.c b/src/lib/problem_report.c
|
|
Matej Habrnal |
5c8df3 |
new file mode 100644
|
|
Matej Habrnal |
5c8df3 |
index 0000000..0afc1ca
|
|
Matej Habrnal |
5c8df3 |
--- /dev/null
|
|
Matej Habrnal |
5c8df3 |
+++ b/src/lib/problem_report.c
|
|
Matej Habrnal |
5c8df3 |
@@ -0,0 +1,1209 @@
|
|
Matej Habrnal |
5c8df3 |
+/*
|
|
Matej Habrnal |
5c8df3 |
+ Copyright (C) 2014 ABRT team
|
|
Matej Habrnal |
5c8df3 |
+ Copyright (C) 2014 RedHat Inc
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ This program is free software; you can redistribute it and/or modify
|
|
Matej Habrnal |
5c8df3 |
+ it under the terms of the GNU General Public License as published by
|
|
Matej Habrnal |
5c8df3 |
+ the Free Software Foundation; either version 2 of the License, or
|
|
Matej Habrnal |
5c8df3 |
+ (at your option) any later version.
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ This program is distributed in the hope that it will be useful,
|
|
Matej Habrnal |
5c8df3 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Matej Habrnal |
5c8df3 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Matej Habrnal |
5c8df3 |
+ GNU General Public License for more details.
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ You should have received a copy of the GNU General Public License along
|
|
Matej Habrnal |
5c8df3 |
+ with this program; if not, write to the Free Software Foundation, Inc.,
|
|
Matej Habrnal |
5c8df3 |
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
Matej Habrnal |
5c8df3 |
+*/
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+#include "problem_report.h"
|
|
Matej Habrnal |
5c8df3 |
+#include "internal_libreport.h"
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+#include <satyr/stacktrace.h>
|
|
Matej Habrnal |
5c8df3 |
+#include <satyr/abrt.h>
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+#include <assert.h>
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+#define DESTROYED_POINTER (void *)0xdeadbeef
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+/* FORMAT:
|
|
Matej Habrnal |
5c8df3 |
+ * |%summary:: Hello, world
|
|
Matej Habrnal |
5c8df3 |
+ * |Problem description:: %bare_comment
|
|
Matej Habrnal |
5c8df3 |
+ * |
|
|
Matej Habrnal |
5c8df3 |
+ * |Package:: package
|
|
Matej Habrnal |
5c8df3 |
+ * |
|
|
Matej Habrnal |
5c8df3 |
+ * |%attach: %binary, backtrace
|
|
Matej Habrnal |
5c8df3 |
+ * |
|
|
Matej Habrnal |
5c8df3 |
+ * |%additional_info::
|
|
Matej Habrnal |
5c8df3 |
+ * |%reporter%
|
|
Matej Habrnal |
5c8df3 |
+ * |User:: user_name,uid
|
|
Matej Habrnal |
5c8df3 |
+ * |
|
|
Matej Habrnal |
5c8df3 |
+ * |Directories:: root,cwd
|
|
Matej Habrnal |
5c8df3 |
+ *
|
|
Matej Habrnal |
5c8df3 |
+ * PARSED DATA (list of struct section_t):
|
|
Matej Habrnal |
5c8df3 |
+ * {
|
|
Matej Habrnal |
5c8df3 |
+ * section_t {
|
|
Matej Habrnal |
5c8df3 |
+ * .name = '%summary';
|
|
Matej Habrnal |
5c8df3 |
+ * .items = { 'Hello, world' };
|
|
Matej Habrnal |
5c8df3 |
+ * .children = NULL;
|
|
Matej Habrnal |
5c8df3 |
+ * },
|
|
Matej Habrnal |
5c8df3 |
+ * section_t {
|
|
Matej Habrnal |
5c8df3 |
+ * .name = '%attach'
|
|
Matej Habrnal |
5c8df3 |
+ * .items = { '%binary', 'backtrace' };
|
|
Matej Habrnal |
5c8df3 |
+ * .children = NULL;
|
|
Matej Habrnal |
5c8df3 |
+ * },
|
|
Matej Habrnal |
5c8df3 |
+ * section_t {
|
|
Matej Habrnal |
5c8df3 |
+ * .name = '%description'
|
|
Matej Habrnal |
5c8df3 |
+ * .items = NULL;
|
|
Matej Habrnal |
5c8df3 |
+ * .children = {
|
|
Matej Habrnal |
5c8df3 |
+ * section_t {
|
|
Matej Habrnal |
5c8df3 |
+ * .name = 'Problem description:';
|
|
Matej Habrnal |
5c8df3 |
+ * .items = { '%bare_comment' };
|
|
Matej Habrnal |
5c8df3 |
+ * .children = NULL;
|
|
Matej Habrnal |
5c8df3 |
+ * },
|
|
Matej Habrnal |
5c8df3 |
+ * section_t {
|
|
Matej Habrnal |
5c8df3 |
+ * .name = '';
|
|
Matej Habrnal |
5c8df3 |
+ * .items = NULL;
|
|
Matej Habrnal |
5c8df3 |
+ * .children = NULL;
|
|
Matej Habrnal |
5c8df3 |
+ * },
|
|
Matej Habrnal |
5c8df3 |
+ * section_t {
|
|
Matej Habrnal |
5c8df3 |
+ * .name = 'Package:';
|
|
Matej Habrnal |
5c8df3 |
+ * .items = { 'package' };
|
|
Matej Habrnal |
5c8df3 |
+ * .children = NULL;
|
|
Matej Habrnal |
5c8df3 |
+ * },
|
|
Matej Habrnal |
5c8df3 |
+ * }
|
|
Matej Habrnal |
5c8df3 |
+ * },
|
|
Matej Habrnal |
5c8df3 |
+ * section_t {
|
|
Matej Habrnal |
5c8df3 |
+ * .name = '%additional_info'
|
|
Matej Habrnal |
5c8df3 |
+ * .items = { '%reporter%' };
|
|
Matej Habrnal |
5c8df3 |
+ * .children = {
|
|
Matej Habrnal |
5c8df3 |
+ * section_t {
|
|
Matej Habrnal |
5c8df3 |
+ * .name = 'User:';
|
|
Matej Habrnal |
5c8df3 |
+ * .items = { 'user_name', 'uid' };
|
|
Matej Habrnal |
5c8df3 |
+ * .children = NULL;
|
|
Matej Habrnal |
5c8df3 |
+ * },
|
|
Matej Habrnal |
5c8df3 |
+ * section_t {
|
|
Matej Habrnal |
5c8df3 |
+ * .name = '';
|
|
Matej Habrnal |
5c8df3 |
+ * .items = NULL;
|
|
Matej Habrnal |
5c8df3 |
+ * .children = NULL;
|
|
Matej Habrnal |
5c8df3 |
+ * },
|
|
Matej Habrnal |
5c8df3 |
+ * section_t {
|
|
Matej Habrnal |
5c8df3 |
+ * .name = 'Directories:';
|
|
Matej Habrnal |
5c8df3 |
+ * .items = { 'root', 'cwd' };
|
|
Matej Habrnal |
5c8df3 |
+ * .children = NULL;
|
|
Matej Habrnal |
5c8df3 |
+ * },
|
|
Matej Habrnal |
5c8df3 |
+ * }
|
|
Matej Habrnal |
5c8df3 |
+ * }
|
|
Matej Habrnal |
5c8df3 |
+ * }
|
|
Matej Habrnal |
5c8df3 |
+ */
|
|
Matej Habrnal |
5c8df3 |
+struct section_t {
|
|
Matej Habrnal |
5c8df3 |
+ char *name; ///< name or output text (%summar, 'Package version:');
|
|
Matej Habrnal |
5c8df3 |
+ GList *items; ///< list of file names and special items (%reporter, %binar, ...)
|
|
Matej Habrnal |
5c8df3 |
+ GList *children; ///< list of sub sections (struct section_t)
|
|
Matej Habrnal |
5c8df3 |
+};
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+typedef struct section_t section_t;
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+static section_t *
|
|
Matej Habrnal |
5c8df3 |
+section_new(const char *name)
|
|
Matej Habrnal |
5c8df3 |
+{
|
|
Matej Habrnal |
5c8df3 |
+ section_t *self = xmalloc(sizeof(*self));
|
|
Matej Habrnal |
5c8df3 |
+ self->name = xstrdup(name);
|
|
Matej Habrnal |
5c8df3 |
+ self->items = NULL;
|
|
Matej Habrnal |
5c8df3 |
+ self->children = NULL;
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ return self;
|
|
Matej Habrnal |
5c8df3 |
+}
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+static void
|
|
Matej Habrnal |
5c8df3 |
+section_free(section_t *self)
|
|
Matej Habrnal |
5c8df3 |
+{
|
|
Matej Habrnal |
5c8df3 |
+ if (self == NULL)
|
|
Matej Habrnal |
5c8df3 |
+ return;
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ free(self->name);
|
|
Matej Habrnal |
5c8df3 |
+ g_list_free_full(self->items, free);
|
|
Matej Habrnal |
5c8df3 |
+ g_list_free_full(self->children, (GDestroyNotify)section_free);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ free(self);
|
|
Matej Habrnal |
5c8df3 |
+}
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+static int
|
|
Matej Habrnal |
5c8df3 |
+section_name_cmp(section_t *lhs, const char *rhs)
|
|
Matej Habrnal |
5c8df3 |
+{
|
|
Matej Habrnal |
5c8df3 |
+ return strcmp((lhs->name + 1), rhs);
|
|
Matej Habrnal |
5c8df3 |
+}
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+/* Utility functions */
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+static GList*
|
|
Matej Habrnal |
5c8df3 |
+split_string_on_char(const char *str, char ch)
|
|
Matej Habrnal |
5c8df3 |
+{
|
|
Matej Habrnal |
5c8df3 |
+ GList *list = NULL;
|
|
Matej Habrnal |
5c8df3 |
+ for (;;)
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ const char *delim = strchrnul(str, ch);
|
|
Matej Habrnal |
5c8df3 |
+ list = g_list_prepend(list, xstrndup(str, delim - str));
|
|
Matej Habrnal |
5c8df3 |
+ if (*delim == '\0')
|
|
Matej Habrnal |
5c8df3 |
+ break;
|
|
Matej Habrnal |
5c8df3 |
+ str = delim + 1;
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+ return g_list_reverse(list);
|
|
Matej Habrnal |
5c8df3 |
+}
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+static int
|
|
Matej Habrnal |
5c8df3 |
+compare_item_name(const char *lookup, const char *name)
|
|
Matej Habrnal |
5c8df3 |
+{
|
|
Matej Habrnal |
5c8df3 |
+ if (lookup[0] == '-')
|
|
Matej Habrnal |
5c8df3 |
+ lookup++;
|
|
Matej Habrnal |
5c8df3 |
+ else if (strncmp(lookup, "%bare_", 6) == 0)
|
|
Matej Habrnal |
5c8df3 |
+ lookup += 6;
|
|
Matej Habrnal |
5c8df3 |
+ return strcmp(lookup, name);
|
|
Matej Habrnal |
5c8df3 |
+}
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+static int
|
|
Matej Habrnal |
5c8df3 |
+is_item_name_in_section(const section_t *lookup, const char *name)
|
|
Matej Habrnal |
5c8df3 |
+{
|
|
Matej Habrnal |
5c8df3 |
+ if (g_list_find_custom(lookup->items, name, (GCompareFunc)compare_item_name))
|
|
Matej Habrnal |
5c8df3 |
+ return 0; /* "found it!" */
|
|
Matej Habrnal |
5c8df3 |
+ return 1;
|
|
Matej Habrnal |
5c8df3 |
+}
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+static bool is_explicit_or_forbidden(const char *name, GList *comment_fmt_spec);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+static int
|
|
Matej Habrnal |
5c8df3 |
+is_explicit_or_forbidden_child(const section_t *master_section, const char *name)
|
|
Matej Habrnal |
5c8df3 |
+{
|
|
Matej Habrnal |
5c8df3 |
+ if (is_explicit_or_forbidden(name, master_section->children))
|
|
Matej Habrnal |
5c8df3 |
+ return 0; /* "found it!" */
|
|
Matej Habrnal |
5c8df3 |
+ return 1;
|
|
Matej Habrnal |
5c8df3 |
+}
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+/* For example: 'package' belongs to '%oneline', but 'package' is used in
|
|
Matej Habrnal |
5c8df3 |
+ * 'Version of component', so it is not very helpful to include that file once
|
|
Matej Habrnal |
5c8df3 |
+ * more in another section
|
|
Matej Habrnal |
5c8df3 |
+ */
|
|
Matej Habrnal |
5c8df3 |
+static bool
|
|
Matej Habrnal |
5c8df3 |
+is_explicit_or_forbidden(const char *name, GList *comment_fmt_spec)
|
|
Matej Habrnal |
5c8df3 |
+{
|
|
Matej Habrnal |
5c8df3 |
+ return g_list_find_custom(comment_fmt_spec, name, (GCompareFunc)is_item_name_in_section)
|
|
Matej Habrnal |
5c8df3 |
+ || g_list_find_custom(comment_fmt_spec, name, (GCompareFunc)is_explicit_or_forbidden_child);
|
|
Matej Habrnal |
5c8df3 |
+}
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+static GList*
|
|
Matej Habrnal |
5c8df3 |
+load_stream(FILE *fp)
|
|
Matej Habrnal |
5c8df3 |
+{
|
|
Matej Habrnal |
5c8df3 |
+ assert(fp);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ GList *sections = NULL;
|
|
Matej Habrnal |
5c8df3 |
+ section_t *master = section_new("%description");
|
|
Matej Habrnal |
5c8df3 |
+ section_t *sec = NULL;
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ sections = g_list_append(sections, master);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ char *line;
|
|
Matej Habrnal |
5c8df3 |
+ while ((line = xmalloc_fgetline(fp)) != NULL)
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ /* Skip comments */
|
|
Matej Habrnal |
5c8df3 |
+ char first = *skip_whitespace(line);
|
|
Matej Habrnal |
5c8df3 |
+ if (first == '#')
|
|
Matej Habrnal |
5c8df3 |
+ goto free_line;
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ /* Handle trailing backslash continuation */
|
|
Matej Habrnal |
5c8df3 |
+ check_continuation: ;
|
|
Matej Habrnal |
5c8df3 |
+ unsigned len = strlen(line);
|
|
Matej Habrnal |
5c8df3 |
+ if (len && line[len-1] == '\\')
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ line[len-1] = '\0';
|
|
Matej Habrnal |
5c8df3 |
+ char *next_line = xmalloc_fgetline(fp);
|
|
Matej Habrnal |
5c8df3 |
+ if (next_line)
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ line = append_to_malloced_string(line, next_line);
|
|
Matej Habrnal |
5c8df3 |
+ free(next_line);
|
|
Matej Habrnal |
5c8df3 |
+ goto check_continuation;
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ /* We are reusing line buffer to form temporary
|
|
Matej Habrnal |
5c8df3 |
+ * "key\0values\0..." in its beginning
|
|
Matej Habrnal |
5c8df3 |
+ */
|
|
Matej Habrnal |
5c8df3 |
+ bool summary_line = false;
|
|
Matej Habrnal |
5c8df3 |
+ char *value = NULL;
|
|
Matej Habrnal |
5c8df3 |
+ char *src;
|
|
Matej Habrnal |
5c8df3 |
+ char *dst;
|
|
Matej Habrnal |
5c8df3 |
+ for (src = dst = line; *src; src++)
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ char c = *src;
|
|
Matej Habrnal |
5c8df3 |
+ /* did we reach the value list? */
|
|
Matej Habrnal |
5c8df3 |
+ if (!value && c == ':' && src[1] == ':')
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ *dst++ = '\0'; /* terminate key */
|
|
Matej Habrnal |
5c8df3 |
+ src += 1;
|
|
Matej Habrnal |
5c8df3 |
+ value = dst; /* remember where value starts */
|
|
Matej Habrnal |
5c8df3 |
+ summary_line = (strcmp(line, "%summary") == 0);
|
|
Matej Habrnal |
5c8df3 |
+ if (summary_line)
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ value = (src + 1);
|
|
Matej Habrnal |
5c8df3 |
+ break;
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+ continue;
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+ /* skip whitespace in value list */
|
|
Matej Habrnal |
5c8df3 |
+ if (value && isspace(c))
|
|
Matej Habrnal |
5c8df3 |
+ continue;
|
|
Matej Habrnal |
5c8df3 |
+ *dst++ = c; /* store next key or value char */
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ GList *item_list = NULL;
|
|
Matej Habrnal |
5c8df3 |
+ if (summary_line)
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ /* %summary is special */
|
|
Matej Habrnal |
5c8df3 |
+ item_list = g_list_append(NULL, xstrdup(skip_whitespace(value)));
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+ else
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ *dst = '\0'; /* terminate value (or key) */
|
|
Matej Habrnal |
5c8df3 |
+ if (value)
|
|
Matej Habrnal |
5c8df3 |
+ item_list = split_string_on_char(value, ',');
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ sec = section_new(line);
|
|
Matej Habrnal |
5c8df3 |
+ sec->items = item_list;
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ if (sec->name[0] == '%')
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ if (!summary_line && strcmp(sec->name, "%attach") != 0)
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ master->children = g_list_reverse(master->children);
|
|
Matej Habrnal |
5c8df3 |
+ master = sec;
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ sections = g_list_prepend(sections, sec);
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+ else
|
|
Matej Habrnal |
5c8df3 |
+ master->children = g_list_prepend(master->children, sec);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ free_line:
|
|
Matej Habrnal |
5c8df3 |
+ free(line);
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ /* If master equals sec, then master's children list was not yet reversed.
|
|
Matej Habrnal |
5c8df3 |
+ *
|
|
Matej Habrnal |
5c8df3 |
+ * %description is the default section (i.e is not explicitly mentioned)
|
|
Matej Habrnal |
5c8df3 |
+ * and %summary nor %attach cause its children list to reverse.
|
|
Matej Habrnal |
5c8df3 |
+ */
|
|
Matej Habrnal |
5c8df3 |
+ if (master == sec || strcmp(master->name, "%description") == 0)
|
|
Matej Habrnal |
5c8df3 |
+ master->children = g_list_reverse(master->children);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ return sections;
|
|
Matej Habrnal |
5c8df3 |
+}
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+/* Summary generation */
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+#define MAX_OPT_DEPTH 10
|
|
Matej Habrnal |
5c8df3 |
+static int
|
|
Matej Habrnal |
5c8df3 |
+format_percented_string(const char *str, problem_data_t *pd, FILE *result)
|
|
Matej Habrnal |
5c8df3 |
+{
|
|
Matej Habrnal |
5c8df3 |
+ long old_pos[MAX_OPT_DEPTH] = { 0 };
|
|
Matej Habrnal |
5c8df3 |
+ int okay[MAX_OPT_DEPTH] = { 1 };
|
|
Matej Habrnal |
5c8df3 |
+ long len = 0;
|
|
Matej Habrnal |
5c8df3 |
+ int opt_depth = 1;
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ while (*str) {
|
|
Matej Habrnal |
5c8df3 |
+ switch (*str) {
|
|
Matej Habrnal |
5c8df3 |
+ default:
|
|
Matej Habrnal |
5c8df3 |
+ putc(*str, result);
|
|
Matej Habrnal |
5c8df3 |
+ len++;
|
|
Matej Habrnal |
5c8df3 |
+ str++;
|
|
Matej Habrnal |
5c8df3 |
+ break;
|
|
Matej Habrnal |
5c8df3 |
+ case '\\':
|
|
Matej Habrnal |
5c8df3 |
+ if (str[1])
|
|
Matej Habrnal |
5c8df3 |
+ str++;
|
|
Matej Habrnal |
5c8df3 |
+ putc(*str, result);
|
|
Matej Habrnal |
5c8df3 |
+ len++;
|
|
Matej Habrnal |
5c8df3 |
+ str++;
|
|
Matej Habrnal |
5c8df3 |
+ break;
|
|
Matej Habrnal |
5c8df3 |
+ case '[':
|
|
Matej Habrnal |
5c8df3 |
+ if (str[1] == '[' && opt_depth < MAX_OPT_DEPTH)
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ old_pos[opt_depth] = len;
|
|
Matej Habrnal |
5c8df3 |
+ okay[opt_depth] = 1;
|
|
Matej Habrnal |
5c8df3 |
+ opt_depth++;
|
|
Matej Habrnal |
5c8df3 |
+ str += 2;
|
|
Matej Habrnal |
5c8df3 |
+ } else {
|
|
Matej Habrnal |
5c8df3 |
+ putc(*str, result);
|
|
Matej Habrnal |
5c8df3 |
+ len++;
|
|
Matej Habrnal |
5c8df3 |
+ str++;
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+ break;
|
|
Matej Habrnal |
5c8df3 |
+ case ']':
|
|
Matej Habrnal |
5c8df3 |
+ if (str[1] == ']' && opt_depth > 1)
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ opt_depth--;
|
|
Matej Habrnal |
5c8df3 |
+ if (!okay[opt_depth])
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ fseek(result, old_pos[opt_depth], SEEK_SET);
|
|
Matej Habrnal |
5c8df3 |
+ len = old_pos[opt_depth];
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+ str += 2;
|
|
Matej Habrnal |
5c8df3 |
+ } else {
|
|
Matej Habrnal |
5c8df3 |
+ putc(*str, result);
|
|
Matej Habrnal |
5c8df3 |
+ len++;
|
|
Matej Habrnal |
5c8df3 |
+ str++;
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+ break;
|
|
Matej Habrnal |
5c8df3 |
+ case '%': ;
|
|
Matej Habrnal |
5c8df3 |
+ char *nextpercent = strchr(++str, '%');
|
|
Matej Habrnal |
5c8df3 |
+ if (!nextpercent)
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ error_msg_and_die("Unterminated %%element%%: '%s'", str - 1);
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ *nextpercent = '\0';
|
|
Matej Habrnal |
5c8df3 |
+ const problem_item *item = problem_data_get_item_or_NULL(pd, str);
|
|
Matej Habrnal |
5c8df3 |
+ *nextpercent = '%';
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ if (item && (item->flags & CD_FLAG_TXT))
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ fputs(item->content, result);
|
|
Matej Habrnal |
5c8df3 |
+ len += strlen(item->content);
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+ else
|
|
Matej Habrnal |
5c8df3 |
+ okay[opt_depth - 1] = 0;
|
|
Matej Habrnal |
5c8df3 |
+ str = nextpercent + 1;
|
|
Matej Habrnal |
5c8df3 |
+ break;
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ if (opt_depth > 1)
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ error_msg_and_die("Unbalanced [[ ]] bracket");
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ if (!okay[0])
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ error_msg("Undefined variable outside of [[ ]] bracket");
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ return 0;
|
|
Matej Habrnal |
5c8df3 |
+}
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+/* BZ comment generation */
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+static int
|
|
Matej Habrnal |
5c8df3 |
+append_text(struct strbuf *result, const char *item_name, const char *content, bool print_item_name)
|
|
Matej Habrnal |
5c8df3 |
+{
|
|
Matej Habrnal |
5c8df3 |
+ char *eol = strchrnul(content, '\n');
|
|
Matej Habrnal |
5c8df3 |
+ if (eol[0] == '\0' || eol[1] == '\0')
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ /* one-liner */
|
|
Matej Habrnal |
5c8df3 |
+ int pad = 16 - (strlen(item_name) + 2);
|
|
Matej Habrnal |
5c8df3 |
+ if (pad < 0)
|
|
Matej Habrnal |
5c8df3 |
+ pad = 0;
|
|
Matej Habrnal |
5c8df3 |
+ if (print_item_name)
|
|
Matej Habrnal |
5c8df3 |
+ strbuf_append_strf(result,
|
|
Matej Habrnal |
5c8df3 |
+ eol[0] == '\0' ? "%s: %*s%s\n" : "%s: %*s%s",
|
|
Matej Habrnal |
5c8df3 |
+ item_name, pad, "", content
|
|
Matej Habrnal |
5c8df3 |
+ );
|
|
Matej Habrnal |
5c8df3 |
+ else
|
|
Matej Habrnal |
5c8df3 |
+ strbuf_append_strf(result,
|
|
Matej Habrnal |
5c8df3 |
+ eol[0] == '\0' ? "%s\n" : "%s",
|
|
Matej Habrnal |
5c8df3 |
+ content
|
|
Matej Habrnal |
5c8df3 |
+ );
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+ else
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ /* multi-line item */
|
|
Matej Habrnal |
5c8df3 |
+ if (print_item_name)
|
|
Matej Habrnal |
5c8df3 |
+ strbuf_append_strf(result, "%s:\n", item_name);
|
|
Matej Habrnal |
5c8df3 |
+ for (;;)
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ eol = strchrnul(content, '\n');
|
|
Matej Habrnal |
5c8df3 |
+ strbuf_append_strf(result,
|
|
Matej Habrnal |
5c8df3 |
+ /* For %bare_multiline_item, we don't want to print colons */
|
|
Matej Habrnal |
5c8df3 |
+ (print_item_name ? ":%.*s\n" : "%.*s\n"),
|
|
Matej Habrnal |
5c8df3 |
+ (int)(eol - content), content
|
|
Matej Habrnal |
5c8df3 |
+ );
|
|
Matej Habrnal |
5c8df3 |
+ if (eol[0] == '\0' || eol[1] == '\0')
|
|
Matej Habrnal |
5c8df3 |
+ break;
|
|
Matej Habrnal |
5c8df3 |
+ content = eol + 1;
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+ return 1;
|
|
Matej Habrnal |
5c8df3 |
+}
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+static int
|
|
Matej Habrnal |
5c8df3 |
+append_short_backtrace(struct strbuf *result, problem_data_t *problem_data, size_t max_text_size, bool print_item_name)
|
|
Matej Habrnal |
5c8df3 |
+{
|
|
Matej Habrnal |
5c8df3 |
+ const problem_item *item = problem_data_get_item_or_NULL(problem_data,
|
|
Matej Habrnal |
5c8df3 |
+ FILENAME_BACKTRACE);
|
|
Matej Habrnal |
5c8df3 |
+ if (!item)
|
|
Matej Habrnal |
5c8df3 |
+ return 0; /* "I did not print anything" */
|
|
Matej Habrnal |
5c8df3 |
+ if (!(item->flags & CD_FLAG_TXT))
|
|
Matej Habrnal |
5c8df3 |
+ return 0; /* "I did not print anything" */
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ char *truncated = NULL;
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ if (strlen(item->content) >= max_text_size)
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ log_debug("'backtrace' exceeds the text file size, going to append its short version");
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ char *error_msg = NULL;
|
|
Matej Habrnal |
5c8df3 |
+ const char *analyzer = problem_data_get_content_or_NULL(problem_data, FILENAME_ANALYZER);
|
|
Matej Habrnal |
5c8df3 |
+ if (!analyzer)
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ log_debug("Problem data does not contain '"FILENAME_ANALYZER"' file");
|
|
Matej Habrnal |
5c8df3 |
+ return 0;
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ /* For CCpp crashes, use the GDB-produced backtrace which should be
|
|
Matej Habrnal |
5c8df3 |
+ * available by now. sr_abrt_type_from_analyzer returns SR_REPORT_CORE
|
|
Matej Habrnal |
5c8df3 |
+ * by default for CCpp crashes.
|
|
Matej Habrnal |
5c8df3 |
+ */
|
|
Matej Habrnal |
5c8df3 |
+ enum sr_report_type report_type = sr_abrt_type_from_analyzer(analyzer);
|
|
Matej Habrnal |
5c8df3 |
+ if (strcmp(analyzer, "CCpp") == 0)
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ log_debug("Successfully identified 'CCpp' abrt type");
|
|
Matej Habrnal |
5c8df3 |
+ report_type = SR_REPORT_GDB;
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ struct sr_stacktrace *backtrace = sr_stacktrace_parse(report_type,
|
|
Matej Habrnal |
5c8df3 |
+ item->content, &error_msg);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ if (!backtrace)
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ log(_("Can't parse backtrace: %s"), error_msg);
|
|
Matej Habrnal |
5c8df3 |
+ free(error_msg);
|
|
Matej Habrnal |
5c8df3 |
+ return 0;
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ /* Get optimized thread stack trace for 10 top most frames */
|
|
Matej Habrnal |
5c8df3 |
+ truncated = sr_stacktrace_to_short_text(backtrace, 10);
|
|
Matej Habrnal |
5c8df3 |
+ sr_stacktrace_free(backtrace);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ if (!truncated)
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ log(_("Can't generate stacktrace description (no crash thread?)"));
|
|
Matej Habrnal |
5c8df3 |
+ return 0;
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+ else
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ log_debug("'backtrace' is small enough to be included as is");
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ append_text(result,
|
|
Matej Habrnal |
5c8df3 |
+ /*item_name:*/ truncated ? "truncated_backtrace" : FILENAME_BACKTRACE,
|
|
Matej Habrnal |
5c8df3 |
+ /*content:*/ truncated ? truncated : item->content,
|
|
Matej Habrnal |
5c8df3 |
+ print_item_name
|
|
Matej Habrnal |
5c8df3 |
+ );
|
|
Matej Habrnal |
5c8df3 |
+ free(truncated);
|
|
Matej Habrnal |
5c8df3 |
+ return 1;
|
|
Matej Habrnal |
5c8df3 |
+}
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+static int
|
|
Matej Habrnal |
5c8df3 |
+append_item(struct strbuf *result, const char *item_name, problem_data_t *pd, GList *comment_fmt_spec)
|
|
Matej Habrnal |
5c8df3 |
+{
|
|
Matej Habrnal |
5c8df3 |
+ bool print_item_name = (strncmp(item_name, "%bare_", strlen("%bare_")) != 0);
|
|
Matej Habrnal |
5c8df3 |
+ if (!print_item_name)
|
|
Matej Habrnal |
5c8df3 |
+ item_name += strlen("%bare_");
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ if (item_name[0] != '%')
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ struct problem_item *item = problem_data_get_item_or_NULL(pd, item_name);
|
|
Matej Habrnal |
5c8df3 |
+ if (!item)
|
|
Matej Habrnal |
5c8df3 |
+ return 0; /* "I did not print anything" */
|
|
Matej Habrnal |
5c8df3 |
+ if (!(item->flags & CD_FLAG_TXT))
|
|
Matej Habrnal |
5c8df3 |
+ return 0; /* "I did not print anything" */
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ char *formatted = problem_item_format(item);
|
|
Matej Habrnal |
5c8df3 |
+ char *content = formatted ? formatted : item->content;
|
|
Matej Habrnal |
5c8df3 |
+ append_text(result, item_name, content, print_item_name);
|
|
Matej Habrnal |
5c8df3 |
+ free(formatted);
|
|
Matej Habrnal |
5c8df3 |
+ return 1; /* "I printed something" */
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ /* Special item name */
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ /* Compat with previously-existed ad-hockery: %short_backtrace */
|
|
Matej Habrnal |
5c8df3 |
+ if (strcmp(item_name, "%short_backtrace") == 0)
|
|
Matej Habrnal |
5c8df3 |
+ return append_short_backtrace(result, pd, CD_TEXT_ATT_SIZE_BZ, print_item_name);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ /* Compat with previously-existed ad-hockery: %reporter */
|
|
Matej Habrnal |
5c8df3 |
+ if (strcmp(item_name, "%reporter") == 0)
|
|
Matej Habrnal |
5c8df3 |
+ return append_text(result, "reporter", PACKAGE"-"VERSION, print_item_name);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ /* %oneline,%multiline,%text */
|
|
Matej Habrnal |
5c8df3 |
+ bool oneline = (strcmp(item_name+1, "oneline" ) == 0);
|
|
Matej Habrnal |
5c8df3 |
+ bool multiline = (strcmp(item_name+1, "multiline") == 0);
|
|
Matej Habrnal |
5c8df3 |
+ bool text = (strcmp(item_name+1, "text" ) == 0);
|
|
Matej Habrnal |
5c8df3 |
+ if (!oneline && !multiline && !text)
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ log("Unknown or unsupported element specifier '%s'", item_name);
|
|
Matej Habrnal |
5c8df3 |
+ return 0; /* "I did not print anything" */
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ int printed = 0;
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ /* Iterate over _sorted_ items */
|
|
Matej Habrnal |
5c8df3 |
+ GList *sorted_names = g_hash_table_get_keys(pd);
|
|
Matej Habrnal |
5c8df3 |
+ sorted_names = g_list_sort(sorted_names, (GCompareFunc)strcmp);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ /* %text => do as if %oneline, then repeat as if %multiline */
|
|
Matej Habrnal |
5c8df3 |
+ if (text)
|
|
Matej Habrnal |
5c8df3 |
+ oneline = 1;
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ again: ;
|
|
Matej Habrnal |
5c8df3 |
+ GList *l = sorted_names;
|
|
Matej Habrnal |
5c8df3 |
+ while (l)
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ const char *name = l->data;
|
|
Matej Habrnal |
5c8df3 |
+ l = l->next;
|
|
Matej Habrnal |
5c8df3 |
+ struct problem_item *item = g_hash_table_lookup(pd, name);
|
|
Matej Habrnal |
5c8df3 |
+ if (!item)
|
|
Matej Habrnal |
5c8df3 |
+ continue; /* paranoia, won't happen */
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ if (!(item->flags & CD_FLAG_TXT))
|
|
Matej Habrnal |
5c8df3 |
+ continue;
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ if (is_explicit_or_forbidden(name, comment_fmt_spec))
|
|
Matej Habrnal |
5c8df3 |
+ continue;
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ char *formatted = problem_item_format(item);
|
|
Matej Habrnal |
5c8df3 |
+ char *content = formatted ? formatted : item->content;
|
|
Matej Habrnal |
5c8df3 |
+ char *eol = strchrnul(content, '\n');
|
|
Matej Habrnal |
5c8df3 |
+ bool is_oneline = (eol[0] == '\0' || eol[1] == '\0');
|
|
Matej Habrnal |
5c8df3 |
+ if (oneline == is_oneline)
|
|
Matej Habrnal |
5c8df3 |
+ printed |= append_text(result, name, content, print_item_name);
|
|
Matej Habrnal |
5c8df3 |
+ free(formatted);
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+ if (text && oneline)
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ /* %text, and we just did %oneline. Repeat as if %multiline */
|
|
Matej Habrnal |
5c8df3 |
+ oneline = 0;
|
|
Matej Habrnal |
5c8df3 |
+ /*multiline = 1; - not checked in fact, so why bother setting? */
|
|
Matej Habrnal |
5c8df3 |
+ goto again;
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ g_list_free(sorted_names); /* names themselves are not freed */
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ return printed;
|
|
Matej Habrnal |
5c8df3 |
+}
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+#define add_to_section_output(format, ...) \
|
|
Matej Habrnal |
5c8df3 |
+ do { \
|
|
Matej Habrnal |
5c8df3 |
+ for (; empty_lines > 0; --empty_lines) fputc('\n', result); \
|
|
Matej Habrnal |
5c8df3 |
+ empty_lines = 0; \
|
|
Matej Habrnal |
5c8df3 |
+ fprintf(result, format, __VA_ARGS__); \
|
|
Matej Habrnal |
5c8df3 |
+ } while (0)
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+static void
|
|
Matej Habrnal |
5c8df3 |
+format_section(section_t *section, problem_data_t *pd, GList *comment_fmt_spec, FILE *result)
|
|
Matej Habrnal |
5c8df3 |
+{
|
|
Matej Habrnal |
5c8df3 |
+ int empty_lines = -1;
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ for (GList *iter = section->children; iter; iter = g_list_next(iter))
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ section_t *child = (section_t *)iter->data;
|
|
Matej Habrnal |
5c8df3 |
+ if (child->items)
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ /* "Text: item[,item]..." */
|
|
Matej Habrnal |
5c8df3 |
+ struct strbuf *output = strbuf_new();
|
|
Matej Habrnal |
5c8df3 |
+ GList *item = child->items;
|
|
Matej Habrnal |
5c8df3 |
+ while (item)
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ const char *str = item->data;
|
|
Matej Habrnal |
5c8df3 |
+ item = item->next;
|
|
Matej Habrnal |
5c8df3 |
+ if (str[0] == '-') /* "-name", ignore it */
|
|
Matej Habrnal |
5c8df3 |
+ continue;
|
|
Matej Habrnal |
5c8df3 |
+ append_item(output, str, pd, comment_fmt_spec);
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ if (output->len != 0)
|
|
Matej Habrnal |
5c8df3 |
+ add_to_section_output((child->name[0] ? "%s:\n%s" : "%s%s"),
|
|
Matej Habrnal |
5c8df3 |
+ child->name, output->buf);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ strbuf_free(output);
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+ else
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ /* Just "Text" (can be "") */
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ /* Filter out trailint empty lines */
|
|
Matej Habrnal |
5c8df3 |
+ if (child->name[0] != '\0')
|
|
Matej Habrnal |
5c8df3 |
+ add_to_section_output("%s\n", child->name);
|
|
Matej Habrnal |
5c8df3 |
+ /* Do not count empty lines, if output wasn't yet produced */
|
|
Matej Habrnal |
5c8df3 |
+ else if (empty_lines >= 0)
|
|
Matej Habrnal |
5c8df3 |
+ ++empty_lines;
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+}
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+static GList *
|
|
Matej Habrnal |
5c8df3 |
+get_special_items(const char *item_name, problem_data_t *pd, GList *comment_fmt_spec)
|
|
Matej Habrnal |
5c8df3 |
+{
|
|
Matej Habrnal |
5c8df3 |
+ /* %oneline,%multiline,%text,%binary */
|
|
Matej Habrnal |
5c8df3 |
+ bool oneline = (strcmp(item_name+1, "oneline" ) == 0);
|
|
Matej Habrnal |
5c8df3 |
+ bool multiline = (strcmp(item_name+1, "multiline") == 0);
|
|
Matej Habrnal |
5c8df3 |
+ bool text = (strcmp(item_name+1, "text" ) == 0);
|
|
Matej Habrnal |
5c8df3 |
+ bool binary = (strcmp(item_name+1, "binary" ) == 0);
|
|
Matej Habrnal |
5c8df3 |
+ if (!oneline && !multiline && !text && !binary)
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ log("Unknown or unsupported element specifier '%s'", item_name);
|
|
Matej Habrnal |
5c8df3 |
+ return NULL;
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ log_debug("Special item_name '%s', iterating for attach...", item_name);
|
|
Matej Habrnal |
5c8df3 |
+ GList *result = 0;
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ /* Iterate over _sorted_ items */
|
|
Matej Habrnal |
5c8df3 |
+ GList *sorted_names = g_hash_table_get_keys(pd);
|
|
Matej Habrnal |
5c8df3 |
+ sorted_names = g_list_sort(sorted_names, (GCompareFunc)strcmp);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ GList *l = sorted_names;
|
|
Matej Habrnal |
5c8df3 |
+ while (l)
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ const char *name = l->data;
|
|
Matej Habrnal |
5c8df3 |
+ l = l->next;
|
|
Matej Habrnal |
5c8df3 |
+ struct problem_item *item = g_hash_table_lookup(pd, name);
|
|
Matej Habrnal |
5c8df3 |
+ if (!item)
|
|
Matej Habrnal |
5c8df3 |
+ continue; /* paranoia, won't happen */
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ if (is_explicit_or_forbidden(name, comment_fmt_spec))
|
|
Matej Habrnal |
5c8df3 |
+ continue;
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ if ((item->flags & CD_FLAG_TXT) && !binary)
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ char *content = item->content;
|
|
Matej Habrnal |
5c8df3 |
+ char *eol = strchrnul(content, '\n');
|
|
Matej Habrnal |
5c8df3 |
+ bool is_oneline = (eol[0] == '\0' || eol[1] == '\0');
|
|
Matej Habrnal |
5c8df3 |
+ if (text || oneline == is_oneline)
|
|
Matej Habrnal |
5c8df3 |
+ result = g_list_append(result, xstrdup(name));
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+ else if ((item->flags & CD_FLAG_BIN) && binary)
|
|
Matej Habrnal |
5c8df3 |
+ result = g_list_append(result, xstrdup(name));
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ g_list_free(sorted_names); /* names themselves are not freed */
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ log_debug("...Done iterating over '%s' for attach", item_name);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ return result;
|
|
Matej Habrnal |
5c8df3 |
+}
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+static GList *
|
|
Matej Habrnal |
5c8df3 |
+get_attached_files(problem_data_t *pd, GList *items, GList *comment_fmt_spec)
|
|
Matej Habrnal |
5c8df3 |
+{
|
|
Matej Habrnal |
5c8df3 |
+ GList *result = NULL;
|
|
Matej Habrnal |
5c8df3 |
+ GList *item = items;
|
|
Matej Habrnal |
5c8df3 |
+ while (item != NULL)
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ const char *item_name = item->data;
|
|
Matej Habrnal |
5c8df3 |
+ item = item->next;
|
|
Matej Habrnal |
5c8df3 |
+ if (item_name[0] == '-') /* "-name", ignore it */
|
|
Matej Habrnal |
5c8df3 |
+ continue;
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ if (item_name[0] != '%')
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ result = g_list_append(result, xstrdup(item_name));
|
|
Matej Habrnal |
5c8df3 |
+ continue;
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ GList *special = get_special_items(item_name, pd, comment_fmt_spec);
|
|
Matej Habrnal |
5c8df3 |
+ if (special == NULL)
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ log_notice("No attachment found for '%s'", item_name);
|
|
Matej Habrnal |
5c8df3 |
+ continue;
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ result = g_list_concat(result, special);
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ return result;
|
|
Matej Habrnal |
5c8df3 |
+}
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+/*
|
|
Matej Habrnal |
5c8df3 |
+ * Problem Report - memor stream
|
|
Matej Habrnal |
5c8df3 |
+ *
|
|
Matej Habrnal |
5c8df3 |
+ * A wrapper for POSIX memory stream.
|
|
Matej Habrnal |
5c8df3 |
+ *
|
|
Matej Habrnal |
5c8df3 |
+ * A memory stream is presented as FILE *.
|
|
Matej Habrnal |
5c8df3 |
+ *
|
|
Matej Habrnal |
5c8df3 |
+ * A memory stream is associated with a pointer to written data and a pointer
|
|
Matej Habrnal |
5c8df3 |
+ * to size of the written data.
|
|
Matej Habrnal |
5c8df3 |
+ *
|
|
Matej Habrnal |
5c8df3 |
+ * This structure holds all of the used pointers.
|
|
Matej Habrnal |
5c8df3 |
+ */
|
|
Matej Habrnal |
5c8df3 |
+struct memstream_buffer
|
|
Matej Habrnal |
5c8df3 |
+{
|
|
Matej Habrnal |
5c8df3 |
+ char *msb_buffer;
|
|
Matej Habrnal |
5c8df3 |
+ size_t msb_size;
|
|
Matej Habrnal |
5c8df3 |
+ FILE *msb_stream;
|
|
Matej Habrnal |
5c8df3 |
+};
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+static struct memstream_buffer *
|
|
Matej Habrnal |
5c8df3 |
+memstream_buffer_new()
|
|
Matej Habrnal |
5c8df3 |
+{
|
|
Matej Habrnal |
5c8df3 |
+ struct memstream_buffer *self = xmalloc(sizeof(*self));
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ self->msb_buffer = NULL;
|
|
Matej Habrnal |
5c8df3 |
+ self->msb_stream = open_memstream(&(self->msb_buffer), &(self->msb_size));
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ return self;
|
|
Matej Habrnal |
5c8df3 |
+}
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+static void
|
|
Matej Habrnal |
5c8df3 |
+memstream_buffer_free(struct memstream_buffer *self)
|
|
Matej Habrnal |
5c8df3 |
+{
|
|
Matej Habrnal |
5c8df3 |
+ if (self == NULL)
|
|
Matej Habrnal |
5c8df3 |
+ return;
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ fclose(self->msb_stream);
|
|
Matej Habrnal |
5c8df3 |
+ self->msb_stream = DESTROYED_POINTER;
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ free(self->msb_buffer);
|
|
Matej Habrnal |
5c8df3 |
+ self->msb_buffer = DESTROYED_POINTER;
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ free(self);
|
|
Matej Habrnal |
5c8df3 |
+}
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+static FILE *
|
|
Matej Habrnal |
5c8df3 |
+memstream_get_stream(struct memstream_buffer *self)
|
|
Matej Habrnal |
5c8df3 |
+{
|
|
Matej Habrnal |
5c8df3 |
+ assert(self != NULL);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ return self->msb_stream;
|
|
Matej Habrnal |
5c8df3 |
+}
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+static const char *
|
|
Matej Habrnal |
5c8df3 |
+memstream_get_string(struct memstream_buffer *self)
|
|
Matej Habrnal |
5c8df3 |
+{
|
|
Matej Habrnal |
5c8df3 |
+ assert(self != NULL);
|
|
Matej Habrnal |
5c8df3 |
+ assert(self->msb_stream != NULL);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ fflush(self->msb_stream);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ return self->msb_buffer;
|
|
Matej Habrnal |
5c8df3 |
+}
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+/*
|
|
Matej Habrnal |
5c8df3 |
+ * Problem Report
|
|
Matej Habrnal |
5c8df3 |
+ *
|
|
Matej Habrnal |
5c8df3 |
+ * The formated strings are internaly stored in "buffer"s. If a programer wants
|
|
Matej Habrnal |
5c8df3 |
+ * to get a formated section data, a getter function extracts those data from
|
|
Matej Habrnal |
5c8df3 |
+ * the apropriate buffer and returns them in form of null-terminated string.
|
|
Matej Habrnal |
5c8df3 |
+ *
|
|
Matej Habrnal |
5c8df3 |
+ * Each section has own buffer.
|
|
Matej Habrnal |
5c8df3 |
+ *
|
|
Matej Habrnal |
5c8df3 |
+ * There are three common sections that are always present:
|
|
Matej Habrnal |
5c8df3 |
+ * 1. summary
|
|
Matej Habrnal |
5c8df3 |
+ * 2. description
|
|
Matej Habrnal |
5c8df3 |
+ * 3. attach
|
|
Matej Habrnal |
5c8df3 |
+ * Buffers of these sections has own structure member for the sake of
|
|
Matej Habrnal |
5c8df3 |
+ * efficiency.
|
|
Matej Habrnal |
5c8df3 |
+ *
|
|
Matej Habrnal |
5c8df3 |
+ * The custom sections hash their buffers stored in a map where key is a
|
|
Matej Habrnal |
5c8df3 |
+ * section's name and value is a section's buffer.
|
|
Matej Habrnal |
5c8df3 |
+ *
|
|
Matej Habrnal |
5c8df3 |
+ * Problem report provides the programers with the possibility to ammend
|
|
Matej Habrnal |
5c8df3 |
+ * formated output to any section buffer.
|
|
Matej Habrnal |
5c8df3 |
+ */
|
|
Matej Habrnal |
5c8df3 |
+struct problem_report
|
|
Matej Habrnal |
5c8df3 |
+{
|
|
Matej Habrnal |
5c8df3 |
+ struct memstream_buffer *pr_sec_summ; ///< %summary buffer
|
|
Matej Habrnal |
5c8df3 |
+ struct memstream_buffer *pr_sec_desc; ///< %description buffer
|
|
Matej Habrnal |
5c8df3 |
+ GList *pr_attachments; ///< %attach - list of file names
|
|
Matej Habrnal |
5c8df3 |
+ GHashTable *pr_sec_custom; ///< map : %(custom section) -> buffer
|
|
Matej Habrnal |
5c8df3 |
+};
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+static problem_report_t *
|
|
Matej Habrnal |
5c8df3 |
+problem_report_new()
|
|
Matej Habrnal |
5c8df3 |
+{
|
|
Matej Habrnal |
5c8df3 |
+ problem_report_t *self = xmalloc(sizeof(*self));
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ self->pr_sec_summ = memstream_buffer_new();
|
|
Matej Habrnal |
5c8df3 |
+ self->pr_sec_desc = memstream_buffer_new();
|
|
Matej Habrnal |
5c8df3 |
+ self->pr_attachments = NULL;
|
|
Matej Habrnal |
5c8df3 |
+ self->pr_sec_custom = NULL;
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ return self;
|
|
Matej Habrnal |
5c8df3 |
+}
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+static void
|
|
Matej Habrnal |
5c8df3 |
+problem_report_initialize_custom_sections(problem_report_t *self)
|
|
Matej Habrnal |
5c8df3 |
+{
|
|
Matej Habrnal |
5c8df3 |
+ assert(self != NULL);
|
|
Matej Habrnal |
5c8df3 |
+ assert(self->pr_sec_custom == NULL);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ self->pr_sec_custom = g_hash_table_new_full(g_str_hash, g_str_equal, free,
|
|
Matej Habrnal |
5c8df3 |
+ (GDestroyNotify)memstream_buffer_free);
|
|
Matej Habrnal |
5c8df3 |
+}
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+static void
|
|
Matej Habrnal |
5c8df3 |
+problem_report_destroy_custom_sections(problem_report_t *self)
|
|
Matej Habrnal |
5c8df3 |
+{
|
|
Matej Habrnal |
5c8df3 |
+ assert(self != NULL);
|
|
Matej Habrnal |
5c8df3 |
+ assert(self->pr_sec_custom != NULL);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ g_hash_table_destroy(self->pr_sec_custom);
|
|
Matej Habrnal |
5c8df3 |
+}
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+static int
|
|
Matej Habrnal |
5c8df3 |
+problem_report_add_custom_section(problem_report_t *self, const char *name)
|
|
Matej Habrnal |
5c8df3 |
+{
|
|
Matej Habrnal |
5c8df3 |
+ assert(self != NULL);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ if (self->pr_sec_custom == NULL)
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ problem_report_initialize_custom_sections(self);
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ if (problem_report_get_buffer(self, name))
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ log_warning("Custom section already exists : '%s'", name);
|
|
Matej Habrnal |
5c8df3 |
+ return -EEXIST;
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ log_debug("Problem report enriched with section : '%s'", name);
|
|
Matej Habrnal |
5c8df3 |
+ g_hash_table_insert(self->pr_sec_custom, xstrdup(name), memstream_buffer_new());
|
|
Matej Habrnal |
5c8df3 |
+ return 0;
|
|
Matej Habrnal |
5c8df3 |
+}
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+static struct memstream_buffer *
|
|
Matej Habrnal |
5c8df3 |
+problem_report_get_section_buffer(const problem_report_t *self, const char *section_name)
|
|
Matej Habrnal |
5c8df3 |
+{
|
|
Matej Habrnal |
5c8df3 |
+ if (self->pr_sec_custom == NULL)
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ log_debug("Couldn't find section '%s': no custom section added", section_name);
|
|
Matej Habrnal |
5c8df3 |
+ return NULL;
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ return (struct memstream_buffer *)g_hash_table_lookup(self->pr_sec_custom, section_name);
|
|
Matej Habrnal |
5c8df3 |
+}
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+problem_report_buffer *
|
|
Matej Habrnal |
5c8df3 |
+problem_report_get_buffer(const problem_report_t *self, const char *section_name)
|
|
Matej Habrnal |
5c8df3 |
+{
|
|
Matej Habrnal |
5c8df3 |
+ assert(self != NULL);
|
|
Matej Habrnal |
5c8df3 |
+ assert(section_name != NULL);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ if (strcmp(PR_SEC_SUMMARY, section_name) == 0)
|
|
Matej Habrnal |
5c8df3 |
+ return memstream_get_stream(self->pr_sec_summ);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ if (strcmp(PR_SEC_DESCRIPTION, section_name) == 0)
|
|
Matej Habrnal |
5c8df3 |
+ return memstream_get_stream(self->pr_sec_desc);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ struct memstream_buffer *buf = problem_report_get_section_buffer(self, section_name);
|
|
Matej Habrnal |
5c8df3 |
+ return buf == NULL ? NULL : memstream_get_stream(buf);
|
|
Matej Habrnal |
5c8df3 |
+}
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+const char *
|
|
Matej Habrnal |
5c8df3 |
+problem_report_get_summary(const problem_report_t *self)
|
|
Matej Habrnal |
5c8df3 |
+{
|
|
Matej Habrnal |
5c8df3 |
+ assert(self != NULL);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ return memstream_get_string(self->pr_sec_summ);
|
|
Matej Habrnal |
5c8df3 |
+}
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+const char *
|
|
Matej Habrnal |
5c8df3 |
+problem_report_get_description(const problem_report_t *self)
|
|
Matej Habrnal |
5c8df3 |
+{
|
|
Matej Habrnal |
5c8df3 |
+ assert(self != NULL);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ return memstream_get_string(self->pr_sec_desc);
|
|
Matej Habrnal |
5c8df3 |
+}
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+const char *
|
|
Matej Habrnal |
5c8df3 |
+problem_report_get_section(const problem_report_t *self, const char *section_name)
|
|
Matej Habrnal |
5c8df3 |
+{
|
|
Matej Habrnal |
5c8df3 |
+ assert(self != NULL);
|
|
Matej Habrnal |
5c8df3 |
+ assert(section_name);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ struct memstream_buffer *buf = problem_report_get_section_buffer(self, section_name);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ if (buf == NULL)
|
|
Matej Habrnal |
5c8df3 |
+ return NULL;
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ return memstream_get_string(buf);
|
|
Matej Habrnal |
5c8df3 |
+}
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+static void
|
|
Matej Habrnal |
5c8df3 |
+problem_report_set_attachments(problem_report_t *self, GList *attachments)
|
|
Matej Habrnal |
5c8df3 |
+{
|
|
Matej Habrnal |
5c8df3 |
+ assert(self != NULL);
|
|
Matej Habrnal |
5c8df3 |
+ assert(self->pr_attachments == NULL);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ self->pr_attachments = attachments;
|
|
Matej Habrnal |
5c8df3 |
+}
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+GList *
|
|
Matej Habrnal |
5c8df3 |
+problem_report_get_attachments(const problem_report_t *self)
|
|
Matej Habrnal |
5c8df3 |
+{
|
|
Matej Habrnal |
5c8df3 |
+ assert(self != NULL);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ return self->pr_attachments;
|
|
Matej Habrnal |
5c8df3 |
+}
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+void
|
|
Matej Habrnal |
5c8df3 |
+problem_report_free(problem_report_t *self)
|
|
Matej Habrnal |
5c8df3 |
+{
|
|
Matej Habrnal |
5c8df3 |
+ if (self == NULL)
|
|
Matej Habrnal |
5c8df3 |
+ return;
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ memstream_buffer_free(self->pr_sec_summ);
|
|
Matej Habrnal |
5c8df3 |
+ self->pr_sec_summ = DESTROYED_POINTER;
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ memstream_buffer_free(self->pr_sec_desc);
|
|
Matej Habrnal |
5c8df3 |
+ self->pr_sec_desc = DESTROYED_POINTER;
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ g_list_free_full(self->pr_attachments, free);
|
|
Matej Habrnal |
5c8df3 |
+ self->pr_attachments = DESTROYED_POINTER;
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ if (self->pr_sec_custom)
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ problem_report_destroy_custom_sections(self);
|
|
Matej Habrnal |
5c8df3 |
+ self->pr_sec_custom = DESTROYED_POINTER;
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ free(self);
|
|
Matej Habrnal |
5c8df3 |
+}
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+/*
|
|
Matej Habrnal |
5c8df3 |
+ * Problem Formatter - extra section
|
|
Matej Habrnal |
5c8df3 |
+ */
|
|
Matej Habrnal |
5c8df3 |
+struct extra_section
|
|
Matej Habrnal |
5c8df3 |
+{
|
|
Matej Habrnal |
5c8df3 |
+ char *pfes_name; ///< name with % prefix
|
|
Matej Habrnal |
5c8df3 |
+ int pfes_flags; ///< whether is required or not
|
|
Matej Habrnal |
5c8df3 |
+};
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+static struct extra_section *
|
|
Matej Habrnal |
5c8df3 |
+extra_section_new(const char *name, int flags)
|
|
Matej Habrnal |
5c8df3 |
+{
|
|
Matej Habrnal |
5c8df3 |
+ struct extra_section *self = xmalloc(sizeof(*self));
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ self->pfes_name = xstrdup(name);
|
|
Matej Habrnal |
5c8df3 |
+ self->pfes_flags = flags;
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ return self;
|
|
Matej Habrnal |
5c8df3 |
+}
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+static void
|
|
Matej Habrnal |
5c8df3 |
+extra_section_free(struct extra_section *self)
|
|
Matej Habrnal |
5c8df3 |
+{
|
|
Matej Habrnal |
5c8df3 |
+ if (self == NULL)
|
|
Matej Habrnal |
5c8df3 |
+ return;
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ free(self->pfes_name);
|
|
Matej Habrnal |
5c8df3 |
+ self->pfes_name = DESTROYED_POINTER;
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ free(self);
|
|
Matej Habrnal |
5c8df3 |
+}
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+static int
|
|
Matej Habrnal |
5c8df3 |
+extra_section_name_cmp(struct extra_section *lhs, const char *rhs)
|
|
Matej Habrnal |
5c8df3 |
+{
|
|
Matej Habrnal |
5c8df3 |
+ return strcmp(lhs->pfes_name, rhs);
|
|
Matej Habrnal |
5c8df3 |
+}
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+/*
|
|
Matej Habrnal |
5c8df3 |
+ * Problem Formatter
|
|
Matej Habrnal |
5c8df3 |
+ *
|
|
Matej Habrnal |
5c8df3 |
+ * Holds parsed sections lists.
|
|
Matej Habrnal |
5c8df3 |
+ */
|
|
Matej Habrnal |
5c8df3 |
+struct problem_formatter
|
|
Matej Habrnal |
5c8df3 |
+{
|
|
Matej Habrnal |
5c8df3 |
+ GList *pf_sections; ///< parsed sections (struct section_t)
|
|
Matej Habrnal |
5c8df3 |
+ GList *pf_extra_sections; ///< user configured sections (struct extra_section)
|
|
Matej Habrnal |
5c8df3 |
+ char *pf_default_summary; ///< default summary format
|
|
Matej Habrnal |
5c8df3 |
+};
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+problem_formatter_t *
|
|
Matej Habrnal |
5c8df3 |
+problem_formatter_new(void)
|
|
Matej Habrnal |
5c8df3 |
+{
|
|
Matej Habrnal |
5c8df3 |
+ problem_formatter_t *self = xzalloc(sizeof(*self));
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ self->pf_default_summary = xstrdup("%reason%");
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ return self;
|
|
Matej Habrnal |
5c8df3 |
+}
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+void
|
|
Matej Habrnal |
5c8df3 |
+problem_formatter_free(problem_formatter_t *self)
|
|
Matej Habrnal |
5c8df3 |
+{
|
|
Matej Habrnal |
5c8df3 |
+ if (self == NULL)
|
|
Matej Habrnal |
5c8df3 |
+ return;
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ g_list_free_full(self->pf_sections, (GDestroyNotify)section_free);
|
|
Matej Habrnal |
5c8df3 |
+ self->pf_sections = DESTROYED_POINTER;
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ g_list_free_full(self->pf_extra_sections, (GDestroyNotify)extra_section_free);
|
|
Matej Habrnal |
5c8df3 |
+ self->pf_extra_sections = DESTROYED_POINTER;
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ free(self->pf_default_summary);
|
|
Matej Habrnal |
5c8df3 |
+ self->pf_default_summary = DESTROYED_POINTER;
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ free(self);
|
|
Matej Habrnal |
5c8df3 |
+}
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+static int
|
|
Matej Habrnal |
5c8df3 |
+problem_formatter_is_section_known(problem_formatter_t *self, const char *name)
|
|
Matej Habrnal |
5c8df3 |
+{
|
|
Matej Habrnal |
5c8df3 |
+ return strcmp(name, "summary") == 0
|
|
Matej Habrnal |
5c8df3 |
+ || strcmp(name, "attach") == 0
|
|
Matej Habrnal |
5c8df3 |
+ || strcmp(name, "description") == 0
|
|
Matej Habrnal |
5c8df3 |
+ || NULL != g_list_find_custom(self->pf_extra_sections, name, (GCompareFunc)extra_section_name_cmp);
|
|
Matej Habrnal |
5c8df3 |
+}
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+// i.e additional_info -> no flags
|
|
Matej Habrnal |
5c8df3 |
+int
|
|
Matej Habrnal |
5c8df3 |
+problem_formatter_add_section(problem_formatter_t *self, const char *name, int flags)
|
|
Matej Habrnal |
5c8df3 |
+{
|
|
Matej Habrnal |
5c8df3 |
+ /* Do not add already added sections */
|
|
Matej Habrnal |
5c8df3 |
+ if (problem_formatter_is_section_known(self, name))
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ log_debug("Extra section already exists : '%s' ", name);
|
|
Matej Habrnal |
5c8df3 |
+ return -EEXIST;
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ self->pf_extra_sections = g_list_prepend(self->pf_extra_sections,
|
|
Matej Habrnal |
5c8df3 |
+ extra_section_new(name, flags));
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ return 0;
|
|
Matej Habrnal |
5c8df3 |
+}
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+// check format validity and produce warnings
|
|
Matej Habrnal |
5c8df3 |
+static int
|
|
Matej Habrnal |
5c8df3 |
+problem_formatter_validate(problem_formatter_t *self)
|
|
Matej Habrnal |
5c8df3 |
+{
|
|
Matej Habrnal |
5c8df3 |
+ int retval = 0;
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ /* Go through all (struct extra_section)s and check whete those having flag
|
|
Matej Habrnal |
5c8df3 |
+ * PFFF_REQUIRED are present in the parsed (struct section_t)s.
|
|
Matej Habrnal |
5c8df3 |
+ */
|
|
Matej Habrnal |
5c8df3 |
+ for (GList *iter = self->pf_extra_sections; iter; iter = g_list_next(iter))
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ struct extra_section *section = (struct extra_section *)iter->data;
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ log_debug("Validating extra section : '%s'", section->pfes_name);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ if ( (PFFF_REQUIRED & section->pfes_flags)
|
|
Matej Habrnal |
5c8df3 |
+ && NULL == g_list_find_custom(self->pf_sections, section->pfes_name, (GCompareFunc)section_name_cmp))
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ log_warning("Problem format misses required section : '%s'", section->pfes_name);
|
|
Matej Habrnal |
5c8df3 |
+ ++retval;
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ /* Go through all the parsed (struct section_t)s check whether are all
|
|
Matej Habrnal |
5c8df3 |
+ * known, i.e. each section is either one of the common sections (summary,
|
|
Matej Habrnal |
5c8df3 |
+ * description, attach) or is present in the (struct extra_section)s.
|
|
Matej Habrnal |
5c8df3 |
+ */
|
|
Matej Habrnal |
5c8df3 |
+ for (GList *iter = self->pf_sections; iter; iter = g_list_next(iter))
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ section_t *section = (section_t *)iter->data;
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ if (!problem_formatter_is_section_known(self, (section->name + 1)))
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ log_warning("Problem format contains unrecognized section : '%s'", section->name);
|
|
Matej Habrnal |
5c8df3 |
+ ++retval;
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ return retval;
|
|
Matej Habrnal |
5c8df3 |
+}
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+int
|
|
Matej Habrnal |
5c8df3 |
+problem_formatter_load_string(problem_formatter_t *self, const char *fmt)
|
|
Matej Habrnal |
5c8df3 |
+{
|
|
Matej Habrnal |
5c8df3 |
+ const size_t len = strlen(fmt);
|
|
Matej Habrnal |
5c8df3 |
+ if (len != 0)
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ FILE *fp = fmemopen((void *)fmt, len, "r");
|
|
Matej Habrnal |
5c8df3 |
+ if (fp == NULL)
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ error_msg("Not enough memory to open a stream for reading format string.");
|
|
Matej Habrnal |
5c8df3 |
+ return -ENOMEM;
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ self->pf_sections = load_stream(fp);
|
|
Matej Habrnal |
5c8df3 |
+ fclose(fp);
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ return problem_formatter_validate(self);
|
|
Matej Habrnal |
5c8df3 |
+}
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+int
|
|
Matej Habrnal |
5c8df3 |
+problem_formatter_load_file(problem_formatter_t *self, const char *path)
|
|
Matej Habrnal |
5c8df3 |
+{
|
|
Matej Habrnal |
5c8df3 |
+ FILE *fp = stdin;
|
|
Matej Habrnal |
5c8df3 |
+ if (strcmp(path, "-") != 0)
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ fp = fopen(path, "r");
|
|
Matej Habrnal |
5c8df3 |
+ if (!fp)
|
|
Matej Habrnal |
5c8df3 |
+ return -ENOENT;
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ self->pf_sections = load_stream(fp);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ if (fp != stdin)
|
|
Matej Habrnal |
5c8df3 |
+ fclose(fp);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ return problem_formatter_validate(self);
|
|
Matej Habrnal |
5c8df3 |
+}
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+// generates report
|
|
Matej Habrnal |
5c8df3 |
+int
|
|
Matej Habrnal |
5c8df3 |
+problem_formatter_generate_report(const problem_formatter_t *self, problem_data_t *data, problem_report_t **report)
|
|
Matej Habrnal |
5c8df3 |
+{
|
|
Matej Habrnal |
5c8df3 |
+ problem_report_t *pr = problem_report_new();
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ for (GList *iter = self->pf_extra_sections; iter; iter = g_list_next(iter))
|
|
Matej Habrnal |
5c8df3 |
+ problem_report_add_custom_section(pr, ((struct extra_section *)iter->data)->pfes_name);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ bool has_summary = false;
|
|
Matej Habrnal |
5c8df3 |
+ for (GList *iter = self->pf_sections; iter; iter = g_list_next(iter))
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ section_t *section = (section_t *)iter->data;
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ /* %summary is something special */
|
|
Matej Habrnal |
5c8df3 |
+ if (strcmp(section->name, "%summary") == 0)
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ has_summary = true;
|
|
Matej Habrnal |
5c8df3 |
+ format_percented_string((const char *)section->items->data, data,
|
|
Matej Habrnal |
5c8df3 |
+ problem_report_get_buffer(pr, PR_SEC_SUMMARY));
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+ /* %attach as well */
|
|
Matej Habrnal |
5c8df3 |
+ else if (strcmp(section->name, "%attach") == 0)
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ problem_report_set_attachments(pr, get_attached_files(data, section->items, self->pf_sections));
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+ else /* %description or a custom section (e.g. %additional_info) */
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ FILE *buffer = problem_report_get_buffer(pr, section->name + 1);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ if (buffer != NULL)
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ log_debug("Formatting section : '%s'", section->name);
|
|
Matej Habrnal |
5c8df3 |
+ format_section(section, data, self->pf_sections, buffer);
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+ else
|
|
Matej Habrnal |
5c8df3 |
+ log_warning("Unsupported section '%s'", section->name);
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ if (!has_summary) {
|
|
Matej Habrnal |
5c8df3 |
+ log_debug("Problem format misses section '%%summary'. Using the default one : '%s'.",
|
|
Matej Habrnal |
5c8df3 |
+ self->pf_default_summary);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ format_percented_string(self->pf_default_summary,
|
|
Matej Habrnal |
5c8df3 |
+ data, problem_report_get_buffer(pr, PR_SEC_SUMMARY));
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ *report = pr;
|
|
Matej Habrnal |
5c8df3 |
+ return 0;
|
|
Matej Habrnal |
5c8df3 |
+}
|
|
Matej Habrnal |
5c8df3 |
diff --git a/tests/Makefile.am b/tests/Makefile.am
|
|
Matej Habrnal |
5c8df3 |
index a680f05..f6c5fee 100644
|
|
Matej Habrnal |
5c8df3 |
--- a/tests/Makefile.am
|
|
Matej Habrnal |
5c8df3 |
+++ b/tests/Makefile.am
|
|
Matej Habrnal |
5c8df3 |
@@ -42,7 +42,8 @@ TESTSUITE_AT = \
|
|
Matej Habrnal |
5c8df3 |
report_python.at \
|
|
Matej Habrnal |
5c8df3 |
xfuncs.at \
|
|
Matej Habrnal |
5c8df3 |
string_list.at \
|
|
Matej Habrnal |
5c8df3 |
- ureport.at
|
|
Matej Habrnal |
5c8df3 |
+ ureport.at \
|
|
Matej Habrnal |
5c8df3 |
+ problem_report.at
|
|
Matej Habrnal |
5c8df3 |
|
|
Matej Habrnal |
5c8df3 |
EXTRA_DIST += $(TESTSUITE_AT)
|
|
Matej Habrnal |
5c8df3 |
TESTSUITE = $(srcdir)/testsuite
|
|
Matej Habrnal |
5c8df3 |
diff --git a/tests/problem_report.at b/tests/problem_report.at
|
|
Matej Habrnal |
5c8df3 |
new file mode 100644
|
|
Matej Habrnal |
5c8df3 |
index 0000000..8bc469f
|
|
Matej Habrnal |
5c8df3 |
--- /dev/null
|
|
Matej Habrnal |
5c8df3 |
+++ b/tests/problem_report.at
|
|
Matej Habrnal |
5c8df3 |
@@ -0,0 +1,690 @@
|
|
Matej Habrnal |
5c8df3 |
+# -*- Autotest -*-
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+AT_BANNER([problem report])
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+## ------- ##
|
|
Matej Habrnal |
5c8df3 |
+## summary ##
|
|
Matej Habrnal |
5c8df3 |
+## ------- ##
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+AT_TESTFUN([summary],
|
|
Matej Habrnal |
5c8df3 |
+[[
|
|
Matej Habrnal |
5c8df3 |
+#include "problem_report.h"
|
|
Matej Habrnal |
5c8df3 |
+#include "internal_libreport.h"
|
|
Matej Habrnal |
5c8df3 |
+#include <assert.h>
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+int main(int argc, char **argv)
|
|
Matej Habrnal |
5c8df3 |
+{
|
|
Matej Habrnal |
5c8df3 |
+ const char *const test_format_result[][2] = {
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ "%summary:: [abrt] trivial string",
|
|
Matej Habrnal |
5c8df3 |
+ "[abrt] trivial string"
|
|
Matej Habrnal |
5c8df3 |
+ },
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ "%summary:: [abrt] %package%",
|
|
Matej Habrnal |
5c8df3 |
+ "[abrt] libreport"
|
|
Matej Habrnal |
5c8df3 |
+ },
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ "%summary:: [abrt] %package%[[ : %crash_function%()]][[ : %does_not_exist%]][[ : %reason%]][[ TAINTED: %taint_flags%]]",
|
|
Matej Habrnal |
5c8df3 |
+ "[abrt] libreport : run_event() : Killed by SIGSEGV"
|
|
Matej Habrnal |
5c8df3 |
+ },
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ "%summary:: [abrt] %package%[[ : %crash_function%[[ : %does_not_exist%]]()]][[ : %reason%]]",
|
|
Matej Habrnal |
5c8df3 |
+ "[abrt] libreport : run_event() : Killed by SIGSEGV"
|
|
Matej Habrnal |
5c8df3 |
+ },
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ "%summary:: [abrt] %package%[[ : %does_not_exist%[[ : %crash_function%()]]]][[ : %reason%]]",
|
|
Matej Habrnal |
5c8df3 |
+ "[abrt] libreport : Killed by SIGSEGV"
|
|
Matej Habrnal |
5c8df3 |
+ },
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ "%summary:: [[%does_not_exist%]][[%once_more%]][abrt] %package%",
|
|
Matej Habrnal |
5c8df3 |
+ "[abrt] libreport"
|
|
Matej Habrnal |
5c8df3 |
+ },
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ "",
|
|
Matej Habrnal |
5c8df3 |
+ "Killed by SIGSEGV"
|
|
Matej Habrnal |
5c8df3 |
+ },
|
|
Matej Habrnal |
5c8df3 |
+ };
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ g_verbose = 3;
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ problem_data_t *data = problem_data_new();
|
|
Matej Habrnal |
5c8df3 |
+ problem_data_add_text_noteditable(data, "package", "libreport");
|
|
Matej Habrnal |
5c8df3 |
+ problem_data_add_text_noteditable(data, "crash_function", "run_event");
|
|
Matej Habrnal |
5c8df3 |
+ problem_data_add_text_noteditable(data, "reason", "Killed by SIGSEGV");
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ for (size_t i = 0; i < sizeof(test_format_result)/sizeof(*test_format_result); ++i) {
|
|
Matej Habrnal |
5c8df3 |
+ problem_formatter_t *pf = problem_formatter_new();
|
|
Matej Habrnal |
5c8df3 |
+ assert(!problem_formatter_load_string(pf, test_format_result[i][0]));
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ problem_report_t *pr = NULL;
|
|
Matej Habrnal |
5c8df3 |
+ assert(!problem_formatter_generate_report(pf, data, &pr);;
|
|
Matej Habrnal |
5c8df3 |
+ assert(pr != NULL);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ const char *summary = problem_report_get_summary(pr);
|
|
Matej Habrnal |
5c8df3 |
+ assert(summary != NULL);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ fprintf(stderr, "expected: '%s'\n", test_format_result[i][1]);
|
|
Matej Habrnal |
5c8df3 |
+ fprintf(stderr, "result : '%s'\n", summary);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ assert(strcmp(test_format_result[i][1], summary) == 0);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ problem_report_free(pr);
|
|
Matej Habrnal |
5c8df3 |
+ problem_formatter_free(pf);
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ problem_data_free(data);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ return 0;
|
|
Matej Habrnal |
5c8df3 |
+}
|
|
Matej Habrnal |
5c8df3 |
+]])
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+## ---------- ##
|
|
Matej Habrnal |
5c8df3 |
+## desciption ##
|
|
Matej Habrnal |
5c8df3 |
+## ---------- ##
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+AT_TESTFUN([description],
|
|
Matej Habrnal |
5c8df3 |
+[[
|
|
Matej Habrnal |
5c8df3 |
+#include "problem_report.h"
|
|
Matej Habrnal |
5c8df3 |
+#include "internal_libreport.h"
|
|
Matej Habrnal |
5c8df3 |
+#include <assert.h>
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+int main(int argc, char **argv)
|
|
Matej Habrnal |
5c8df3 |
+{
|
|
Matej Habrnal |
5c8df3 |
+ const char *const test_format_result[][2] = {
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ "\n"\
|
|
Matej Habrnal |
5c8df3 |
+ "\n"\
|
|
Matej Habrnal |
5c8df3 |
+ "\n"\
|
|
Matej Habrnal |
5c8df3 |
+ "Single line\n"
|
|
Matej Habrnal |
5c8df3 |
+ "\n"\
|
|
Matej Habrnal |
5c8df3 |
+ "\n"\
|
|
Matej Habrnal |
5c8df3 |
+ "\n",
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ "Single line\n"
|
|
Matej Habrnal |
5c8df3 |
+ },
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ "\n"\
|
|
Matej Habrnal |
5c8df3 |
+ "\n"\
|
|
Matej Habrnal |
5c8df3 |
+ "\n"\
|
|
Matej Habrnal |
5c8df3 |
+ "Comment:: %bare_comment"
|
|
Matej Habrnal |
5c8df3 |
+ "\n"\
|
|
Matej Habrnal |
5c8df3 |
+ "\n"\
|
|
Matej Habrnal |
5c8df3 |
+ "\n"\
|
|
Matej Habrnal |
5c8df3 |
+ "Ad-hoc line\n"
|
|
Matej Habrnal |
5c8df3 |
+ "\n"\
|
|
Matej Habrnal |
5c8df3 |
+ "\n"\
|
|
Matej Habrnal |
5c8df3 |
+ "\n"\
|
|
Matej Habrnal |
5c8df3 |
+ "Additional:: package,\\\n"
|
|
Matej Habrnal |
5c8df3 |
+ "uuid,cwd\\\\"
|
|
Matej Habrnal |
5c8df3 |
+ ",user_name"
|
|
Matej Habrnal |
5c8df3 |
+ "\n"\
|
|
Matej Habrnal |
5c8df3 |
+ "\n",
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ "Comment:\n" \
|
|
Matej Habrnal |
5c8df3 |
+ "Hello, world!\n"
|
|
Matej Habrnal |
5c8df3 |
+ "\n"\
|
|
Matej Habrnal |
5c8df3 |
+ "\n"\
|
|
Matej Habrnal |
5c8df3 |
+ "Ad-hoc line\n"
|
|
Matej Habrnal |
5c8df3 |
+ "\n"\
|
|
Matej Habrnal |
5c8df3 |
+ "\n"\
|
|
Matej Habrnal |
5c8df3 |
+ "\n"\
|
|
Matej Habrnal |
5c8df3 |
+ "Additional:\n"\
|
|
Matej Habrnal |
5c8df3 |
+ "package: libreport\n"\
|
|
Matej Habrnal |
5c8df3 |
+ "uuid: 123456789ABCDEF\n"\
|
|
Matej Habrnal |
5c8df3 |
+ "user_name: abrt\n",
|
|
Matej Habrnal |
5c8df3 |
+ },
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ ":: %bare_description",
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ "I run will_segfault and\n"\
|
|
Matej Habrnal |
5c8df3 |
+ "it crashed as expected\n"
|
|
Matej Habrnal |
5c8df3 |
+ },
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ "User:: %bare_user_name,uid\n"\
|
|
Matej Habrnal |
5c8df3 |
+ "Additional info:: -uuid,%oneline,-comment,-package",
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ "User:\n"\
|
|
Matej Habrnal |
5c8df3 |
+ "abrt\n"\
|
|
Matej Habrnal |
5c8df3 |
+ "uid: 69\n"\
|
|
Matej Habrnal |
5c8df3 |
+ "Additional info:\n"\
|
|
Matej Habrnal |
5c8df3 |
+ "analyzer: CCpp\n"\
|
|
Matej Habrnal |
5c8df3 |
+ "root: /var/run/mock/abrt\n"\
|
|
Matej Habrnal |
5c8df3 |
+ "type: CCpp\n"
|
|
Matej Habrnal |
5c8df3 |
+ },
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ ":: %reporter",
|
|
Matej Habrnal |
5c8df3 |
+ NULL /* do no check results*/
|
|
Matej Habrnal |
5c8df3 |
+ },
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ "Truncated backtrace:: %bare_%short_backtrace",
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ "Truncated backtrace:\n"
|
|
Matej Habrnal |
5c8df3 |
+ "Thread no. 0 (7 frames)\n"
|
|
Matej Habrnal |
5c8df3 |
+ " #1 crash at will_segfault.c:19\n"
|
|
Matej Habrnal |
5c8df3 |
+ " #2 varargs at will_segfault.c:31\n"
|
|
Matej Habrnal |
5c8df3 |
+ " #3 inlined at will_segfault.c:40\n"
|
|
Matej Habrnal |
5c8df3 |
+ " #4 f at will_segfault.c:45\n"
|
|
Matej Habrnal |
5c8df3 |
+ " #5 callback at will_segfault.c:50\n"
|
|
Matej Habrnal |
5c8df3 |
+ " #6 call_me_back at libwillcrash.c:8\n"
|
|
Matej Habrnal |
5c8df3 |
+ " #7 recursive at will_segfault.c:59\n"
|
|
Matej Habrnal |
5c8df3 |
+ },
|
|
Matej Habrnal |
5c8df3 |
+ };
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ g_verbose = 3;
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ problem_data_t *data = problem_data_new();
|
|
Matej Habrnal |
5c8df3 |
+ problem_data_add_text_noteditable(data, "package", "libreport");
|
|
Matej Habrnal |
5c8df3 |
+ problem_data_add_text_noteditable(data, "analyzer", "CCpp");
|
|
Matej Habrnal |
5c8df3 |
+ problem_data_add_text_noteditable(data, "type", "CCpp");
|
|
Matej Habrnal |
5c8df3 |
+ problem_data_add_text_noteditable(data, "comment", "Hello, world!");
|
|
Matej Habrnal |
5c8df3 |
+ problem_data_add_text_noteditable(data, "uuid", "123456789ABCDEF");
|
|
Matej Habrnal |
5c8df3 |
+ problem_data_add_text_noteditable(data, "uid", "69");
|
|
Matej Habrnal |
5c8df3 |
+ problem_data_add_text_noteditable(data, "user_name", "abrt");
|
|
Matej Habrnal |
5c8df3 |
+ problem_data_add_text_noteditable(data, "root", "/var/run/mock/abrt");
|
|
Matej Habrnal |
5c8df3 |
+ problem_data_add_text_noteditable(data, "description", "I run will_segfault and\nit crashed as expected\n");
|
|
Matej Habrnal |
5c8df3 |
+ problem_data_add_text_noteditable(data, "backtrace",
|
|
Matej Habrnal |
5c8df3 |
+"Thread 1 (LWP 11865):\n"\
|
|
Matej Habrnal |
5c8df3 |
+"#0 printf (__fmt=0x400acf \"Result: %d\\n\") at /usr/include/bits/stdio2.h:104\n"\
|
|
Matej Habrnal |
5c8df3 |
+"No locals.\n"\
|
|
Matej Habrnal |
5c8df3 |
+"#1 crash (p=p@entry=0x0) at will_segfault.c:19\n"\
|
|
Matej Habrnal |
5c8df3 |
+"i = <error reading variable i (Cannot access memory at address 0x0)>\n"\
|
|
Matej Habrnal |
5c8df3 |
+"#2 0x0000000000400964 in varargs (num_args=1, num_args@entry=2) at will_segfault.c:31\n"\
|
|
Matej Habrnal |
5c8df3 |
+"p = <optimized out>\n"\
|
|
Matej Habrnal |
5c8df3 |
+"ap = {{gp_offset = 24, fp_offset = 32767, overflow_arg_area = 0x7fff4fc8a0c0, reg_save_area = 0x7fff4fc8a080}}\n"\
|
|
Matej Habrnal |
5c8df3 |
+"#3 0x00000000004009be in inlined (p=0x0) at will_segfault.c:40\n"\
|
|
Matej Habrnal |
5c8df3 |
+"num = 42\n"\
|
|
Matej Habrnal |
5c8df3 |
+"#4 f (p=p@entry=0x0) at will_segfault.c:45\n"\
|
|
Matej Habrnal |
5c8df3 |
+"No locals.\n"\
|
|
Matej Habrnal |
5c8df3 |
+"#5 0x00000000004009e9 in callback (data=data@entry=0x0) at will_segfault.c:50\n"\
|
|
Matej Habrnal |
5c8df3 |
+"No locals.\n"\
|
|
Matej Habrnal |
5c8df3 |
+"#6 0x00000032f76006f9 in call_me_back (cb=cb@entry=0x4009e0 <callback>, data=data@entry=0x0) at libwillcrash.c:8\n"\
|
|
Matej Habrnal |
5c8df3 |
+"res = <optimized out>\n"\
|
|
Matej Habrnal |
5c8df3 |
+"#7 0x0000000000400a14 in recursive (i=i@entry=0) at will_segfault.c:59\n"\
|
|
Matej Habrnal |
5c8df3 |
+"p = <optimized out>\n"\
|
|
Matej Habrnal |
5c8df3 |
+"#8 0x0000000000400a00 in recursive (i=i@entry=1) at will_segfault.c:66\n"\
|
|
Matej Habrnal |
5c8df3 |
+"No locals.\n"\
|
|
Matej Habrnal |
5c8df3 |
+"#9 0x0000000000400a00 in recursive (i=i@entry=2) at will_segfault.c:66\n"\
|
|
Matej Habrnal |
5c8df3 |
+"No locals.\n"\
|
|
Matej Habrnal |
5c8df3 |
+"#10 0x0000000000400775 in main (argc=<optimized out>, argv=<optimized out>) at will_segfault.c:83\n"\
|
|
Matej Habrnal |
5c8df3 |
+"No locals.\n"\
|
|
Matej Habrnal |
5c8df3 |
+"From To Syms Read Shared Object Library\n"\
|
|
Matej Habrnal |
5c8df3 |
+"0x00000032f76005f0 0x00000032f7600712 Yes /lib64/libwillcrash.so.0\n"\
|
|
Matej Habrnal |
5c8df3 |
+"0x0000003245c1f4f0 0x0000003245d6aca4 Yes /lib64/libc.so.6\n"\
|
|
Matej Habrnal |
5c8df3 |
+"0x0000003245800b10 0x000000324581b6d0 Yes /lib64/ld-linux-x86-64.so.2\n"\
|
|
Matej Habrnal |
5c8df3 |
+"$1 = 0x0\n"
|
|
Matej Habrnal |
5c8df3 |
+"No symbol \"__glib_assert_msg\" in current context.\n"\
|
|
Matej Habrnal |
5c8df3 |
+"rax 0xf 15\n"\
|
|
Matej Habrnal |
5c8df3 |
+"rbx 0x0 0\n"\
|
|
Matej Habrnal |
5c8df3 |
+"rcx 0x7ff96f752000 140709293531136\n"\
|
|
Matej Habrnal |
5c8df3 |
+"rdx 0x3245fb9a40 215922481728\n"\
|
|
Matej Habrnal |
5c8df3 |
+"rsi 0x7ff96f752000 140709293531136\n"\
|
|
Matej Habrnal |
5c8df3 |
+"rdi 0x1 1\n"\
|
|
Matej Habrnal |
5c8df3 |
+"rbp 0x400a30 0x400a30 <__libc_csu_init>\n"\
|
|
Matej Habrnal |
5c8df3 |
+"rsp 0x7fff4fc8a050 0x7fff4fc8a050\n"\
|
|
Matej Habrnal |
5c8df3 |
+"r8 0xffffffff 4294967295\n"\
|
|
Matej Habrnal |
5c8df3 |
+"r9 0x0 0\n"\
|
|
Matej Habrnal |
5c8df3 |
+"r10 0x22 34\n"\
|
|
Matej Habrnal |
5c8df3 |
+"r11 0x246 582\n"\
|
|
Matej Habrnal |
5c8df3 |
+"r12 0x40079f 4196255\n"\
|
|
Matej Habrnal |
5c8df3 |
+"r13 0x7fff4fc8a210 140734531936784\n"\
|
|
Matej Habrnal |
5c8df3 |
+"r14 0x0 0\n"\
|
|
Matej Habrnal |
5c8df3 |
+"r15 0x0 0\n"\
|
|
Matej Habrnal |
5c8df3 |
+"rip 0x4008ae 0x4008ae <crash+14>\n"\
|
|
Matej Habrnal |
5c8df3 |
+"eflags 0x10246 [ PF ZF IF RF ]\n"\
|
|
Matej Habrnal |
5c8df3 |
+"cs 0x33 51\n"\
|
|
Matej Habrnal |
5c8df3 |
+"ss 0x2b 43\n"\
|
|
Matej Habrnal |
5c8df3 |
+"ds 0x0 0\n"\
|
|
Matej Habrnal |
5c8df3 |
+"es 0x0 0\n"\
|
|
Matej Habrnal |
5c8df3 |
+"fs 0x0 0\n"\
|
|
Matej Habrnal |
5c8df3 |
+"gs 0x0 0\n"\
|
|
Matej Habrnal |
5c8df3 |
+"st0 0 (raw 0x00000000000000000000)\n"\
|
|
Matej Habrnal |
5c8df3 |
+"st1 0 (raw 0x00000000000000000000)\n"\
|
|
Matej Habrnal |
5c8df3 |
+"st2 0 (raw 0x00000000000000000000)\n"\
|
|
Matej Habrnal |
5c8df3 |
+"st3 0 (raw 0x00000000000000000000)\n"\
|
|
Matej Habrnal |
5c8df3 |
+"st4 0 (raw 0x00000000000000000000)\n"\
|
|
Matej Habrnal |
5c8df3 |
+"st5 0 (raw 0x00000000000000000000)\n"\
|
|
Matej Habrnal |
5c8df3 |
+"st6 0 (raw 0x00000000000000000000)\n"\
|
|
Matej Habrnal |
5c8df3 |
+"st7 0 (raw 0x00000000000000000000)\n"\
|
|
Matej Habrnal |
5c8df3 |
+"fctrl 0x37f 895\n"\
|
|
Matej Habrnal |
5c8df3 |
+"fstat 0x0 0\n"\
|
|
Matej Habrnal |
5c8df3 |
+"ftag 0xffff 65535\n"\
|
|
Matej Habrnal |
5c8df3 |
+"fiseg 0x0 0\n"\
|
|
Matej Habrnal |
5c8df3 |
+"fioff 0x0 0\n"\
|
|
Matej Habrnal |
5c8df3 |
+"foseg 0x0 0\n"\
|
|
Matej Habrnal |
5c8df3 |
+"fooff 0x0 0\n"\
|
|
Matej Habrnal |
5c8df3 |
+"fop 0x0 0\n"\
|
|
Matej Habrnal |
5c8df3 |
+"xmm0 {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0}, v2_int64 = {0x0, 0x0}, uint128 = 0x00000000000000000000000000000000}\n"\
|
|
Matej Habrnal |
5c8df3 |
+"xmm1 {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, v16_int8 = {0x2f <repeats 16 times>}, v8_int16 = {0x2f2f, 0x2f2f, 0x2f2f, 0x2f2f, 0x2f2f, 0x2f2f, 0x2f2f, 0x2f2f}, v4_int32 = {0x2f2f2f2f, 0x2f2f2f2f, 0x2f2f2f2f, 0x2f2f2f2f}, v2_int64 = {0x2f2f2f2f2f2f2f2f, 0x2f2f2f2f2f2f2f2f}, uint128 = 0x2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f}\n"\
|
|
Matej Habrnal |
5c8df3 |
+"xmm2 {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0}, v2_int64 = {0x0, 0x0}, uint128 = 0x00000000000000000000000000000000}\n"\
|
|
Matej Habrnal |
5c8df3 |
+"xmm3 {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, v16_int8 = {0x0 <repeats 13 times>, 0xff, 0x0, 0x0}, v8_int16 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff00, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0xff00}, v2_int64 = {0x0, 0xff0000000000}, uint128 = 0x0000ff00000000000000000000000000}\n"\
|
|
Matej Habrnal |
5c8df3 |
+"xmm4 {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, v16_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0x0, 0x0, 0x0, 0x0, 0x0}, v8_int16 = {0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0xff0000, 0x0}, v2_int64 = {0x0, 0xff0000}, uint128 = 0x0000000000ff00000000000000000000}\n"\
|
|
Matej Habrnal |
5c8df3 |
+"xmm5 {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0}, v2_int64 = {0x0, 0x0}, uint128 = 0x00000000000000000000000000000000}\n"\
|
|
Matej Habrnal |
5c8df3 |
+"xmm6 {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0}, v2_int64 = {0x0, 0x0}, uint128 = 0x00000000000000000000000000000000}\n"\
|
|
Matej Habrnal |
5c8df3 |
+"xmm7 {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0}, v2_int64 = {0x0, 0x0}, uint128 = 0x00000000000000000000000000000000}\n"\
|
|
Matej Habrnal |
5c8df3 |
+"xmm8 {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0}, v2_int64 = {0x0, 0x0}, uint128 = 0x00000000000000000000000000000000}\n"\
|
|
Matej Habrnal |
5c8df3 |
+"xmm9 {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0}, v2_int64 = {0x0, 0x0}, uint128 = 0x00000000000000000000000000000000}\n"\
|
|
Matej Habrnal |
5c8df3 |
+"xmm10 {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0}, v2_int64 = {0x0, 0x0}, uint128 = 0x00000000000000000000000000000000}\n"\
|
|
Matej Habrnal |
5c8df3 |
+"xmm11 {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0}, v2_int64 = {0x0, 0x0}, uint128 = 0x00000000000000000000000000000000}\n"\
|
|
Matej Habrnal |
5c8df3 |
+"xmm12 {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, v16_int8 = {0x0 <repeats 14 times>, 0xff, 0x0}, v8_int16 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff}, v4_int32 = {0x0, 0x0, 0x0, 0xff0000}, v2_int64 = {0x0, 0xff000000000000}, uint128 = 0x00ff0000000000000000000000000000}\n"\
|
|
Matej Habrnal |
5c8df3 |
+"xmm13 {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0}, v2_int64 = {0x0, 0x0}, uint128 = 0x00000000000000000000000000000000}\n"\
|
|
Matej Habrnal |
5c8df3 |
+"xmm14 {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0}, v2_int64 = {0x0, 0x0}, uint128 = 0x00000000000000000000000000000000}\n"\
|
|
Matej Habrnal |
5c8df3 |
+"xmm15 {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, 0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0}, v2_int64 = {0x0, 0x0}, uint128 = 0x00000000000000000000000000000000}\n"\
|
|
Matej Habrnal |
5c8df3 |
+"mxcsr 0x1f80 [ IM DM ZM OM UM PM ]\n"\
|
|
Matej Habrnal |
5c8df3 |
+"Dump of assembler code for function crash:\n"\
|
|
Matej Habrnal |
5c8df3 |
+" 0x00000000004008a0 <+0>: push %rbx\n"\
|
|
Matej Habrnal |
5c8df3 |
+" 0x00000000004008a1 <+1>: mov %rdi,%rbx\n"\
|
|
Matej Habrnal |
5c8df3 |
+" 0x00000000004008a4 <+4>: mov $0x400ac0,%edi\n"\
|
|
Matej Habrnal |
5c8df3 |
+" 0x00000000004008a9 <+9>: callq 0x4006f0 <puts@plt>\n"\
|
|
Matej Habrnal |
5c8df3 |
+" => 0x00000000004008ae <+14>: mov (%rbx),%edx\n"\
|
|
Matej Habrnal |
5c8df3 |
+" 0x00000000004008b0 <+16>: mov $0x400acf,%esi\n"\
|
|
Matej Habrnal |
5c8df3 |
+" 0x00000000004008b5 <+21>: mov $0x1,%edi\n"\
|
|
Matej Habrnal |
5c8df3 |
+" 0x00000000004008ba <+26>: xor %eax,%eax\n"\
|
|
Matej Habrnal |
5c8df3 |
+" 0x00000000004008bc <+28>: callq 0x400740 <__printf_chk@plt>\n"\
|
|
Matej Habrnal |
5c8df3 |
+" 0x00000000004008c1 <+33>: pop %rbx\n"\
|
|
Matej Habrnal |
5c8df3 |
+" 0x00000000004008c2 <+34>: retq\n"\
|
|
Matej Habrnal |
5c8df3 |
+"End of assembler dump.\n"
|
|
Matej Habrnal |
5c8df3 |
+ );
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ for (size_t i = 0; i < sizeof(test_format_result)/sizeof(*test_format_result); ++i) {
|
|
Matej Habrnal |
5c8df3 |
+ problem_formatter_t *pf = problem_formatter_new();
|
|
Matej Habrnal |
5c8df3 |
+ assert(!problem_formatter_load_string(pf, test_format_result[i][0]));
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ problem_report_t *pr = NULL;
|
|
Matej Habrnal |
5c8df3 |
+ assert(!problem_formatter_generate_report(pf, data, &pr);;
|
|
Matej Habrnal |
5c8df3 |
+ assert(pr != NULL);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ const char *summary = problem_report_get_description(pr);
|
|
Matej Habrnal |
5c8df3 |
+ assert(summary != NULL);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ if (test_format_result[i][1] != NULL) {
|
|
Matej Habrnal |
5c8df3 |
+ fprintf(stderr, "####\n");
|
|
Matej Habrnal |
5c8df3 |
+ fprintf(stderr, "expected: '%s'\n", test_format_result[i][1]);
|
|
Matej Habrnal |
5c8df3 |
+ fprintf(stderr, "====\n");
|
|
Matej Habrnal |
5c8df3 |
+ fprintf(stderr, "result : '%s'\n", summary);
|
|
Matej Habrnal |
5c8df3 |
+ fprintf(stderr, "####\n");
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ assert(strcmp(test_format_result[i][1], summary) == 0);
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ problem_report_free(pr);
|
|
Matej Habrnal |
5c8df3 |
+ problem_formatter_free(pf);
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ problem_data_free(data);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ return 0;
|
|
Matej Habrnal |
5c8df3 |
+}
|
|
Matej Habrnal |
5c8df3 |
+]])
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+## ------ ##
|
|
Matej Habrnal |
5c8df3 |
+## attach ##
|
|
Matej Habrnal |
5c8df3 |
+## ------ ##
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+AT_TESTFUN([attach],
|
|
Matej Habrnal |
5c8df3 |
+[[
|
|
Matej Habrnal |
5c8df3 |
+#include "problem_report.h"
|
|
Matej Habrnal |
5c8df3 |
+#include "internal_libreport.h"
|
|
Matej Habrnal |
5c8df3 |
+#include <assert.h>
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+int main(int argc, char **argv)
|
|
Matej Habrnal |
5c8df3 |
+{
|
|
Matej Habrnal |
5c8df3 |
+ g_verbose = 3;
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ const char *fst[] = { "backtrace", "screenshot", "description", NULL };
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ struct test_case {
|
|
Matej Habrnal |
5c8df3 |
+ const char *format;
|
|
Matej Habrnal |
5c8df3 |
+ const char *const *files;
|
|
Matej Habrnal |
5c8df3 |
+ } cases [] = {
|
|
Matej Habrnal |
5c8df3 |
+ {
|
|
Matej Habrnal |
5c8df3 |
+ .format = "%attach:: %multiline,%binary,-coredump",
|
|
Matej Habrnal |
5c8df3 |
+ .files = fst,
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+ };
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ problem_data_t *data = problem_data_new();
|
|
Matej Habrnal |
5c8df3 |
+ problem_data_add_text_noteditable(data, "package", "libreport");
|
|
Matej Habrnal |
5c8df3 |
+ problem_data_add_text_noteditable(data, "analyzer", "CCpp");
|
|
Matej Habrnal |
5c8df3 |
+ problem_data_add_text_noteditable(data, "type", "CCpp");
|
|
Matej Habrnal |
5c8df3 |
+ problem_data_add_text_noteditable(data, "comment", "Hello, world!");
|
|
Matej Habrnal |
5c8df3 |
+ problem_data_add_text_noteditable(data, "uuid", "123456789ABCDEF");
|
|
Matej Habrnal |
5c8df3 |
+ problem_data_add_text_noteditable(data, "uid", "69");
|
|
Matej Habrnal |
5c8df3 |
+ problem_data_add_text_noteditable(data, "user_name", "abrt");
|
|
Matej Habrnal |
5c8df3 |
+ problem_data_add_text_noteditable(data, "root", "/var/run/mock/abrt");
|
|
Matej Habrnal |
5c8df3 |
+ problem_data_add_text_noteditable(data, "description", "I run will_segfault and\nit crashed as expected\n");
|
|
Matej Habrnal |
5c8df3 |
+ problem_data_add_file(data, "coredump", "/what/ever/path/to/coredump");
|
|
Matej Habrnal |
5c8df3 |
+ problem_data_add_file(data, "screenshot", "/what/ever/path/to/screenshot");
|
|
Matej Habrnal |
5c8df3 |
+ problem_data_add_text_noteditable(data, "backtrace",
|
|
Matej Habrnal |
5c8df3 |
+"Thread 1 (LWP 11865):\n"\
|
|
Matej Habrnal |
5c8df3 |
+"#0 printf (__fmt=0x400acf \"Result: %d\\n\") at /usr/include/bits/stdio2.h:104\n"\
|
|
Matej Habrnal |
5c8df3 |
+"No locals.\n"\
|
|
Matej Habrnal |
5c8df3 |
+"#1 crash (p=p@entry=0x0) at will_segfault.c:19\n"\
|
|
Matej Habrnal |
5c8df3 |
+"i = <error reading variable i (Cannot access memory at address 0x0)>\n"\
|
|
Matej Habrnal |
5c8df3 |
+"#2 0x0000000000400964 in varargs (num_args=1, num_args@entry=2) at will_segfault.c:31\n"\
|
|
Matej Habrnal |
5c8df3 |
+"p = <optimized out>\n"\
|
|
Matej Habrnal |
5c8df3 |
+"ap = {{gp_offset = 24, fp_offset = 32767, overflow_arg_area = 0x7fff4fc8a0c0, reg_save_area = 0x7fff4fc8a080}}\n"\
|
|
Matej Habrnal |
5c8df3 |
+"#3 0x00000000004009be in inlined (p=0x0) at will_segfault.c:40\n"\
|
|
Matej Habrnal |
5c8df3 |
+"num = 42\n"\
|
|
Matej Habrnal |
5c8df3 |
+"#4 f (p=p@entry=0x0) at will_segfault.c:45\n"\
|
|
Matej Habrnal |
5c8df3 |
+"No locals.\n"\
|
|
Matej Habrnal |
5c8df3 |
+"#5 0x00000000004009e9 in callback (data=data@entry=0x0) at will_segfault.c:50\n"\
|
|
Matej Habrnal |
5c8df3 |
+"No locals.\n"\
|
|
Matej Habrnal |
5c8df3 |
+"#6 0x00000032f76006f9 in call_me_back (cb=cb@entry=0x4009e0 <callback>, data=data@entry=0x0) at libwillcrash.c:8\n"\
|
|
Matej Habrnal |
5c8df3 |
+"res = <optimized out>\n"\
|
|
Matej Habrnal |
5c8df3 |
+"#7 0x0000000000400a14 in recursive (i=i@entry=0) at will_segfault.c:59\n"\
|
|
Matej Habrnal |
5c8df3 |
+"p = <optimized out>\n"\
|
|
Matej Habrnal |
5c8df3 |
+"#8 0x0000000000400a00 in recursive (i=i@entry=1) at will_segfault.c:66\n"\
|
|
Matej Habrnal |
5c8df3 |
+"No locals.\n"\
|
|
Matej Habrnal |
5c8df3 |
+"#9 0x0000000000400a00 in recursive (i=i@entry=2) at will_segfault.c:66\n"\
|
|
Matej Habrnal |
5c8df3 |
+"No locals.\n"\
|
|
Matej Habrnal |
5c8df3 |
+"#10 0x0000000000400775 in main (argc=<optimized out>, argv=<optimized out>) at will_segfault.c:83\n"\
|
|
Matej Habrnal |
5c8df3 |
+"No locals.\n");
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ for (size_t i = 0; i < sizeof(cases)/sizeof(*cases); ++i) {
|
|
Matej Habrnal |
5c8df3 |
+ fprintf(stderr, "%s", cases[i].format);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ problem_formatter_t *pf = problem_formatter_new();
|
|
Matej Habrnal |
5c8df3 |
+ assert(!problem_formatter_load_string(pf, cases[i].format));
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ problem_report_t *pr = NULL;
|
|
Matej Habrnal |
5c8df3 |
+ assert(!problem_formatter_generate_report(pf, data, &pr);;
|
|
Matej Habrnal |
5c8df3 |
+ assert(pr != NULL);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ const char *const *iter = cases[i].files;
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ if (*iter != NULL) {
|
|
Matej Habrnal |
5c8df3 |
+ assert(problem_report_get_attachments(pr));
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ GList *clone = g_list_copy_deep(problem_report_get_attachments(pr), (GCopyFunc)xstrdup, NULL);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ while (*iter) {
|
|
Matej Habrnal |
5c8df3 |
+ GList *item = g_list_find_custom(clone, *iter, (GCompareFunc)strcmp);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ if (item == NULL) {
|
|
Matej Habrnal |
5c8df3 |
+ fprintf(stderr, "format: '%s'\n", cases[i].format);
|
|
Matej Habrnal |
5c8df3 |
+ fprintf(stderr, "missing file: '%s'\n", *iter);
|
|
Matej Habrnal |
5c8df3 |
+ abort();
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+ else {
|
|
Matej Habrnal |
5c8df3 |
+ free(item->data);
|
|
Matej Habrnal |
5c8df3 |
+ clone = g_list_delete_link(clone, item);
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ ++iter;
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ if (clone != NULL) {
|
|
Matej Habrnal |
5c8df3 |
+ for (GList *iter = clone; iter; iter = g_list_next(iter)) {
|
|
Matej Habrnal |
5c8df3 |
+ fprintf(stderr, "extra : '%s'\n", (const char *)iter->data);
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+ abort();
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ problem_report_free(pr);
|
|
Matej Habrnal |
5c8df3 |
+ problem_formatter_free(pf);
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ problem_data_free(data);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ return 0;
|
|
Matej Habrnal |
5c8df3 |
+}
|
|
Matej Habrnal |
5c8df3 |
+]])
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+## -------------- ##
|
|
Matej Habrnal |
5c8df3 |
+## custom_section ##
|
|
Matej Habrnal |
5c8df3 |
+## -------------- ##
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+AT_TESTFUN([custom_section],
|
|
Matej Habrnal |
5c8df3 |
+[[
|
|
Matej Habrnal |
5c8df3 |
+#include "problem_report.h"
|
|
Matej Habrnal |
5c8df3 |
+#include "internal_libreport.h"
|
|
Matej Habrnal |
5c8df3 |
+#include <assert.h>
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+int main(int argc, char **argv)
|
|
Matej Habrnal |
5c8df3 |
+{
|
|
Matej Habrnal |
5c8df3 |
+ g_verbose = 3;
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ struct test_case;
|
|
Matej Habrnal |
5c8df3 |
+ struct test_case {
|
|
Matej Habrnal |
5c8df3 |
+ const char *section_name;
|
|
Matej Habrnal |
5c8df3 |
+ int section_flags;
|
|
Matej Habrnal |
5c8df3 |
+ int retval_load;
|
|
Matej Habrnal |
5c8df3 |
+ int retval_generate;
|
|
Matej Habrnal |
5c8df3 |
+ const char *format;
|
|
Matej Habrnal |
5c8df3 |
+ const char *output;
|
|
Matej Habrnal |
5c8df3 |
+ } cases [] = {
|
|
Matej Habrnal |
5c8df3 |
+ { .section_name = NULL,
|
|
Matej Habrnal |
5c8df3 |
+ .section_flags = 0,
|
|
Matej Habrnal |
5c8df3 |
+ .retval_load = 1,
|
|
Matej Habrnal |
5c8df3 |
+ .retval_generate = 0,
|
|
Matej Habrnal |
5c8df3 |
+ .format =
|
|
Matej Habrnal |
5c8df3 |
+ "%additional_info::\n"
|
|
Matej Habrnal |
5c8df3 |
+ ":: package,\\\n"
|
|
Matej Habrnal |
5c8df3 |
+ "uuid,cwd\\\\"
|
|
Matej Habrnal |
5c8df3 |
+ ",user_name"
|
|
Matej Habrnal |
5c8df3 |
+ ,
|
|
Matej Habrnal |
5c8df3 |
+ .output = NULL,
|
|
Matej Habrnal |
5c8df3 |
+ },
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ { .section_name = "additional_info",
|
|
Matej Habrnal |
5c8df3 |
+ .section_flags = 0,
|
|
Matej Habrnal |
5c8df3 |
+ .retval_load = 0,
|
|
Matej Habrnal |
5c8df3 |
+ .retval_generate = 0,
|
|
Matej Habrnal |
5c8df3 |
+ .format =
|
|
Matej Habrnal |
5c8df3 |
+ "%additional_info::\n"
|
|
Matej Habrnal |
5c8df3 |
+ ":: package,\\\n"
|
|
Matej Habrnal |
5c8df3 |
+ "uuid,cwd\\\\"
|
|
Matej Habrnal |
5c8df3 |
+ ",user_name"
|
|
Matej Habrnal |
5c8df3 |
+ ,
|
|
Matej Habrnal |
5c8df3 |
+ .output =
|
|
Matej Habrnal |
5c8df3 |
+ "package: libreport\n"
|
|
Matej Habrnal |
5c8df3 |
+ "uuid: 0123456789ABCDEF\n"
|
|
Matej Habrnal |
5c8df3 |
+ "user_name: abrt\n"
|
|
Matej Habrnal |
5c8df3 |
+ ,
|
|
Matej Habrnal |
5c8df3 |
+ },
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ { .section_name = "additional_info",
|
|
Matej Habrnal |
5c8df3 |
+ .section_flags = PFFF_REQUIRED,
|
|
Matej Habrnal |
5c8df3 |
+ .retval_load = 1,
|
|
Matej Habrnal |
5c8df3 |
+ .retval_generate = 0,
|
|
Matej Habrnal |
5c8df3 |
+ .format = "%summary:: [abrt] %package%\n:: %reporter\n",
|
|
Matej Habrnal |
5c8df3 |
+ .output = NULL,
|
|
Matej Habrnal |
5c8df3 |
+ },
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ { .section_name = "additional_info",
|
|
Matej Habrnal |
5c8df3 |
+ .section_flags = 0,
|
|
Matej Habrnal |
5c8df3 |
+ .retval_load = 0,
|
|
Matej Habrnal |
5c8df3 |
+ .retval_generate = 0,
|
|
Matej Habrnal |
5c8df3 |
+ .format = "%summary:: [abrt] %package%\n:: %reporter\n",
|
|
Matej Habrnal |
5c8df3 |
+ .output = "",
|
|
Matej Habrnal |
5c8df3 |
+ },
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ { .section_name = "additional_info",
|
|
Matej Habrnal |
5c8df3 |
+ .section_flags = 0,
|
|
Matej Habrnal |
5c8df3 |
+ .retval_load = 0,
|
|
Matej Habrnal |
5c8df3 |
+ .retval_generate = 0,
|
|
Matej Habrnal |
5c8df3 |
+ .format =
|
|
Matej Habrnal |
5c8df3 |
+ "%additional_info:: root\n"
|
|
Matej Habrnal |
5c8df3 |
+ "Info:: package,\\\n"
|
|
Matej Habrnal |
5c8df3 |
+ "uuid,cwd\\\\"
|
|
Matej Habrnal |
5c8df3 |
+ ",user_name"
|
|
Matej Habrnal |
5c8df3 |
+ ,
|
|
Matej Habrnal |
5c8df3 |
+ .output =
|
|
Matej Habrnal |
5c8df3 |
+ "Info:\n"
|
|
Matej Habrnal |
5c8df3 |
+ "package: libreport\n"
|
|
Matej Habrnal |
5c8df3 |
+ "uuid: 0123456789ABCDEF\n"
|
|
Matej Habrnal |
5c8df3 |
+ "user_name: abrt\n"
|
|
Matej Habrnal |
5c8df3 |
+ ,
|
|
Matej Habrnal |
5c8df3 |
+ },
|
|
Matej Habrnal |
5c8df3 |
+ };
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ problem_data_t *data = problem_data_new();
|
|
Matej Habrnal |
5c8df3 |
+ problem_data_add_text_noteditable(data, "package", "libreport");
|
|
Matej Habrnal |
5c8df3 |
+ problem_data_add_text_noteditable(data, "crash_function", "run_event");
|
|
Matej Habrnal |
5c8df3 |
+ problem_data_add_text_noteditable(data, "reason", "Killed by SIGSEGV");
|
|
Matej Habrnal |
5c8df3 |
+ problem_data_add_text_noteditable(data, "uuid", "0123456789ABCDEF");
|
|
Matej Habrnal |
5c8df3 |
+ problem_data_add_text_noteditable(data, "user_name", "abrt");
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ for (size_t i = 0; i < sizeof(cases)/sizeof(*cases); ++i) {
|
|
Matej Habrnal |
5c8df3 |
+ fprintf(stderr, "#### Test case %zd ####\n", i + 1);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ struct test_case *tcase = cases + i;
|
|
Matej Habrnal |
5c8df3 |
+ problem_formatter_t *pf = problem_formatter_new();
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ if (tcase->section_name != NULL) {
|
|
Matej Habrnal |
5c8df3 |
+ problem_formatter_add_section(pf, tcase->section_name, tcase->section_flags);
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ int r = problem_formatter_load_string(pf, tcase->format);
|
|
Matej Habrnal |
5c8df3 |
+ if (r != tcase->retval_load) {
|
|
Matej Habrnal |
5c8df3 |
+ fprintf(stderr, "Load : expected : %d , got : %d\n", tcase->retval_load, r);
|
|
Matej Habrnal |
5c8df3 |
+ abort();
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ if (tcase->retval_load != 0) {
|
|
Matej Habrnal |
5c8df3 |
+ goto next_test_case;
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ problem_report_t *pr = NULL;
|
|
Matej Habrnal |
5c8df3 |
+ r = problem_formatter_generate_report(pf, data, &pr);
|
|
Matej Habrnal |
5c8df3 |
+ if (r != tcase->retval_generate) {
|
|
Matej Habrnal |
5c8df3 |
+ fprintf(stderr, "Generaet : expected : %d , got : %d\n", tcase->retval_generate, r);
|
|
Matej Habrnal |
5c8df3 |
+ abort();
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ if (tcase->retval_generate != 0) {
|
|
Matej Habrnal |
5c8df3 |
+ goto next_test_case;
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ const char *output = problem_report_get_section(pr, tcase->section_name);
|
|
Matej Habrnal |
5c8df3 |
+ assert(output);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ if (strcmp(output, tcase->output) != 0) {
|
|
Matej Habrnal |
5c8df3 |
+ fprintf(stderr, "expected:\n'%s'\n", tcase->output);
|
|
Matej Habrnal |
5c8df3 |
+ fprintf(stderr, "result :\n'%s'\n", output);
|
|
Matej Habrnal |
5c8df3 |
+ abort();
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ problem_report_free(pr);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+next_test_case:
|
|
Matej Habrnal |
5c8df3 |
+ problem_formatter_free(pf);
|
|
Matej Habrnal |
5c8df3 |
+ fprintf(stderr, "#### Finished - Test case %zd ####\n", i + 1);
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ problem_data_free(data);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ return 0;
|
|
Matej Habrnal |
5c8df3 |
+}
|
|
Matej Habrnal |
5c8df3 |
+]])
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+## ------ ##
|
|
Matej Habrnal |
5c8df3 |
+## sanity ##
|
|
Matej Habrnal |
5c8df3 |
+## ------ ##
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+AT_TESTFUN([sanity],
|
|
Matej Habrnal |
5c8df3 |
+[[
|
|
Matej Habrnal |
5c8df3 |
+#include "problem_report.h"
|
|
Matej Habrnal |
5c8df3 |
+#include "internal_libreport.h"
|
|
Matej Habrnal |
5c8df3 |
+#include <errno.h>
|
|
Matej Habrnal |
5c8df3 |
+#include <assert.h>
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+void assert_equal_strings(const char *res, const char *exp)
|
|
Matej Habrnal |
5c8df3 |
+{
|
|
Matej Habrnal |
5c8df3 |
+ if ( (res == NULL && exp != NULL)
|
|
Matej Habrnal |
5c8df3 |
+ || (res != NULL && exp == NULL)
|
|
Matej Habrnal |
5c8df3 |
+ || ((res != NULL && exp != NULL) && strcmp(res, exp) != 0)
|
|
Matej Habrnal |
5c8df3 |
+ ) {
|
|
Matej Habrnal |
5c8df3 |
+ fprintf(stderr, "expected : '%s'\n", exp);
|
|
Matej Habrnal |
5c8df3 |
+ fprintf(stderr, "result : '%s'\n", res);
|
|
Matej Habrnal |
5c8df3 |
+ abort();
|
|
Matej Habrnal |
5c8df3 |
+ }
|
|
Matej Habrnal |
5c8df3 |
+}
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+int main(int argc, char **argv)
|
|
Matej Habrnal |
5c8df3 |
+{
|
|
Matej Habrnal |
5c8df3 |
+ g_verbose = 3;
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ problem_formatter_t *pf = problem_formatter_new();
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ assert(problem_formatter_add_section(pf, "summary", 0) == -EEXIST);
|
|
Matej Habrnal |
5c8df3 |
+ assert(problem_formatter_add_section(pf, "description", 0) == -EEXIST);
|
|
Matej Habrnal |
5c8df3 |
+ assert(problem_formatter_add_section(pf, "attach", 0) == -EEXIST);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ assert(problem_formatter_add_section(pf, "additional_info", 0) == 0);
|
|
Matej Habrnal |
5c8df3 |
+ assert(problem_formatter_add_section(pf, "additional_info", 0) == -EEXIST);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ problem_data_t *data = problem_data_new();
|
|
Matej Habrnal |
5c8df3 |
+ problem_data_add_text_noteditable(data, "package", "libreport");
|
|
Matej Habrnal |
5c8df3 |
+ problem_data_add_text_noteditable(data, "crash_function", "run_event");
|
|
Matej Habrnal |
5c8df3 |
+ problem_data_add_text_noteditable(data, "reason", "Killed by SIGSEGV");
|
|
Matej Habrnal |
5c8df3 |
+ problem_data_add_text_noteditable(data, "comment", "Hello, world!");
|
|
Matej Habrnal |
5c8df3 |
+ problem_data_add_text_noteditable(data, "root", "/var/run/mock/abrt");
|
|
Matej Habrnal |
5c8df3 |
+ problem_data_add_text_noteditable(data, "user_name", "abrt");
|
|
Matej Habrnal |
5c8df3 |
+ problem_data_add_file(data, "screenshot", "/what/ever/path/to/screenshot");
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ problem_formatter_load_string(pf,
|
|
Matej Habrnal |
5c8df3 |
+ "%summary:: [abrt] %package% : %reason%\n\n"
|
|
Matej Habrnal |
5c8df3 |
+ "Description:: %bare_comment\n\n"
|
|
Matej Habrnal |
5c8df3 |
+ "%attach:: screenshot\n\n"
|
|
Matej Habrnal |
5c8df3 |
+ "%additional_info::\n\n"
|
|
Matej Habrnal |
5c8df3 |
+ "User:: root,user_name,uid\n\n\n"
|
|
Matej Habrnal |
5c8df3 |
+ );
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ problem_report_t *pr = NULL;
|
|
Matej Habrnal |
5c8df3 |
+ problem_formatter_generate_report(pf, data, &pr);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ assert_equal_strings(problem_report_get_summary(pr),
|
|
Matej Habrnal |
5c8df3 |
+ "[abrt] libreport : Killed by SIGSEGV");
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ problem_report_buffer_printf(problem_report_get_buffer(pr, PR_SEC_SUMMARY), " - test");
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ assert_equal_strings(problem_report_get_summary(pr),
|
|
Matej Habrnal |
5c8df3 |
+ "[abrt] libreport : Killed by SIGSEGV - test");
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ assert_equal_strings(problem_report_get_description(pr),
|
|
Matej Habrnal |
5c8df3 |
+ "Description:\nHello, world!\n");
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ problem_report_buffer_printf(problem_report_get_buffer(pr, PR_SEC_DESCRIPTION), "Test line\n");
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ assert_equal_strings(problem_report_get_description(pr),
|
|
Matej Habrnal |
5c8df3 |
+ "Description:\nHello, world!\nTest line\n");
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ assert_equal_strings(problem_report_get_section(pr, "additional_info"),
|
|
Matej Habrnal |
5c8df3 |
+ "User:\n"
|
|
Matej Habrnal |
5c8df3 |
+ "root: /var/run/mock/abrt\n"
|
|
Matej Habrnal |
5c8df3 |
+ "user_name: abrt\n"
|
|
Matej Habrnal |
5c8df3 |
+ );
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ problem_report_buffer_printf(problem_report_get_buffer(pr, "additional_info"), "uid: 42\n");
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ assert_equal_strings(problem_report_get_section(pr, "additional_info"),
|
|
Matej Habrnal |
5c8df3 |
+ "User:\n"
|
|
Matej Habrnal |
5c8df3 |
+ "root: /var/run/mock/abrt\n"
|
|
Matej Habrnal |
5c8df3 |
+ "user_name: abrt\n"
|
|
Matej Habrnal |
5c8df3 |
+ "uid: 42\n"
|
|
Matej Habrnal |
5c8df3 |
+ );
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ problem_report_free(pr);
|
|
Matej Habrnal |
5c8df3 |
+ problem_data_free(data);
|
|
Matej Habrnal |
5c8df3 |
+ problem_formatter_free(pf);
|
|
Matej Habrnal |
5c8df3 |
+
|
|
Matej Habrnal |
5c8df3 |
+ return 0;
|
|
Matej Habrnal |
5c8df3 |
+}
|
|
Matej Habrnal |
5c8df3 |
+]])
|
|
Matej Habrnal |
5c8df3 |
diff --git a/tests/testsuite.at b/tests/testsuite.at
|
|
Matej Habrnal |
5c8df3 |
index abad32b..340c758 100644
|
|
Matej Habrnal |
5c8df3 |
--- a/tests/testsuite.at
|
|
Matej Habrnal |
5c8df3 |
+++ b/tests/testsuite.at
|
|
Matej Habrnal |
5c8df3 |
@@ -17,3 +17,4 @@ m4_include([xml_definition.at])
|
|
Matej Habrnal |
5c8df3 |
m4_include([report_python.at])
|
|
Matej Habrnal |
5c8df3 |
m4_include([string_list.at])
|
|
Matej Habrnal |
5c8df3 |
m4_include([ureport.at])
|
|
Matej Habrnal |
5c8df3 |
+m4_include([problem_report.at])
|
|
Matej Habrnal |
5c8df3 |
--
|
|
Matej Habrnal |
5c8df3 |
1.8.3.1
|
|
Matej Habrnal |
5c8df3 |
|