Commit cfa0963d authored by Masami Hiramatsu's avatar Masami Hiramatsu Committed by Steven Rostedt

kselftests/ftrace : Add event trigger testcases

This adds simple event trigger testcases for ftracetest,
which covers following triggers.
 - traceon-traceoff trigger
 - enable/disable_event trigger
 - snapshot trigger
 - stacktrace trigger
 - trigger filters

Here is the test result.

  ----
  # ./ftracetest test.d/trigger/
  === Ftrace unit tests ===
  [1] event trigger - test event enable/disable trigger   [PASS]
  [2] event trigger - test trigger filter [PASS]
  [3] event trigger - test snapshot-trigger       [PASS]
  [4] event trigger - test stacktrace-trigger     [PASS]
  [5] event trigger - test traceon/off trigger    [PASS]

  # of passed:  5
  # of failed:  0
  # of unresolved:  0
  # of untested:  0
  # of unsupported:  0
  # of xfailed:  0
  # of undefined(test bug):  0
  ----

Link: http://lkml.kernel.org/r/12b9c2b289a0dc1e4386e7b77674611a83abca85.1457029949.git.tom.zanussi@linux.intel.comSigned-off-by: default avatarMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Shuah Khan <shuahkh@osg.samsung.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Tom Zanussi <tom.zanussi@linux.intel.com>
Reviewed-by: default avatarNamhyung Kim <namhyung@kernel.org>
Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
parent 5463bfda
......@@ -14,3 +14,12 @@ enable_tracing() { # start trace recording
reset_tracer() { # reset the current tracer
echo nop > current_tracer
}
reset_trigger() { # reset all current setting triggers
grep -v ^# events/*/*/trigger |
while read line; do
cmd=`echo $line | cut -f2- -d: | cut -f1 -d" "`
echo "!$cmd" > `echo $line | cut -f1 -d:`
done
}
#!/bin/sh
# description: event trigger - test event enable/disable trigger
do_reset() {
reset_trigger
echo > set_event
clear_trace
}
fail() { #msg
do_reset
echo $1
exit $FAIL
}
if [ ! -f set_event -o ! -d events/sched ]; then
echo "event tracing is not supported"
exit_unsupported
fi
if [ ! -f events/sched/sched_process_fork/trigger ]; then
echo "event trigger is not supported"
exit_unsupported
fi
reset_tracer
do_reset
FEATURE=`grep enable_event events/sched/sched_process_fork/trigger`
if [ -z "$FEATURE" ]; then
echo "event enable/disable trigger is not supported"
exit_unsupported
fi
echo "Test enable_event trigger"
echo 0 > events/sched/sched_switch/enable
echo 'enable_event:sched:sched_switch' > events/sched/sched_process_fork/trigger
( echo "forked")
if [ `cat events/sched/sched_switch/enable` != '1*' ]; then
fail "enable_event trigger on sched_process_fork did not work"
fi
reset_trigger
echo "Test disable_event trigger"
echo 1 > events/sched/sched_switch/enable
echo 'disable_event:sched:sched_switch' > events/sched/sched_process_fork/trigger
( echo "forked")
if [ `cat events/sched/sched_switch/enable` != '0*' ]; then
fail "disable_event trigger on sched_process_fork did not work"
fi
reset_trigger
echo "Test semantic error for event enable/disable trigger"
! echo 'enable_event:nogroup:noevent' > events/sched/sched_process_fork/trigger
! echo 'disable_event+1' > events/sched/sched_process_fork/trigger
echo 'enable_event:sched:sched_switch' > events/sched/sched_process_fork/trigger
! echo 'enable_event:sched:sched_switch' > events/sched/sched_process_fork/trigger
! echo 'disable_event:sched:sched_switch' > events/sched/sched_process_fork/trigger
do_reset
exit 0
#!/bin/sh
# description: event trigger - test trigger filter
do_reset() {
reset_trigger
echo > set_event
clear_trace
}
fail() { #msg
do_reset
echo $1
exit $FAIL
}
if [ ! -f set_event -o ! -d events/sched ]; then
echo "event tracing is not supported"
exit_unsupported
fi
if [ ! -f events/sched/sched_process_fork/trigger ]; then
echo "event trigger is not supported"
exit_unsupported
fi
reset_tracer
do_reset
echo "Test trigger filter"
echo 1 > tracing_on
echo 'traceoff if child_pid == 0' > events/sched/sched_process_fork/trigger
( echo "forked")
if [ `cat tracing_on` -ne 1 ]; then
fail "traceoff trigger on sched_process_fork did not work"
fi
reset_trigger
echo "Test semantic error for trigger filter"
! echo 'traceoff if a' > events/sched/sched_process_fork/trigger
! echo 'traceoff if common_pid=0' > events/sched/sched_process_fork/trigger
! echo 'traceoff if common_pid==b' > events/sched/sched_process_fork/trigger
echo 'traceoff if common_pid == 0' > events/sched/sched_process_fork/trigger
echo '!traceoff' > events/sched/sched_process_fork/trigger
! echo 'traceoff if common_pid == child_pid' > events/sched/sched_process_fork/trigger
echo 'traceoff if common_pid <= 0' > events/sched/sched_process_fork/trigger
echo '!traceoff' > events/sched/sched_process_fork/trigger
echo 'traceoff if common_pid >= 0' > events/sched/sched_process_fork/trigger
echo '!traceoff' > events/sched/sched_process_fork/trigger
echo 'traceoff if parent_pid >= 0 && child_pid >= 0' > events/sched/sched_process_fork/trigger
echo '!traceoff' > events/sched/sched_process_fork/trigger
echo 'traceoff if parent_pid >= 0 || child_pid >= 0' > events/sched/sched_process_fork/trigger
echo '!traceoff' > events/sched/sched_process_fork/trigger
do_reset
exit 0
#!/bin/sh
# description: event trigger - test snapshot-trigger
do_reset() {
reset_trigger
echo > set_event
clear_trace
}
fail() { #msg
do_reset
echo $1
exit $FAIL
}
if [ ! -f set_event -o ! -d events/sched ]; then
echo "event tracing is not supported"
exit_unsupported
fi
if [ ! -f events/sched/sched_process_fork/trigger ]; then
echo "event trigger is not supported"
exit_unsupported
fi
reset_tracer
do_reset
FEATURE=`grep snapshot events/sched/sched_process_fork/trigger`
if [ -z "$FEATURE" ]; then
echo "snapshot trigger is not supported"
exit_unsupported
fi
echo "Test snapshot tigger"
echo 0 > snapshot
echo 1 > events/sched/sched_process_fork/enable
( echo "forked")
echo 'snapshot:1' > events/sched/sched_process_fork/trigger
( echo "forked")
grep sched_process_fork snapshot > /dev/null || \
fail "snapshot trigger on sched_process_fork did not work"
reset_trigger
echo 0 > snapshot
echo 0 > events/sched/sched_process_fork/enable
echo "Test snapshot semantic errors"
! echo "snapshot+1" > events/sched/sched_process_fork/trigger
echo "snapshot" > events/sched/sched_process_fork/trigger
! echo "snapshot" > events/sched/sched_process_fork/trigger
do_reset
exit 0
#!/bin/sh
# description: event trigger - test stacktrace-trigger
do_reset() {
reset_trigger
echo > set_event
clear_trace
}
fail() { #msg
do_reset
echo $1
exit $FAIL
}
if [ ! -f set_event -o ! -d events/sched ]; then
echo "event tracing is not supported"
exit_unsupported
fi
if [ ! -f events/sched/sched_process_fork/trigger ]; then
echo "event trigger is not supported"
exit_unsupported
fi
reset_tracer
do_reset
FEATURE=`grep stacktrace events/sched/sched_process_fork/trigger`
if [ -z "$FEATURE" ]; then
echo "stacktrace trigger is not supported"
exit_unsupported
fi
echo "Test stacktrace tigger"
echo 0 > trace
echo 0 > options/stacktrace
echo 'stacktrace' > events/sched/sched_process_fork/trigger
( echo "forked")
grep "<stack trace>" trace > /dev/null || \
fail "stacktrace trigger on sched_process_fork did not work"
reset_trigger
echo "Test stacktrace semantic errors"
! echo "stacktrace:foo" > events/sched/sched_process_fork/trigger
echo "stacktrace" > events/sched/sched_process_fork/trigger
! echo "stacktrace" > events/sched/sched_process_fork/trigger
do_reset
exit 0
#!/bin/sh
# description: event trigger - test traceon/off trigger
do_reset() {
reset_trigger
echo > set_event
clear_trace
}
fail() { #msg
do_reset
echo $1
exit $FAIL
}
if [ ! -f set_event -o ! -d events/sched ]; then
echo "event tracing is not supported"
exit_unsupported
fi
if [ ! -f events/sched/sched_process_fork/trigger ]; then
echo "event trigger is not supported"
exit_unsupported
fi
reset_tracer
do_reset
echo "Test traceoff trigger"
echo 1 > tracing_on
echo 'traceoff' > events/sched/sched_process_fork/trigger
( echo "forked")
if [ `cat tracing_on` -ne 0 ]; then
fail "traceoff trigger on sched_process_fork did not work"
fi
reset_trigger
echo "Test traceon trigger"
echo 0 > tracing_on
echo 'traceon' > events/sched/sched_process_fork/trigger
( echo "forked")
if [ `cat tracing_on` -ne 1 ]; then
fail "traceoff trigger on sched_process_fork did not work"
fi
reset_trigger
echo "Test semantic error for traceoff/on trigger"
! echo 'traceoff:badparam' > events/sched/sched_process_fork/trigger
! echo 'traceoff+0' > events/sched/sched_process_fork/trigger
echo 'traceon' > events/sched/sched_process_fork/trigger
! echo 'traceon' > events/sched/sched_process_fork/trigger
! echo 'traceoff' > events/sched/sched_process_fork/trigger
do_reset
exit 0
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment