aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tools/testing/selftests/ftrace/test.d/ftrace/fgraph-retval.tc
blob: e34c0bdef3ed3d4d69a17cf5337ae2836ab25cd9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# description: ftrace - function graph print function return value
# requires: options/funcgraph-retval options/funcgraph-retval-hex function_graph:tracer

# Make sure that funcgraph-retval works

fail() { # msg
    echo $1
    exit_fail
}

disable_tracing
clear_trace

# get self PID, can not use $$, because it is PPID
read PID _ < /proc/self/stat

[ -f set_ftrace_filter ] && echo proc_reg_write > set_ftrace_filter
[ -f set_ftrace_pid ] && echo ${PID} > set_ftrace_pid
echo function_graph > current_tracer
echo 1 > options/funcgraph-retval

set +e
enable_tracing
echo > /proc/interrupts
disable_tracing
set -e

: "Test printing the error code in signed decimal format"
echo 0 > options/funcgraph-retval-hex
count=`cat trace | grep 'proc_reg_write' | grep '= -5' | wc -l`
if [ $count -eq 0 ]; then
    fail "Return value can not be printed in signed decimal format"
fi

: "Test printing the error code in hexadecimal format"
echo 1 > options/funcgraph-retval-hex
count=`cat trace | grep 'proc_reg_write' | grep 'fffffffb' | wc -l`
if [ $count -eq 0 ]; then
    fail "Return value can not be printed in hexadecimal format"
fi

exit 0