]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/blob - tools/testing/selftests/ftrace/test.d/ftrace/fgraph-filter-stack.tc
Merge branches 'acpi-fan', 'acpi-video' and 'acpi-ec'
[mirror_ubuntu-focal-kernel.git] / tools / testing / selftests / ftrace / test.d / ftrace / fgraph-filter-stack.tc
1 #!/bin/sh
2 # description: ftrace - function graph filters with stack tracer
3
4 # Make sure that function graph filtering works, and is not
5 # affected by other tracers enabled (like stack tracer)
6
7 if ! grep -q function_graph available_tracers; then
8 echo "no function graph tracer configured"
9 exit_unsupported
10 fi
11
12 if [ ! -f set_ftrace_filter ]; then
13 echo "set_ftrace_filter not found? Is dynamic ftrace not set?"
14 exit_unsupported
15 fi
16
17 do_reset() {
18 reset_tracer
19 echo 0 > /proc/sys/kernel/stack_tracer_enabled
20 enable_tracing
21 clear_trace
22 echo > set_ftrace_filter
23 }
24
25 fail() { # msg
26 do_reset
27 echo $1
28 exit -1
29 }
30
31 disable_tracing
32 clear_trace;
33
34 # filter something, schedule is always good
35 if ! echo "schedule" > set_ftrace_filter; then
36 # test for powerpc 64
37 if ! echo ".schedule" > set_ftrace_filter; then
38 fail "can not enable schedule filter"
39 fi
40 fi
41
42 echo function_graph > current_tracer
43
44 if [ ! -f stack_trace ]; then
45 echo "Stack tracer not configured"
46 do_reset
47 exit_unsupported;
48 fi
49
50 echo "Now testing with stack tracer"
51
52 echo 1 > /proc/sys/kernel/stack_tracer_enabled
53
54 disable_tracing
55 clear_trace
56 enable_tracing
57 sleep 1
58
59 count=`cat trace | grep '()' | grep -v schedule | wc -l`
60
61 if [ $count -ne 0 ]; then
62 fail "Graph filtering not working with stack tracer?"
63 fi
64
65 # Make sure we did find something
66 count=`cat trace | grep 'schedule()' | wc -l`
67 if [ $count -eq 0 ]; then
68 fail "No schedule traces found?"
69 fi
70
71 echo 0 > /proc/sys/kernel/stack_tracer_enabled
72 clear_trace
73 sleep 1
74
75
76 count=`cat trace | grep '()' | grep -v schedule | wc -l`
77
78 if [ $count -ne 0 ]; then
79 fail "Graph filtering not working after stack tracer disabled?"
80 fi
81
82 count=`cat trace | grep 'schedule()' | wc -l`
83 if [ $count -eq 0 ]; then
84 fail "No schedule traces found?"
85 fi
86
87 do_reset
88
89 exit 0