|
| 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 | + |
| 8 | +INSTANCE1="instances/test1_$$" |
| 9 | +INSTANCE2="instances/test2_$$" |
| 10 | +INSTANCE3="instances/test3_$$" |
| 11 | + |
| 12 | +WD=`pwd` |
| 13 | + |
| 14 | +do_reset() { |
| 15 | + cd $WD |
| 16 | + if [ -d $INSTANCE1 ]; then |
| 17 | + echo nop > $INSTANCE1/current_tracer |
| 18 | + rmdir $INSTANCE1 |
| 19 | + fi |
| 20 | + if [ -d $INSTANCE2 ]; then |
| 21 | + echo nop > $INSTANCE2/current_tracer |
| 22 | + rmdir $INSTANCE2 |
| 23 | + fi |
| 24 | + if [ -d $INSTANCE3 ]; then |
| 25 | + echo nop > $INSTANCE3/current_tracer |
| 26 | + rmdir $INSTANCE3 |
| 27 | + fi |
| 28 | +} |
| 29 | + |
| 30 | +mkdir $INSTANCE1 |
| 31 | +if ! grep -q function_graph $INSTANCE1/available_tracers; then |
| 32 | + echo "function_graph not allowed with instances" |
| 33 | + rmdir $INSTANCE1 |
| 34 | + exit_unsupported |
| 35 | +fi |
| 36 | + |
| 37 | +mkdir $INSTANCE2 |
| 38 | +mkdir $INSTANCE3 |
| 39 | + |
| 40 | +fail() { # msg |
| 41 | + do_reset |
| 42 | + echo $1 |
| 43 | + exit_fail |
| 44 | +} |
| 45 | + |
| 46 | +disable_tracing |
| 47 | +clear_trace |
| 48 | + |
| 49 | +do_test() { |
| 50 | + REGEX=$1 |
| 51 | + TEST=$2 |
| 52 | + |
| 53 | + # filter something, schedule is always good |
| 54 | + if ! echo "$REGEX" > set_ftrace_filter; then |
| 55 | + fail "can not enable filter $REGEX" |
| 56 | + fi |
| 57 | + |
| 58 | + echo > trace |
| 59 | + echo function_graph > current_tracer |
| 60 | + enable_tracing |
| 61 | + sleep 1 |
| 62 | + # search for functions (has "{" or ";" on the line) |
| 63 | + echo 0 > tracing_on |
| 64 | + count=`cat trace | grep -v '^#' | grep -e '{' -e ';' | grep -v "$TEST" | wc -l` |
| 65 | + echo 1 > tracing_on |
| 66 | + if [ $count -ne 0 ]; then |
| 67 | + fail "Graph filtering not working by itself against $TEST?" |
| 68 | + fi |
| 69 | + |
| 70 | + # Make sure we did find something |
| 71 | + echo 0 > tracing_on |
| 72 | + count=`cat trace | grep -v '^#' | grep -e '{' -e ';' | grep "$TEST" | wc -l` |
| 73 | + echo 1 > tracing_on |
| 74 | + if [ $count -eq 0 ]; then |
| 75 | + fail "No traces found with $TEST?" |
| 76 | + fi |
| 77 | +} |
| 78 | + |
| 79 | +do_test '*sched*' 'sched' |
| 80 | +cd $INSTANCE1 |
| 81 | +do_test '*lock*' 'lock' |
| 82 | +cd $WD |
| 83 | +cd $INSTANCE2 |
| 84 | +do_test '*rcu*' 'rcu' |
| 85 | +cd $WD |
| 86 | +cd $INSTANCE3 |
| 87 | +echo function_graph > current_tracer |
| 88 | + |
| 89 | +sleep 1 |
| 90 | +count=`cat trace | grep -v '^#' | grep -e '{' -e ';' | grep "$TEST" | wc -l` |
| 91 | +if [ $count -eq 0 ]; then |
| 92 | + fail "No traces found with all tracing?" |
| 93 | +fi |
| 94 | + |
| 95 | +cd $WD |
| 96 | +echo nop > current_tracer |
| 97 | +echo nop > $INSTANCE1/current_tracer |
| 98 | +echo nop > $INSTANCE2/current_tracer |
| 99 | +echo nop > $INSTANCE3/current_tracer |
| 100 | + |
| 101 | +do_reset |
| 102 | + |
| 103 | +exit 0 |
0 commit comments