#!/bin/bash # perf_probe :: Add probes, list and remove them (exclusive) # SPDX-License-Identifier: GPL-2.0
# # test_adding_kernel of perf_probe test # Author: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> # Author: Michael Petlan <mpetlan@redhat.com> # # Description: # # This test tests adding of probes, their correct listing # and removing. #
# set NO_DEBUGINFO to skip testcase if debuginfo is not present # skip_if_no_debuginfo returns 2 if debuginfo is not present
skip_if_no_debuginfo if [ $? -eq 2 ]; then
NO_DEBUGINFO=1 fi
check_kprobes_available if [ $? -ne 0 ]; then
print_overall_skipped
exit 2 fi
### basic probe adding
for opt in """-a""--add"; do
clear_all_probes
$CMD_PERF probe $opt $TEST_PROBE 2> $LOGS_DIR/adding_kernel_add$opt.err
PERF_EXIT_CODE=$?
../common/check_all_patterns_found.pl "Added new events?:""probe:$TEST_PROBE""on $TEST_PROBE" < $LOGS_DIR/adding_kernel_add$opt.err
CHECK_EXIT_CODE=$?
# removed probes should NOT appear in perf-list output
$CMD_PERF list probe:\* > $LOGS_DIR/adding_kernel_list_removed.log
PERF_EXIT_CODE=$?
../common/check_all_lines_matched.pl "$RE_LINE_EMPTY""List of pre-defined events""Metric Groups:" < $LOGS_DIR/adding_kernel_list_removed.log
CHECK_EXIT_CODE=$?
print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "listing removed probe (should NOT be listed)"
(( TEST_RESULT += $? ))
### dry run
# the '-n' switch should run it in dry mode
$CMD_PERF probe -n --add $TEST_PROBE 2> $LOGS_DIR/adding_kernel_dryrun.err
PERF_EXIT_CODE=$?
# check for the output (should be the same as usual)
../common/check_all_patterns_found.pl "Added new events?:""probe:$TEST_PROBE""on $TEST_PROBE" < $LOGS_DIR/adding_kernel_dryrun.err
CHECK_EXIT_CODE=$?
# check that no probe was added in real
! ( $CMD_PERF probe -l | grep "probe:$TEST_PROBE" )
(( CHECK_EXIT_CODE += $? ))
# when using '--force' a probe should be added even if it is already there
$CMD_PERF probe --add $TEST_PROBE 2> $LOGS_DIR/adding_kernel_forceadd_01.err
PERF_EXIT_CODE=$?
../common/check_all_patterns_found.pl "Added new events?:""probe:$TEST_PROBE""on $TEST_PROBE" < $LOGS_DIR/adding_kernel_forceadd_01.err
CHECK_EXIT_CODE=$?
# since they are the same, they should produce the same results
$CMD_PERF stat -e probe:$TEST_PROBE -e probe:${TEST_PROBE}_${NO_OF_PROBES} -x';' -o $LOGS_DIR/adding_kernel_using_two.log -- bash -c 'cat /proc/cpuinfo > /dev/null'
PERF_EXIT_CODE=$?
if [ $NO_DEBUGINFO ] ; then
print_testcase_skipped $NO_DEBUGINFO $NO_DEBUGINFO "Skipped due to missing debuginfo" else
print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "wildcard adding support" fi
(( TEST_RESULT += $? ))
### non-existing variable
# perf probe should survive a non-existing variable probing attempt
{ $CMD_PERF probe 'vfs_read somenonexistingrandomstuffwhichisalsoprettylongorevenlongertoexceed64' ; } 2> $LOGS_DIR/adding_kernel_nonexisting.err
PERF_EXIT_CODE=$?
# the exitcode should not be 0 or segfault
test $PERF_EXIT_CODE -ne 139 -a $PERF_EXIT_CODE -ne 0
PERF_EXIT_CODE=$?
# check that the error message is reasonable
../common/check_all_patterns_found.pl "Failed to find""somenonexistingrandomstuffwhichisalsoprettylongorevenlongertoexceed64" < $LOGS_DIR/adding_kernel_nonexisting.err
CHECK_EXIT_CODE=$?
../common/check_all_patterns_found.pl "in this function|at this address""Error""Failed to add events" < $LOGS_DIR/adding_kernel_nonexisting.err
(( CHECK_EXIT_CODE += $? ))
../common/check_all_lines_matched.pl "Failed to find""Error""Probe point .+ not found""optimized out""Use.+\-\-range option to show.+location range" < $LOGS_DIR/adding_kernel_nonexisting.err
(( CHECK_EXIT_CODE += $? ))
../common/check_no_patterns_found.pl "$RE_SEGFAULT" < $LOGS_DIR/adding_kernel_nonexisting.err
(( CHECK_EXIT_CODE += $? ))
if [ $NO_DEBUGINFO ]; then
print_testcase_skipped $NO_DEBUGINFO $NO_DEBUGINFO "Skipped due to missing debuginfo" else
print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "non-existing variable" fi
(( TEST_RESULT += $? ))
### function with return value
# adding probe with return value
$CMD_PERF probe --add "$TEST_PROBE%return \$retval" 2> $LOGS_DIR/adding_kernel_func_retval_add.err
PERF_EXIT_CODE=$?
../common/check_all_patterns_found.pl "Added new events?:""probe:$TEST_PROBE""on $TEST_PROBE%return with \\\$retval" < $LOGS_DIR/adding_kernel_func_retval_add.err
CHECK_EXIT_CODE=$?
# perf script should report the function calls with the correct arg values
$CMD_PERF script -i $CURRENT_TEST_DIR/perf.data > $LOGS_DIR/adding_kernel_func_retval_script.log
PERF_EXIT_CODE=$?
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.