From: Thomas Wood <thomas.wood@intel.com>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH i-g-t 2/2] lib: print recent log messages to stderr when a test or subtest fails
Date: Thu, 29 Jan 2015 14:22:27 +0000 [thread overview]
Message-ID: <1422541347-584-3-git-send-email-thomas.wood@intel.com> (raw)
In-Reply-To: <1422541347-584-1-git-send-email-thomas.wood@intel.com>
Signed-off-by: Thomas Wood <thomas.wood@intel.com>
---
lib/igt_core.c | 40 +++++++++++++++++++++++++++++++++++++---
1 file changed, 37 insertions(+), 3 deletions(-)
diff --git a/lib/igt_core.c b/lib/igt_core.c
index b03b7df..596ab77 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -236,6 +236,9 @@ enum {
OPT_HELP = 'h'
};
+static int igt_exitcode = IGT_EXIT_SUCCESS;
+static const char *command_str;
+
static char* igt_log_domain_filter;
static struct {
char *entries[256];
@@ -265,7 +268,39 @@ static void _igt_log_buffer_reset(void)
pthread_mutex_unlock(&log_buffer_mutex);
}
+static void _igt_log_buffer_dump(void)
+{
+ uint8_t i;
+
+ if (in_subtest)
+ fprintf(stderr, "Subtest %s failed.\n", in_subtest);
+ else
+ fprintf(stderr, "Test %s failed.\n", command_str);
+
+ if (log_buffer.start == log_buffer.end) {
+ fprintf(stderr, "No log.\n");
+ return;
+ }
+
+ pthread_mutex_lock(&log_buffer_mutex);
+ fprintf(stderr, "Log Start\n");
+
+ i = log_buffer.start;
+ do {
+ char *last_line = log_buffer.entries[i];
+ fprintf(stderr, "%s%s", last_line,
+ (last_line[strlen(last_line)-1] != '\n') ? "\n" : "");
+ i++;
+ } while (i != log_buffer.start && i != log_buffer.end);
+
+ /* reset the buffer */
+ log_buffer.start = log_buffer.end = 0;
+
+ pthread_mutex_unlock(&log_buffer_mutex);
+
+ fprintf(stderr, "Log End\n");
+}
__attribute__((format(printf, 1, 2)))
static void kmsg(const char *format, ...)
@@ -422,8 +457,6 @@ static void print_version(void)
uts.sysname, uts.release, uts.machine);
}
-static const char *command_str;
-
static void print_usage(const char *help_str, bool output_on_stderr)
{
FILE *f = output_on_stderr ? stderr : stdout;
@@ -777,7 +810,6 @@ bool igt_only_list_subtests(void)
static bool skipped_one = false;
static bool succeeded_one = false;
static bool failed_one = false;
-static int igt_exitcode = IGT_EXIT_SUCCESS;
static void exit_subtest(const char *) __attribute__((noreturn));
static void exit_subtest(const char *result)
@@ -910,6 +942,8 @@ void igt_fail(int exitcode)
if (test_child)
exit(exitcode);
+ _igt_log_buffer_dump();
+
if (in_subtest) {
if (exitcode == IGT_EXIT_TIMEOUT)
exit_subtest("TIMEOUT");
--
2.1.0
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
prev parent reply other threads:[~2015-01-29 14:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-29 14:22 [PATCH i-g-t 0/2] printing log messages on test failure Thomas Wood
2015-01-29 14:22 ` [PATCH i-g-t 1/2] lib: add a ring buffer for log entries Thomas Wood
2015-01-29 14:22 ` Thomas Wood [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1422541347-584-3-git-send-email-thomas.wood@intel.com \
--to=thomas.wood@intel.com \
--cc=intel-gfx@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox