From: Steven Rostedt <rostedt@goodmis.org>
To: Tom Zanussi <tom.zanussi@linux.intel.com>
Cc: masami.hiramatsu.pt@hitachi.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 0/2] tracing/triggers: A couple minor variable name changes
Date: Tue, 7 Jan 2014 12:56:55 -0500 [thread overview]
Message-ID: <20140107125655.20cd27d6@gandalf.local.home> (raw)
In-Reply-To: <1389115745.3040.104.camel@empanada>
[-- Attachment #1: Type: text/plain, Size: 1710 bytes --]
On Tue, 07 Jan 2014 11:29:05 -0600
Tom Zanussi <tom.zanussi@linux.intel.com> wrote:
> Just so you know what encompasses my 'normal testing', below is what I
> normally run through - if everything checks out, I'm satisfied things
> are basically good, though of course it didn't catch your traceoff bug
> so it's not complete.
>
> As soon as I get the chance, I'll automate it and add more tests for
> completeness - as it is it's grown into something that already takes too
> long to do manually, so I need to find the time....
>
> ---- basic high-level check
> - quick enable/disable_event, capture limited number of events
> - both counted and not
> - verify flags
> - verify removal
>
Thanks, I may look at these in the future to update my tests. I've
attached some trigger tests that I just wrote up.
ftrace-event-traceon-off : tests the traceon and traceoff triggers.
- enables tracing, sets traceoff trigger, checks if it disables
- disables tracing, sets traceon trigger, checks if it enables
- does a countdown from 3 to make sure the tracing is disabled
3 times.
ftrace-event-stacktrace : tests the event stack trace. It
- checks enabling of events (non trigger)
- checks enabling only the stack trace
- checks enabling both the stack trace and events
- checks if the count works from 1 2 or 3 times
ftrace-event-trigger-event : tests enable/disable_event trigger
- checks if the event enables another event (several times)
- checks if the event disables another event (several times)
- checks if it enables an event count times "1 2 3"
- then it tests the filter part of the event trigger (enable only)
Feel free to add onto these.
-- Steve
[-- Attachment #2: ftrace-test-event-stacktrace --]
[-- Type: application/octet-stream, Size: 3202 bytes --]
#!/bin/bash
find_debugfs() {
debugfs=`cat /proc/mounts | while read mount dir type opts a b; do
if [ $mount == "debugfs" ]; then
echo $dir;
break
fi
done`
if [ -z "$debugfs" ]; then
if ! mount -t debugfs nodev /sys/kernel/debug; then
echo "FAILED to mount debugfs"
exit -1
fi
echo "/sys/kernel/debug"
else
echo $debugfs
fi
}
debugfs=`find_debugfs`
TRACEDIR="$debugfs/tracing"
EVENTDIR=$TRACEDIR/events
EVENT=$EVENTDIR/sched/sched_switch
EVENT_ENABLE=$EVENT/enable
TRIGGER_FILE=$EVENT/trigger
TRACE_FILE=$TRACEDIR/trace
TRACING_ON=$TRACEDIR/tracing_on
if [ ! -f $TRIGGER_FILE ]; then
echo "triggers are not set for this kernel"
exit 0
fi
function cnt_trace() {
grep -v '^#' $TRACE_FILE | wc -l
}
function clear_triggers() {
grep -v '^#' $TRIGGER_FILE | while read t; do
tr=`echo $t | sed -e s'/:.*//'`
if [ $tr == "enable_event" -o $tr == "disable_event" ]; then
tr=`echo $t | sed -e s'/\([^:]*:[^:]*:[^:]*\):.*/\1/'`
fi
echo "!$tr" > $TRIGGER_FILE
done
}
function check_events() {
events=$1
stack=$2
count=$3
if [ $events -eq 1 ]; then
if ! grep -q 'sched_switch:' $TRACE_FILE ; then
echo "Expected event but it wasn't there"
exit -1
fi
else
if grep -q 'sched_switch:' $TRACE_FILE ; then
echo "Expected no events but events were found"
exit -1
fi
fi
if [ $stack -eq 1 ]; then
if [ $count -eq 0 ]; then
# unlimited, find the sleep call
if ! grep -q '^ => .*sleep' $TRACE_FILE; then
echo "Could not find sleep call"
exit -1
fi
else
# count the stack traces
cnt=`grep '<stack trace>' $TRACE_FILE | wc -l`;
if [ $cnt -ne $count ]; then
echo "Expected $count hits but only see $cnt"
exit -1
fi
fi
else
if grep -q '^ =>' $TRACE_FILE; then
echo "Found stack trace when not enabled"
exit -1
fi
fi
}
function do_reset() {
clear_triggers
echo nop > $TRACEDIR/current_tracer || exit -1
echo 0 > $TRACEDIR/events/enable || exit -1
echo > $TRACE_FILE || exit -1
echo 1 > $TRACING_ON || exit -1
}
#set -x
echo '** CLEAR TRACE'
do_reset
# check stacktrace available
if ! grep -q stacktrace $TRIGGER_FILE; then
echo "stacktrace trigger not available"
exit 0
fi
cnt=`cnt_trace`
if [ $cnt -ne 0 ]; then
echo "Found junk in trace file, exiting"
exit -1
fi
echo "Enable only events"
echo 1 > $EVENT_ENABLE
sleep 1
echo 0 > $TRACING_ON
check_events 1 0 0
do_reset
echo "Enable only stack trace"
echo 0 > $TRACING_ON
echo stacktrace > $TRIGGER_FILE
echo 1 > $TRACING_ON
sleep 1
echo 0 > $TRACING_ON
check_events 0 1 0
do_reset
echo "Enable both stack trace and events"
echo 0 > $TRACING_ON
echo stacktrace > $TRIGGER_FILE
echo 1 > $EVENT_ENABLE
echo 1 > $TRACING_ON
sleep 1
echo 0 > $TRACING_ON
check_events 1 1 0
do_reset
for i in 1 2 3; do
if [ $i -gt 1 ]; then
s='s'
else
s=''
fi
echo "Enable stack trace only $i time$s"
echo 0 > $TRACING_ON
echo stacktrace:$i > $TRIGGER_FILE
echo 1 > $EVENT_ENABLE
echo 1 > $TRACING_ON
sleep 1
echo 0 > $TRACING_ON
check_events 1 1 $i
do_reset
done
echo '** SUCCESS'
exit 0
[-- Attachment #3: ftrace-test-event-traceon-off --]
[-- Type: application/octet-stream, Size: 2408 bytes --]
#!/bin/bash
find_debugfs() {
debugfs=`cat /proc/mounts | while read mount dir type opts a b; do
if [ $mount == "debugfs" ]; then
echo $dir;
break
fi
done`
if [ -z "$debugfs" ]; then
if ! mount -t debugfs nodev /sys/kernel/debug; then
echo "FAILED to mount debugfs"
exit -1
fi
echo "/sys/kernel/debug"
else
echo $debugfs
fi
}
debugfs=`find_debugfs`
TRACEDIR="$debugfs/tracing"
EVENTDIR=$TRACEDIR/events
if [ ! -f $EVENTDIR/sched/sched_switch/trigger ]; then
echo "triggers are not set for this kernel"
exit 0
fi
function cnt_trace() {
grep -v '^#' $TRACEDIR/trace | wc -l
}
function check_traceon() {
val=$1
cur=`cat $TRACEDIR/tracing_on`
if [ $val -ne $cur ]; then
echo "traceon expected to be $val but was $cur"
exit 1
fi
}
set -x
echo '** DISABLE TRACING'
echo 0 > $TRACEDIR/tracing_on || exit -1
echo > $TRACEDIR/trace || exit -1
check_traceon 0
cnt=`cnt_trace`
if [ $cnt -ne 0 ]; then
exit -1
fi
echo '** ENABLE FUNCTION TRACING'
echo function > $TRACEDIR/current_tracer || exit -1
echo '** ENABLE TRACING'
echo 1 > $TRACEDIR/tracing_on || exit -1
cnt=`cnt_trace`
if [ $cnt -eq 0 ]; then
exit -1
fi
echo '** SET EVENT TRACEOFF'
check_traceon 1
echo "traceoff" > $EVENTDIR/sched/sched_switch/trigger
sleep 1
check_traceon 0
cnt=`cnt_trace`
sleep 1
cnt2=`cnt_trace`
if [ $cnt -ne $cnt2 ]; then
exit -1;
fi
line1=`cat $TRACEDIR/trace | tail -1`
sleep 1
line2=`cat $TRACEDIR/trace | tail -1`
if [ $line1 != $line2 ]; then
exit -1
fi
echo > $TRACEDIR/trace || exit -1
check_traceon 0
echo "!traceoff" >> $EVENTDIR/sched/sched_switch/trigger
check_traceon 0
echo "traceon" >> $EVENTDIR/sched/sched_switch/trigger
sleep 1
cnt=`cnt_trace`
if [ $cnt -eq 0 ]; then
exit -1
fi
check_traceon 1
echo "!traceon" >> $EVENTDIR/sched/sched_switch/trigger
check_sleep() {
val=$1
sleep 1
check_traceon $val
}
echo '** TEST COUNT traceoff (3)'
echo "traceoff:3" >> $EVENTDIR/sched/sched_switch/trigger
check_sleep "0"
echo '** TEST COUNT traceoff (2)'
echo 1 > $TRACEDIR/tracing_on
check_sleep "0"
echo '** TEST COUNT traceoff (1)'
echo 1 > $TRACEDIR/tracing_on
check_sleep "0"
echo '** TEST COUNT traceoff (0)'
echo 1 > $TRACEDIR/tracing_on
check_sleep "1"
echo "!traceoff:0" >> $EVENTDIR/sched/sched_switch/trigger
echo nop > $TRACEDIR/current_tracer
echo '** SUCCESS'
exit 0
[-- Attachment #4: ftrace-test-event-trigger-event --]
[-- Type: application/octet-stream, Size: 4079 bytes --]
#!/bin/bash
find_debugfs() {
debugfs=`cat /proc/mounts | while read mount dir type opts a b; do
if [ $mount == "debugfs" ]; then
echo $dir;
break
fi
done`
if [ -z "$debugfs" ]; then
if ! mount -t debugfs nodev /sys/kernel/debug; then
echo "FAILED to mount debugfs"
exit -1
fi
echo "/sys/kernel/debug"
else
echo $debugfs
fi
}
debugfs=`find_debugfs`
TRACEDIR="$debugfs/tracing"
EVENTDIR=$TRACEDIR/events
EVENT=$EVENTDIR/sched/sched_wakeup
EVENT_ENABLE=$EVENT/enable
TRIGGER_FILE=$EVENT/trigger
TRACE_FILE=$TRACEDIR/trace
TRACING_ON=$TRACEDIR/tracing_on
OTHER="sched:sched_switch"
OTHER_EVENT=$EVENTDIR/sched/sched_switch
OTHER_EVENT_ENABLE=$OTHER_EVENT/enable
if [ ! -f $TRIGGER_FILE ]; then
echo "triggers are not set for this kernel"
exit 0
fi
function cnt_trace() {
grep -v '^#' $TRACE_FILE | wc -l
}
function clear_triggers() {
grep -v '^#' $TRIGGER_FILE | while read t; do
tr=`echo $t | sed -e s'/:.*//'`
if [ $tr == "enable_event" -o $tr == "disable_event" ]; then
tr=`echo $t | sed -e s'/\([^:]*:[^:]*:[^:]*\):.*/\1/'`
fi
echo "!$tr" > $TRIGGER_FILE
done
}
function check_events() {
events=$1
stack=$2
count=$3
if [ $events -eq 1 ]; then
if ! grep -q 'sched_switch:' $TRACE_FILE ; then
echo "Expected event but it wasn't there"
exit -1
fi
else
if grep -q 'sched_switch:' $TRACE_FILE ; then
echo "Expected no events but events were found"
exit -1
fi
fi
if [ $stack -eq 1 ]; then
if [ $count -eq 0 ]; then
# unlimited, find the sleep call
if ! grep -q '^ => .*sleep' $TRACE_FILE; then
echo "Could not find sleep call"
exit -1
fi
else
# count the stack traces
cnt=`grep '<stack trace>' $TRACE_FILE | wc -l`;
if [ $cnt -ne $count ]; then
echo "Expected $count hits but only see $cnt"
exit -1
fi
fi
else
if grep -q '^ =>' $TRACE_FILE; then
echo "Found stack trace when not enabled"
exit -1
fi
fi
}
function test_other_enabled() {
val=$1
e=`cat $OTHER_EVENT_ENABLE`
if [ "$e" != $val ]; then
echo "Expected $val but found $e"
exit -1
fi
}
function do_reset() {
clear_triggers
echo nop > $TRACEDIR/current_tracer || exit -1
echo 0 > $TRACEDIR/events/enable || exit -1
echo > $TRACE_FILE || exit -1
echo 1 > $TRACING_ON || exit -1
}
#set -x
echo '** CLEAR TRACE'
do_reset
run_enable_disable() {
enable=$1 # enable
Enable=$2 # Enable
check_disable=$3 # 0
check_enable_star=$4 # 1*
# check stacktrace available
if ! grep -q ${enable}_event $TRIGGER_FILE; then
echo "$enable trigger not available"
exit 0
fi
cnt=`cnt_trace`
if [ $cnt -ne 0 ]; then
echo "Found junk in trace file, exiting"
exit -1
fi
echo "$Enable event all the time"
echo $check_disable > $OTHER_EVENT_ENABLE
sleep 1
test_other_enabled $check_disable
echo "${enable}_event:$OTHER" > $TRIGGER_FILE
echo " make sure it works 5 times"
for i in `seq 5`; do
sleep 1
echo " test $i"
test_other_enabled $check_enable_star
echo $check_disable > $OTHER_EVENT_ENABLE
done
sleep 1
echo " make sure it's still works"
test_other_enabled $check_enable_star
do_reset
}
run_enable_disable enable Enable 0 "1*"
run_enable_disable disable Disable 1 "0*"
for i in 1 2 3; do
if [ $i -gt 1 ]; then
s='s'
else
s=''
fi
echo "Enable event only $i time$s"
echo 0 > $TRACING_ON
echo "enable_event:$OTHER:$i" > $TRIGGER_FILE
echo 1 > $EVENT_ENABLE
for x in `seq $i`; do
echo " test $x"
sleep 1
test_other_enabled "1*"
echo 0 > $OTHER_EVENT_ENABLE
done
sleep 1
echo "Make sure it didn't do it for more"
test_other_enabled "0*"
do_reset
done
echo "Now testing filter"
sleep 100&
x=`jobs -l`
pid=`echo $x | cut -d' ' -f2`
echo "enable_event:$OTHER if pid==$pid" > $TRIGGER_FILE
test_other_enabled "0*"
sleep 1
test_other_enabled "0*"
sleep 1
kill $pid
sleep 1
test_other_enabled "1*"
do_reset
echo '** SUCCESS'
exit 0
next prev parent reply other threads:[~2014-01-07 17:57 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-06 19:44 Tom Zanussi
2014-01-06 19:44 ` [PATCH 1/2 v2] tracing/kprobes: Add trace event trigger invocations Tom Zanussi
2014-01-06 21:56 ` Masami Hiramatsu
2014-01-06 19:44 ` [PATCH 2/2] tracing: Remove double-underscore naming in syscall " Tom Zanussi
2014-01-06 21:13 ` [PATCH 0/2] tracing/triggers: A couple minor variable name changes Steven Rostedt
2014-01-07 0:47 ` Tom Zanussi
2014-01-07 1:50 ` Steven Rostedt
2014-01-07 2:51 ` Tom Zanussi
2014-01-07 3:27 ` Steven Rostedt
2014-01-07 17:29 ` Tom Zanussi
2014-01-07 17:56 ` Steven Rostedt [this message]
2014-01-07 3:31 ` Steven Rostedt
2014-01-07 17:30 ` Tom Zanussi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140107125655.20cd27d6@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=linux-kernel@vger.kernel.org \
--cc=masami.hiramatsu.pt@hitachi.com \
--cc=tom.zanussi@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®