]>
Commit | Line | Data |
---|---|---|
6dab2778 AV |
1 | /* |
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 | ||
4e6a0535 | 13 | #include <linux/completion.h> |
ad118c54 | 14 | #include <linux/delay.h> |
4e6a0535 | 15 | #include <linux/interrupt.h> |
6dab2778 AV |
16 | #include <linux/module.h> |
17 | #include <linux/sched.h> | |
ad118c54 | 18 | #include <linux/stacktrace.h> |
6dab2778 | 19 | |
4e6a0535 VN |
20 | static void backtrace_test_normal(void) |
21 | { | |
462b29b8 FF |
22 | pr_info("Testing a backtrace from process context.\n"); |
23 | pr_info("The following trace is a kernel self test and not a bug!\n"); | |
4e6a0535 VN |
24 | |
25 | dump_stack(); | |
26 | } | |
27 | ||
28 | static DECLARE_COMPLETION(backtrace_work); | |
29 | ||
30 | static void backtrace_test_irq_callback(unsigned long data) | |
31 | { | |
32 | dump_stack(); | |
33 | complete(&backtrace_work); | |
34 | } | |
35 | ||
36 | static DECLARE_TASKLET(backtrace_tasklet, &backtrace_test_irq_callback, 0); | |
6dab2778 | 37 | |
4e6a0535 | 38 | static void backtrace_test_irq(void) |
6dab2778 | 39 | { |
462b29b8 FF |
40 | pr_info("Testing a backtrace from irq context.\n"); |
41 | pr_info("The following trace is a kernel self test and not a bug!\n"); | |
4e6a0535 VN |
42 | |
43 | init_completion(&backtrace_work); | |
44 | tasklet_schedule(&backtrace_tasklet); | |
45 | wait_for_completion(&backtrace_work); | |
6dab2778 | 46 | } |
ad118c54 VN |
47 | |
48 | #ifdef CONFIG_STACKTRACE | |
49 | static void backtrace_test_saved(void) | |
50 | { | |
ad118c54 | 51 | unsigned long entries[8]; |
1b59562d | 52 | unsigned int nr_entries; |
ad118c54 | 53 | |
462b29b8 FF |
54 | pr_info("Testing a saved backtrace.\n"); |
55 | pr_info("The following trace is a kernel self test and not a bug!\n"); | |
ad118c54 | 56 | |
1b59562d TG |
57 | nr_entries = stack_trace_save(entries, ARRAY_SIZE(entries), 0); |
58 | stack_trace_print(entries, nr_entries, 0); | |
ad118c54 VN |
59 | } |
60 | #else | |
61 | static void backtrace_test_saved(void) | |
62 | { | |
462b29b8 | 63 | pr_info("Saved backtrace test skipped.\n"); |
ad118c54 VN |
64 | } |
65 | #endif | |
66 | ||
6dab2778 AV |
67 | static int backtrace_regression_test(void) |
68 | { | |
462b29b8 | 69 | pr_info("====[ backtrace testing ]===========\n"); |
6dab2778 | 70 | |
4e6a0535 VN |
71 | backtrace_test_normal(); |
72 | backtrace_test_irq(); | |
ad118c54 VN |
73 | backtrace_test_saved(); |
74 | ||
462b29b8 | 75 | pr_info("====[ end of backtrace testing ]====\n"); |
6dab2778 AV |
76 | return 0; |
77 | } | |
78 | ||
79 | static void exitf(void) | |
80 | { | |
81 | } | |
82 | ||
83 | module_init(backtrace_regression_test); | |
84 | module_exit(exitf); | |
85 | MODULE_LICENSE("GPL"); | |
86 | MODULE_AUTHOR("Arjan van de Ven <arjan@linux.intel.com>"); |