diff mbox series

[v2,3/7] selftests/ftrace: Add "requires:" list support

Message ID 159108891139.42416.16735397217311780715.stgit@devnote2 (mailing list archive)
State New
Headers show
Series selftsts/ftrace: Add requires list for each test case | expand

Commit Message

Masami Hiramatsu (Google) June 2, 2020, 9:08 a.m. UTC
Introduce "requires:" list to check required ftrace interface
for each test. This will simplify the interface checking code
and unify the error message. Another good point is, it can
skip the ftrace initializing.

Note that this requires list must be written as a shell
comment.

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Reviewed-by: Tom Zanussi <zanussi@kernel.org>
---
 tools/testing/selftests/ftrace/ftracetest       |    8 +++++++-
 tools/testing/selftests/ftrace/test.d/functions |    9 +++++++++
 tools/testing/selftests/ftrace/test.d/template  |    1 +
 3 files changed, 17 insertions(+), 1 deletion(-)

Comments

Steven Rostedt June 2, 2020, 1:21 p.m. UTC | #1
On Tue,  2 Jun 2020 18:08:31 +0900
Masami Hiramatsu <mhiramat@kernel.org> wrote:

> +++ b/tools/testing/selftests/ftrace/test.d/template
> @@ -1,6 +1,7 @@
>  #!/bin/sh
>  # SPDX-License-Identifier: GPL-2.0
>  # description: %HERE DESCRIBE WHAT THIS DOES%
> +# requires: %HERE LIST UP REQUIRED FILES%

Not sure what you mean by "LIST UP". Perhaps you mean "LIST OF"?

-- Steve


>  # you have to add ".tc" extention for your testcase file
>  # Note that all tests are run with "errexit" option.
Masami Hiramatsu (Google) June 2, 2020, 11:51 p.m. UTC | #2
On Tue, 2 Jun 2020 09:21:45 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:

> On Tue,  2 Jun 2020 18:08:31 +0900
> Masami Hiramatsu <mhiramat@kernel.org> wrote:
> 
> > +++ b/tools/testing/selftests/ftrace/test.d/template
> > @@ -1,6 +1,7 @@
> >  #!/bin/sh
> >  # SPDX-License-Identifier: GPL-2.0
> >  # description: %HERE DESCRIBE WHAT THIS DOES%
> > +# requires: %HERE LIST UP REQUIRED FILES%
> 
> Not sure what you mean by "LIST UP". Perhaps you mean "LIST OF"?

Ah, perhups we don't need UP. "list the required files" will be OK?

Thank you,

> 
> -- Steve
> 
> 
> >  # you have to add ".tc" extention for your testcase file
> >  # Note that all tests are run with "errexit" option.
Steven Rostedt June 3, 2020, 2:33 p.m. UTC | #3
On Wed, 3 Jun 2020 08:51:13 +0900
Masami Hiramatsu <mhiramat@kernel.org> wrote:

> On Tue, 2 Jun 2020 09:21:45 -0400
> Steven Rostedt <rostedt@goodmis.org> wrote:
> 
> > On Tue,  2 Jun 2020 18:08:31 +0900
> > Masami Hiramatsu <mhiramat@kernel.org> wrote:
> >   
> > > +++ b/tools/testing/selftests/ftrace/test.d/template
> > > @@ -1,6 +1,7 @@
> > >  #!/bin/sh
> > >  # SPDX-License-Identifier: GPL-2.0
> > >  # description: %HERE DESCRIBE WHAT THIS DOES%
> > > +# requires: %HERE LIST UP REQUIRED FILES%  
> > 
> > Not sure what you mean by "LIST UP". Perhaps you mean "LIST OF"?  
> 
> Ah, perhups we don't need UP. "list the required files" will be OK?
> 
>

Yes, that sounds much better.

I tested out the patches with a few different configurations, and they all
look good.

Although I found that the irqsoff_tracer.tc (test for the preemptirqsoff
tracer) changed from UNRESOLVED to UNSUPPORTED.

I'll run a few more different configs and see what happens, but you can add:

Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>

-- Steve
Masami Hiramatsu (Google) June 4, 2020, 3:08 p.m. UTC | #4
Hi Steve,

On Wed, 3 Jun 2020 10:33:43 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:

> On Wed, 3 Jun 2020 08:51:13 +0900
> Masami Hiramatsu <mhiramat@kernel.org> wrote:
> 
> > On Tue, 2 Jun 2020 09:21:45 -0400
> > Steven Rostedt <rostedt@goodmis.org> wrote:
> > 
> > > On Tue,  2 Jun 2020 18:08:31 +0900
> > > Masami Hiramatsu <mhiramat@kernel.org> wrote:
> > >   
> > > > +++ b/tools/testing/selftests/ftrace/test.d/template
> > > > @@ -1,6 +1,7 @@
> > > >  #!/bin/sh
> > > >  # SPDX-License-Identifier: GPL-2.0
> > > >  # description: %HERE DESCRIBE WHAT THIS DOES%
> > > > +# requires: %HERE LIST UP REQUIRED FILES%  
> > > 
> > > Not sure what you mean by "LIST UP". Perhaps you mean "LIST OF"?  
> > 
> > Ah, perhups we don't need UP. "list the required files" will be OK?
> > 
> >
> 
> Yes, that sounds much better.
> 
> I tested out the patches with a few different configurations, and they all
> look good.
> 
> Although I found that the irqsoff_tracer.tc (test for the preemptirqsoff
> tracer) changed from UNRESOLVED to UNSUPPORTED.

Yes, I think it should be unsupported if the kernel doesn't configure the
feature.

> 
> I'll run a few more different configs and see what happens, but you can add:
> 
> Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>

Thanks, and I've already sent v3.

https://lkml.kernel.org/r/159115200085.70027.6141550347953439240.stgit@devnote2


Thank you,
Steven Rostedt June 4, 2020, 3:16 p.m. UTC | #5
On Fri, 5 Jun 2020 00:08:50 +0900
Masami Hiramatsu <mhiramat@kernel.org> wrote:

> > Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>  
> 
> Thanks, and I've already sent v3.
> 
> https://lkml.kernel.org/r/159115200085.70027.6141550347953439240.stgit@devnote2

I tested that too, and you can keep my Reviewed-by on the patch set.

Shuah,

Want to take v3 for 5.9?

-- Steve
diff mbox series

Patch

diff --git a/tools/testing/selftests/ftrace/ftracetest b/tools/testing/selftests/ftrace/ftracetest
index d3f6652311ef..cdf7940b6610 100755
--- a/tools/testing/selftests/ftrace/ftracetest
+++ b/tools/testing/selftests/ftrace/ftracetest
@@ -267,6 +267,11 @@  testcase() { # testfile
   prlog -n "[$CASENO]$INSTANCE$desc"
 }
 
+checkreq() { # testfile
+  requires=`grep "^#[ \t]*requires:" $1 | cut -f2- -d:`
+  check_requires $requires
+}
+
 test_on_instance() { # testfile
   grep -q "^#[ \t]*flags:.*instance" $1
 }
@@ -356,7 +361,8 @@  trap 'SIG_RESULT=$XFAIL' $SIG_XFAIL
 
 __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;
+   checkreq $1; initialize_ftrace; . $1)
   [ $? -ne 0 ] && kill -s $SIG_FAIL $SIG_PID
 }
 
diff --git a/tools/testing/selftests/ftrace/test.d/functions b/tools/testing/selftests/ftrace/test.d/functions
index 697c77ef2e2b..5100eb1ada0f 100644
--- a/tools/testing/selftests/ftrace/test.d/functions
+++ b/tools/testing/selftests/ftrace/test.d/functions
@@ -113,6 +113,15 @@  initialize_ftrace() { # Reset ftrace to initial-state
     enable_tracing
 }
 
+check_requires() { # Check required files
+    for i in $* ; do
+        if [ ! -e $i ]; then
+            echo "Required feature interface $i doesn't exist."
+            exit_unsupported
+        fi
+    done
+}
+
 LOCALHOST=127.0.0.1
 
 yield() {
diff --git a/tools/testing/selftests/ftrace/test.d/template b/tools/testing/selftests/ftrace/test.d/template
index e1a5d14c4eaf..d679e5c9e1ee 100644
--- a/tools/testing/selftests/ftrace/test.d/template
+++ b/tools/testing/selftests/ftrace/test.d/template
@@ -1,6 +1,7 @@ 
 #!/bin/sh
 # SPDX-License-Identifier: GPL-2.0
 # description: %HERE DESCRIBE WHAT THIS DOES%
+# requires: %HERE LIST UP REQUIRED FILES%
 # you have to add ".tc" extention for your testcase file
 # Note that all tests are run with "errexit" option.