2022-06-06 16:27:23

by Jeff Xie

[permalink] [raw]
Subject: [PATCH v12 3/4] trace/objtrace: Add testcases for objtrace

Add a series of testcases to illustrate correct and incorrect usage of
objtrace trigger.

Signed-off-by: Jeff Xie <[email protected]>
---
.../ftrace/test.d/trigger/trigger-objtrace.tc | 41 +++++++++++++++++++
1 file changed, 41 insertions(+)
create mode 100644 tools/testing/selftests/ftrace/test.d/trigger/trigger-objtrace.tc

diff --git a/tools/testing/selftests/ftrace/test.d/trigger/trigger-objtrace.tc b/tools/testing/selftests/ftrace/test.d/trigger/trigger-objtrace.tc
new file mode 100644
index 000000000000..d894442b6a30
--- /dev/null
+++ b/tools/testing/selftests/ftrace/test.d/trigger/trigger-objtrace.tc
@@ -0,0 +1,41 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+# description: event trigger - test objtrace-trigger
+# requires: kprobe_events "objtrace":README
+
+fail() { #msg
+ echo $1
+ exit_fail
+}
+
+echo 'p bio_add_page arg1=$arg1 arg2=$arg2' > kprobe_events
+
+FEATURE=`grep objtrace events/kprobes/p_bio_add_page_0/trigger`
+if [ -z "$FEATURE" ]; then
+ echo "objtrace trigger is not supported"
+ exit_unsupported
+fi
+
+echo "Test objtrace trigger"
+echo 'objtrace:add:arg1,0x28:u32:1 if comm == "cat"' > \
+ events/kprobes/p_bio_add_page_0/trigger
+if [ -z $? ]; then
+ fail "objtrace trigger syntax error"
+fi
+
+echo "Test objtrace semantic errors"
+
+# Being lack of objtrace command
+! echo 'objtrace:arg1,0x28:u32:1' > events/kprobes/p_bio_add_page_0/trigger
+# Bad parameter name
+! echo 'objtrace:add:argx:u32:1' > events/kprobes/p_bio_add_page_0/trigger
+# The parameter existed on event
+! echo 'objtrace:add:arg2:u32:1' > events/kprobes/p_bio_add_page_0/trigger
+
+echo "reset objtrace trigger"
+
+echo '!objtrace:add:arg1,0x28:u32' > \
+ events/kprobes/p_bio_add_page_0/trigger
+echo '-:p_bio_add_page_0' >> ./kprobe_events
+
+exit 0
--
2.25.1


2022-06-25 16:27:16

by Masami Hiramatsu

[permalink] [raw]
Subject: Re: [PATCH v12 3/4] trace/objtrace: Add testcases for objtrace

Hi,

This looks good to me (and I tested).

Tested-by: Masami Hiramatsu (Google) <[email protected]>
Acked-by: Masami Hiramatsu (Google) <[email protected]>

BTW, please use 'selftests/ftrace:' tag instead of (or in addition to)
'trace/objtrace:' for the ftracetest patch. And please Cc to
[email protected] and Shuah Khan.

Thank you,

On Tue, 7 Jun 2022 00:09:42 +0800
Jeff Xie <[email protected]> wrote:

> Add a series of testcases to illustrate correct and incorrect usage of
> objtrace trigger.
>
> Signed-off-by: Jeff Xie <[email protected]>
> ---
> .../ftrace/test.d/trigger/trigger-objtrace.tc | 41 +++++++++++++++++++
> 1 file changed, 41 insertions(+)
> create mode 100644 tools/testing/selftests/ftrace/test.d/trigger/trigger-objtrace.tc
>
> diff --git a/tools/testing/selftests/ftrace/test.d/trigger/trigger-objtrace.tc b/tools/testing/selftests/ftrace/test.d/trigger/trigger-objtrace.tc
> new file mode 100644
> index 000000000000..d894442b6a30
> --- /dev/null
> +++ b/tools/testing/selftests/ftrace/test.d/trigger/trigger-objtrace.tc
> @@ -0,0 +1,41 @@
> +#!/bin/sh
> +# SPDX-License-Identifier: GPL-2.0
> +# description: event trigger - test objtrace-trigger
> +# requires: kprobe_events "objtrace":README
> +
> +fail() { #msg
> + echo $1
> + exit_fail
> +}
> +
> +echo 'p bio_add_page arg1=$arg1 arg2=$arg2' > kprobe_events
> +
> +FEATURE=`grep objtrace events/kprobes/p_bio_add_page_0/trigger`
> +if [ -z "$FEATURE" ]; then
> + echo "objtrace trigger is not supported"
> + exit_unsupported
> +fi
> +
> +echo "Test objtrace trigger"
> +echo 'objtrace:add:arg1,0x28:u32:1 if comm == "cat"' > \
> + events/kprobes/p_bio_add_page_0/trigger
> +if [ -z $? ]; then
> + fail "objtrace trigger syntax error"
> +fi
> +
> +echo "Test objtrace semantic errors"
> +
> +# Being lack of objtrace command
> +! echo 'objtrace:arg1,0x28:u32:1' > events/kprobes/p_bio_add_page_0/trigger
> +# Bad parameter name
> +! echo 'objtrace:add:argx:u32:1' > events/kprobes/p_bio_add_page_0/trigger
> +# The parameter existed on event
> +! echo 'objtrace:add:arg2:u32:1' > events/kprobes/p_bio_add_page_0/trigger
> +
> +echo "reset objtrace trigger"
> +
> +echo '!objtrace:add:arg1,0x28:u32' > \
> + events/kprobes/p_bio_add_page_0/trigger
> +echo '-:p_bio_add_page_0' >> ./kprobe_events
> +
> +exit 0
> --
> 2.25.1
>


--
Masami Hiramatsu (Google) <[email protected]>

2022-06-25 17:29:28

by Jeff Xie

[permalink] [raw]
Subject: Re: [PATCH v12 3/4] trace/objtrace: Add testcases for objtrace

Hi Masami,

On Sun, Jun 26, 2022 at 12:03 AM Masami Hiramatsu <[email protected]> wrote:
>
> Hi,
>
> This looks good to me (and I tested).
>
> Tested-by: Masami Hiramatsu (Google) <[email protected]>
> Acked-by: Masami Hiramatsu (Google) <[email protected]>
>
> BTW, please use 'selftests/ftrace:' tag instead of (or in addition to)
> 'trace/objtrace:' for the ftracetest patch. And please Cc to
> [email protected] and Shuah Khan.

Thanks for the reminder, I will do it like this in my next version.

> Thank you,
>
> On Tue, 7 Jun 2022 00:09:42 +0800
> Jeff Xie <[email protected]> wrote:
>
> > Add a series of testcases to illustrate correct and incorrect usage of
> > objtrace trigger.
> >
> > Signed-off-by: Jeff Xie <[email protected]>
> > ---
> > .../ftrace/test.d/trigger/trigger-objtrace.tc | 41 +++++++++++++++++++
> > 1 file changed, 41 insertions(+)
> > create mode 100644 tools/testing/selftests/ftrace/test.d/trigger/trigger-objtrace.tc
> >
> > diff --git a/tools/testing/selftests/ftrace/test.d/trigger/trigger-objtrace.tc b/tools/testing/selftests/ftrace/test.d/trigger/trigger-objtrace.tc
> > new file mode 100644
> > index 000000000000..d894442b6a30
> > --- /dev/null
> > +++ b/tools/testing/selftests/ftrace/test.d/trigger/trigger-objtrace.tc
> > @@ -0,0 +1,41 @@
> > +#!/bin/sh
> > +# SPDX-License-Identifier: GPL-2.0
> > +# description: event trigger - test objtrace-trigger
> > +# requires: kprobe_events "objtrace":README
> > +
> > +fail() { #msg
> > + echo $1
> > + exit_fail
> > +}
> > +
> > +echo 'p bio_add_page arg1=$arg1 arg2=$arg2' > kprobe_events
> > +
> > +FEATURE=`grep objtrace events/kprobes/p_bio_add_page_0/trigger`
> > +if [ -z "$FEATURE" ]; then
> > + echo "objtrace trigger is not supported"
> > + exit_unsupported
> > +fi
> > +
> > +echo "Test objtrace trigger"
> > +echo 'objtrace:add:arg1,0x28:u32:1 if comm == "cat"' > \
> > + events/kprobes/p_bio_add_page_0/trigger
> > +if [ -z $? ]; then
> > + fail "objtrace trigger syntax error"
> > +fi
> > +
> > +echo "Test objtrace semantic errors"
> > +
> > +# Being lack of objtrace command
> > +! echo 'objtrace:arg1,0x28:u32:1' > events/kprobes/p_bio_add_page_0/trigger
> > +# Bad parameter name
> > +! echo 'objtrace:add:argx:u32:1' > events/kprobes/p_bio_add_page_0/trigger
> > +# The parameter existed on event
> > +! echo 'objtrace:add:arg2:u32:1' > events/kprobes/p_bio_add_page_0/trigger
> > +
> > +echo "reset objtrace trigger"
> > +
> > +echo '!objtrace:add:arg1,0x28:u32' > \
> > + events/kprobes/p_bio_add_page_0/trigger
> > +echo '-:p_bio_add_page_0' >> ./kprobe_events
> > +
> > +exit 0
> > --
> > 2.25.1
> >
>
>
> --
> Masami Hiramatsu (Google) <[email protected]>

Thanks,
JeffXie

2022-06-27 20:02:48

by Shuah Khan

[permalink] [raw]
Subject: Re: [PATCH v12 3/4] trace/objtrace: Add testcases for objtrace

On 6/25/22 11:05 AM, Jeff Xie wrote:
> Hi Masami,
>
> On Sun, Jun 26, 2022 at 12:03 AM Masami Hiramatsu <[email protected]> wrote:
>>
>> Hi,
>>
>> This looks good to me (and I tested).
>>
>> Tested-by: Masami Hiramatsu (Google) <[email protected]>
>> Acked-by: Masami Hiramatsu (Google) <[email protected]>
>>
>> BTW, please use 'selftests/ftrace:' tag instead of (or in addition to)
>> 'trace/objtrace:' for the ftracetest patch. And please Cc to
>> [email protected] and Shuah Khan.
>
> Thanks for the reminder, I will do it like this in my next version.
>

Yes. Please. It isn't my Inbox or patchwork ... Send v2 with Masami's
Tested-by and Ack so I can pull this in.

thanks,
-- Shuah