1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
3# description: ftrace - function graph filters
4# requires: set_ftrace_filter function_graph:tracer
5
6# Make sure that function graph filtering works
7
8fail() { # msg
9    echo $1
10    exit_fail
11}
12
13disable_tracing
14clear_trace
15
16# filter something, schedule is always good
17if ! echo "schedule" > set_ftrace_filter; then
18    # test for powerpc 64
19    if ! echo ".schedule" > set_ftrace_filter; then
20	fail "can not enable schedule filter"
21    fi
22fi
23
24echo function_graph > current_tracer
25enable_tracing
26sleep 1
27# search for functions (has "()" on the line), and make sure
28# that only the schedule function was found
29count=`cat trace | grep '()' | grep -v schedule | wc -l`
30if [ $count -ne 0 ]; then
31    fail "Graph filtering not working by itself?"
32fi
33
34# Make sure we did find something
35count=`cat trace | grep 'schedule()' | wc -l` 
36if [ $count -eq 0 ]; then
37    fail "No schedule traces found?"
38fi
39
40exit 0
41