aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorVegard Nossum <vegard.nossum@gmail.com>2008-06-27 12:04:48 -0400
committerIngo Molnar <mingo@elte.hu>2008-06-27 12:09:15 -0400
commitad118c54a3587b2c69a769d0ba37d4d8dce4559d (patch)
tree779557f1734da19951e3d7d82167926bdaefd080 /kernel
parenta5a242dceed5d1c74fe46088762a9e4312c2d000 (diff)
stacktrace: add saved stack traces to backtrace self-test
This patch adds saved stack-traces to the backtrace suite of self-tests. Note that we don't depend on or unconditionally enable CONFIG_STACKTRACE because not all architectures may have it (and we still want to enable the other tests for those architectures). Cc: Arjan van de Ven <arjan@infradead.org> Signed-off-by: Vegard Nossum <vegard.nossum@gmail.com> Cc: Arjan van de Ven <arjan@infradead.org> Cc: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/backtracetest.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/kernel/backtracetest.c b/kernel/backtracetest.c
index d1a7605c5b8f..50f7abd0813d 100644
--- a/kernel/backtracetest.c
+++ b/kernel/backtracetest.c
@@ -10,9 +10,10 @@
10 * of the License. 10 * of the License.
11 */ 11 */
12 12
13#include <linux/delay.h>
13#include <linux/module.h> 14#include <linux/module.h>
14#include <linux/sched.h> 15#include <linux/sched.h>
15#include <linux/delay.h> 16#include <linux/stacktrace.h>
16 17
17static struct timer_list backtrace_timer; 18static struct timer_list backtrace_timer;
18 19
@@ -22,6 +23,31 @@ static void backtrace_test_timer(unsigned long data)
22 printk("The following trace is a kernel self test and not a bug!\n"); 23 printk("The following trace is a kernel self test and not a bug!\n");
23 dump_stack(); 24 dump_stack();
24} 25}
26
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
25static int backtrace_regression_test(void) 51static int backtrace_regression_test(void)
26{ 52{
27 printk("====[ backtrace testing ]===========\n"); 53 printk("====[ backtrace testing ]===========\n");
@@ -29,6 +55,8 @@ static int backtrace_regression_test(void)
29 printk("The following trace is a kernel self test and not a bug!\n"); 55 printk("The following trace is a kernel self test and not a bug!\n");
30 dump_stack(); 56 dump_stack();
31 57
58 backtrace_test_saved();
59
32 init_timer(&backtrace_timer); 60 init_timer(&backtrace_timer);
33 backtrace_timer.function = backtrace_test_timer; 61 backtrace_timer.function = backtrace_test_timer;
34 mod_timer(&backtrace_timer, jiffies + 10); 62 mod_timer(&backtrace_timer, jiffies + 10);