Files
linux/tools/perf/tests/shell/base_probe/test_line_semantics.sh
T
Veronika Molnarova c0964af816 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 <[email protected]>
Cc: Athira Rajeev <[email protected]>
Cc: Ian Rogers <[email protected]>
Cc: Masami Hiramatsu <[email protected]>
Cc: Namhyung Kim <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Michael Petlan <[email protected]>
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
2024-08-28 18:07:21 -03:00

56 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
#
# test_line_semantics of perf_probe test
# Author: Masami Hiramatsu <[email protected]>
# Author: Michael Petlan <[email protected]>
#
# 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 [email protected] [email protected]: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 $?