GNU Linux-libre 4.14.295-gnu1
[releases.git] / tools / testing / selftests / ftrace / test.d / kprobe / kprobe_args_type.tc
1 #!/bin/sh
2 # SPDX-License-Identifier: GPL-2.0
3 # description: Kprobes event arguments with types
4
5 [ -f kprobe_events ] || exit_unsupported # this is configurable
6
7 grep "x8/16/32/64" README > /dev/null || exit_unsupported # version issue
8
9 echo 0 > events/enable
10 echo > kprobe_events
11 enable_tracing
12
13 echo 'p:testprobe _do_fork $stack0:s32 $stack0:u32 $stack0:x32 $stack0:b8@4/32' > kprobe_events
14 grep testprobe kprobe_events
15 test -d events/kprobes/testprobe
16
17 echo 1 > events/kprobes/testprobe/enable
18 ( echo "forked")
19 echo 0 > events/kprobes/testprobe/enable
20 ARGS=`tail -n 1 trace | sed -e 's/.* arg1=\(.*\) arg2=\(.*\) arg3=\(.*\) arg4=\(.*\)/\1 \2 \3 \4/'`
21
22 check_types() {
23   X1=`printf "%x" $1 | tail -c 8`
24   X2=`printf "%x" $2`
25   X3=`printf "%x" $3`
26   test $X1 = $X2
27   test $X2 = $X3
28   test 0x$X3 = $3
29
30   B4=`printf "%02x" $4`
31   B3=`echo -n $X3 | tail -c 3 | head -c 2`
32   test $B3 = $B4
33 }
34 check_types $ARGS
35
36 echo "-:testprobe" >> kprobe_events
37 clear_trace
38 test -d events/kprobes/testprobe && exit 1 || exit 0