summaryrefslogtreecommitdiff
path: root/tools/perf/tests/shell/base_probe/test_line_semantics.sh
blob: d8f4bde0f585ac80b7314af64d7c12dc4d49a79a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash

# SPDX-License-Identifier: GPL-2.0

#
#	test_line_semantics of perf_probe test
#	Author: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
#	Author: Michael Petlan <mpetlan@redhat.com>
#
#	Description:
#
#		This test checks whether the semantic errors of line option's
#		arguments are properly reported.
#

# include working environment
. ../common/init.sh

TEST_RESULT=0

if ! check_kprobes_available; then
	print_overall_skipped
	exit 0
fi


### acceptable --line descriptions

# testing acceptance of valid patterns for the '--line' option
VALID_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"
for desc in $VALID_PATTERNS; do
	! ( $CMD_PERF probe --line $desc 2>&1 | grep -q "Semantic error" )
	CHECK_EXIT_CODE=$?

	print_results 0 $CHECK_EXIT_CODE "acceptable descriptions :: $desc"
	(( TEST_RESULT += $? ))
done


### unacceptable --line descriptions

# testing handling of invalid patterns for the '--line' option
INVALID_PATTERNS="func:foo func:1-foo func:1+foo func;lazy\*pattern"
for desc in $INVALID_PATTERNS; do
	$CMD_PERF probe --line $desc 2>&1 | grep -q "Semantic error"
	CHECK_EXIT_CODE=$?

	print_results 0 $CHECK_EXIT_CODE "unacceptable descriptions :: $desc"
	(( TEST_RESULT += $? ))
done


# print overall results
print_overall_results "$TEST_RESULT"
exit $?