linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Masami Hiramatsu <mhiramat@kernel.org>
To: Shuah Khan <skhan@linuxfoundation.org>,
	Steven Rostedt <rostedt@goodmis.org>
Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
	Shuah Khan <shuah@kernel.org>,
	Tom Zanussi <tom.zanussi@linux.intel.com>,
	Masami Hiramatsu <mhiramat@kernel.org>
Subject: [PATCH v2 3/7] selftests/ftrace: Add "requires:" list support
Date: Tue,  2 Jun 2020 18:08:31 +0900	[thread overview]
Message-ID: <159108891139.42416.16735397217311780715.stgit@devnote2> (raw)
In-Reply-To: <159108888259.42416.547252366885528860.stgit@devnote2>

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(-)

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.
 


  parent reply	other threads:[~2020-06-02  9:08 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-02  9:08 [PATCH v2 0/7] selftsts/ftrace: Add requires list for each test case Masami Hiramatsu
2020-06-02  9:08 ` [PATCH v2 1/7] selftests/ftrace: Allow ":" in description Masami Hiramatsu
2020-06-02  9:08 ` [PATCH v2 2/7] selftests/ftrace: Return unsupported for the unconfigured features Masami Hiramatsu
2020-06-02  9:08 ` Masami Hiramatsu [this message]
2020-06-02 13:21   ` [PATCH v2 3/7] selftests/ftrace: Add "requires:" list support Steven Rostedt
2020-06-02 23:51     ` Masami Hiramatsu
2020-06-03 14:33       ` Steven Rostedt
2020-06-04 15:08         ` Masami Hiramatsu
2020-06-04 15:16           ` Steven Rostedt
2020-06-02  9:08 ` [PATCH v2 4/7] selftests/ftrace: Convert required interface checks into requires list Masami Hiramatsu
2020-06-02  9:08 ` [PATCH v2 5/7] selftests/ftrace: Convert check_filter_file() with " Masami Hiramatsu
2020-06-02  9:09 ` [PATCH v2 6/7] selftests/ftrace: Support ":tracer" suffix for requires Masami Hiramatsu
2020-06-02  9:09 ` [PATCH v2 7/7] selftests/ftrace: Support ":README" " 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=159108891139.42416.16735397217311780715.stgit@devnote2 \
    --to=mhiramat@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=shuah@kernel.org \
    --cc=skhan@linuxfoundation.org \
    --cc=tom.zanussi@linux.intel.com \
    /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).