tools/testing/selftests/ftrace/test.d/ftrace/func_traceonoff_triggers.tc

Source file repositories/reference/linux-study-clean/tools/testing/selftests/ftrace/test.d/ftrace/func_traceonoff_triggers.tc

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/ftrace/test.d/ftrace/func_traceonoff_triggers.tc
Extension
.tc
Size
3564 bytes
Lines
174
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

#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# description: ftrace - test for function traceon/off triggers
# flags: instance
#
# The triggers are set within the set_ftrace_filter file
# requires: set_ftrace_filter
#
# Ftrace allows to add triggers to functions, such as enabling or disabling
# tracing, enabling or disabling trace events, or recording a stack trace
# within the ring buffer.
#
# This test is designed to test enabling and disabling tracing triggers
#

fail() { # mesg
    echo $1
    exit_fail
}

SLEEP_TIME=".1"

echo "Testing function probes with enabling disabling tracing:"

cnt_trace() {
    grep -v '^#' trace | wc -l
}

echo '** DISABLE TRACING'
disable_tracing
clear_trace

cnt=`cnt_trace`
if [ $cnt -ne 0 ]; then
    fail "Found junk in trace"
fi


echo '** ENABLE EVENTS'

echo 1 > events/sched/enable

echo '** ENABLE TRACING'
enable_tracing

cnt=`cnt_trace`
if [ $cnt -eq 0 ]; then
   fail "Nothing found in trace"
fi

# powerpc uses .schedule
func="schedule"
available_file=available_filter_functions
if [ -d ../../instances -a -f ../../available_filter_functions ]; then
   available_file=../../available_filter_functions
fi
x=`grep '^\.schedule$' available_filter_functions | wc -l`
if [ "$x" -eq 1 ]; then
   func=".schedule"
fi

echo '** SET TRACEOFF'

echo "$func:traceoff" > set_ftrace_filter
if [ -d ../../instances ]; then # Check instances
    cur=`cat set_ftrace_filter`
    top=`cat ../../set_ftrace_filter`
    if [ "$cur" = "$top" ]; then
	echo "This kernel is too old to support per instance filter"
	reset_ftrace_filter

Annotation

Implementation Notes