License cleanup: add SPDX GPL-2.0 license identifier to files with no license
[linux-2.6-block.git] / tools / testing / selftests / ftrace / test.d / ftrace / func-filter-glob.tc
CommitLineData
60c1afbf 1#!/bin/sh
b2441318 2# SPDX-License-Identifier: GPL-2.0
60c1afbf
MH
3# description: ftrace - function glob filters
4
5# Make sure that function glob matching filter works.
6
7if ! grep -q function available_tracers; then
8 echo "no function tracer configured"
9 exit_unsupported
10fi
11
12disable_tracing
13clear_trace
14
60c1afbf
MH
15ftrace_filter_check() { # glob grep
16 echo "$1" > set_ftrace_filter
17 cut -f1 -d" " set_ftrace_filter > $TMPDIR/actual
18 cut -f1 -d" " available_filter_functions | grep "$2" > $TMPDIR/expected
19 DIFF=`diff $TMPDIR/actual $TMPDIR/expected`
20 test -z "$DIFF"
21}
22
23# filter by *, front match
24ftrace_filter_check '*schedule' '^.*schedule$'
25
26# filter by *, middle match
27ftrace_filter_check '*schedule*' '^.*schedule.*$'
28
29# filter by *, end match
30ftrace_filter_check 'schedule*' '^schedule.*$'
31
27af344b
MH
32# Advanced full-glob matching feature is recently supported.
33# Skip the tests if we are sure the kernel does not support it.
34if grep -q 'accepts: .* glob-matching-pattern' README ; then
35
60c1afbf
MH
36# filter by *, both side match
37ftrace_filter_check 'sch*ule' '^sch.*ule$'
38
39# filter by char class.
40ftrace_filter_check '[Ss]y[Ss]_*' '^[Ss]y[Ss]_.*$'
41
27af344b
MH
42# filter by ?, schedule is always good
43if ! echo "sch?dule" > set_ftrace_filter; then
44 # test for powerpc 64
45 if ! echo ".sch?dule" > set_ftrace_filter; then
46 fail "can not enable schedule filter"
47 fi
48 cat set_ftrace_filter | grep '^.schedule$'
49else
50 cat set_ftrace_filter | grep '^schedule$'
51fi
52
53fi
54
60c1afbf
MH
55echo > set_ftrace_filter
56enable_tracing