diff options
author | Frederic Weisbecker <fweisbec@gmail.com> | 2009-02-07 15:33:57 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-02-09 04:51:37 -0500 |
commit | 7447dce96f2233d250bc39a4a10a42f7c3dd46fc (patch) | |
tree | c02c991cca658e69a0c83c1a93b068df1d5caa53 | |
parent | 2db270a80b8f2238e536876cfb3987af02684df8 (diff) |
tracing/function-graph-tracer: provide a selftest for the function graph tracer
Making it more easy to do a basic regression test for this tracer.
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r-- | kernel/trace/trace.h | 2 | ||||
-rw-r--r-- | kernel/trace/trace_functions_graph.c | 3 | ||||
-rw-r--r-- | kernel/trace/trace_selftest.c | 50 |
3 files changed, 55 insertions, 0 deletions
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index b9838f4a6929..a011ec062225 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h | |||
@@ -500,6 +500,8 @@ extern int DYN_FTRACE_TEST_NAME(void); | |||
500 | #ifdef CONFIG_FTRACE_STARTUP_TEST | 500 | #ifdef CONFIG_FTRACE_STARTUP_TEST |
501 | extern int trace_selftest_startup_function(struct tracer *trace, | 501 | extern int trace_selftest_startup_function(struct tracer *trace, |
502 | struct trace_array *tr); | 502 | struct trace_array *tr); |
503 | extern int trace_selftest_startup_function_graph(struct tracer *trace, | ||
504 | struct trace_array *tr); | ||
503 | extern int trace_selftest_startup_irqsoff(struct tracer *trace, | 505 | extern int trace_selftest_startup_irqsoff(struct tracer *trace, |
504 | struct trace_array *tr); | 506 | struct trace_array *tr); |
505 | extern int trace_selftest_startup_preemptoff(struct tracer *trace, | 507 | extern int trace_selftest_startup_preemptoff(struct tracer *trace, |
diff --git a/kernel/trace/trace_functions_graph.c b/kernel/trace/trace_functions_graph.c index 222f97d336a6..88f8d9d80a93 100644 --- a/kernel/trace/trace_functions_graph.c +++ b/kernel/trace/trace_functions_graph.c | |||
@@ -750,6 +750,9 @@ static struct tracer graph_trace __read_mostly = { | |||
750 | .print_line = print_graph_function, | 750 | .print_line = print_graph_function, |
751 | .print_header = print_graph_headers, | 751 | .print_header = print_graph_headers, |
752 | .flags = &tracer_flags, | 752 | .flags = &tracer_flags, |
753 | #ifdef CONFIG_FTRACE_SELFTEST | ||
754 | .selftest = trace_selftest_startup_function_graph, | ||
755 | #endif | ||
753 | }; | 756 | }; |
754 | 757 | ||
755 | static __init int init_graph_trace(void) | 758 | static __init int init_graph_trace(void) |
diff --git a/kernel/trace/trace_selftest.c b/kernel/trace/trace_selftest.c index 445700e51f6d..0c9aa1457e51 100644 --- a/kernel/trace/trace_selftest.c +++ b/kernel/trace/trace_selftest.c | |||
@@ -13,6 +13,8 @@ static inline int trace_valid_entry(struct trace_entry *entry) | |||
13 | case TRACE_PRINT: | 13 | case TRACE_PRINT: |
14 | case TRACE_SPECIAL: | 14 | case TRACE_SPECIAL: |
15 | case TRACE_BRANCH: | 15 | case TRACE_BRANCH: |
16 | case TRACE_GRAPH_ENT: | ||
17 | case TRACE_GRAPH_RET: | ||
16 | return 1; | 18 | return 1; |
17 | } | 19 | } |
18 | return 0; | 20 | return 0; |
@@ -227,6 +229,54 @@ trace_selftest_startup_function(struct tracer *trace, struct trace_array *tr) | |||
227 | } | 229 | } |
228 | #endif /* CONFIG_FUNCTION_TRACER */ | 230 | #endif /* CONFIG_FUNCTION_TRACER */ |
229 | 231 | ||
232 | |||
233 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER | ||
234 | /* | ||
235 | * Pretty much the same than for the function tracer from which the selftest | ||
236 | * has been borrowed. | ||
237 | */ | ||
238 | int | ||
239 | trace_selftest_startup_function_graph(struct tracer *trace, | ||
240 | struct trace_array *tr) | ||
241 | { | ||
242 | int ret; | ||
243 | unsigned long count; | ||
244 | |||
245 | ret = tracer_init(trace, tr); | ||
246 | if (ret) { | ||
247 | warn_failed_init_tracer(trace, ret); | ||
248 | goto out; | ||
249 | } | ||
250 | |||
251 | /* Sleep for a 1/10 of a second */ | ||
252 | msleep(100); | ||
253 | |||
254 | tracing_stop(); | ||
255 | |||
256 | /* check the trace buffer */ | ||
257 | ret = trace_test_buffer(tr, &count); | ||
258 | |||
259 | trace->reset(tr); | ||
260 | tracing_start(); | ||
261 | |||
262 | if (!ret && !count) { | ||
263 | printk(KERN_CONT ".. no entries found .."); | ||
264 | ret = -1; | ||
265 | goto out; | ||
266 | } | ||
267 | |||
268 | /* Don't test dynamic tracing, the function tracer already did */ | ||
269 | |||
270 | out: | ||
271 | /* Stop it if we failed */ | ||
272 | if (ret) | ||
273 | ftrace_graph_stop(); | ||
274 | |||
275 | return ret; | ||
276 | } | ||
277 | #endif /* CONFIG_FUNCTION_GRAPH_TRACER */ | ||
278 | |||
279 | |||
230 | #ifdef CONFIG_IRQSOFF_TRACER | 280 | #ifdef CONFIG_IRQSOFF_TRACER |
231 | int | 281 | int |
232 | trace_selftest_startup_irqsoff(struct tracer *trace, struct trace_array *tr) | 282 | trace_selftest_startup_irqsoff(struct tracer *trace, struct trace_array *tr) |