1#!/bin/bash 2 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 16# include working environment 17. ../common/init.sh 18 19TEST_RESULT=0 20 21if ! check_kprobes_available; then 22 print_overall_skipped 23 exit 0 24fi 25 26 27### acceptable --line descriptions 28 29# testing acceptance of valid patterns for the '--line' option 30VALID_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" 31for desc in $VALID_PATTERNS; do 32 ! ( $CMD_PERF probe --line $desc 2>&1 | grep -q "Semantic error" ) 33 CHECK_EXIT_CODE=$? 34 35 print_results 0 $CHECK_EXIT_CODE "acceptable descriptions :: $desc" 36 (( TEST_RESULT += $? )) 37done 38 39 40### unacceptable --line descriptions 41 42# testing handling of invalid patterns for the '--line' option 43INVALID_PATTERNS="func:foo func:1-foo func:1+foo func;lazy\*pattern" 44for desc in $INVALID_PATTERNS; do 45 $CMD_PERF probe --line $desc 2>&1 | grep -q "Semantic error" 46 CHECK_EXIT_CODE=$? 47 48 print_results 0 $CHECK_EXIT_CODE "unacceptable descriptions :: $desc" 49 (( TEST_RESULT += $? )) 50done 51 52 53# print overall results 54print_overall_results "$TEST_RESULT" 55exit $? 56