linux-trace-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>
Cc: linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org,
	Steven Rostedt <rostedt@goodmis.org>,
	Florent Revest <revest@chromium.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Will Deacon <will@kernel.org>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Martin KaFai Lau <martin.lau@linux.dev>,
	bpf@vger.kernel.org
Subject: Re: [PATCH v11 09/11] selftests/ftrace: Add tracepoint probe test case
Date: Wed, 17 May 2023 23:37:07 +0900	[thread overview]
Message-ID: <20230517233707.a3696258ea700925764586c1@kernel.org> (raw)
In-Reply-To: <168432121009.1351929.4077460131525842825.stgit@mhiramat.roam.corp.google.com>

On Wed, 17 May 2023 20:00:10 +0900
"Masami Hiramatsu (Google)" <mhiramat@kernel.org> wrote:

> From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> 
> Add test cases for tracepoint probe events.
> 
> Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> ---
>  .../ftrace/test.d/dynevent/add_remove_tprobe.tc    |   27 +++++++
>  .../ftrace/test.d/dynevent/tprobe_syntax_errors.tc |   82 ++++++++++++++++++++
>  2 files changed, 109 insertions(+)
>  create mode 100644 tools/testing/selftests/ftrace/test.d/dynevent/add_remove_tprobe.tc
>  create mode 100644 tools/testing/selftests/ftrace/test.d/dynevent/tprobe_syntax_errors.tc
> 
> diff --git a/tools/testing/selftests/ftrace/test.d/dynevent/add_remove_tprobe.tc b/tools/testing/selftests/ftrace/test.d/dynevent/add_remove_tprobe.tc
> new file mode 100644
> index 000000000000..afc8412fde6b
> --- /dev/null
> +++ b/tools/testing/selftests/ftrace/test.d/dynevent/add_remove_tprobe.tc
> @@ -0,0 +1,27 @@
> +#!/bin/sh
> +# SPDX-License-Identifier: GPL-2.0
> +# description: Generic dynamic event - add/remove tracepoint probe events
> +# requires: dynamic_events "t[:[<group>/][<event>]] <tracepoint> [<args>]": README

Hmm, there is a space between keyword and README, which allows selftests runs this
without fprobe. This needs to be fixed.

Thank you,

> +
> +echo 0 > events/enable
> +echo > dynamic_events
> +
> +TRACEPOINT1=kmem_cache_alloc
> +TRACEPOINT2=kmem_cache_free
> +
> +echo "t:myevent1 $TRACEPOINT1" >> dynamic_events
> +echo "t:myevent2 $TRACEPOINT2" >> dynamic_events
> +
> +grep -q myevent1 dynamic_events
> +grep -q myevent2 dynamic_events
> +test -d events/tracepoints/myevent1
> +test -d events/tracepoints/myevent2
> +
> +echo "-:myevent2" >> dynamic_events
> +
> +grep -q myevent1 dynamic_events
> +! grep -q myevent2 dynamic_events
> +
> +echo > dynamic_events
> +
> +clear_trace
> diff --git a/tools/testing/selftests/ftrace/test.d/dynevent/tprobe_syntax_errors.tc b/tools/testing/selftests/ftrace/test.d/dynevent/tprobe_syntax_errors.tc
> new file mode 100644
> index 000000000000..c8dac5c1cfa8
> --- /dev/null
> +++ b/tools/testing/selftests/ftrace/test.d/dynevent/tprobe_syntax_errors.tc
> @@ -0,0 +1,82 @@
> +#!/bin/sh
> +# SPDX-License-Identifier: GPL-2.0
> +# description: Tracepoint probe event parser error log check
> +# requires: dynamic_events "t[:[<group>/][<event>]] <tracepoint> [<args>]": README
> +
> +check_error() { # command-with-error-pos-by-^
> +    ftrace_errlog_check 'trace_fprobe' "$1" 'dynamic_events'
> +}
> +
> +check_error 't^100 kfree'		# BAD_MAXACT_TYPE
> +
> +check_error 't ^non_exist_tracepoint'	# NO_TRACEPOINT
> +check_error 't:^/bar kfree'		# NO_GROUP_NAME
> +check_error 't:^12345678901234567890123456789012345678901234567890123456789012345/bar kfree'	# GROUP_TOO_LONG
> +
> +check_error 't:^foo.1/bar kfree'	# BAD_GROUP_NAME
> +check_error 't:^ kfree'			# NO_EVENT_NAME
> +check_error 't:foo/^12345678901234567890123456789012345678901234567890123456789012345 kfree'	# EVENT_TOO_LONG
> +check_error 't:foo/^bar.1 kfree'	# BAD_EVENT_NAME
> +
> +check_error 't kfree ^$retval'		# RETVAL_ON_PROBE
> +check_error 't kfree ^$stack10000'	# BAD_STACK_NUM
> +
> +check_error 't kfree ^$arg10000'	# BAD_ARG_NUM
> +
> +check_error 't kfree ^$none_var'	# BAD_VAR
> +check_error 't kfree ^%rax'		# BAD_VAR
> +
> +check_error 't kfree ^@12345678abcde'	# BAD_MEM_ADDR
> +check_error 't kfree ^@+10'		# FILE_ON_KPROBE
> +
> +grep -q "imm-value" README && \
> +check_error 't kfree arg1=\^x'	# BAD_IMM
> +grep -q "imm-string" README && \
> +check_error 't kfree arg1=\"abcd^'	# IMMSTR_NO_CLOSE
> +
> +check_error 't kfree ^+0@0)'		# DEREF_NEED_BRACE
> +check_error 't kfree ^+0ab1(@0)'	# BAD_DEREF_OFFS
> +check_error 't kfree +0(+0(@0^)'	# DEREF_OPEN_BRACE
> +
> +if grep -A1 "fetcharg:" README | grep -q '\$comm' ; then
> +check_error 't kfree +0(^$comm)'	# COMM_CANT_DEREF
> +fi
> +
> +check_error 't kfree ^&1'		# BAD_FETCH_ARG
> +
> +
> +# We've introduced this limitation with array support
> +if grep -q ' <type>\\\[<array-size>\\\]' README; then
> +check_error 't kfree +0(^+0(+0(+0(+0(+0(+0(+0(+0(+0(+0(+0(+0(+0(@0))))))))))))))'	# TOO_MANY_OPS?
> +check_error 't kfree +0(@11):u8[10^'		# ARRAY_NO_CLOSE
> +check_error 't kfree +0(@11):u8[10]^a'		# BAD_ARRAY_SUFFIX
> +check_error 't kfree +0(@11):u8[^10a]'		# BAD_ARRAY_NUM
> +check_error 't kfree +0(@11):u8[^256]'		# ARRAY_TOO_BIG
> +fi
> +
> +check_error 't kfree @11:^unknown_type'		# BAD_TYPE
> +check_error 't kfree $stack0:^string'		# BAD_STRING
> +check_error 't kfree @11:^b10@a/16'		# BAD_BITFIELD
> +
> +check_error 't kfree ^arg123456789012345678901234567890=@11'	# ARG_NAME_TOO_LOG
> +check_error 't kfree ^=@11'			# NO_ARG_NAME
> +check_error 't kfree ^var.1=@11'		# BAD_ARG_NAME
> +check_error 't kfree var1=@11 ^var1=@12'	# USED_ARG_NAME
> +check_error 't kfree ^+1234567(+1234567(+1234567(+1234567(+1234567(+1234567(@1234))))))'	# ARG_TOO_LONG
> +check_error 't kfree arg1=^'			# NO_ARG_BODY
> +
> +
> +# multiprobe errors
> +if grep -q "Create/append/" README && grep -q "imm-value" README; then
> +echo "t:tracepoint/testevent kfree" > dynamic_events
> +check_error '^f:tracepoint/testevent kfree'	# DIFF_PROBE_TYPE
> +
> +# Explicitly use printf "%s" to not interpret \1
> +printf "%s" "t:tracepoints/testevent kfree abcd=\\1" > dynamic_events
> +check_error "t:tracepoints/testevent kfree ^bcd=\\1"	# DIFF_ARG_TYPE
> +check_error "t:tracepoints/testevent kfree ^abcd=\\1:u8"	# DIFF_ARG_TYPE
> +check_error "t:tracepoints/testevent kfree ^abcd=\\\"foo\"" # DIFF_ARG_TYPE
> +check_error "^t:tracepoints/testevent kfree abcd=\\1"	# SAME_PROBE
> +fi
> +
> +exit 0
> 


-- 
Masami Hiramatsu (Google) <mhiramat@kernel.org>

  reply	other threads:[~2023-05-17 14:37 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-17 10:58 [PATCH v11 00/11] tracing: Add fprobe/tracepoint events Masami Hiramatsu (Google)
2023-05-17 10:58 ` [PATCH v11 01/11] fprobe: Pass return address to the handlers Masami Hiramatsu (Google)
2023-05-17 10:59 ` [PATCH v11 02/11] tracing/probes: Add fprobe events for tracing function entry and exit Masami Hiramatsu (Google)
2023-06-08 20:52   ` Steven Rostedt
2023-07-07 14:17     ` Masami Hiramatsu
2023-05-17 10:59 ` [PATCH v11 03/11] selftests/ftrace: Add fprobe related testcases Masami Hiramatsu (Google)
2023-05-17 10:59 ` [PATCH v11 04/11] tracing/probes: Add tracepoint support on fprobe_events Masami Hiramatsu (Google)
2023-05-17 10:59 ` [PATCH v11 05/11] tracing/probes: Move event parameter fetching code to common parser Masami Hiramatsu (Google)
2023-05-17 10:59 ` [PATCH v11 06/11] tracing/probes: Support function parameters if BTF is available Masami Hiramatsu (Google)
2023-05-17 10:59 ` [PATCH v11 07/11] tracing/probes: Add $arg* meta argument for all function args Masami Hiramatsu (Google)
2023-05-17 11:00 ` [PATCH v11 08/11] tracing/probes: Add BTF retval type support Masami Hiramatsu (Google)
2023-05-17 11:00 ` [PATCH v11 09/11] selftests/ftrace: Add tracepoint probe test case Masami Hiramatsu (Google)
2023-05-17 14:37   ` Masami Hiramatsu [this message]
2023-05-17 11:00 ` [PATCH v11 10/11] selftests/ftrace: Add BTF arguments test cases Masami Hiramatsu (Google)
2023-05-17 11:00 ` [PATCH v11 11/11] Documentation: tracing/probes: Add fprobe event tracing document Masami Hiramatsu (Google)
2023-05-17 13:05   ` Bagas Sanjaya
2023-05-17 14:39     ` Masami Hiramatsu

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=20230517233707.a3696258ea700925764586c1@kernel.org \
    --to=mhiramat@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=martin.lau@linux.dev \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=revest@chromium.org \
    --cc=rostedt@goodmis.org \
    --cc=will@kernel.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;
as well as URLs for NNTP newsgroup(s).