diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2014-07-24 12:46:00 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2014-07-24 14:54:30 +0100 |
commit | 52915fc88a3948eab9e6f243b81285420897ab95 (patch) | |
tree | 604833de8cb2ad5b32f1d76f61e59adce054dc6c /lib | |
parent | 66e46630f8ba04060d73e18e46a956bf25201fc4 (diff) |
core: Inject subtest message into dmesg
One of the side-effects we test for are kernel oops and knowing the
guilty subtest can help speed up debugging. We can write to /dev/kmsg to
inject messages into dmesg, so let's do so before the start of every
test.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/igt_core.c | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/lib/igt_core.c b/lib/igt_core.c index b0800e83..91964281 100644 --- a/lib/igt_core.c +++ b/lib/igt_core.c @@ -269,8 +269,9 @@ static void print_version(void) uts.sysname, uts.release, uts.machine); } -static void print_usage(const char *command_str, const char *help_str, - bool output_on_stderr) +static const char *command_str; + +static void print_usage(const char *help_str, bool output_on_stderr) { FILE *f = output_on_stderr ? stderr : stdout; @@ -306,7 +307,6 @@ static int common_init(int argc, char **argv, {"debug", 0, 0, 'd'}, {"help", 0, 0, 'h'}, }; - const char *command_str; char *short_opts; struct option *combined_opts; int extra_opt_count; @@ -364,11 +364,11 @@ static int common_init(int argc, char **argv, run_single_subtest = strdup(optarg); break; case 'h': - print_usage(command_str, help_str, false); + print_usage(help_str, false); ret = -1; goto out; case '?': - print_usage(command_str, help_str, true); + print_usage(help_str, true); ret = -2; goto out; default: @@ -498,6 +498,24 @@ void igt_simple_init_parse_opts(int argc, char **argv, extra_opt_handler); } +__attribute__((format(printf, 1, 2))) +static void kmsg(const char *format, ...) +#define KERN_INFO "<5>" +{ + va_list ap; + FILE *file; + + file = fopen("/dev/kmsg", "w"); + if (file == NULL) + return; + + va_start(ap, format); + vfprintf(file, format, ap); + va_end(ap); + + fclose(file); +} + /* * Note: Testcases which use these helpers MUST NOT output anything to stdout * outside of places protected by igt_run_subtest checks - the piglit @@ -529,6 +547,8 @@ bool __igt_run_subtest(const char *subtest_name) return false; } + kmsg(KERN_INFO "%s: starting subtest %s\n", command_str, subtest_name); + return (in_subtest = subtest_name); } |