aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>2014-12-04 14:41:23 -0500
committerSteven Rostedt <rostedt@goodmis.org>2014-12-04 10:40:34 -0500
commit57cee23650d768130ff2d80aa4cd0b053feabf97 (patch)
treefcad4078c4c8bee03aee5476178fc43ee85303d6
parent36922d133c931a5a7b844204d554de6ae85bee34 (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-xtools/testing/selftests/ftrace/ftracetest33
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)]"
13echo " Options:" 13echo " Options:"
14echo " -h|--help Show help message" 14echo " -h|--help Show help message"
15echo " -k|--keep Keep passed test logs" 15echo " -k|--keep Keep passed test logs"
16echo " -v|--verbose Show all stdout messages in testcases"
16echo " -d|--debug Debug mode (trace all shell commands)" 17echo " -d|--debug Debug mode (trace all shell commands)"
17exit $1 18exit $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`
90LOG_DIR=$TOP_DIR/logs/`date +%Y%m%d-%H%M%S`/ 95LOG_DIR=$TOP_DIR/logs/`date +%Y%m%d-%H%M%S`/
91KEEP_LOG=0 96KEEP_LOG=0
92DEBUG=0 97DEBUG=0
98VERBOSE=0
93# Parse command-line options 99# Parse command-line options
94parse_opts $* 100parse_opts $*
95 101
@@ -139,12 +145,8 @@ testcase() { # testfile
139 prlog -n "[$CASENO]$desc" 145 prlog -n "[$CASENO]$desc"
140} 146}
141 147
142eval_result() { # retval sigval 148eval_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=
188SIG_BASE=36 # Use realtime signals 190SIG_BASE=36 # Use realtime signals
189SIG_PID=$$ 191SIG_PID=$$
190 192
193SIG_FAIL=$((SIG_BASE + FAIL))
194trap 'SIG_RESULT=$FAIL' $SIG_FAIL
195
191SIG_UNRESOLVED=$((SIG_BASE + UNRESOLVED)) 196SIG_UNRESOLVED=$((SIG_BASE + UNRESOLVED))
192exit_unresolved () { 197exit_unresolved () {
193 kill -s $SIG_UNRESOLVED $SIG_PID 198 kill -s $SIG_UNRESOLVED $SIG_PID
@@ -216,6 +221,12 @@ exit_xfail () {
216} 221}
217trap 'SIG_RESULT=$XFAIL' $SIG_XFAIL 222trap '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
220run_test() { # testfile 231run_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