diff options
Diffstat (limited to 'tools/testing/selftests/ftrace/ftracetest')
-rwxr-xr-x | tools/testing/selftests/ftrace/ftracetest | 45 |
1 files changed, 31 insertions, 14 deletions
diff --git a/tools/testing/selftests/ftrace/ftracetest b/tools/testing/selftests/ftrace/ftracetest index a8f81c782856..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)]" echo " Options:" echo " -h|--help Show help message" 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)" exit $1 } @@ -37,7 +38,7 @@ abspath() { } find_testcases() { #directory - echo `find $1 -name \*.tc` + echo `find $1 -name \*.tc | sort` } parse_opts() { # opts @@ -53,6 +54,10 @@ parse_opts() { # opts KEEP_LOG=1 shift 1 ;; + --verbose|-v) + VERBOSE=1 + shift 1 + ;; --debug|-d) DEBUG=1 shift 1 @@ -82,7 +87,7 @@ parse_opts() { # opts } # Parameters -DEBUGFS_DIR=`grep debugfs /proc/mounts | cut -f2 -d' '` +DEBUGFS_DIR=`grep debugfs /proc/mounts | cut -f2 -d' ' | head -1` TRACING_DIR=$DEBUGFS_DIR/tracing TOP_DIR=`absdir $0` TEST_DIR=$TOP_DIR/test.d @@ -90,6 +95,7 @@ TEST_CASES=`find_testcases $TEST_DIR` LOG_DIR=$TOP_DIR/logs/`date +%Y%m%d-%H%M%S`/ KEEP_LOG=0 DEBUG=0 +VERBOSE=0 # Parse command-line options parse_opts $* @@ -135,15 +141,12 @@ TOTAL_RESULT=0 CASENO=0 testcase() { # testfile CASENO=$((CASENO+1)) - prlog -n "[$CASENO]"`grep "^#[ \t]*description:" $1 | cut -f2 -d:` + desc=`grep "^#[ \t]*description:" $1 | cut -f2 -d:` + prlog -n "[$CASENO]$desc" } -eval_result() { # retval sigval - local retval=$2 - if [ $2 -eq 0 ]; then - test $1 -ne 0 && retval=$FAIL - fi - case $retval in +eval_result() { # sigval + case $1 in $PASS) prlog " [PASS]" PASSED_CASES="$PASSED_CASES $CASENO" @@ -187,6 +190,9 @@ SIG_RESULT= SIG_BASE=36 # Use realtime signals SIG_PID=$$ +SIG_FAIL=$((SIG_BASE + FAIL)) +trap 'SIG_RESULT=$FAIL' $SIG_FAIL + SIG_UNRESOLVED=$((SIG_BASE + UNRESOLVED)) exit_unresolved () { kill -s $SIG_UNRESOLVED $SIG_PID @@ -215,17 +221,25 @@ exit_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_test() { # testfile local testname=`basename $1` - local testlog=`mktemp --tmpdir=$LOG_DIR ${testname}-XXXXXX.log` + local testlog=`mktemp $LOG_DIR/${testname}-log.XXXXXX` testcase $1 echo "execute: "$1 > $testlog SIG_RESULT=0 - # setup PID and PPID, $$ is not updated. - (cd $TRACING_DIR; read PID _ < /proc/self/stat ; - set -e; set -x; . $1) >> $testlog 2>&1 - eval_result $? $SIG_RESULT + if [ $VERBOSE -ne 0 ]; then + __run_test $1 2>> $testlog | tee -a $testlog + else + __run_test $1 >> $testlog 2>&1 + fi + eval_result $SIG_RESULT if [ $? -eq 0 ]; then # Remove test log if the test was done as it was expected. [ $KEEP_LOG -eq 0 ] && rm $testlog @@ -235,6 +249,9 @@ run_test() { # testfile fi } +# load in the helper functions +. $TEST_DIR/functions + # Main loop for t in $TEST_CASES; do run_test $t |