tools/perf/tests/shell/base_probe/test_adding_kernel.sh

Source file repositories/reference/linux-study-clean/tools/perf/tests/shell/base_probe/test_adding_kernel.sh

File Facts

System
Linux kernel
Corpus path
tools/perf/tests/shell/base_probe/test_adding_kernel.sh
Extension
.sh
Size
11466 bytes
Lines
347
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: tools
Status
atlas-only

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

"probe:vfs_link" "probe:vfs_write" < $LOGS_DIR/adding_kernel_adding_wildcard.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 "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
"$DIR_PATH/../common/check_all_patterns_found.pl" \
	"Failed to find" \
	"somenonexistingrandomstuffwhichisalsoprettylongorevenlongertoexceed64" \
	< $LOGS_DIR/adding_kernel_nonexisting.err
CHECK_EXIT_CODE=$?
"$DIR_PATH/../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 += $? ))
"$DIR_PATH/../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 += $? ))
"$DIR_PATH/../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=$?

"$DIR_PATH/../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=$?

print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "function with retval :: add"
(( TEST_RESULT += $? ))

# recording some data
$CMD_PERF record -e probe:$TEST_PROBE\* -o $CURRENT_TEST_DIR/perf.data -- cat /proc/cpuinfo > /dev/null 2> $LOGS_DIR/adding_kernel_func_retval_record.err
PERF_EXIT_CODE=$?

"$DIR_PATH/../common/check_all_patterns_found.pl" \

Annotation

Implementation Notes