diff options
| author | Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com> | 2017-07-07 14:57:32 -0400 |
|---|---|---|
| committer | Steven Rostedt (VMware) <rostedt@goodmis.org> | 2017-07-09 07:46:25 -0400 |
| commit | ff431b1390cbf8764f8550b8e427eb28d4a6328e (patch) | |
| tree | 5340d8442b87aba4e5d3da5df546ab354b955e5f /tools/testing | |
| parent | f7181e5aaab58d81c5453887e39a1e1041f6bb1a (diff) | |
selftests/ftrace: Add a test to probe module functions
Add a kprobes test to ensure that we are able to add a probe on a
module function using 'p <mod>:<func>' format, with/without having to
specify a probe name.
Link: http://lkml.kernel.org/r/2d8087e25a7ad9206f3e2b7b4bb0c3c86eaa38af.1499453040.git.naveen.n.rao@linux.vnet.ibm.com
Suggested-by: Masami Hiramatsu <mhiramat@kernel.org>
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Diffstat (limited to 'tools/testing')
| -rw-r--r-- | tools/testing/selftests/ftrace/test.d/kprobe/kprobe_module.tc | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_module.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_module.tc new file mode 100644 index 000000000000..6d634e4b7680 --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_module.tc | |||
| @@ -0,0 +1,28 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | # description: Kprobe dynamic event - probing module | ||
| 3 | |||
| 4 | [ -f kprobe_events ] || exit_unsupported # this is configurable | ||
| 5 | |||
| 6 | disable_events | ||
| 7 | echo > kprobe_events | ||
| 8 | |||
| 9 | :;: "Add an event on a module function without specifying event name" ;: | ||
| 10 | |||
| 11 | MOD=`lsmod | head -n 2 | tail -n 1 | cut -f1 -d" "` | ||
| 12 | FUNC=`grep -m 1 ".* t .*\\[$MOD\\]" /proc/kallsyms | xargs | cut -f3 -d" "` | ||
| 13 | [ "x" != "x$MOD" -a "y" != "y$FUNC" ] || exit_unresolved | ||
| 14 | echo "p $MOD:$FUNC" > kprobe_events | ||
| 15 | PROBE_NAME=`echo $MOD:$FUNC | tr ".:" "_"` | ||
| 16 | test -d events/kprobes/p_${PROBE_NAME}_0 || exit_failure | ||
| 17 | |||
| 18 | :;: "Add an event on a module function with new event name" ;: | ||
| 19 | |||
| 20 | echo "p:event1 $MOD:$FUNC" > kprobe_events | ||
| 21 | test -d events/kprobes/event1 || exit_failure | ||
| 22 | |||
| 23 | :;: "Add an event on a module function with new event and group name" ;: | ||
| 24 | |||
| 25 | echo "p:kprobes1/event1 $MOD:$FUNC" > kprobe_events | ||
| 26 | test -d events/kprobes1/event1 || exit_failure | ||
| 27 | |||
| 28 | echo > kprobe_events | ||
