linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Masami Hiramatsu <mhiramat@kernel.org>
To: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Shuah Khan <shuah@kernel.org>, Namhyung Kim <namhyung@kernel.org>
Subject: Re: [RFC][PATCH] selftests: ftrace: Allow some tests to be run in a tracing instance
Date: Fri, 21 Apr 2017 19:00:25 +0900	[thread overview]
Message-ID: <20170421190025.f398a44b662c9bff80b3cc10@kernel.org> (raw)
In-Reply-To: <20170421183617.fbab5eb08f137f436c1f69cf@kernel.org>

On Fri, 21 Apr 2017 18:36:17 +0900
Masami Hiramatsu <mhiramat@kernel.org> wrote:

> On Thu, 20 Apr 2017 13:30:34 -0400
> Steven Rostedt <rostedt@goodmis.org> wrote:
> > 
> > An tracing instance has several of the same capabilities as the top level
> > instance, but may be implemented slightly different. Instead of just writing
> > tests that duplicat the same test cases of the top level instance, allow a
> > test to be written for both the top level as well as for an instance.
> > 
> > If a test case can be run in both the top level as well as in an tracing
> > instance directory, then it should have a ".itc" extension instead of just
> > the ".tc" extension.
> 
> Hm, I'd rather like to have a tag for each script instead of
> using the extension. E.g.
> 
> #!/bin/sh
> # description: Kprobe dynamic event - busy event check
> # test: instance

BTW, I also have some comments, see below,

[...]
> > +INSTANCE_DIR="."
> >  __run_test() { # testfile
> >    # setup PID and PPID, $$ is not updated.
> > -  (cd $TRACING_DIR; read PID _ < /proc/self/stat; set -e; set -x; initialize_ftrace; . $1)
> > +  (cd $TRACING_DIR; read PID _ < /proc/self/stat; set -e; set -x; initialize_ftrace; cd $INSTANCE_DIR; . $1)

You can just change "cd $TRACING_DIR;" with "cd $TRACING_DIR/$INSTANCE_DIR;"
Then, the default value of INSTANCE_DIR can be "".

> >    [ $? -ne 0 ] && kill -s $SIG_FAIL $SIG_PID
> >  }
> >  
> >  # Run one test case
> > -run_test() { # testfile
> > +run_test() { # [-i] testfile
> > +  local makeinstance=0
> > +  if [ $1 == "-i" ]; then
> > +    makeinstance=1
> > +    shift
> > +  fi

No, don't parse argument in the function. You can just define
MAKEINSTANCE=1 global variable before calling this.

> >    local testname=`basename $1`
> >    local testlog=`mktemp $LOG_DIR/${testname}-log.XXXXXX`
> >    export TMPDIR=`mktemp -d /tmp/ftracetest-dir.XXXXXX`
> >    testcase $1

Anyway, if we use a "tag" in the script header, we can get it
in this testcase() and update TEST_TAGS global variable there.

> > +  if [ $makeinstance -eq 1 ]; then

and check whether "instance" tag in $TEST_TAGS here.

> > +    INSTANCE_DIR=$TRACING_DIR/instances/${testname}_test
> > +    mkdir $INSTANCE_DIR
> > +  fi


> >    echo "execute: "$1 > $testlog
> >    SIG_RESULT=0
> >    if [ $VERBOSE -ge 2 ]; then
> > @@ -260,17 +274,36 @@ run_test() { # testfile
> >      [ $VERBOSE -ge 1 ] && catlog $testlog
> >      TOTAL_RESULT=1
> >    fi
> > +  if [ $makeinstance -eq 1 ]; then

Here also we can just check the "$INSTANCE_DIR" is not empty.

Thank you,

> > +    rmdir $INSTANCE_DIR
> > +    INSTANCE_DIR="."
> > +  fi
> >    rm -rf $TMPDIR
> >  }
> >  
> >  # load in the helper functions
> >  . $TEST_DIR/functions
> >  
> > +RUN_INSTANCES=0
> > +
> >  # Main loop
> >  for t in $TEST_CASES; do
> > +  if [ "${t/*./}" == "itc" ]; then
> > +    RUN_INSTANCES=1
> > +  fi
> >    run_test $t
> >  done
> >  
> > +if [ $RUN_INSTANCES -eq 1 ]; then
> > +    echo "Running tests in an tracing instance:"
> > +    for t in $TEST_CASES; do
> > +	if [ "${t/*./}" != "itc" ]; then
> > +	    continue
> > +	fi
> > +	run_test -i $t
> > +    done
> > +fi
> > +
> >  prlog ""
> >  prlog "# of passed: " `echo $PASSED_CASES | wc -w`
> >  prlog "# of failed: " `echo $FAILED_CASES | wc -w`
> > -- 
> > 2.9.3
> > 
> 
> 
> -- 
> Masami Hiramatsu <mhiramat@kernel.org>


-- 
Masami Hiramatsu <mhiramat@kernel.org>

  reply	other threads:[~2017-04-21 10:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-20 17:30 [RFC][PATCH] selftests: ftrace: Allow some tests to be run in a tracing instance Steven Rostedt
2017-04-20 18:16 ` Steven Rostedt
2017-04-21  9:36 ` Masami Hiramatsu
2017-04-21 10:00   ` Masami Hiramatsu [this message]
2017-04-21 13:53     ` Steven Rostedt
2017-04-21 22:26       ` 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=20170421190025.f398a44b662c9bff80b3cc10@kernel.org \
    --to=mhiramat@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=namhyung@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=shuah@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).