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 basic perf-probe options

Test basic behavior of perf-probe subcommand. It 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-7-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
adc1dd00 def5480d

+80
+80
tools/perf/tests/shell/base_probe/test_basic.sh
··· 1 + #!/bin/bash 2 + 3 + # SPDX-License-Identifier: GPL-2.0 4 + 5 + # 6 + # test_basic of perf_probe test 7 + # Author: Michael Petlan <mpetlan@redhat.com> 8 + # Author: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> 9 + # 10 + # Description: 11 + # 12 + # This test tests basic functionality of perf probe command. 13 + # 14 + 15 + # include working environment 16 + . ../common/init.sh 17 + 18 + TEST_RESULT=0 19 + 20 + if ! check_kprobes_available; then 21 + print_overall_skipped 22 + exit 0 23 + fi 24 + 25 + 26 + ### help message 27 + 28 + if [ "$PARAM_GENERAL_HELP_TEXT_CHECK" = "y" ]; then 29 + # test that a help message is shown and looks reasonable 30 + $CMD_PERF probe --help > $LOGS_DIR/basic_helpmsg.log 2> $LOGS_DIR/basic_helpmsg.err 31 + PERF_EXIT_CODE=$? 32 + 33 + ../common/check_all_patterns_found.pl "PERF-PROBE" "NAME" "SYNOPSIS" "DESCRIPTION" "OPTIONS" "PROBE\s+SYNTAX" "PROBE\s+ARGUMENT" "LINE\s+SYNTAX" < $LOGS_DIR/basic_helpmsg.log 34 + CHECK_EXIT_CODE=$? 35 + ../common/check_all_patterns_found.pl "LAZY\s+MATCHING" "FILTER\s+PATTERN" "EXAMPLES" "SEE\s+ALSO" < $LOGS_DIR/basic_helpmsg.log 36 + (( CHECK_EXIT_CODE += $? )) 37 + ../common/check_all_patterns_found.pl "vmlinux" "module=" "source=" "verbose" "quiet" "add=" "del=" "list.*EVENT" "line=" "vars=" "externs" < $LOGS_DIR/basic_helpmsg.log 38 + (( CHECK_EXIT_CODE += $? )) 39 + ../common/check_all_patterns_found.pl "no-inlines" "funcs.*FILTER" "filter=FILTER" "force" "dry-run" "max-probes" "exec=" "demangle-kernel" < $LOGS_DIR/basic_helpmsg.log 40 + (( CHECK_EXIT_CODE += $? )) 41 + ../common/check_no_patterns_found.pl "No manual entry for" < $LOGS_DIR/basic_helpmsg.err 42 + (( CHECK_EXIT_CODE += $? )) 43 + 44 + print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "help message" 45 + (( TEST_RESULT += $? )) 46 + else 47 + print_testcase_skipped "help message" 48 + fi 49 + 50 + 51 + ### usage message 52 + 53 + # without any args perf-probe should print usage 54 + $CMD_PERF probe 2> $LOGS_DIR/basic_usage.log > /dev/null 55 + 56 + ../common/check_all_patterns_found.pl "[Uu]sage" "perf probe" "verbose" "quiet" "add" "del" "force" "line" "vars" "externs" "range" < $LOGS_DIR/basic_usage.log 57 + CHECK_EXIT_CODE=$? 58 + 59 + print_results 0 $CHECK_EXIT_CODE "usage message" 60 + (( TEST_RESULT += $? )) 61 + 62 + 63 + ### quiet switch 64 + 65 + # '--quiet' should mute all output 66 + $CMD_PERF probe --quiet --add vfs_read > $LOGS_DIR/basic_quiet01.log 2> $LOGS_DIR/basic_quiet01.err 67 + PERF_EXIT_CODE=$? 68 + $CMD_PERF probe --quiet --del vfs_read > $LOGS_DIR/basic_quiet03.log 2> $LOGS_DIR/basic_quiet02.err 69 + (( PERF_EXIT_CODE += $? )) 70 + 71 + test "`cat $LOGS_DIR/basic_quiet*log $LOGS_DIR/basic_quiet*err | wc -l`" -eq 0 72 + CHECK_EXIT_CODE=$? 73 + 74 + print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "quiet switch" 75 + (( TEST_RESULT += $? )) 76 + 77 + 78 + # print overall results 79 + print_overall_results "$TEST_RESULT" 80 + exit $?