Debian Codegraph @

tools/perf/tests/shell/base_probe/test_line_semantics.sh

raw
1 #!/bin/bash
2 # perf_probe :: Check patterns for line semantics (exclusive)
3 # SPDX-License-Identifier: GPL-2.0
4
5 #
6 # test_line_semantics of perf_probe test
7 # Author: Masami Hiramatsu <[email protected]>
8 # Author: Michael Petlan <[email protected]>
9 #
10 # Description:
11 #
12 # This test checks whether the semantic errors of line option's
13 # arguments are properly reported.
14 #
15
16 DIR_PATH="$(dirname $0)"
17 TEST_RESULT=0
18
19 # include working environment
20 . "$DIR_PATH/../common/init.sh"
21
22 if ! check_kprobes_available; then
23 print_overall_skipped
24 exit 2
25 fi
26
27 # Check for presence of DWARF
28 $CMD_PERF check feature -q dwarf
29 [ $? -ne 0 ] && HINT_FAIL="Some of the tests need DWARF to run"
30
31 ### acceptable --line descriptions
32
33 # testing acceptance of valid patterns for the '--line' option
34 VALID_PATTERNS="func func:10 func:0-10 func:2+10 [email protected] [email protected]:1 source.c:1 source.c:1+1 source.c:1-10"
35 for desc in $VALID_PATTERNS; do
36 ! ( $CMD_PERF probe --line $desc 2>&1 | grep -q "Semantic error" )
37 CHECK_EXIT_CODE=$?
38
39 print_results 0 $CHECK_EXIT_CODE "acceptable descriptions :: $desc"
40 (( TEST_RESULT += $? ))
41 done
42
43
44 ### unacceptable --line descriptions
45
46 # testing handling of invalid patterns for the '--line' option
47 INVALID_PATTERNS="func:foo func:1-foo func:1+foo func;lazy\*pattern"
48 for desc in $INVALID_PATTERNS; do
49 $CMD_PERF probe --line $desc 2>&1 | grep -q "Semantic error"
50 CHECK_EXIT_CODE=$?
51
52 print_results 0 $CHECK_EXIT_CODE "unacceptable descriptions :: $desc"
53 (( TEST_RESULT += $? ))
54 done
55
56
57 # print overall results
58 print_overall_results "$TEST_RESULT" $HINT_FAIL
59 exit $?