core: Inject program name into dmesg
authorChris Wilson <chris@chris-wilson.co.uk>
Fri, 25 Jul 2014 13:29:47 +0000 (14:29 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Fri, 25 Jul 2014 13:39:18 +0000 (14:39 +0100)
Write the program name if !list_only so that we associate oops with
simple tests.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
lib/igt_core.c

index 7bd8e19..a0c9499 100644 (file)
@@ -218,6 +218,24 @@ int num_test_children;
 int test_children_sz;
 bool test_child;
 
+__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);
+}
+
 bool __igt_fixture(void)
 {
        assert(!in_fixture);
@@ -378,8 +396,6 @@ static int common_init(int argc, char **argv,
                }
        }
 
-       oom_adjust_for_doom();
-
 out:
        free(short_opts);
        free(combined_opts);
@@ -399,7 +415,12 @@ out:
                /* exit with no error for -h/--help */
                exit(ret == -1 ? 0 : IGT_EXIT_INVALID);
 
-       print_version();
+       if (!list_subtests) {
+               kmsg(KERN_INFO "%s: executing\n", command_str);
+               print_version();
+
+               oom_adjust_for_doom();
+       }
 
        return ret;
 }
@@ -498,24 +519,6 @@ 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