Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
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 <masami.hiramatsu.pt@hitachi.com>
8# Author: Michael Petlan <mpetlan@redhat.com>
9#
10# Description:
11#
12# This test checks whether the semantic errors of line option's
13# arguments are properly reported.
14#
15
16DIR_PATH="$(dirname $0)"
17TEST_RESULT=0
18
19# include working environment
20. "$DIR_PATH/../common/init.sh"
21
22if ! check_kprobes_available; then
23 print_overall_skipped
24 exit 2
25fi
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
34VALID_PATTERNS="func func:10 func:0-10 func:2+10 func@source.c func@source.c:1 source.c:1 source.c:1+1 source.c:1-10"
35for 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 += $? ))
41done
42
43
44### unacceptable --line descriptions
45
46# testing handling of invalid patterns for the '--line' option
47INVALID_PATTERNS="func:foo func:1-foo func:1+foo func;lazy\*pattern"
48for 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 += $? ))
54done
55
56
57# print overall results
58print_overall_results "$TEST_RESULT" $HINT_FAIL
59exit $?