Skip to content

Commit 6009177

Browse files
Donglin Pengrostedt
authored andcommitted
selftests/ftrace: Add funcgraph-retval test case
Add a test case for the funcgraph-retval and funcgraph-retval-hex trace options. Link: https://lkml.kernel.org/r/9fedbd25e63f012cade5dad13be21225fec2fb5d.1680954589.git.pengdonglin@sangfor.com.cn Signed-off-by: Donglin Peng <[email protected]> Acked-by: Masami Hiramatsu (Google) <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent 5779e3c commit 6009177

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/sh
2+
# SPDX-License-Identifier: GPL-2.0
3+
# description: ftrace - function graph print function return value
4+
# requires: options/funcgraph-retval options/funcgraph-retval-hex function_graph:tracer
5+
6+
# Make sure that funcgraph-retval works
7+
8+
fail() { # msg
9+
echo $1
10+
exit_fail
11+
}
12+
13+
disable_tracing
14+
clear_trace
15+
16+
# get self PID, can not use $$, because it is PPID
17+
read PID _ < /proc/self/stat
18+
19+
[ -f set_ftrace_filter ] && echo proc_reg_write > set_ftrace_filter
20+
[ -f set_ftrace_pid ] && echo ${PID} > set_ftrace_pid
21+
echo function_graph > current_tracer
22+
echo 1 > options/funcgraph-retval
23+
24+
set +e
25+
enable_tracing
26+
echo > /proc/interrupts
27+
disable_tracing
28+
set -e
29+
30+
: "Test printing the error code in signed decimal format"
31+
echo 0 > options/funcgraph-retval-hex
32+
count=`cat trace | grep 'proc_reg_write' | grep '= -5' | wc -l`
33+
if [ $count -eq 0 ]; then
34+
fail "Return value can not be printed in signed decimal format"
35+
fi
36+
37+
: "Test printing the error code in hexadecimal format"
38+
echo 1 > options/funcgraph-retval-hex
39+
count=`cat trace | grep 'proc_reg_write' | grep 'fffffffb' | wc -l`
40+
if [ $count -eq 0 ]; then
41+
fail "Return value can not be printed in hexadecimal format"
42+
fi
43+
44+
exit 0

0 commit comments

Comments
 (0)