diff options
author | Masami Hiramatsu <mhiramat@kernel.org> | 2018-08-30 10:17:38 -0400 |
---|---|---|
committer | Shuah Khan (Samsung OSG) <shuah@kernel.org> | 2018-10-24 16:49:35 -0400 |
commit | af2a0750f374935c07b8beab78d6032b1ca2218d (patch) | |
tree | 0106a715c64efea24c371a04afe7c4762648f5b1 /tools/testing | |
parent | cec3adf5f57160d829a033bcb578c3dd0a90c693 (diff) |
selftests/ftrace: Improve kprobe on module testcase to load/unload module
Improve kprobe events on module testcase to check module
load/unload with disabled/enabled events. This also change
the target module to trace_printk.ko, so it depends on
CONFIG_SAMPLE_TRACE_PRINTK=m.
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Shuah Khan (Samsung OSG) <shuah@kernel.org>
Diffstat (limited to 'tools/testing')
-rw-r--r-- | tools/testing/selftests/ftrace/config | 4 | ||||
-rw-r--r-- | tools/testing/selftests/ftrace/test.d/kprobe/kprobe_module.tc | 35 |
2 files changed, 36 insertions, 3 deletions
diff --git a/tools/testing/selftests/ftrace/config b/tools/testing/selftests/ftrace/config index 07db5ab09cc7..32cf61b6bb54 100644 --- a/tools/testing/selftests/ftrace/config +++ b/tools/testing/selftests/ftrace/config | |||
@@ -7,3 +7,7 @@ CONFIG_HIST_TRIGGERS=y | |||
7 | CONFIG_PREEMPT_TRACER=y | 7 | CONFIG_PREEMPT_TRACER=y |
8 | CONFIG_IRQSOFF_TRACER=y | 8 | CONFIG_IRQSOFF_TRACER=y |
9 | CONFIG_PREEMPTIRQ_DELAY_TEST=m | 9 | CONFIG_PREEMPTIRQ_DELAY_TEST=m |
10 | CONFIG_MODULES=y | ||
11 | CONFIG_MODULE_UNLOAD=y | ||
12 | CONFIG_SAMPLES=y | ||
13 | CONFIG_SAMPLE_TRACE_PRINTK=m | ||
diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_module.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_module.tc index ec6c5fffef1e..d861bd776c5e 100644 --- a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_module.tc +++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_module.tc | |||
@@ -4,11 +4,18 @@ | |||
4 | 4 | ||
5 | [ -f kprobe_events ] || exit_unsupported # this is configurable | 5 | [ -f kprobe_events ] || exit_unsupported # this is configurable |
6 | 6 | ||
7 | rmmod trace-printk ||: | ||
8 | if ! modprobe trace-printk ; then | ||
9 | echo "No trace-printk sample module - please make CONFIG_SAMPLE_TRACE_PRINTK= | ||
10 | m" | ||
11 | exit_unresolved; | ||
12 | fi | ||
13 | |||
14 | MOD=trace_printk | ||
15 | FUNC=trace_printk_irq_work | ||
16 | |||
7 | :;: "Add an event on a module function without specifying event name" ;: | 17 | :;: "Add an event on a module function without specifying event name" ;: |
8 | 18 | ||
9 | MOD=`lsmod | head -n 2 | tail -n 1 | cut -f1 -d" "` | ||
10 | FUNC=`grep -m 1 ".* t .*\\[$MOD\\]" /proc/kallsyms | xargs | cut -f3 -d" "` | ||
11 | [ "x" != "x$MOD" -a "y" != "y$FUNC" ] || exit_unresolved | ||
12 | echo "p $MOD:$FUNC" > kprobe_events | 19 | echo "p $MOD:$FUNC" > kprobe_events |
13 | PROBE_NAME=`echo $MOD:$FUNC | tr ".:" "_"` | 20 | PROBE_NAME=`echo $MOD:$FUNC | tr ".:" "_"` |
14 | test -d events/kprobes/p_${PROBE_NAME}_0 || exit_failure | 21 | test -d events/kprobes/p_${PROBE_NAME}_0 || exit_failure |
@@ -22,3 +29,25 @@ test -d events/kprobes/event1 || exit_failure | |||
22 | 29 | ||
23 | echo "p:kprobes1/event1 $MOD:$FUNC" > kprobe_events | 30 | echo "p:kprobes1/event1 $MOD:$FUNC" > kprobe_events |
24 | test -d events/kprobes1/event1 || exit_failure | 31 | test -d events/kprobes1/event1 || exit_failure |
32 | |||
33 | :;: "Remove target module, but event still be there" ;: | ||
34 | if ! rmmod trace-printk ; then | ||
35 | echo "Failed to unload module - please enable CONFIG_MODULE_UNLOAD" | ||
36 | exit_unresolved; | ||
37 | fi | ||
38 | test -d events/kprobes1/event1 | ||
39 | |||
40 | :;: "Check posibility to defining events on unloaded module";: | ||
41 | echo "p:event2 $MOD:$FUNC" >> kprobe_events | ||
42 | |||
43 | :;: "Target is gone, but we can prepare for next time";: | ||
44 | echo 1 > events/kprobes1/event1/enable | ||
45 | |||
46 | :;: "Load module again, which means the event1 should be recorded";: | ||
47 | modprobe trace-printk | ||
48 | grep "event1:" trace | ||
49 | |||
50 | :;: "Remove the module again and check the event is not locked" | ||
51 | rmmod trace-printk | ||
52 | echo 0 > events/kprobes1/event1/enable | ||
53 | echo "-:kprobes1/event1" >> kprobe_events | ||