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
7if ! grep -q function_graph available_tracers; then
8    echo "no function graph tracer configured"
9    exit_unsupported
10fi
11
12fail() { # msg
13    echo $1
14    exit_fail
15}
16
17disable_tracing
18clear_trace
19
20# filter something, schedule is always good
21if ! echo "schedule" > set_ftrace_filter; then
22    # test for powerpc 64
23    if ! echo ".schedule" > set_ftrace_filter; then
24	fail "can not enable schedule filter"
25    fi
26fi
27
28echo function_graph > current_tracer
29enable_tracing
30sleep 1
31# search for functions (has "()" on the line), and make sure
32# that only the schedule function was found
33count=`cat trace | grep '()' | grep -v schedule | wc -l`
34if [ $count -ne 0 ]; then
35    fail "Graph filtering not working by itself?"
36fi
37
38# Make sure we did find something
39count=`cat trace | grep 'schedule()' | wc -l`
40if [ $count -eq 0 ]; then
41    fail "No schedule traces found?"
42fi
43
44exit 0
45