From: "Steven Rostedt (VMware)" rostedt@goodmis.org
Add a test case that adds an event probe, makes sure that it works, and then removes it.
Link: https://lore.kernel.org/linux-kselftest/20210819152825.526931866@goodmis.org...
Cc: Shuah Khan shuah@kernel.org Cc: Shuah Khan skhan@linuxfoundation.org Cc: linux-kselftest@vger.kernel.org Signed-off-by: Steven Rostedt (VMware) rostedt@goodmis.org --- .../test.d/dynevent/add_remove_eprobe.tc | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/dynevent/add_remove_eprobe.tc
diff --git a/tools/testing/selftests/ftrace/test.d/dynevent/add_remove_eprobe.tc b/tools/testing/selftests/ftrace/test.d/dynevent/add_remove_eprobe.tc new file mode 100644 index 000000000000..25a3da4eaa44 --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/dynevent/add_remove_eprobe.tc @@ -0,0 +1,40 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# description: Generic dynamic event - add/remove eprobe events +# requires: dynamic_events events/syscalls/sys_enter_openat "e[:[<group>/]<event>] <attached-group>.<attached-event> [<args>]":README + +echo 0 > events/enable + +clear_dynamic_events + +SYSTEM="syscalls" +EVENT="sys_enter_openat" +FIELD="filename" +EPROBE="eprobe_open" + +echo "e:$EPROBE $SYSTEM/$EVENT file=+0($filename):ustring" >> dynamic_events + +grep -q "$EPROBE" dynamic_events +test -d events/eprobes/$EPROBE + +echo 1 > events/eprobes/$EPROBE/enable +ls +echo 0 > events/eprobes/$EPROBE/enable + +content=`grep '^ *ls-' trace | grep 'file='` +nocontent=`grep '^ *ls-' trace | grep 'file=' | grep -v -e '"/' -e '"."'` || true + +if [ -z "$content" ]; then + exit_fail +fi + +if [ ! -z "$nocontent" ]; then + exit_fail +fi + +echo "-:$EPROBE" >> dynamic_events + +! grep -q "$EPROBE" dynamic_events +! test -d events/eprobes/$EPROBE + +clear_trace
On Fri, 20 Aug 2021 16:46:48 -0400 Steven Rostedt rostedt@goodmis.org wrote:
From: "Steven Rostedt (VMware)" rostedt@goodmis.org
Add a test case that adds an event probe, makes sure that it works, and then removes it.
Link: https://lore.kernel.org/linux-kselftest/20210819152825.526931866@goodmis.org...
Cc: Shuah Khan shuah@kernel.org Cc: Shuah Khan skhan@linuxfoundation.org Cc: linux-kselftest@vger.kernel.org Signed-off-by: Steven Rostedt (VMware) rostedt@goodmis.org
This looks good to me.
Acked-by: Masami Hiramatsu mhiramat@kernel.org
Thank you!
.../test.d/dynevent/add_remove_eprobe.tc | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/dynevent/add_remove_eprobe.tc
diff --git a/tools/testing/selftests/ftrace/test.d/dynevent/add_remove_eprobe.tc b/tools/testing/selftests/ftrace/test.d/dynevent/add_remove_eprobe.tc new file mode 100644 index 000000000000..25a3da4eaa44 --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/dynevent/add_remove_eprobe.tc @@ -0,0 +1,40 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# description: Generic dynamic event - add/remove eprobe events +# requires: dynamic_events events/syscalls/sys_enter_openat "e[:[<group>/]<event>] <attached-group>.<attached-event> [<args>]":README
+echo 0 > events/enable
+clear_dynamic_events
+SYSTEM="syscalls" +EVENT="sys_enter_openat" +FIELD="filename" +EPROBE="eprobe_open"
+echo "e:$EPROBE $SYSTEM/$EVENT file=+0($filename):ustring" >> dynamic_events
+grep -q "$EPROBE" dynamic_events +test -d events/eprobes/$EPROBE
+echo 1 > events/eprobes/$EPROBE/enable +ls +echo 0 > events/eprobes/$EPROBE/enable
+content=`grep '^ *ls-' trace | grep 'file='` +nocontent=`grep '^ *ls-' trace | grep 'file=' | grep -v -e '"/' -e '"."'` || true
+if [ -z "$content" ]; then
- exit_fail
+fi
+if [ ! -z "$nocontent" ]; then
- exit_fail
+fi
+echo "-:$EPROBE" >> dynamic_events
+! grep -q "$EPROBE" dynamic_events +! test -d events/eprobes/$EPROBE
+clear_trace
2.30.2
linux-kselftest-mirror@lists.linaro.org