public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Masami Hiramatsu <mhiramat@kernel.org>
To: Steven Rostedt <rostedt@goodmis.org>,
	Jonathan Corbet <corbet@lwn.net>,
	Shuah Khan <skhan@linuxfoundation.org>
Cc: mhiramat@kernel.org, linux-kernel@vger.kernel.org,
	linux-doc@vger.kernel.org, Randy Dunlap <rdunlap@infradead.org>,
	Ingo Molnar <mingo@kernel.org>,
	linux-kselftest@vger.kernel.org
Subject: [PATCH v3 8/8] selftests/ftrace: Add %return suffix tests
Date: Thu, 10 Sep 2020 17:56:16 +0900	[thread overview]
Message-ID: <159972817653.428528.9180599115849301184.stgit@devnote2> (raw)
In-Reply-To: <159972809455.428528.4737752126800169128.stgit@devnote2>

Add kprobe %return suffix testcase and syntax error tests
for %return suffix.

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
---
 .../ftrace/test.d/kprobe/kprobe_syntax_errors.tc   |    6 ++++++
 .../test.d/kprobe/kretprobe_return_suffix.tc       |   21 ++++++++++++++++++++
 .../ftrace/test.d/kprobe/uprobe_syntax_errors.tc   |    6 ++++++
 3 files changed, 33 insertions(+)
 create mode 100644 tools/testing/selftests/ftrace/test.d/kprobe/kretprobe_return_suffix.tc

diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_syntax_errors.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_syntax_errors.tc
index b4d834675e59..56b3f36c722b 100644
--- a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_syntax_errors.tc
+++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_syntax_errors.tc
@@ -97,4 +97,10 @@ check_error 'p:kprobes/testevent _do_fork ^abcd=\"foo"'	# DIFF_ARG_TYPE
 check_error '^p:kprobes/testevent _do_fork abcd=\1'	# SAME_PROBE
 fi
 
+# %return suffix errors
+if grep -q "place (kretprobe): .*%return.*" README; then
+check_error 'p vfs_read^%hoge'		# BAD_ADDR_SUFFIX
+check_error 'p ^vfs_read+10%return'	# BAD_RETPROBE
+fi
+
 exit 0
diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kretprobe_return_suffix.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kretprobe_return_suffix.tc
new file mode 100644
index 000000000000..f07bd15cc033
--- /dev/null
+++ b/tools/testing/selftests/ftrace/test.d/kprobe/kretprobe_return_suffix.tc
@@ -0,0 +1,21 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+# description: Kretprobe %%return suffix test
+# requires: kprobe_events '<symbol>[+<offset>]%return':README
+
+# Test for kretprobe by "r"
+echo 'r:myprobeaccept vfs_read' > kprobe_events
+RESULT1=`cat kprobe_events`
+
+# Test for kretprobe by "%return"
+echo 'p:myprobeaccept vfs_read%return' > kprobe_events
+RESULT2=`cat kprobe_events`
+
+if [ "$RESULT1" != "$RESULT2" ]; then
+	echo "Error: %return suffix didn't make a return probe."
+	echo "r-command: $RESULT1"
+	echo "%return: $RESULT2"
+	exit_fail
+fi
+
+echo > kprobe_events
diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/uprobe_syntax_errors.tc b/tools/testing/selftests/ftrace/test.d/kprobe/uprobe_syntax_errors.tc
index 7b5b60c3c5a2..f5e3f9e4a01f 100644
--- a/tools/testing/selftests/ftrace/test.d/kprobe/uprobe_syntax_errors.tc
+++ b/tools/testing/selftests/ftrace/test.d/kprobe/uprobe_syntax_errors.tc
@@ -17,4 +17,10 @@ check_error 'p /bin/sh:10(10)^a'	# BAD_REFCNT_SUFFIX
 check_error 'p /bin/sh:10 ^@+ab'	# BAD_FILE_OFFS
 check_error 'p /bin/sh:10 ^@symbol'	# SYM_ON_UPROBE
 
+# %return suffix error
+if grep -q "place (uprobe): .*%return.*" README; then
+check_error 'p /bin/sh:10^%hoge'	# BAD_ADDR_SUFFIX
+check_error 'p /bin/sh:10(10)^%return'	# BAD_REFCNT_SUFFIX
+fi
+
 exit 0


  parent reply	other threads:[~2020-09-10  8:58 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-10  8:54 [PATCH v3 0/8] tracing/boot: Add new options for tracing specific period Masami Hiramatsu
2020-09-10  8:55 ` [PATCH v3 1/8] kprobes: tracing/kprobes: Fix to kill kprobes on initmem after boot Masami Hiramatsu
2020-09-10  8:55 ` [PATCH v3 2/8] tracing/boot: Add per-instance tracing_on option support Masami Hiramatsu
2020-09-10  8:55 ` [PATCH v3 3/8] Documentation: tracing: Add tracing_on option to boot-time tracer Masami Hiramatsu
2020-09-10 13:26   ` Bird, Tim
2020-09-10 22:41     ` Masami Hiramatsu
2020-09-11  0:47       ` [PATCH v3.1 " Masami Hiramatsu
2020-09-10  8:55 ` [PATCH v3 4/8] tracing/kprobes: Support perf-style return probe Masami Hiramatsu
2020-09-10  8:55 ` [PATCH v3 5/8] tracing/uprobes: " Masami Hiramatsu
2020-09-10  8:55 ` [PATCH v3 6/8] Documentation: tracing: Add %return suffix description Masami Hiramatsu
2020-09-10  8:56 ` [PATCH v3 7/8] Documentation: tracing: boot: Add an example of tracing function-calls Masami Hiramatsu
2020-09-10  8:56 ` Masami Hiramatsu [this message]
2020-09-10 23:34 ` [PATCH v3 0/8] tracing/boot: Add new options for tracing specific period Steven Rostedt
2020-09-11  1:27   ` Masami Hiramatsu
2020-09-11  1:34     ` Shuah Khan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=159972817653.428528.9180599115849301184.stgit@devnote2 \
    --to=mhiramat@kernel.org \
    --cc=corbet@lwn.net \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=rdunlap@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=skhan@linuxfoundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox