perf/core: Replace zero-length array with flexible-array
[linux-2.6-microblaze.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 gen_event() { # Bitsize
10   echo "p:testprobe _do_fork \$stack0:s$1 \$stack0:u$1 \$stack0:x$1 \$stack0:b4@4/$1"
11 }
12
13 check_types() { # s-type u-type x-type bf-type width
14   test $# -eq 5
15   CW=$5
16   CW=$((CW / 4))
17   X1=`printf "%x" $1 | tail -c ${CW}`
18   X2=`printf "%x" $2`
19   X3=`printf "%x" $3`
20   test $X1 = $X2
21   test $X2 = $X3
22   test 0x$X3 = $3
23
24   B4=`printf "%1x" $4`
25   B3=`printf "%03x" 0x$X3 | tail -c 2 | head -c 1`
26   test $B3 = $B4
27 }
28
29 for width in 64 32 16 8; do
30   : "Add new event with basic types"
31   gen_event $width > kprobe_events
32   grep testprobe kprobe_events
33   test -d events/kprobes/testprobe
34
35   : "Trace the event"
36   echo 1 > events/kprobes/testprobe/enable
37   ( echo "forked")
38   echo 0 > events/kprobes/testprobe/enable
39
40   : "Confirm the arguments is recorded in given types correctly"
41   ARGS=`grep "testprobe" trace | sed -e 's/.* arg1=\(.*\) arg2=\(.*\) arg3=\(.*\) arg4=\(.*\)/\1 \2 \3 \4/'`
42   check_types $ARGS $width
43
44   : "Clear event for next loop"
45   echo "-:testprobe" >> kprobe_events
46   clear_trace
47
48 done
49
50 exit_pass