~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/ftrace/ftracetest

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /tools/testing/selftests/ftrace/ftracetest (Architecture alpha) and /tools/testing/selftests/ftrace/ftracetest (Architecture m68k)


  1 #!/bin/sh                                           1 #!/bin/sh
  2 # SPDX-License-Identifier: GPL-2.0-only             2 # SPDX-License-Identifier: GPL-2.0-only
  3                                                     3 
  4 # ftracetest - Ftrace test shell scripts            4 # ftracetest - Ftrace test shell scripts
  5 #                                                   5 #
  6 # Copyright (C) Hitachi Ltd., 2014                  6 # Copyright (C) Hitachi Ltd., 2014
  7 #  Written by Masami Hiramatsu <masami.hiramats      7 #  Written by Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
  8 #                                                   8 #
  9                                                     9 
 10 usage() { # errno [message]                        10 usage() { # errno [message]
 11 [ ! -z "$2" ] && echo $2                           11 [ ! -z "$2" ] && echo $2
 12 echo "Usage: ftracetest [options] [testcase(s)     12 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 lo     15 echo "          -k|--keep  Keep passed test logs"
 16 echo "          -K|--ktap  Output in KTAP form     16 echo "          -K|--ktap  Output in KTAP format"
 17 echo "          -v|--verbose Increase verbosit     17 echo "          -v|--verbose Increase verbosity of test messages"
 18 echo "          -vv        Alias of -v -v (Sho     18 echo "          -vv        Alias of -v -v (Show all results in stdout)"
 19 echo "          -vvv       Alias of -v -v -v (     19 echo "          -vvv       Alias of -v -v -v (Show all commands immediately)"
 20 echo "          --fail-unsupported Treat UNSUP     20 echo "          --fail-unsupported Treat UNSUPPORTED as a failure"
 21 echo "          --fail-unresolved Treat UNRESO     21 echo "          --fail-unresolved Treat UNRESOLVED as a failure"
 22 echo "          -d|--debug Debug mode (trace a     22 echo "          -d|--debug Debug mode (trace all shell commands)"
 23 echo "          -l|--logdir <dir> Save logs on     23 echo "          -l|--logdir <dir> Save logs on the <dir>"
 24 echo "                      If <dir> is -, all     24 echo "                      If <dir> is -, all logs output in console only"
 25 exit $1                                            25 exit $1
 26 }                                                  26 }
 27                                                    27 
 28 # default error                                    28 # default error
 29 err_ret=1                                          29 err_ret=1
 30                                                    30 
 31 # kselftest skip code is 4                         31 # kselftest skip code is 4
 32 err_skip=4                                         32 err_skip=4
 33                                                    33 
 34 # umount required                                  34 # umount required
 35 UMOUNT_DIR=""                                      35 UMOUNT_DIR=""
 36                                                    36 
 37 # cgroup RT scheduling prevents chrt commands      37 # cgroup RT scheduling prevents chrt commands from succeeding, which
 38 # induces failures in test wakeup tests.  Disa     38 # induces failures in test wakeup tests.  Disable for the duration of
 39 # the tests.                                       39 # the tests.
 40                                                    40 
 41 readonly sched_rt_runtime=/proc/sys/kernel/sch     41 readonly sched_rt_runtime=/proc/sys/kernel/sched_rt_runtime_us
 42                                                    42 
 43 sched_rt_runtime_orig=$(cat $sched_rt_runtime)     43 sched_rt_runtime_orig=$(cat $sched_rt_runtime)
 44                                                    44 
 45 setup() {                                          45 setup() {
 46   echo -1 > $sched_rt_runtime                      46   echo -1 > $sched_rt_runtime
 47 }                                                  47 }
 48                                                    48 
 49 cleanup() {                                        49 cleanup() {
 50   echo $sched_rt_runtime_orig > $sched_rt_runt     50   echo $sched_rt_runtime_orig > $sched_rt_runtime
 51   if [ -n "${UMOUNT_DIR}" ]; then                  51   if [ -n "${UMOUNT_DIR}" ]; then
 52     umount ${UMOUNT_DIR} ||:                       52     umount ${UMOUNT_DIR} ||:
 53   fi                                               53   fi
 54 }                                                  54 }
 55                                                    55 
 56 errexit() { # message                              56 errexit() { # message
 57   echo "Error: $1" 1>&2                            57   echo "Error: $1" 1>&2
 58   cleanup                                          58   cleanup
 59   exit $err_ret                                    59   exit $err_ret
 60 }                                                  60 }
 61                                                    61 
 62 # Ensuring user privilege                          62 # Ensuring user privilege
 63 if [ `id -u` -ne 0 ]; then                         63 if [ `id -u` -ne 0 ]; then
 64   errexit "this must be run by root user"          64   errexit "this must be run by root user"
 65 fi                                                 65 fi
 66                                                    66 
 67 setup                                              67 setup
 68                                                    68 
 69 # Utilities                                        69 # Utilities
 70 absdir() { # file_path                             70 absdir() { # file_path
 71   (cd `dirname $1`; pwd)                           71   (cd `dirname $1`; pwd)
 72 }                                                  72 }
 73                                                    73 
 74 abspath() {                                        74 abspath() {
 75   echo `absdir $1`/`basename $1`                   75   echo `absdir $1`/`basename $1`
 76 }                                                  76 }
 77                                                    77 
 78 find_testcases() { #directory                      78 find_testcases() { #directory
 79   echo `find $1 -name \*.tc | sort`                79   echo `find $1 -name \*.tc | sort`
 80 }                                                  80 }
 81                                                    81 
 82 parse_opts() { # opts                              82 parse_opts() { # opts
 83   local OPT_TEST_CASES=                            83   local OPT_TEST_CASES=
 84   local OPT_TEST_DIR=                              84   local OPT_TEST_DIR=
 85                                                    85 
 86   while [ ! -z "$1" ]; do                          86   while [ ! -z "$1" ]; do
 87     case "$1" in                                   87     case "$1" in
 88     --help|-h)                                     88     --help|-h)
 89       usage 0                                      89       usage 0
 90     ;;                                             90     ;;
 91     --keep|-k)                                     91     --keep|-k)
 92       KEEP_LOG=1                                   92       KEEP_LOG=1
 93       shift 1                                      93       shift 1
 94     ;;                                             94     ;;
 95     --ktap|-K)                                     95     --ktap|-K)
 96       KTAP=1                                       96       KTAP=1
 97       shift 1                                      97       shift 1
 98     ;;                                             98     ;;
 99     --verbose|-v|-vv|-vvv)                         99     --verbose|-v|-vv|-vvv)
100       if [ $VERBOSE -eq -1 ]; then                100       if [ $VERBOSE -eq -1 ]; then
101         usage "--console can not use with --ve    101         usage "--console can not use with --verbose"
102       fi                                          102       fi
103       VERBOSE=$((VERBOSE + 1))                    103       VERBOSE=$((VERBOSE + 1))
104       [ $1 = '-vv' ] && VERBOSE=$((VERBOSE + 1    104       [ $1 = '-vv' ] && VERBOSE=$((VERBOSE + 1))
105       [ $1 = '-vvv' ] && VERBOSE=$((VERBOSE +     105       [ $1 = '-vvv' ] && VERBOSE=$((VERBOSE + 2))
106       shift 1                                     106       shift 1
107     ;;                                            107     ;;
108     --console)                                    108     --console)
109       if [ $VERBOSE -ne 0 ]; then                 109       if [ $VERBOSE -ne 0 ]; then
110         usage "--console can not use with --ve    110         usage "--console can not use with --verbose"
111       fi                                          111       fi
112       VERBOSE=-1                                  112       VERBOSE=-1
113       shift 1                                     113       shift 1
114     ;;                                            114     ;;
115     --debug|-d)                                   115     --debug|-d)
116       DEBUG=1                                     116       DEBUG=1
117       shift 1                                     117       shift 1
118     ;;                                            118     ;;
119     --stop-fail)                                  119     --stop-fail)
120       STOP_FAILURE=1                              120       STOP_FAILURE=1
121       shift 1                                     121       shift 1
122     ;;                                            122     ;;
123     --fail-unsupported)                           123     --fail-unsupported)
124       UNSUPPORTED_RESULT=1                        124       UNSUPPORTED_RESULT=1
125       shift 1                                     125       shift 1
126     ;;                                            126     ;;
127     --fail-unresolved)                            127     --fail-unresolved)
128       UNRESOLVED_RESULT=1                         128       UNRESOLVED_RESULT=1
129       shift 1                                     129       shift 1
130     ;;                                            130     ;;
131     --logdir|-l)                                  131     --logdir|-l)
132       LOG_DIR=$2                                  132       LOG_DIR=$2
133       LINK_PTR=                                   133       LINK_PTR=
134       shift 2                                     134       shift 2
135     ;;                                            135     ;;
136     *.tc)                                         136     *.tc)
137       if [ -f "$1" ]; then                        137       if [ -f "$1" ]; then
138         OPT_TEST_CASES="$OPT_TEST_CASES `abspa    138         OPT_TEST_CASES="$OPT_TEST_CASES `abspath $1`"
139         shift 1                                   139         shift 1
140       else                                        140       else
141         usage 1 "$1 is not a testcase"            141         usage 1 "$1 is not a testcase"
142       fi                                          142       fi
143       ;;                                          143       ;;
144     *)                                            144     *)
145       if [ -d "$1" ]; then                        145       if [ -d "$1" ]; then
146         OPT_TEST_DIR=`abspath $1`                 146         OPT_TEST_DIR=`abspath $1`
147         OPT_TEST_CASES="$OPT_TEST_CASES `find_    147         OPT_TEST_CASES="$OPT_TEST_CASES `find_testcases $OPT_TEST_DIR`"
148         shift 1                                   148         shift 1
149       else                                        149       else
150         usage 1 "Invalid option ($1)"             150         usage 1 "Invalid option ($1)"
151       fi                                          151       fi
152     ;;                                            152     ;;
153     esac                                          153     esac
154   done                                            154   done
155   if [ ! -z "$OPT_TEST_CASES" ]; then             155   if [ ! -z "$OPT_TEST_CASES" ]; then
156     TEST_CASES=$OPT_TEST_CASES                    156     TEST_CASES=$OPT_TEST_CASES
157   fi                                              157   fi
158 }                                                 158 }
159                                                   159 
160 # Parameters                                      160 # Parameters
161 TRACING_DIR=`grep tracefs /proc/mounts | cut -    161 TRACING_DIR=`grep tracefs /proc/mounts | cut -f2 -d' ' | head -1`
162 if [ -z "$TRACING_DIR" ]; then                    162 if [ -z "$TRACING_DIR" ]; then
163     DEBUGFS_DIR=`grep debugfs /proc/mounts | c    163     DEBUGFS_DIR=`grep debugfs /proc/mounts | cut -f2 -d' ' | head -1`
164     if [ -z "$DEBUGFS_DIR" ]; then                164     if [ -z "$DEBUGFS_DIR" ]; then
165         # If tracefs exists, then so does /sys    165         # If tracefs exists, then so does /sys/kernel/tracing
166         if [ -d "/sys/kernel/tracing" ]; then     166         if [ -d "/sys/kernel/tracing" ]; then
167             mount -t tracefs nodev /sys/kernel    167             mount -t tracefs nodev /sys/kernel/tracing ||
168               errexit "Failed to mount /sys/ke    168               errexit "Failed to mount /sys/kernel/tracing"
169             TRACING_DIR="/sys/kernel/tracing"     169             TRACING_DIR="/sys/kernel/tracing"
170             UMOUNT_DIR=${TRACING_DIR}             170             UMOUNT_DIR=${TRACING_DIR}
171         # If debugfs exists, then so does /sys    171         # If debugfs exists, then so does /sys/kernel/debug
172         elif [ -d "/sys/kernel/debug" ]; then     172         elif [ -d "/sys/kernel/debug" ]; then
173             mount -t debugfs nodev /sys/kernel    173             mount -t debugfs nodev /sys/kernel/debug ||
174               errexit "Failed to mount /sys/ke    174               errexit "Failed to mount /sys/kernel/debug"
175             TRACING_DIR="/sys/kernel/debug/tra    175             TRACING_DIR="/sys/kernel/debug/tracing"
176             UMOUNT_DIR=${TRACING_DIR}             176             UMOUNT_DIR=${TRACING_DIR}
177         else                                      177         else
178             err_ret=$err_skip                     178             err_ret=$err_skip
179             errexit "debugfs and tracefs are n    179             errexit "debugfs and tracefs are not configured in this kernel"
180         fi                                        180         fi
181     else                                          181     else
182         TRACING_DIR="$DEBUGFS_DIR/tracing"        182         TRACING_DIR="$DEBUGFS_DIR/tracing"
183     fi                                            183     fi
184 fi                                                184 fi
185 if [ ! -d "$TRACING_DIR" ]; then                  185 if [ ! -d "$TRACING_DIR" ]; then
186     err_ret=$err_skip                             186     err_ret=$err_skip
187     errexit "ftrace is not configured in this     187     errexit "ftrace is not configured in this kernel"
188 fi                                                188 fi
189                                                   189 
190 TOP_DIR=`absdir $0`                               190 TOP_DIR=`absdir $0`
191 TEST_DIR=$TOP_DIR/test.d                          191 TEST_DIR=$TOP_DIR/test.d
192 TEST_CASES=`find_testcases $TEST_DIR`             192 TEST_CASES=`find_testcases $TEST_DIR`
193 LOG_TOP_DIR=$TOP_DIR/logs                         193 LOG_TOP_DIR=$TOP_DIR/logs
194 LOG_DATE=`date +%Y%m%d-%H%M%S`                    194 LOG_DATE=`date +%Y%m%d-%H%M%S`
195 LOG_DIR=$LOG_TOP_DIR/$LOG_DATE/                   195 LOG_DIR=$LOG_TOP_DIR/$LOG_DATE/
196 LINK_PTR=$LOG_TOP_DIR/latest                      196 LINK_PTR=$LOG_TOP_DIR/latest
197 KEEP_LOG=0                                        197 KEEP_LOG=0
198 KTAP=0                                            198 KTAP=0
199 DEBUG=0                                           199 DEBUG=0
200 VERBOSE=0                                         200 VERBOSE=0
201 UNSUPPORTED_RESULT=0                              201 UNSUPPORTED_RESULT=0
202 UNRESOLVED_RESULT=0                               202 UNRESOLVED_RESULT=0
203 STOP_FAILURE=0                                    203 STOP_FAILURE=0
204 # Parse command-line options                      204 # Parse command-line options
205 parse_opts $*                                     205 parse_opts $*
206                                                   206 
207 [ $DEBUG -ne 0 ] && set -x                        207 [ $DEBUG -ne 0 ] && set -x
208                                                   208 
209 # Verify parameters                               209 # Verify parameters
210 if [ -z "$TRACING_DIR" -o ! -d "$TRACING_DIR"     210 if [ -z "$TRACING_DIR" -o ! -d "$TRACING_DIR" ]; then
211   errexit "No ftrace directory found"             211   errexit "No ftrace directory found"
212 fi                                                212 fi
213                                                   213 
214 # Preparing logs                                  214 # Preparing logs
215 if [ "x$LOG_DIR" = "x-" ]; then                   215 if [ "x$LOG_DIR" = "x-" ]; then
216   LOG_FILE=                                       216   LOG_FILE=
217   date                                            217   date
218 else                                              218 else
219   LOG_FILE=$LOG_DIR/ftracetest.log                219   LOG_FILE=$LOG_DIR/ftracetest.log
220   mkdir -p $LOG_DIR || errexit "Failed to make    220   mkdir -p $LOG_DIR || errexit "Failed to make a log directory: $LOG_DIR"
221   date > $LOG_FILE                                221   date > $LOG_FILE
222   if [ "x-$LINK_PTR" != "x-" ]; then              222   if [ "x-$LINK_PTR" != "x-" ]; then
223     unlink $LINK_PTR                              223     unlink $LINK_PTR
224     ln -fs $LOG_DATE $LINK_PTR                    224     ln -fs $LOG_DATE $LINK_PTR
225   fi                                              225   fi
226 fi                                                226 fi
227                                                   227 
228 # Define text colors                              228 # Define text colors
229 # Check available colors on the terminal, if a    229 # Check available colors on the terminal, if any
230 ncolors=`tput colors 2>/dev/null || echo 0`       230 ncolors=`tput colors 2>/dev/null || echo 0`
231 color_reset=                                      231 color_reset=
232 color_red=                                        232 color_red=
233 color_green=                                      233 color_green=
234 color_blue=                                       234 color_blue=
235 # If stdout exists and number of colors is eig    235 # If stdout exists and number of colors is eight or more, use them
236 if [ -t 1 -a "$ncolors" -ge 8 ]; then             236 if [ -t 1 -a "$ncolors" -ge 8 ]; then
237   color_reset="\033[0m"                           237   color_reset="\033[0m"
238   color_red="\033[31m"                            238   color_red="\033[31m"
239   color_green="\033[32m"                          239   color_green="\033[32m"
240   color_blue="\033[34m"                           240   color_blue="\033[34m"
241 fi                                                241 fi
242                                                   242 
243 strip_esc() {                                     243 strip_esc() {
244   # busybox sed implementation doesn't accept     244   # busybox sed implementation doesn't accept "\x1B", so use [:cntrl:] instead.
245   sed -E "s/[[:cntrl:]]\[([0-9]{1,2}(;[0-9]{1,    245   sed -E "s/[[:cntrl:]]\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g"
246 }                                                 246 }
247                                                   247 
248 prlog() { # messages                              248 prlog() { # messages
249   newline="\n"                                    249   newline="\n"
250   if [ "$1" = "-n" ] ; then                       250   if [ "$1" = "-n" ] ; then
251     newline=                                      251     newline=
252     shift                                         252     shift
253   fi                                              253   fi
254   [ "$KTAP" != "1" ] && printf "$*$newline"       254   [ "$KTAP" != "1" ] && printf "$*$newline"
255   [ "$LOG_FILE" ] && printf "$*$newline" | str    255   [ "$LOG_FILE" ] && printf "$*$newline" | strip_esc >> $LOG_FILE
256 }                                                 256 }
257 catlog() { #file                                  257 catlog() { #file
258   if [ "${KTAP}" = "1" ]; then                    258   if [ "${KTAP}" = "1" ]; then
259     cat $1 | while read line ; do                 259     cat $1 | while read line ; do
260       echo "# $line"                              260       echo "# $line"
261     done                                          261     done
262   else                                            262   else
263     cat $1                                        263     cat $1
264   fi                                              264   fi
265   [ "$LOG_FILE" ] && cat $1 | strip_esc >> $LO    265   [ "$LOG_FILE" ] && cat $1 | strip_esc >> $LOG_FILE
266 }                                                 266 }
267 prlog "=== Ftrace unit tests ==="                 267 prlog "=== Ftrace unit tests ==="
268                                                   268 
269                                                   269 
270 # Testcase management                             270 # Testcase management
271 # Test result codes - Dejagnu extended code       271 # Test result codes - Dejagnu extended code
272 PASS=0  # The test succeeded.                     272 PASS=0  # The test succeeded.
273 FAIL=1  # The test failed, but was expected to    273 FAIL=1  # The test failed, but was expected to succeed.
274 UNRESOLVED=2  # The test produced indeterminat    274 UNRESOLVED=2  # The test produced indeterminate results. (e.g. interrupted)
275 UNTESTED=3    # The test was not run, currentl    275 UNTESTED=3    # The test was not run, currently just a placeholder.
276 UNSUPPORTED=4 # The test failed because of lac    276 UNSUPPORTED=4 # The test failed because of lack of feature.
277 XFAIL=5 # The test failed, and was expected to    277 XFAIL=5 # The test failed, and was expected to fail.
278                                                   278 
279 # Accumulations                                   279 # Accumulations
280 PASSED_CASES=                                     280 PASSED_CASES=
281 FAILED_CASES=                                     281 FAILED_CASES=
282 UNRESOLVED_CASES=                                 282 UNRESOLVED_CASES=
283 UNTESTED_CASES=                                   283 UNTESTED_CASES=
284 UNSUPPORTED_CASES=                                284 UNSUPPORTED_CASES=
285 XFAILED_CASES=                                    285 XFAILED_CASES=
286 UNDEFINED_CASES=                                  286 UNDEFINED_CASES=
287 TOTAL_RESULT=0                                    287 TOTAL_RESULT=0
288                                                   288 
289 INSTANCE=                                         289 INSTANCE=
290 CASENO=0                                          290 CASENO=0
291 CASENAME=                                         291 CASENAME=
292                                                   292 
293 testcase() { # testfile                           293 testcase() { # testfile
294   CASENO=$((CASENO+1))                            294   CASENO=$((CASENO+1))
295   CASENAME=`grep "^#[ \t]*description:" $1 | c    295   CASENAME=`grep "^#[ \t]*description:" $1 | cut -f2- -d:`
296 }                                                 296 }
297                                                   297 
298 checkreq() { # testfile                           298 checkreq() { # testfile
299   requires=`grep "^#[ \t]*requires:" $1 | cut     299   requires=`grep "^#[ \t]*requires:" $1 | cut -f2- -d:`
300   # Use eval to pass quoted-patterns correctly    300   # Use eval to pass quoted-patterns correctly.
301   eval check_requires "$requires"                 301   eval check_requires "$requires"
302 }                                                 302 }
303                                                   303 
304 test_on_instance() { # testfile                   304 test_on_instance() { # testfile
305   grep -q "^#[ \t]*flags:.*instance" $1           305   grep -q "^#[ \t]*flags:.*instance" $1
306 }                                                 306 }
307                                                   307 
308 ktaptest() { # result comment                     308 ktaptest() { # result comment
309   if [ "$KTAP" != "1" ]; then                     309   if [ "$KTAP" != "1" ]; then
310     return                                        310     return
311   fi                                              311   fi
312                                                   312 
313   local result=                                   313   local result=
314   if [ "$1" = "1" ]; then                         314   if [ "$1" = "1" ]; then
315     result="ok"                                   315     result="ok"
316   else                                            316   else
317     result="not ok"                               317     result="not ok"
318   fi                                              318   fi
319   shift                                           319   shift
320                                                   320 
321   local comment=$*                                321   local comment=$*
322   if [ "$comment" != "" ]; then                   322   if [ "$comment" != "" ]; then
323     comment="# $comment"                          323     comment="# $comment"
324   fi                                              324   fi
325                                                   325 
326   echo $result $CASENO $INSTANCE$CASENAME $com    326   echo $result $CASENO $INSTANCE$CASENAME $comment
327 }                                                 327 }
328                                                   328 
329 eval_result() { # sigval                          329 eval_result() { # sigval
330   case $1 in                                      330   case $1 in
331     $PASS)                                        331     $PASS)
332       prlog "   [${color_green}PASS${color_res    332       prlog "   [${color_green}PASS${color_reset}]"
333       ktaptest 1                                  333       ktaptest 1
334       PASSED_CASES="$PASSED_CASES $CASENO"        334       PASSED_CASES="$PASSED_CASES $CASENO"
335       return 0                                    335       return 0
336     ;;                                            336     ;;
337     $FAIL)                                        337     $FAIL)
338       prlog "   [${color_red}FAIL${color_reset    338       prlog "   [${color_red}FAIL${color_reset}]"
339       ktaptest 0                                  339       ktaptest 0
340       FAILED_CASES="$FAILED_CASES $CASENO"        340       FAILED_CASES="$FAILED_CASES $CASENO"
341       return 1 # this is a bug.                   341       return 1 # this is a bug.
342     ;;                                            342     ;;
343     $UNRESOLVED)                                  343     $UNRESOLVED)
344       prlog "   [${color_blue}UNRESOLVED${colo    344       prlog "   [${color_blue}UNRESOLVED${color_reset}]"
345       ktaptest 0 UNRESOLVED                       345       ktaptest 0 UNRESOLVED
346       UNRESOLVED_CASES="$UNRESOLVED_CASES $CAS    346       UNRESOLVED_CASES="$UNRESOLVED_CASES $CASENO"
347       return $UNRESOLVED_RESULT # depends on u    347       return $UNRESOLVED_RESULT # depends on use case
348     ;;                                            348     ;;
349     $UNTESTED)                                    349     $UNTESTED)
350       prlog "   [${color_blue}UNTESTED${color_    350       prlog "   [${color_blue}UNTESTED${color_reset}]"
351       ktaptest 1 SKIP                             351       ktaptest 1 SKIP
352       UNTESTED_CASES="$UNTESTED_CASES $CASENO"    352       UNTESTED_CASES="$UNTESTED_CASES $CASENO"
353       return 0                                    353       return 0
354     ;;                                            354     ;;
355     $UNSUPPORTED)                                 355     $UNSUPPORTED)
356       prlog "   [${color_blue}UNSUPPORTED${col    356       prlog "   [${color_blue}UNSUPPORTED${color_reset}]"
357       ktaptest 1 SKIP                             357       ktaptest 1 SKIP
358       UNSUPPORTED_CASES="$UNSUPPORTED_CASES $C    358       UNSUPPORTED_CASES="$UNSUPPORTED_CASES $CASENO"
359       return $UNSUPPORTED_RESULT # depends on     359       return $UNSUPPORTED_RESULT # depends on use case
360     ;;                                            360     ;;
361     $XFAIL)                                       361     $XFAIL)
362       prlog "   [${color_green}XFAIL${color_re    362       prlog "   [${color_green}XFAIL${color_reset}]"
363       ktaptest 1 XFAIL                            363       ktaptest 1 XFAIL
364       XFAILED_CASES="$XFAILED_CASES $CASENO"      364       XFAILED_CASES="$XFAILED_CASES $CASENO"
365       return 0                                    365       return 0
366     ;;                                            366     ;;
367     *)                                            367     *)
368       prlog "   [${color_blue}UNDEFINED${color    368       prlog "   [${color_blue}UNDEFINED${color_reset}]"
369       ktaptest 0 error                            369       ktaptest 0 error
370       UNDEFINED_CASES="$UNDEFINED_CASES $CASEN    370       UNDEFINED_CASES="$UNDEFINED_CASES $CASENO"
371       return 1 # this must be a test bug          371       return 1 # this must be a test bug
372     ;;                                            372     ;;
373   esac                                            373   esac
374 }                                                 374 }
375                                                   375 
376 # Signal handling for result codes                376 # Signal handling for result codes
377 SIG_RESULT=                                       377 SIG_RESULT=
378 SIG_BASE=36     # Use realtime signals            378 SIG_BASE=36     # Use realtime signals
379 SIG_PID=$$                                        379 SIG_PID=$$
380                                                   380 
381 exit_pass () {                                    381 exit_pass () {
382   exit 0                                          382   exit 0
383 }                                                 383 }
384                                                   384 
385 SIG_FAIL=$((SIG_BASE + FAIL))                     385 SIG_FAIL=$((SIG_BASE + FAIL))
386 exit_fail () {                                    386 exit_fail () {
387   exit 1                                          387   exit 1
388 }                                                 388 }
389 trap 'SIG_RESULT=$FAIL' $SIG_FAIL                 389 trap 'SIG_RESULT=$FAIL' $SIG_FAIL
390                                                   390 
391 SIG_UNRESOLVED=$((SIG_BASE + UNRESOLVED))         391 SIG_UNRESOLVED=$((SIG_BASE + UNRESOLVED))
392 exit_unresolved () {                              392 exit_unresolved () {
393   kill -s $SIG_UNRESOLVED $SIG_PID                393   kill -s $SIG_UNRESOLVED $SIG_PID
394   exit 0                                          394   exit 0
395 }                                                 395 }
396 trap 'SIG_RESULT=$UNRESOLVED' $SIG_UNRESOLVED     396 trap 'SIG_RESULT=$UNRESOLVED' $SIG_UNRESOLVED
397                                                   397 
398 SIG_UNTESTED=$((SIG_BASE + UNTESTED))             398 SIG_UNTESTED=$((SIG_BASE + UNTESTED))
399 exit_untested () {                                399 exit_untested () {
400   kill -s $SIG_UNTESTED $SIG_PID                  400   kill -s $SIG_UNTESTED $SIG_PID
401   exit 0                                          401   exit 0
402 }                                                 402 }
403 trap 'SIG_RESULT=$UNTESTED' $SIG_UNTESTED         403 trap 'SIG_RESULT=$UNTESTED' $SIG_UNTESTED
404                                                   404 
405 SIG_UNSUPPORTED=$((SIG_BASE + UNSUPPORTED))       405 SIG_UNSUPPORTED=$((SIG_BASE + UNSUPPORTED))
406 exit_unsupported () {                             406 exit_unsupported () {
407   kill -s $SIG_UNSUPPORTED $SIG_PID               407   kill -s $SIG_UNSUPPORTED $SIG_PID
408   exit 0                                          408   exit 0
409 }                                                 409 }
410 trap 'SIG_RESULT=$UNSUPPORTED' $SIG_UNSUPPORTE    410 trap 'SIG_RESULT=$UNSUPPORTED' $SIG_UNSUPPORTED
411                                                   411 
412 SIG_XFAIL=$((SIG_BASE + XFAIL))                   412 SIG_XFAIL=$((SIG_BASE + XFAIL))
413 exit_xfail () {                                   413 exit_xfail () {
414   kill -s $SIG_XFAIL $SIG_PID                     414   kill -s $SIG_XFAIL $SIG_PID
415   exit 0                                          415   exit 0
416 }                                                 416 }
417 trap 'SIG_RESULT=$XFAIL' $SIG_XFAIL               417 trap 'SIG_RESULT=$XFAIL' $SIG_XFAIL
418                                                   418 
419 __run_test() { # testfile                         419 __run_test() { # testfile
420   # setup PID and PPID, $$ is not updated.        420   # setup PID and PPID, $$ is not updated.
421   (cd $TRACING_DIR; read PID _ < /proc/self/st    421   (cd $TRACING_DIR; read PID _ < /proc/self/stat; set -e; set -x;
422    checkreq $1; initialize_ftrace; . $1)          422    checkreq $1; initialize_ftrace; . $1)
423   [ $? -ne 0 ] && kill -s $SIG_FAIL $SIG_PID      423   [ $? -ne 0 ] && kill -s $SIG_FAIL $SIG_PID
424 }                                                 424 }
425                                                   425 
426 # Run one test case                               426 # Run one test case
427 run_test() { # testfile                           427 run_test() { # testfile
428   local testname=`basename $1`                    428   local testname=`basename $1`
429   testcase $1                                     429   testcase $1
430   prlog -n "[$CASENO]$INSTANCE$CASENAME"          430   prlog -n "[$CASENO]$INSTANCE$CASENAME"
431   if [ ! -z "$LOG_FILE" ] ; then                  431   if [ ! -z "$LOG_FILE" ] ; then
432     local testlog=`mktemp $LOG_DIR/${CASENO}-$    432     local testlog=`mktemp $LOG_DIR/${CASENO}-${testname}-log.XXXXXX`
433   else                                            433   else
434     local testlog=/proc/self/fd/1                 434     local testlog=/proc/self/fd/1
435   fi                                              435   fi
436   export TMPDIR=`mktemp -d /tmp/ftracetest-dir    436   export TMPDIR=`mktemp -d /tmp/ftracetest-dir.XXXXXX`
437   export FTRACETEST_ROOT=$TOP_DIR                 437   export FTRACETEST_ROOT=$TOP_DIR
438   echo "execute$INSTANCE: "$1 > $testlog          438   echo "execute$INSTANCE: "$1 > $testlog
439   SIG_RESULT=0                                    439   SIG_RESULT=0
440   if [ $VERBOSE -eq -1 ]; then                    440   if [ $VERBOSE -eq -1 ]; then
441     __run_test $1                                 441     __run_test $1
442   elif [ -z "$LOG_FILE" ]; then                   442   elif [ -z "$LOG_FILE" ]; then
443     __run_test $1 2>&1                            443     __run_test $1 2>&1
444   elif [ $VERBOSE -ge 3 ]; then                   444   elif [ $VERBOSE -ge 3 ]; then
445     __run_test $1 | tee -a $testlog 2>&1          445     __run_test $1 | tee -a $testlog 2>&1
446   elif [ $VERBOSE -eq 2 ]; then                   446   elif [ $VERBOSE -eq 2 ]; then
447     __run_test $1 2>> $testlog | tee -a $testl    447     __run_test $1 2>> $testlog | tee -a $testlog
448   else                                            448   else
449     __run_test $1 >> $testlog 2>&1                449     __run_test $1 >> $testlog 2>&1
450   fi                                              450   fi
451   eval_result $SIG_RESULT                         451   eval_result $SIG_RESULT
452   if [ $? -eq 0 ]; then                           452   if [ $? -eq 0 ]; then
453     # Remove test log if the test was done as     453     # Remove test log if the test was done as it was expected.
454     [ $KEEP_LOG -eq 0 -a ! -z "$LOG_FILE" ] &&    454     [ $KEEP_LOG -eq 0 -a ! -z "$LOG_FILE" ] && rm $testlog
455   else                                            455   else
456     [ $VERBOSE -eq 1 -o $VERBOSE -eq 2 ] && ca    456     [ $VERBOSE -eq 1 -o $VERBOSE -eq 2 ] && catlog $testlog
457     TOTAL_RESULT=1                                457     TOTAL_RESULT=1
458   fi                                              458   fi
459   rm -rf $TMPDIR                                  459   rm -rf $TMPDIR
460 }                                                 460 }
461                                                   461 
462 # load in the helper functions                    462 # load in the helper functions
463 . $TEST_DIR/functions                             463 . $TEST_DIR/functions
464                                                   464 
465 if [ "$KTAP" = "1" ]; then                        465 if [ "$KTAP" = "1" ]; then
466   echo "TAP version 13"                           466   echo "TAP version 13"
467                                                   467 
468   casecount=`echo $TEST_CASES | wc -w`            468   casecount=`echo $TEST_CASES | wc -w`
469   for t in $TEST_CASES; do                        469   for t in $TEST_CASES; do
470     test_on_instance $t || continue               470     test_on_instance $t || continue
471     casecount=$((casecount+1))                    471     casecount=$((casecount+1))
472   done                                            472   done
473   echo "1..${casecount}"                          473   echo "1..${casecount}"
474 fi                                                474 fi
475                                                   475 
476 # Main loop                                       476 # Main loop
477 for t in $TEST_CASES; do                          477 for t in $TEST_CASES; do
478   run_test $t                                     478   run_test $t
479   if [ $STOP_FAILURE -ne 0 -a $TOTAL_RESULT -n    479   if [ $STOP_FAILURE -ne 0 -a $TOTAL_RESULT -ne 0 ]; then
480     echo "A failure detected. Stop test."         480     echo "A failure detected. Stop test."
481     exit 1                                        481     exit 1
482   fi                                              482   fi
483 done                                              483 done
484                                                   484 
485 # Test on instance loop                           485 # Test on instance loop
486 INSTANCE=" (instance) "                           486 INSTANCE=" (instance) "
487 for t in $TEST_CASES; do                          487 for t in $TEST_CASES; do
488   test_on_instance $t || continue                 488   test_on_instance $t || continue
489   SAVED_TRACING_DIR=$TRACING_DIR                  489   SAVED_TRACING_DIR=$TRACING_DIR
490   export TRACING_DIR=`mktemp -d $TRACING_DIR/i    490   export TRACING_DIR=`mktemp -d $TRACING_DIR/instances/ftracetest.XXXXXX`
491   run_test $t                                     491   run_test $t
492   rmdir $TRACING_DIR                              492   rmdir $TRACING_DIR
493   TRACING_DIR=$SAVED_TRACING_DIR                  493   TRACING_DIR=$SAVED_TRACING_DIR
494   if [ $STOP_FAILURE -ne 0 -a $TOTAL_RESULT -n    494   if [ $STOP_FAILURE -ne 0 -a $TOTAL_RESULT -ne 0 ]; then
495     echo "A failure detected. Stop test."         495     echo "A failure detected. Stop test."
496     exit 1                                        496     exit 1
497   fi                                              497   fi
498 done                                              498 done
499 (cd $TRACING_DIR; finish_ftrace) # for cleanup    499 (cd $TRACING_DIR; finish_ftrace) # for cleanup
500                                                   500 
501 prlog ""                                          501 prlog ""
502 prlog "# of passed: " `echo $PASSED_CASES | wc    502 prlog "# of passed: " `echo $PASSED_CASES | wc -w`
503 prlog "# of failed: " `echo $FAILED_CASES | wc    503 prlog "# of failed: " `echo $FAILED_CASES | wc -w`
504 prlog "# of unresolved: " `echo $UNRESOLVED_CA    504 prlog "# of unresolved: " `echo $UNRESOLVED_CASES | wc -w`
505 prlog "# of untested: " `echo $UNTESTED_CASES     505 prlog "# of untested: " `echo $UNTESTED_CASES | wc -w`
506 prlog "# of unsupported: " `echo $UNSUPPORTED_    506 prlog "# of unsupported: " `echo $UNSUPPORTED_CASES | wc -w`
507 prlog "# of xfailed: " `echo $XFAILED_CASES |     507 prlog "# of xfailed: " `echo $XFAILED_CASES | wc -w`
508 prlog "# of undefined(test bug): " `echo $UNDE    508 prlog "# of undefined(test bug): " `echo $UNDEFINED_CASES | wc -w`
509                                                   509 
510 if [ "$KTAP" = "1" ]; then                        510 if [ "$KTAP" = "1" ]; then
511   echo -n "# Totals:"                             511   echo -n "# Totals:"
512   echo -n " pass:"`echo $PASSED_CASES | wc -w`    512   echo -n " pass:"`echo $PASSED_CASES | wc -w`
513   echo -n " fail:"`echo $FAILED_CASES | wc -w`    513   echo -n " fail:"`echo $FAILED_CASES | wc -w`
514   echo -n " xfail:"`echo $XFAILED_CASES | wc -    514   echo -n " xfail:"`echo $XFAILED_CASES | wc -w`
515   echo -n " xpass:0"                              515   echo -n " xpass:0"
516   echo -n " skip:"`echo $UNTESTED_CASES $UNSUP    516   echo -n " skip:"`echo $UNTESTED_CASES $UNSUPPORTED_CASES | wc -w`
517   echo -n " error:"`echo $UNRESOLVED_CASES $UN    517   echo -n " error:"`echo $UNRESOLVED_CASES $UNDEFINED_CASES | wc -w`
518   echo                                            518   echo
519 fi                                                519 fi
520                                                   520 
521 cleanup                                           521 cleanup
522                                                   522 
523 # if no error, return 0                           523 # if no error, return 0
524 exit $TOTAL_RESULT                                524 exit $TOTAL_RESULT
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php