56 lines · bash
1#!/bin/bash2 3# SPDX-License-Identifier: GPL-2.04 5#6# test_line_semantics of perf_probe test7# 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's13# arguments are properly reported.14#15 16# include working environment17. ../common/init.sh18 19TEST_RESULT=020 21if ! check_kprobes_available; then22 print_overall_skipped23 exit 024fi25 26 27### acceptable --line descriptions28 29# testing acceptance of valid patterns for the '--line' option30VALID_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; do32 ! ( $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 += $? ))37done38 39 40### unacceptable --line descriptions41 42# testing handling of invalid patterns for the '--line' option43INVALID_PATTERNS="func:foo func:1-foo func:1+foo func;lazy\*pattern"44for desc in $INVALID_PATTERNS; do45 $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 += $? ))50done51 52 53# print overall results54print_overall_results "$TEST_RESULT"55exit $?56