Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf testsuite probe: Add test for line semantics

The perf-probe command uses a specific semantics to describe probes.
Test some patterns that are known to be both valid and invalid if
they are handled appropriately.

This test is run as a part of perftool-testsuite_probe test case.

Signed-off-by: Veronika Molnarova <vmolnaro@redhat.com>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20240702110849.31904-9-vmolnaro@redhat.com
Signed-off-by: Michael Petlan <mpetlan@redhat.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Veronika Molnarova and committed by
Arnaldo Carvalho de Melo
c0964af8 83b6815d

+55
+55
tools/perf/tests/shell/base_probe/test_line_semantics.sh
··· 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 + 19 + TEST_RESULT=0 20 + 21 + if ! check_kprobes_available; then 22 + print_overall_skipped 23 + exit 0 24 + fi 25 + 26 + 27 + ### acceptable --line descriptions 28 + 29 + # testing acceptance of valid patterns for the '--line' option 30 + 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" 31 + for 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 += $? )) 37 + done 38 + 39 + 40 + ### unacceptable --line descriptions 41 + 42 + # testing handling of invalid patterns for the '--line' option 43 + INVALID_PATTERNS="func:foo func:1-foo func:1+foo func;lazy\*pattern" 44 + for 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 += $? )) 50 + done 51 + 52 + 53 + # print overall results 54 + print_overall_results "$TEST_RESULT" 55 + exit $?