提交 76929ab5 编写于 作者: M Masami Hiramatsu 提交者: Steven Rostedt

kselftests/ftrace: Add hist trigger testcases

Add the hist trigger testcases for ftracetest.
This checks the basic histogram trigger behaviors like as;
 - Histogram trigger itself
 - Histogram with string key
 - Histogram with compound keys
 - Histogram with sort key
 - Histogram trigger modifiers (execname, hex, syscall)
 - Multiple histograms on an event
 - Named histogram
 - Named histogram on multi events

Here is the test result.
  ----
  # ./ftracetest test.d/trigger/*hist*.tc
  === Ftrace unit tests ===
  [1] event trigger - test histogram modifiers    [PASS]
  [2] event trigger - test histogram trigger      [PASS]
  [3] event trigger - test multiple histogram triggers    [PASS]

  # of passed:  3
  # 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/17cb3a3d9eeadc3282645147905455a298e7fbeb.1457029949.git.tom.zanussi@linux.intel.comSigned-off-by: NMasami 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>
Signed-off-by: NTom Zanussi <tom.zanussi@linux.intel.com>
[Tom Zanussi: Change multihist test from truncate ('>') to append ('>>')]
Reviewed-by: NNamhyung Kim <namhyung@kernel.org>
Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
上级 cfa0963d
#!/bin/sh
# description: event trigger - test histogram modifiers
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 hist events/sched/sched_process_fork/trigger`
if [ -z "$FEATURE" ]; then
echo "hist trigger is not supported"
exit_unsupported
fi
echo "Test histogram with execname modifier"
echo 'hist:keys=common_pid.execname' > events/sched/sched_process_fork/trigger
for i in `seq 1 10` ; do ( echo "forked" > /dev/null); done
COMM=`cat /proc/$$/comm`
grep "common_pid: $COMM" events/sched/sched_process_fork/hist > /dev/null || \
fail "execname modifier on sched_process_fork did not work"
reset_trigger
echo "Test histogram with hex modifier"
echo 'hist:keys=parent_pid.hex' > events/sched/sched_process_fork/trigger
for i in `seq 1 10` ; do ( echo "forked" > /dev/null); done
# Note that $$ is the parent pid. $PID is current PID.
HEX=`printf %x $PID`
grep "parent_pid: $HEX" events/sched/sched_process_fork/hist > /dev/null || \
fail "hex modifier on sched_process_fork did not work"
reset_trigger
echo "Test histogram with syscall modifier"
echo 'hist:keys=id.syscall' > events/raw_syscalls/sys_exit/trigger
for i in `seq 1 10` ; do ( echo "forked" > /dev/null); done
grep "id: sys_" events/raw_syscalls/sys_exit/hist > /dev/null || \
fail "syscall modifier on raw_syscalls/sys_exit did not work"
do_reset
exit 0
#!/bin/sh
# description: event trigger - test histogram 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 hist events/sched/sched_process_fork/trigger`
if [ -z "$FEATURE" ]; then
echo "hist trigger is not supported"
exit_unsupported
fi
echo "Test histogram basic tigger"
echo 'hist:keys=parent_pid:vals=child_pid' > events/sched/sched_process_fork/trigger
for i in `seq 1 10` ; do ( echo "forked" > /dev/null); done
grep parent_pid events/sched/sched_process_fork/hist > /dev/null || \
fail "hist trigger on sched_process_fork did not work"
grep child events/sched/sched_process_fork/hist > /dev/null || \
fail "hist trigger on sched_process_fork did not work"
reset_trigger
echo "Test histogram with compound keys"
echo 'hist:keys=parent_pid,child_pid' > events/sched/sched_process_fork/trigger
for i in `seq 1 10` ; do ( echo "forked" > /dev/null); done
grep '^{ parent_pid:.*, child_pid:.*}' events/sched/sched_process_fork/hist > /dev/null || \
fail "compound keys on sched_process_fork did not work"
reset_trigger
echo "Test histogram with string key"
echo 'hist:keys=parent_comm' > events/sched/sched_process_fork/trigger
for i in `seq 1 10` ; do ( echo "forked" > /dev/null); done
COMM=`cat /proc/$$/comm`
grep "parent_comm: $COMM" events/sched/sched_process_fork/hist > /dev/null || \
fail "string key on sched_process_fork did not work"
reset_trigger
echo "Test histogram with sort key"
echo 'hist:keys=parent_pid,child_pid:sort=child_pid.ascending' > events/sched/sched_process_fork/trigger
for i in `seq 1 10` ; do ( echo "forked" > /dev/null); done
check_inc() {
while [ $# -gt 1 ]; do
[ $1 -gt $2 ] && return 1
shift 1
done
return 0
}
check_inc `grep -o "child_pid:[[:space:]]*[[:digit:]]*" \
events/sched/sched_process_fork/hist | cut -d: -f2 ` ||
fail "sort param on sched_process_fork did not work"
do_reset
exit 0
#!/bin/sh
# description: event trigger - test multiple histogram triggers
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 hist events/sched/sched_process_fork/trigger`
if [ -z "$FEATURE" ]; then
echo "hist trigger is not supported"
exit_unsupported
fi
reset_trigger
echo "Test histogram multiple tiggers"
echo 'hist:keys=parent_pid:vals=child_pid' > events/sched/sched_process_fork/trigger
echo 'hist:keys=parent_comm:vals=child_pid' >> events/sched/sched_process_fork/trigger
for i in `seq 1 10` ; do ( echo "forked" > /dev/null); done
grep parent_pid events/sched/sched_process_fork/hist > /dev/null || \
fail "hist trigger on sched_process_fork did not work"
grep child events/sched/sched_process_fork/hist > /dev/null || \
fail "hist trigger on sched_process_fork did not work"
COMM=`cat /proc/$$/comm`
grep "parent_comm: $COMM" events/sched/sched_process_fork/hist > /dev/null || \
fail "string key on sched_process_fork did not work"
reset_trigger
echo "Test histogram with its name"
echo 'hist:name=test_hist:keys=common_pid' > events/sched/sched_process_fork/trigger
for i in `seq 1 10` ; do ( echo "forked" > /dev/null); done
grep test_hist events/sched/sched_process_fork/hist > /dev/null || \
fail "named event on sched_process_fork did not work"
echo "Test same named histogram on different events"
echo 'hist:name=test_hist:keys=common_pid' > events/sched/sched_process_exit/trigger
for i in `seq 1 10` ; do ( echo "forked" > /dev/null); done
grep test_hist events/sched/sched_process_exit/hist > /dev/null || \
fail "named event on sched_process_fork did not work"
diffs=`diff events/sched/sched_process_exit/hist events/sched/sched_process_fork/hist | wc -l`
test $diffs -eq 0 || fail "Same name histograms are not same"
reset_trigger
do_reset
exit 0
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册