diff mbox series

selftests/uprobes: Add a basic uprobe testcase

Message ID 171651179523.161068.3164659198838770307.stgit@devnote2 (mailing list archive)
State Accepted
Commit 98f8faea4b6379de2c1483125253b73f7449e6b6
Headers show
Series selftests/uprobes: Add a basic uprobe testcase | expand

Commit Message

Masami Hiramatsu (Google) May 24, 2024, 12:49 a.m. UTC
From: Masami Hiramatsu (Google) <mhiramat@kernel.org>

Add a basic uprobe testcase which checks whether add/remove/trace
operations works on /bin/sh.

Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
---
 .../ftrace/test.d/dynevent/add_remove_uprobe.tc    |   26 ++++++++++++++++++++
 1 file changed, 26 insertions(+)
 create mode 100644 tools/testing/selftests/ftrace/test.d/dynevent/add_remove_uprobe.tc

Comments

Steven Rostedt Aug. 7, 2024, 8:36 p.m. UTC | #1
On Fri, 24 May 2024 09:49:55 +0900
"Masami Hiramatsu (Google)" <mhiramat@kernel.org> wrote:

> From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> 
> Add a basic uprobe testcase which checks whether add/remove/trace
> operations works on /bin/sh.
> 
> Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>

Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org>

Shuah, can you take this too.

-- Steve

> ---
>  .../ftrace/test.d/dynevent/add_remove_uprobe.tc    |   26 ++++++++++++++++++++
>  1 file changed, 26 insertions(+)
>  create mode 100644 tools/testing/selftests/ftrace/test.d/dynevent/add_remove_uprobe.tc
> 
> diff --git a/tools/testing/selftests/ftrace/test.d/dynevent/add_remove_uprobe.tc b/tools/testing/selftests/ftrace/test.d/dynevent/add_remove_uprobe.tc
> new file mode 100644
> index 000000000000..a275decdc880
> --- /dev/null
> +++ b/tools/testing/selftests/ftrace/test.d/dynevent/add_remove_uprobe.tc
> @@ -0,0 +1,26 @@
> +#!/bin/sh
> +# SPDX-License-Identifier: GPL-2.0
> +# description: Generic dynamic event - add/remove/test uprobe events
> +# requires: uprobe_events
> +
> +echo 0 > events/enable
> +echo > dynamic_events
> +
> +echo 'cat /proc/$$/maps' | /bin/sh | \
> +	grep "r-xp .*/bin/.*sh$" | \
> +	awk '{printf "p:myevent %s:0x%s\n", $6,$3 }' >> uprobe_events
> +
> +grep -q myevent uprobe_events
> +test -d events/uprobes/myevent
> +
> +echo 1 > events/uprobes/myevent/enable
> +echo 'ls' | /bin/sh > /dev/null
> +echo 0 > events/uprobes/myevent/enable
> +grep -q myevent trace
> +
> +echo "-:myevent" >> uprobe_events
> +! grep -q myevent uprobe_events
> +
> +echo > uprobe_events
> +
> +clear_trace
Shuah Khan Aug. 7, 2024, 8:46 p.m. UTC | #2
On 8/7/24 14:36, Steven Rostedt wrote:
> On Fri, 24 May 2024 09:49:55 +0900
> "Masami Hiramatsu (Google)" <mhiramat@kernel.org> wrote:
> 
>> From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
>>
>> Add a basic uprobe testcase which checks whether add/remove/trace
>> operations works on /bin/sh.
>>
>> Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> 
> Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org>
> 
> Shuah, can you take this too.

Yes.

> 
> -- Steve

Applied to linux-kselftest next for Linux 6.12-rc1.

thanks,
-- Shuah
diff mbox series

Patch

diff --git a/tools/testing/selftests/ftrace/test.d/dynevent/add_remove_uprobe.tc b/tools/testing/selftests/ftrace/test.d/dynevent/add_remove_uprobe.tc
new file mode 100644
index 000000000000..a275decdc880
--- /dev/null
+++ b/tools/testing/selftests/ftrace/test.d/dynevent/add_remove_uprobe.tc
@@ -0,0 +1,26 @@ 
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+# description: Generic dynamic event - add/remove/test uprobe events
+# requires: uprobe_events
+
+echo 0 > events/enable
+echo > dynamic_events
+
+echo 'cat /proc/$$/maps' | /bin/sh | \
+	grep "r-xp .*/bin/.*sh$" | \
+	awk '{printf "p:myevent %s:0x%s\n", $6,$3 }' >> uprobe_events
+
+grep -q myevent uprobe_events
+test -d events/uprobes/myevent
+
+echo 1 > events/uprobes/myevent/enable
+echo 'ls' | /bin/sh > /dev/null
+echo 0 > events/uprobes/myevent/enable
+grep -q myevent trace
+
+echo "-:myevent" >> uprobe_events
+! grep -q myevent uprobe_events
+
+echo > uprobe_events
+
+clear_trace