blob: 50f7abd0813df0abd436391244bb3f1ca98bff99 [file] [log] [blame]
Arjan van de Ven6dab2772008-01-30 13:33:08 +01001/*
2 * Simple stack backtrace regression test module
3 *
4 * (C) Copyright 2008 Intel Corporation
5 * Author: Arjan van de Ven <arjan@linux.intel.com>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; version 2
10 * of the License.
11 */
12
Vegard Nossumad118c52008-06-27 18:04:48 +020013#include <linux/delay.h>
Arjan van de Ven6dab2772008-01-30 13:33:08 +010014#include <linux/module.h>
15#include <linux/sched.h>
Vegard Nossumad118c52008-06-27 18:04:48 +020016#include <linux/stacktrace.h>
Arjan van de Ven6dab2772008-01-30 13:33:08 +010017
18static struct timer_list backtrace_timer;
19
20static void backtrace_test_timer(unsigned long data)
21{
22 printk("Testing a backtrace from irq context.\n");
23 printk("The following trace is a kernel self test and not a bug!\n");
24 dump_stack();
25}
Vegard Nossumad118c52008-06-27 18:04:48 +020026
27#ifdef CONFIG_STACKTRACE
28static void backtrace_test_saved(void)
29{
30 struct stack_trace trace;
31 unsigned long entries[8];
32
33 printk("Testing a saved backtrace.\n");
34 printk("The following trace is a kernel self test and not a bug!\n");
35
36 trace.nr_entries = 0;
37 trace.max_entries = ARRAY_SIZE(entries);
38 trace.entries = entries;
39 trace.skip = 0;
40
41 save_stack_trace(&trace);
42 print_stack_trace(&trace, 0);
43}
44#else
45static void backtrace_test_saved(void)
46{
47 printk("Saved backtrace test skipped.\n");
48}
49#endif
50
Arjan van de Ven6dab2772008-01-30 13:33:08 +010051static int backtrace_regression_test(void)
52{
53 printk("====[ backtrace testing ]===========\n");
54 printk("Testing a backtrace from process context.\n");
55 printk("The following trace is a kernel self test and not a bug!\n");
56 dump_stack();
57
Vegard Nossumad118c52008-06-27 18:04:48 +020058 backtrace_test_saved();
59
Arjan van de Ven6dab2772008-01-30 13:33:08 +010060 init_timer(&backtrace_timer);
61 backtrace_timer.function = backtrace_test_timer;
62 mod_timer(&backtrace_timer, jiffies + 10);
63
64 msleep(10);
65 printk("====[ end of backtrace testing ]====\n");
66 return 0;
67}
68
69static void exitf(void)
70{
71}
72
73module_init(backtrace_regression_test);
74module_exit(exitf);
75MODULE_LICENSE("GPL");
76MODULE_AUTHOR("Arjan van de Ven <arjan@linux.intel.com>");