Linux-libre 4.14.68-gnu
[librecmc/linux-libre.git] / tools / testing / selftests / ftrace / test.d / ftrace / fgraph-filter.tc
1 #!/bin/sh
2 # SPDX-License-Identifier: GPL-2.0
3 # description: ftrace - function graph filters
4
5 # Make sure that function graph filtering works
6
7 if ! grep -q function_graph available_tracers; then
8     echo "no function graph tracer configured"
9     exit_unsupported
10 fi
11
12 do_reset() {
13     reset_tracer
14     enable_tracing
15     clear_trace
16 }
17
18 fail() { # msg
19     do_reset
20     echo $1
21     exit $FAIL
22 }
23
24 disable_tracing
25 clear_trace
26
27 # filter something, schedule is always good
28 if ! echo "schedule" > set_ftrace_filter; then
29     # test for powerpc 64
30     if ! echo ".schedule" > set_ftrace_filter; then
31         fail "can not enable schedule filter"
32     fi
33 fi
34
35 echo function_graph > current_tracer
36 enable_tracing
37 sleep 1
38 # search for functions (has "()" on the line), and make sure
39 # that only the schedule function was found
40 count=`cat trace | grep '()' | grep -v schedule | wc -l`
41 if [ $count -ne 0 ]; then
42     fail "Graph filtering not working by itself?"
43 fi
44
45 # Make sure we did find something
46 count=`cat trace | grep 'schedule()' | wc -l` 
47 if [ $count -eq 0 ]; then
48     fail "No schedule traces found?"
49 fi
50
51 do_reset
52
53 exit 0