]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/blame - tools/testing/selftests/ftrace/test.d/ftrace/func_profiler.tc
Linux 4.14-rc6
[mirror_ubuntu-focal-kernel.git] / tools / testing / selftests / ftrace / test.d / ftrace / func_profiler.tc
CommitLineData
c6c93242
SRRH
1#!/bin/sh
2# description: ftrace - function profiler with function tracing
3
4# There was a bug after a rewrite of the ftrace infrastructure that
5# caused the function_profiler not to be able to run with the function
6# tracer, because the function_profiler used the function_graph tracer
7# and it was assumed the two could not run simultaneously.
8#
9# There was another related bug where the solution to the first bug
10# broke the way filtering of the function tracer worked.
11#
12# This test triggers those bugs on those kernels.
13#
14# We need function_graph and profiling to to run this test
15if ! grep -q function_graph available_tracers; then
16 echo "no function graph tracer configured"
17 exit_unsupported;
18fi
19
20if [ ! -f set_ftrace_filter ]; then
21 echo "set_ftrace_filter not found? Is dynamic ftrace not set?"
22 exit_unsupported
23fi
24
25if [ ! -f function_profile_enabled ]; then
26 echo "function_profile_enabled not found, function profiling enabled?"
27 exit_unsupported
28fi
29
30fail() { # mesg
31 reset_tracer
32 echo > set_ftrace_filter
33 echo $1
44164c4b 34 exit $FAIL
c6c93242
SRRH
35}
36
37echo "Testing function tracer with profiler:"
38echo "enable function tracer"
39echo function > current_tracer
40echo "enable profiler"
41echo 1 > function_profile_enabled
42
43sleep 1
44
45echo "Now filter on just schedule"
46echo '*schedule' > set_ftrace_filter
47clear_trace
48
49echo "Now disable function profiler"
50echo 0 > function_profile_enabled
51
52sleep 1
53
54# make sure only schedule functions exist
55
56echo "testing if only schedule is being traced"
57if grep -v -e '^#' -e 'schedule' trace; then
58 fail "more than schedule was found"
59fi
60
61echo "Make sure schedule was traced"
62if ! grep -e 'schedule' trace > /dev/null; then
63 cat trace
64 fail "can not find schedule in trace"
65fi
66
67echo > set_ftrace_filter
68clear_trace
69
70sleep 1
71
72echo "make sure something other than scheduler is being traced"
73if ! grep -v -e '^#' -e 'schedule' trace > /dev/null; then
74 cat trace
75 fail "no other functions besides schedule was found"
76fi
77
78reset_tracer
79
80exit 0