Skip to content

Commit 00b2f2b

Browse files
mhiramatShuah Khan (Samsung OSG)
authored andcommitted
selftests/ftrace: Test kprobe-event argument with various bitsize
Improve the kprobe-event with argument types testcase to test it with various bitsize. kprobe-event argument can be recorded in given types with various bitsize (8, 16, 32, 64), thus the type testcase should test the different bitsize too. Signed-off-by: Masami Hiramatsu <[email protected]> Signed-off-by: Shuah Khan (Samsung OSG) <[email protected]>
1 parent 1e51263 commit 00b2f2b

File tree

1 file changed

+32
-16
lines changed

1 file changed

+32
-16
lines changed

tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_type.tc

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,45 @@
66

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

9-
echo 'p:testprobe _do_fork $stack0:s32 $stack0:u32 $stack0:x32 $stack0:b8@4/32' > kprobe_events
10-
grep testprobe kprobe_events
11-
test -d events/kprobes/testprobe
12-
13-
echo 1 > events/kprobes/testprobe/enable
14-
( echo "forked")
15-
echo 0 > events/kprobes/testprobe/enable
16-
ARGS=`tail -n 1 trace | sed -e 's/.* arg1=\(.*\) arg2=\(.*\) arg3=\(.*\) arg4=\(.*\)/\1 \2 \3 \4/'`
9+
gen_event() { # Bitsize
10+
echo "p:testprobe _do_fork \$stack0:s$1 \$stack0:u$1 \$stack0:x$1 \$stack0:b4@4/$1"
11+
}
1712

18-
check_types() {
19-
X1=`printf "%x" $1 | tail -c 8`
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}`
2018
X2=`printf "%x" $2`
2119
X3=`printf "%x" $3`
2220
test $X1 = $X2
2321
test $X2 = $X3
2422
test 0x$X3 = $3
2523

26-
B4=`printf "%02x" $4`
27-
B3=`echo -n $X3 | tail -c 3 | head -c 2`
24+
B4=`printf "%1x" $4`
25+
B3=`printf "%03x" 0x$X3 | tail -c 2 | head -c 1`
2826
test $B3 = $B4
2927
}
30-
check_types $ARGS
3128

32-
echo "-:testprobe" >> kprobe_events
33-
clear_trace
34-
test -d events/kprobes/testprobe && exit_fail || exit_pass
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

0 commit comments

Comments
 (0)