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
8fail() { # msg
9    echo $1
10    exit_fail
11}
12
13disable_tracing
14clear_trace
15
16# get self PID, can not use $$, because it is PPID
17read 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
21echo function_graph > current_tracer
22echo 1 > options/funcgraph-retval
23
24set +e
25enable_tracing
26echo > /proc/interrupts
27disable_tracing
28set -e
29
30: "Test printing the error code in signed decimal format"
31echo 0 > options/funcgraph-retval-hex
32count=`cat trace | grep 'proc_reg_write' | grep '= -5' | wc -l`
33if [ $count -eq 0 ]; then
34    fail "Return value can not be printed in signed decimal format"
35fi
36
37: "Test printing the error code in hexadecimal format"
38echo 1 > options/funcgraph-retval-hex
39count=`cat trace | grep 'proc_reg_write' | grep 'fffffffb' | wc -l`
40if [ $count -eq 0 ]; then
41    fail "Return value can not be printed in hexadecimal format"
42fi
43
44exit 0
45