diff options
author | Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> | 2014-12-04 14:41:23 -0500 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2014-12-04 10:40:34 -0500 |
commit | 57cee23650d768130ff2d80aa4cd0b053feabf97 (patch) | |
tree | fcad4078c4c8bee03aee5476178fc43ee85303d6 | |
parent | 36922d133c931a5a7b844204d554de6ae85bee34 (diff) |
ftracetest: Add --verbose option for showing echo output
Add --verbose/-v option for showing echo output in testcases.
This is good for checking the progress of testcases which
take a longer time to run.
To implement this feature, all the testcase failures are
captured in ftracetest and send signal to set SIG_RESULT=FAIL.
Link: http://lkml.kernel.org/r/20141204194123.7376.22964.stgit@localhost.localdomain
Suggested-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rwxr-xr-x | tools/testing/selftests/ftrace/ftracetest | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/tools/testing/selftests/ftrace/ftracetest b/tools/testing/selftests/ftrace/ftracetest index e8b402193a82..da48812ab95e 100755 --- a/tools/testing/selftests/ftrace/ftracetest +++ b/tools/testing/selftests/ftrace/ftracetest | |||
@@ -13,6 +13,7 @@ echo "Usage: ftracetest [options] [testcase(s)] [testcase-directory(s)]" | |||
13 | echo " Options:" | 13 | echo " Options:" |
14 | echo " -h|--help Show help message" | 14 | echo " -h|--help Show help message" |
15 | echo " -k|--keep Keep passed test logs" | 15 | echo " -k|--keep Keep passed test logs" |
16 | echo " -v|--verbose Show all stdout messages in testcases" | ||
16 | echo " -d|--debug Debug mode (trace all shell commands)" | 17 | echo " -d|--debug Debug mode (trace all shell commands)" |
17 | exit $1 | 18 | exit $1 |
18 | } | 19 | } |
@@ -53,6 +54,10 @@ parse_opts() { # opts | |||
53 | KEEP_LOG=1 | 54 | KEEP_LOG=1 |
54 | shift 1 | 55 | shift 1 |
55 | ;; | 56 | ;; |
57 | --verbose|-v) | ||
58 | VERBOSE=1 | ||
59 | shift 1 | ||
60 | ;; | ||
56 | --debug|-d) | 61 | --debug|-d) |
57 | DEBUG=1 | 62 | DEBUG=1 |
58 | shift 1 | 63 | shift 1 |
@@ -90,6 +95,7 @@ TEST_CASES=`find_testcases $TEST_DIR` | |||
90 | LOG_DIR=$TOP_DIR/logs/`date +%Y%m%d-%H%M%S`/ | 95 | LOG_DIR=$TOP_DIR/logs/`date +%Y%m%d-%H%M%S`/ |
91 | KEEP_LOG=0 | 96 | KEEP_LOG=0 |
92 | DEBUG=0 | 97 | DEBUG=0 |
98 | VERBOSE=0 | ||
93 | # Parse command-line options | 99 | # Parse command-line options |
94 | parse_opts $* | 100 | parse_opts $* |
95 | 101 | ||
@@ -139,12 +145,8 @@ testcase() { # testfile | |||
139 | prlog -n "[$CASENO]$desc" | 145 | prlog -n "[$CASENO]$desc" |
140 | } | 146 | } |
141 | 147 | ||
142 | eval_result() { # retval sigval | 148 | eval_result() { # sigval |
143 | local retval=$2 | 149 | case $1 in |
144 | if [ $2 -eq 0 ]; then | ||
145 | test $1 -ne 0 && retval=$FAIL | ||
146 | fi | ||
147 | case $retval in | ||
148 | $PASS) | 150 | $PASS) |
149 | prlog " [PASS]" | 151 | prlog " [PASS]" |
150 | PASSED_CASES="$PASSED_CASES $CASENO" | 152 | PASSED_CASES="$PASSED_CASES $CASENO" |
@@ -188,6 +190,9 @@ SIG_RESULT= | |||
188 | SIG_BASE=36 # Use realtime signals | 190 | SIG_BASE=36 # Use realtime signals |
189 | SIG_PID=$$ | 191 | SIG_PID=$$ |
190 | 192 | ||
193 | SIG_FAIL=$((SIG_BASE + FAIL)) | ||
194 | trap 'SIG_RESULT=$FAIL' $SIG_FAIL | ||
195 | |||
191 | SIG_UNRESOLVED=$((SIG_BASE + UNRESOLVED)) | 196 | SIG_UNRESOLVED=$((SIG_BASE + UNRESOLVED)) |
192 | exit_unresolved () { | 197 | exit_unresolved () { |
193 | kill -s $SIG_UNRESOLVED $SIG_PID | 198 | kill -s $SIG_UNRESOLVED $SIG_PID |
@@ -216,6 +221,12 @@ exit_xfail () { | |||
216 | } | 221 | } |
217 | trap 'SIG_RESULT=$XFAIL' $SIG_XFAIL | 222 | trap 'SIG_RESULT=$XFAIL' $SIG_XFAIL |
218 | 223 | ||
224 | __run_test() { # testfile | ||
225 | # setup PID and PPID, $$ is not updated. | ||
226 | (cd $TRACING_DIR; read PID _ < /proc/self/stat ; set -e; set -x; . $1) | ||
227 | [ $? -ne 0 ] && kill -s $SIG_FAIL $SIG_PID | ||
228 | } | ||
229 | |||
219 | # Run one test case | 230 | # Run one test case |
220 | run_test() { # testfile | 231 | run_test() { # testfile |
221 | local testname=`basename $1` | 232 | local testname=`basename $1` |
@@ -223,10 +234,12 @@ run_test() { # testfile | |||
223 | testcase $1 | 234 | testcase $1 |
224 | echo "execute: "$1 > $testlog | 235 | echo "execute: "$1 > $testlog |
225 | SIG_RESULT=0 | 236 | SIG_RESULT=0 |
226 | # setup PID and PPID, $$ is not updated. | 237 | if [ $VERBOSE -ne 0 ]; then |
227 | (cd $TRACING_DIR; read PID _ < /proc/self/stat ; | 238 | __run_test $1 2>> $testlog | tee -a $testlog |
228 | set -e; set -x; . $1) >> $testlog 2>&1 | 239 | else |
229 | eval_result $? $SIG_RESULT | 240 | __run_test $1 >> $testlog 2>&1 |
241 | fi | ||
242 | eval_result $SIG_RESULT | ||
230 | if [ $? -eq 0 ]; then | 243 | if [ $? -eq 0 ]; then |
231 | # Remove test log if the test was done as it was expected. | 244 | # Remove test log if the test was done as it was expected. |
232 | [ $KEEP_LOG -eq 0 ] && rm $testlog | 245 | [ $KEEP_LOG -eq 0 ] && rm $testlog |