]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - tools/testing/selftests/ftrace/ftracetest
selftests: ftrace: Introduce TMPDIR for temporary files
[linux.git] / tools / testing / selftests / ftrace / ftracetest
index 4c6a0bf8ba79971143508580b92534b58eb8df00..685376b485a2de9c9abd8adad27c0e3a9409959a 100755 (executable)
@@ -14,6 +14,7 @@ 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 "         -q|--quiet Do not show error log on stdout"
 echo "         -d|--debug Debug mode (trace all shell commands)"
 exit $1
 }
@@ -58,6 +59,10 @@ parse_opts() { # opts
       VERBOSE=1
       shift 1
     ;;
+    --quiet|-q)
+      BE_QUIET=1
+      shift 1
+    ;;
     --debug|-d)
       DEBUG=1
       shift 1
@@ -101,6 +106,7 @@ LOG_DIR=$TOP_DIR/logs/`date +%Y%m%d-%H%M%S`/
 KEEP_LOG=0
 DEBUG=0
 VERBOSE=0
+BE_QUIET=0
 # Parse command-line options
 parse_opts $*
 
@@ -228,7 +234,7 @@ 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)
+  (cd $TRACING_DIR; read PID _ < /proc/self/stat; set -e; set -x; initialize_ftrace; . $1)
   [ $? -ne 0 ] && kill -s $SIG_FAIL $SIG_PID
 }
 
@@ -236,6 +242,7 @@ __run_test() { # testfile
 run_test() { # testfile
   local testname=`basename $1`
   local testlog=`mktemp $LOG_DIR/${testname}-log.XXXXXX`
+  export TMPDIR=`mktemp -d /tmp/ftracetest-dir.XXXXXX`
   testcase $1
   echo "execute: "$1 > $testlog
   SIG_RESULT=0
@@ -249,9 +256,10 @@ run_test() { # testfile
     # Remove test log if the test was done as it was expected.
     [ $KEEP_LOG -eq 0 ] && rm $testlog
   else
-    catlog $testlog
+    [ $BE_QUIET -eq 0 ] && catlog $testlog
     TOTAL_RESULT=1
   fi
+  rm -rf $TMPDIR
 }
 
 # load in the helper functions