Commit 57cee236 authored by Masami Hiramatsu's avatar Masami Hiramatsu Committed by Steven Rostedt

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.localdomainSuggested-by: default avatarSteven Rostedt <rostedt@goodmis.org>
Signed-off-by: default avatarMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
parent 36922d13
...@@ -13,6 +13,7 @@ echo "Usage: ftracetest [options] [testcase(s)] [testcase-directory(s)]" ...@@ -13,6 +13,7 @@ echo "Usage: ftracetest [options] [testcase(s)] [testcase-directory(s)]"
echo " Options:" echo " Options:"
echo " -h|--help Show help message" echo " -h|--help Show help message"
echo " -k|--keep Keep passed test logs" echo " -k|--keep Keep passed test logs"
echo " -v|--verbose Show all stdout messages in testcases"
echo " -d|--debug Debug mode (trace all shell commands)" echo " -d|--debug Debug mode (trace all shell commands)"
exit $1 exit $1
} }
...@@ -53,6 +54,10 @@ parse_opts() { # opts ...@@ -53,6 +54,10 @@ parse_opts() { # opts
KEEP_LOG=1 KEEP_LOG=1
shift 1 shift 1
;; ;;
--verbose|-v)
VERBOSE=1
shift 1
;;
--debug|-d) --debug|-d)
DEBUG=1 DEBUG=1
shift 1 shift 1
...@@ -90,6 +95,7 @@ TEST_CASES=`find_testcases $TEST_DIR` ...@@ -90,6 +95,7 @@ TEST_CASES=`find_testcases $TEST_DIR`
LOG_DIR=$TOP_DIR/logs/`date +%Y%m%d-%H%M%S`/ LOG_DIR=$TOP_DIR/logs/`date +%Y%m%d-%H%M%S`/
KEEP_LOG=0 KEEP_LOG=0
DEBUG=0 DEBUG=0
VERBOSE=0
# Parse command-line options # Parse command-line options
parse_opts $* parse_opts $*
...@@ -139,12 +145,8 @@ testcase() { # testfile ...@@ -139,12 +145,8 @@ testcase() { # testfile
prlog -n "[$CASENO]$desc" prlog -n "[$CASENO]$desc"
} }
eval_result() { # retval sigval eval_result() { # sigval
local retval=$2 case $1 in
if [ $2 -eq 0 ]; then
test $1 -ne 0 && retval=$FAIL
fi
case $retval in
$PASS) $PASS)
prlog " [PASS]" prlog " [PASS]"
PASSED_CASES="$PASSED_CASES $CASENO" PASSED_CASES="$PASSED_CASES $CASENO"
...@@ -188,6 +190,9 @@ SIG_RESULT= ...@@ -188,6 +190,9 @@ SIG_RESULT=
SIG_BASE=36 # Use realtime signals SIG_BASE=36 # Use realtime signals
SIG_PID=$$ SIG_PID=$$
SIG_FAIL=$((SIG_BASE + FAIL))
trap 'SIG_RESULT=$FAIL' $SIG_FAIL
SIG_UNRESOLVED=$((SIG_BASE + UNRESOLVED)) SIG_UNRESOLVED=$((SIG_BASE + UNRESOLVED))
exit_unresolved () { exit_unresolved () {
kill -s $SIG_UNRESOLVED $SIG_PID kill -s $SIG_UNRESOLVED $SIG_PID
...@@ -216,6 +221,12 @@ exit_xfail () { ...@@ -216,6 +221,12 @@ exit_xfail () {
} }
trap 'SIG_RESULT=$XFAIL' $SIG_XFAIL 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; . $1)
[ $? -ne 0 ] && kill -s $SIG_FAIL $SIG_PID
}
# Run one test case # Run one test case
run_test() { # testfile run_test() { # testfile
local testname=`basename $1` local testname=`basename $1`
...@@ -223,10 +234,12 @@ run_test() { # testfile ...@@ -223,10 +234,12 @@ run_test() { # testfile
testcase $1 testcase $1
echo "execute: "$1 > $testlog echo "execute: "$1 > $testlog
SIG_RESULT=0 SIG_RESULT=0
# setup PID and PPID, $$ is not updated. if [ $VERBOSE -ne 0 ]; then
(cd $TRACING_DIR; read PID _ < /proc/self/stat ; __run_test $1 2>> $testlog | tee -a $testlog
set -e; set -x; . $1) >> $testlog 2>&1 else
eval_result $? $SIG_RESULT __run_test $1 >> $testlog 2>&1
fi
eval_result $SIG_RESULT
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
# Remove test log if the test was done as it was expected. # Remove test log if the test was done as it was expected.
[ $KEEP_LOG -eq 0 ] && rm $testlog [ $KEEP_LOG -eq 0 ] && rm $testlog
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment