Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753340AbbG0Jgl (ORCPT ); Mon, 27 Jul 2015 05:36:41 -0400 Received: from mail-pa0-f53.google.com ([209.85.220.53]:34003 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750883AbbG0Jgj (ORCPT ); Mon, 27 Jul 2015 05:36:39 -0400 Date: Mon, 27 Jul 2015 18:34:11 +0900 From: Namhyung Kim To: Masami Hiramatsu Cc: Steven Rostedt , Tom Zanussi , linux-api@vger.kernel.org, Shuah Khan , linux-kernel@vger.kernel.org, Ingo Molnar Subject: Re: [PATCH] kselftests/ftrace : Add event trigger testcases Message-ID: <20150727093411.GE22022@danjae.kornet> References: <20150725011310.4601.76087.stgit@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20150725011310.4601.76087.stgit@localhost.localdomain> User-Agent: Mutt/1.5.23+102 (2ca89bed6448) (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 12450 Lines: 393 Hi Masami, On Sat, Jul 25, 2015 at 10:13:10AM +0900, Masami Hiramatsu wrote: > This adds simple event trigger testcases for ftracetest, > which covers following triggers. > - traceon-traceoff trigger > - enable/disable_event trigger > - snapshot trigger > - stacktrace trigger > - trigger filters > > Signed-off-by: Masami Hiramatsu > Cc: Steven Rostedt > Cc: Ingo Molnar > Cc: Shuah Khan > Cc: Namhyung Kim > Cc: Tom Zanussi > --- > tools/testing/selftests/ftrace/test.d/functions | 9 +++ > .../ftrace/test.d/trigger/trigger-eventonoff.tc | 64 ++++++++++++++++++++ > .../ftrace/test.d/trigger/trigger-filter.tc | 59 ++++++++++++++++++ > .../ftrace/test.d/trigger/trigger-snapshot.tc | 56 ++++++++++++++++++ > .../ftrace/test.d/trigger/trigger-stacktrace.tc | 53 +++++++++++++++++ > .../ftrace/test.d/trigger/trigger-traceonoff.tc | 58 ++++++++++++++++++ > 6 files changed, 299 insertions(+) > create mode 100644 tools/testing/selftests/ftrace/test.d/trigger/trigger-eventonoff.tc > create mode 100644 tools/testing/selftests/ftrace/test.d/trigger/trigger-filter.tc > create mode 100644 tools/testing/selftests/ftrace/test.d/trigger/trigger-snapshot.tc > create mode 100644 tools/testing/selftests/ftrace/test.d/trigger/trigger-stacktrace.tc > create mode 100644 tools/testing/selftests/ftrace/test.d/trigger/trigger-traceonoff.tc > > diff --git a/tools/testing/selftests/ftrace/test.d/functions b/tools/testing/selftests/ftrace/test.d/functions > index 5d8cd06..36ca18e 100644 > --- a/tools/testing/selftests/ftrace/test.d/functions > +++ b/tools/testing/selftests/ftrace/test.d/functions > @@ -14,3 +14,12 @@ enable_tracing() { # start trace recording > reset_tracer() { # reset the current tracer > echo nop > current_tracer > } > + > +reset_trigger() { # reset all current setting triggers > + grep -v ^# events/*/*/trigger | > + while read line; do > + cmd=`echo $line | cut -f2- -d:` > + echo "!$cmd" > `echo $line | cut -f1 -d:` Broken whitespaces? > + done > +} > + > diff --git a/tools/testing/selftests/ftrace/test.d/trigger/trigger-eventonoff.tc b/tools/testing/selftests/ftrace/test.d/trigger/trigger-eventonoff.tc > new file mode 100644 > index 0000000..1a94450 > --- /dev/null > +++ b/tools/testing/selftests/ftrace/test.d/trigger/trigger-eventonoff.tc > @@ -0,0 +1,64 @@ > +#!/bin/sh > +# description: event trigger - test event enable/disable trigger > + > +do_reset() { > + reset_trigger > + echo > set_event > + clear_trace > +} > + > +fail() { #msg > + do_reset > + echo $1 > + exit $FAIL > +} > + > +if [ ! -f set_event -o ! -d events/sched ]; then > + echo "event tracing is not supported" > + exit_unsupported > +fi > + > +if [ ! -f events/sched/sched_process_fork/trigger ]; then > + echo "event trigger is not supported" > + exit_unsupported > +fi > + > +reset_tracer > +do_reset > + > +FEATURE=`grep enable_event events/sched/sched_process_fork/trigger` > +if [ -z "$FEATURE" ]; then > + echo "event enable/disable trigger is not supported" > + exit_unsupported > +fi > + > +echo "Test enable_event trigger" > +echo 0 > events/sched/sched_switch/enable > +echo 'enable_event:sched:sched_switch' > events/sched/sched_process_fork/trigger > +( echo "forked") > +if [ `cat events/sched/sched_switch/enable` != '1*' ]; then > + fail "enable_event trigger on sched_process_fork did not work" > +fi > + > +reset_trigger > + > +echo "Test disable_event trigger" > +echo 1 > events/sched/sched_switch/enable > +echo 'disable_event:sched:sched_switch' > events/sched/sched_process_fork/trigger > +( echo "forked") > +if [ `cat events/sched/sched_switch/enable` != '0*' ]; then > + fail "disable_event trigger on sched_process_fork did not work" > +fi > + > +reset_trigger > + > +echo "Test semantic error for event enable/disable trigger" > +! echo 'enable_event:nogroup:noevent' > events/sched/sched_process_fork/trigger > +! echo 'disable_event+1' > events/sched/sched_process_fork/trigger > +echo 'enable_event:sched:sched_switch' > events/sched/sched_process_fork/trigger > +! echo 'enable_event:sched:sched_switch' > events/sched/sched_process_fork/trigger > +! echo 'disable_event:sched:sched_switch' > events/sched/sched_process_fork/trigger I don't know whether the '!' sign works for all shells. Btw, what is the last two lines for? > + > +do_reset > + > +exit 0 > diff --git a/tools/testing/selftests/ftrace/test.d/trigger/trigger-filter.tc b/tools/testing/selftests/ftrace/test.d/trigger/trigger-filter.tc > new file mode 100644 > index 0000000..514e466 > --- /dev/null > +++ b/tools/testing/selftests/ftrace/test.d/trigger/trigger-filter.tc > @@ -0,0 +1,59 @@ > +#!/bin/sh > +# description: event trigger - test trigger filter > + > +do_reset() { > + reset_trigger > + echo > set_event > + clear_trace > +} > + > +fail() { #msg > + do_reset > + echo $1 > + exit $FAIL > +} > + > +if [ ! -f set_event -o ! -d events/sched ]; then > + echo "event tracing is not supported" > + exit_unsupported > +fi > + > +if [ ! -f events/sched/sched_process_fork/trigger ]; then > + echo "event trigger is not supported" > + exit_unsupported > +fi > + > +reset_tracer > +do_reset > + > +echo "Test trigger filter" > +echo 1 > tracing_on > +echo 'traceoff if child_pid == 0' > events/sched/sched_process_fork/trigger What about checking child_comm too to verify complex filter pattern with string type? Maybe something like below (not tested..)? echo 'traceoff if child_pid != 0 && child_comm ~ '*sh' > events/.../trigger Thanks, Namhyung > +( echo "forked") > +if [ `cat tracing_on` -ne 1 ]; then > + fail "traceoff trigger on sched_process_fork did not work" > +fi > + > +reset_trigger > + > +echo "Test semantic error for trigger filter" > +! echo 'traceoff if a' > events/sched/sched_process_fork/trigger > +! echo 'traceoff if common_pid=0' > events/sched/sched_process_fork/trigger > +! echo 'traceoff if common_pid==b' > events/sched/sched_process_fork/trigger > +echo 'traceoff if common_pid == 0' > events/sched/sched_process_fork/trigger > +echo '!traceoff' > events/sched/sched_process_fork/trigger > +! echo 'traceoff if common_pid == child_pid' > events/sched/sched_process_fork/trigger > +echo 'traceoff if common_pid <= 0' > events/sched/sched_process_fork/trigger > +echo '!traceoff' > events/sched/sched_process_fork/trigger > +echo 'traceoff if common_pid >= 0' > events/sched/sched_process_fork/trigger > +echo '!traceoff' > events/sched/sched_process_fork/trigger > +echo 'traceoff if parent_pid >= 0 && child_pid >= 0' > events/sched/sched_process_fork/trigger > +echo '!traceoff' > events/sched/sched_process_fork/trigger > +echo 'traceoff if parent_pid >= 0 || child_pid >= 0' > events/sched/sched_process_fork/trigger > +echo '!traceoff' > events/sched/sched_process_fork/trigger > + > + > + > +do_reset > + > +exit 0 > diff --git a/tools/testing/selftests/ftrace/test.d/trigger/trigger-snapshot.tc b/tools/testing/selftests/ftrace/test.d/trigger/trigger-snapshot.tc > new file mode 100644 > index 0000000..f84b80d > --- /dev/null > +++ b/tools/testing/selftests/ftrace/test.d/trigger/trigger-snapshot.tc > @@ -0,0 +1,56 @@ > +#!/bin/sh > +# description: event trigger - test snapshot-trigger > + > +do_reset() { > + reset_trigger > + echo > set_event > + clear_trace > +} > + > +fail() { #msg > + do_reset > + echo $1 > + exit $FAIL > +} > + > +if [ ! -f set_event -o ! -d events/sched ]; then > + echo "event tracing is not supported" > + exit_unsupported > +fi > + > +if [ ! -f events/sched/sched_process_fork/trigger ]; then > + echo "event trigger is not supported" > + exit_unsupported > +fi > + > +reset_tracer > +do_reset > + > +FEATURE=`grep snapshot events/sched/sched_process_fork/trigger` > +if [ -z "$FEATURE" ]; then > + echo "snapshot trigger is not supported" > + exit_unsupported > +fi > + > +echo "Test snapshot tigger" > +echo 0 > snapshot > +echo 1 > events/sched/sched_process_fork/enable > +( echo "forked") > +echo 'snapshot:1' > events/sched/sched_process_fork/trigger > +( echo "forked") > +grep sched_process_fork snapshot > /dev/null || \ > + fail "snapshot trigger on sched_process_fork did not work" > + > +reset_trigger > +echo 0 > snapshot > +echo 0 > events/sched/sched_process_fork/enable > + > +echo "Test snapshot semantic errors" > + > +! echo "snapshot+1" > events/sched/sched_process_fork/trigger > +echo "snapshot" > events/sched/sched_process_fork/trigger > +! echo "snapshot" > events/sched/sched_process_fork/trigger > + > +do_reset > + > +exit 0 > diff --git a/tools/testing/selftests/ftrace/test.d/trigger/trigger-stacktrace.tc b/tools/testing/selftests/ftrace/test.d/trigger/trigger-stacktrace.tc > new file mode 100644 > index 0000000..9fa23b0 > --- /dev/null > +++ b/tools/testing/selftests/ftrace/test.d/trigger/trigger-stacktrace.tc > @@ -0,0 +1,53 @@ > +#!/bin/sh > +# description: event trigger - test stacktrace-trigger > + > +do_reset() { > + reset_trigger > + echo > set_event > + clear_trace > +} > + > +fail() { #msg > + do_reset > + echo $1 > + exit $FAIL > +} > + > +if [ ! -f set_event -o ! -d events/sched ]; then > + echo "event tracing is not supported" > + exit_unsupported > +fi > + > +if [ ! -f events/sched/sched_process_fork/trigger ]; then > + echo "event trigger is not supported" > + exit_unsupported > +fi > + > +reset_tracer > +do_reset > + > +FEATURE=`grep stacktrace events/sched/sched_process_fork/trigger` > +if [ -z "$FEATURE" ]; then > + echo "stacktrace trigger is not supported" > + exit_unsupported > +fi > + > +echo "Test stacktrace tigger" > +echo 0 > trace > +echo 0 > options/stacktrace > +echo 'stacktrace' > events/sched/sched_process_fork/trigger > +( echo "forked") > +grep "" trace > /dev/null || \ > + fail "stacktrace trigger on sched_process_fork did not work" > + > +reset_trigger > + > +echo "Test stacktrace semantic errors" > + > +! echo "stacktrace:foo" > events/sched/sched_process_fork/trigger > +echo "stacktrace" > events/sched/sched_process_fork/trigger > +! echo "stacktrace" > events/sched/sched_process_fork/trigger > + > +do_reset > + > +exit 0 > diff --git a/tools/testing/selftests/ftrace/test.d/trigger/trigger-traceonoff.tc b/tools/testing/selftests/ftrace/test.d/trigger/trigger-traceonoff.tc > new file mode 100644 > index 0000000..87648e5 > --- /dev/null > +++ b/tools/testing/selftests/ftrace/test.d/trigger/trigger-traceonoff.tc > @@ -0,0 +1,58 @@ > +#!/bin/sh > +# description: event trigger - test traceon/off trigger > + > +do_reset() { > + reset_trigger > + echo > set_event > + clear_trace > +} > + > +fail() { #msg > + do_reset > + echo $1 > + exit $FAIL > +} > + > +if [ ! -f set_event -o ! -d events/sched ]; then > + echo "event tracing is not supported" > + exit_unsupported > +fi > + > +if [ ! -f events/sched/sched_process_fork/trigger ]; then > + echo "event trigger is not supported" > + exit_unsupported > +fi > + > +reset_tracer > +do_reset > + > +echo "Test traceoff trigger" > +echo 1 > tracing_on > +echo 'traceoff' > events/sched/sched_process_fork/trigger > +( echo "forked") > +if [ `cat tracing_on` -ne 0 ]; then > + fail "traceoff trigger on sched_process_fork did not work" > +fi > + > +reset_trigger > + > +echo "Test traceon trigger" > +echo 0 > tracing_on > +echo 'traceon' > events/sched/sched_process_fork/trigger > +( echo "forked") > +if [ `cat tracing_on` -ne 1 ]; then > + fail "traceoff trigger on sched_process_fork did not work" > +fi > + > +reset_trigger > + > +echo "Test semantic error for traceoff/on trigger" > +! echo 'traceoff:badparam' > events/sched/sched_process_fork/trigger > +! echo 'traceoff+0' > events/sched/sched_process_fork/trigger > +echo 'traceon' > events/sched/sched_process_fork/trigger > +! echo 'traceon' > events/sched/sched_process_fork/trigger > +! echo 'traceoff' > events/sched/sched_process_fork/trigger > + > +do_reset > + > +exit 0 > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/