Skip to content

Commit

Permalink
selftests: ftrace: Add a testcase for types of kprobe event
Browse files Browse the repository at this point in the history
Add a testcase for types of kprobe event. This checks
kprobe event can accept and correctly expressed the
arguments typed as s32, u32, x32 and bitfield.

Here is the test result.
  -----
  # ./ftracetest test.d/kprobe/kprobe_args_type.tc
  === Ftrace unit tests ===
  [1] Kprobes event arguments with types	[PASS]

  # of passed:  1
  # 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/147928409063.22982.3499119203875115458.stgit@devbox

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
  • Loading branch information
Masami Hiramatsu authored and Steven Rostedt committed Nov 22, 2016
1 parent 60c1afb commit 153aae5
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_type.tc
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/sh
# description: Kprobes event arguments with types

[ -f kprobe_events ] || exit_unsupported # this is configurable

grep "x8/16/32/64" README > /dev/null || exit_unsupported # version issue

echo 0 > events/enable
echo > kprobe_events
enable_tracing

echo 'p:testprobe _do_fork $stack0:s32 $stack0:u32 $stack0:x32 $stack0:b8@4/32' > kprobe_events
grep testprobe kprobe_events
test -d events/kprobes/testprobe

echo 1 > events/kprobes/testprobe/enable
( echo "forked")
echo 0 > events/kprobes/testprobe/enable
ARGS=`tail -n 1 trace | sed -e 's/.* arg1=\(.*\) arg2=\(.*\) arg3=\(.*\) arg4=\(.*\)/\1 \2 \3 \4/'`

check_types() {
X1=`printf "%x" $1 | tail -c 8`
X2=`printf "%x" $2`
X3=`printf "%x" $3`
test $X1 = $X2
test $X2 = $X3
test 0x$X3 = $3

B4=`printf "%x" $4`
B3=`echo -n $X3 | tail -c 3 | head -c 2`
test $B3 = $B4
}
check_types $ARGS

echo "-:testprobe" >> kprobe_events
clear_trace
test -d events/kprobes/testprobe && exit 1 || exit 0

0 comments on commit 153aae5

Please sign in to comment.