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