Re: [PATCH v3] selftests: ftrace: Allow some tests to be run in a tracing instance

From: Steven Rostedt
Date: Mon Apr 24 2017 - 18:02:06 EST


On Sun, 23 Apr 2017 09:02:24 +0900
Masami Hiramatsu <mhiramat@xxxxxxxxxx> wrote:


> > >
> > > > +}
> > > > +
> > > > eval_result() { # sigval
> > > > case $1 in
> > > > $PASS)
> > > > @@ -271,6 +275,21 @@ for t in $TEST_CASES; do
> > > > run_test $t
> > > > done
> > > >
> > > > +# Test on instance loop
> > > > +FIRST_INSTANCE=0
> > > > +for t in $TEST_CASES; do
> > > > + test_on_instance $t || continue
> > > > + if [ $FIRST_INSTANCE -eq 0 ]; then
> > > > + FIRST_INSTANCE=1
> > > > + echo "Running tests in a tracing instance:"
> > > > + fi
> > >
> > > Ah, I see. This is important. And I would rather like to show
> > > it on the description line of each test so that we can check
> > > which test log is run in an instance. E.g. passing "(instance)"
> > > message to run_test() and testcase() as the 2nd arg, and print
> > > it in testlog and console?
> >
> > OK, I'll update to v4.

What about something like this:

-- Steve

diff --git a/tools/testing/selftests/ftrace/ftracetest b/tools/testing/selftests/ftrace/ftracetest
index a8631d9..32e6211 100755
--- a/tools/testing/selftests/ftrace/ftracetest
+++ b/tools/testing/selftests/ftrace/ftracetest
@@ -150,11 +150,16 @@ XFAILED_CASES=
UNDEFINED_CASES=
TOTAL_RESULT=0

+INSTANCE=
CASENO=0
testcase() { # testfile
CASENO=$((CASENO+1))
desc=`grep "^#[ \t]*description:" $1 | cut -f2 -d:`
- prlog -n "[$CASENO]$desc"
+ prlog -n "[$CASENO]$INSTANCE$desc"
+}
+
+test_on_instance() { # testfile
+ grep -q "^#[ \t]*flags:.*instance" $1
}

eval_result() { # sigval
@@ -271,6 +276,17 @@ for t in $TEST_CASES; do
run_test $t
done

+# Test on instance loop
+INSTANCE=" (instance) "
+for t in $TEST_CASES; do
+ test_on_instance $t || continue
+ SAVED_TRACING_DIR=$TRACING_DIR
+ export TRACING_DIR=`mktemp -d $TRACING_DIR/instances/ftracetest.XXXXXX`
+ run_test $t
+ rmdir $TRACING_DIR
+ TRACING_DIR=$SAVED_TRACING_DIR
+done
+
prlog ""
prlog "# of passed: " `echo $PASSED_CASES | wc -w`
prlog "# of failed: " `echo $FAILED_CASES | wc -w`