mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-06-12 02:16:17 +00:00
lib: print recent log messages to stderr when a test or subtest fails
Signed-off-by: Thomas Wood <thomas.wood@intel.com>
This commit is contained in:
parent
a5f21726cd
commit
f8fd4c977a
@ -237,6 +237,9 @@ enum {
|
|||||||
OPT_HELP = 'h'
|
OPT_HELP = 'h'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static int igt_exitcode = IGT_EXIT_SUCCESS;
|
||||||
|
static const char *command_str;
|
||||||
|
|
||||||
static char* igt_log_domain_filter;
|
static char* igt_log_domain_filter;
|
||||||
static struct {
|
static struct {
|
||||||
char *entries[256];
|
char *entries[256];
|
||||||
@ -266,7 +269,39 @@ static void _igt_log_buffer_reset(void)
|
|||||||
pthread_mutex_unlock(&log_buffer_mutex);
|
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)))
|
__attribute__((format(printf, 1, 2)))
|
||||||
static void kmsg(const char *format, ...)
|
static void kmsg(const char *format, ...)
|
||||||
@ -423,8 +458,6 @@ static void print_version(void)
|
|||||||
uts.sysname, uts.release, uts.machine);
|
uts.sysname, uts.release, uts.machine);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *command_str;
|
|
||||||
|
|
||||||
static void print_usage(const char *help_str, bool output_on_stderr)
|
static void print_usage(const char *help_str, bool output_on_stderr)
|
||||||
{
|
{
|
||||||
FILE *f = output_on_stderr ? stderr : stdout;
|
FILE *f = output_on_stderr ? stderr : stdout;
|
||||||
@ -793,7 +826,6 @@ bool igt_only_list_subtests(void)
|
|||||||
static bool skipped_one = false;
|
static bool skipped_one = false;
|
||||||
static bool succeeded_one = false;
|
static bool succeeded_one = false;
|
||||||
static bool failed_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 *) __attribute__((noreturn));
|
||||||
static void exit_subtest(const char *result)
|
static void exit_subtest(const char *result)
|
||||||
@ -926,6 +958,8 @@ void igt_fail(int exitcode)
|
|||||||
if (test_child)
|
if (test_child)
|
||||||
exit(exitcode);
|
exit(exitcode);
|
||||||
|
|
||||||
|
_igt_log_buffer_dump();
|
||||||
|
|
||||||
if (in_subtest) {
|
if (in_subtest) {
|
||||||
if (exitcode == IGT_EXIT_TIMEOUT)
|
if (exitcode == IGT_EXIT_TIMEOUT)
|
||||||
exit_subtest("TIMEOUT");
|
exit_subtest("TIMEOUT");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user