Allow running utimensat test from a directory different from $LTPROOT/testcases/bin
[ltp-debian.git] / runltp
blob7d9e0738d6632efe69759fbd338f98c6479feada
1 #!/bin/sh
2 ################################################################################
3 ## ##
4 ## Copyright (c) International Business Machines Corp., 2001 ##
5 ## ##
6 ## This program is free software; you can redistribute it and#or modify ##
7 ## it under the terms of the GNU General Public License as published by ##
8 ## the Free Software Foundation; either version 2 of the License, or ##
9 ## (at your option) any later version. ##
10 ## ##
11 ## This program is distributed in the hope that it will be useful, but ##
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
13 ## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ##
14 ## for more details. ##
15 ## ##
16 ## You should have received a copy of the GNU General Public License ##
17 ## along with this program; if not, write to the Free Software ##
18 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ##
19 ## ##
20 ################################################################################
21 # File: runltp
23 # Description: This script can be used to the tests in the LTP test suite
25 # Authors: Manoj Iyer - manjo@mail.utexas.edu
26 # Robbe Williamson - robbiew@us.ibm.com
28 # History: Oct 07 2003 - Modified - Manoj Iyer
29 # - use functions
30 # - clean up on script exit
31 # - error checking etc.
33 # Oct 08 2003 - Modified - Manoj Iyer
34 # - fixed bug in creating results directory
35 # - all checks should be enlclosed in " " to avoid bash error
36 # - exit with error if ltp-pan is not found in pan directory
38 # Jul 22 2007 - Modified - Ricardo Salveti de Araujo
39 # - added support to put more then one file at CMDLINE (-f)
40 # - added a new option, that the user can pass the address of
41 # the command file, and it'll use wget to get it (-w)
42 # - now -s does the grep at the selected command files (default,
43 # -f or -w)
45 # Jul 23 2007 - Modified - Ricardo Salveti de Araujo
46 # - added flag to get the command file that has all failed tests
48 # Sep 11 2007 - Modified - Subrata Modak
49 # - added option to create Failed File if it is not an absolute path
50 # - added option to create Output File if it is not an absolute path
51 # - added option to create Failed File compulsory, even if user has not mentioned it
53 # Sep 14 2007 - Modified - Ricardo Salveti de Araujo
54 # - cleaning and removing duplicated code
56 # Oct 27 2007 - Modified - Ricardo Salveti de Araujo and Subrata Modak
57 # - better ways to integrate "ltp/tools/genload/stress" with "ltp/runltp"
58 # Nov 24 2007 - Modified - Subrata Modak
59 # - Added a new option to generate output in HTML format also. Also retaining
60 # the original test format
61 # Nov 28 2007 - Modified - Subrata Modak
62 # - Added a new option to mail back LTP reports
63 # May 19 2008 - Modified - Subrata Modak
64 # - Added capability for default Log file generation
65 # Aug 17 2009 - Modified - Subrata Modak
66 # - Added Fault Injection generation Capability through -F Option
68 # Debian changes:
70 # May 12 2004 - Modified Alastair McKinstry
71 # - changed directory, file locations for ltp package
73 #################################################################################
77 setup()
79 cd `dirname $0` || \
81 echo "FATAL: unable to change directory to $(dirname $0)"
82 exit 1
84 export LTPROOT=/usr/lib/ltp
85 export LTPTOOLS=/usr/lib/ltp/tools
86 export RESULTSDIR=/var/cache/ltp/results
87 export TMPBASE="/tmp"
88 export PATH="${PATH}:${LTPROOT}/testcases/bin"
90 [ -d "$LTPROOT/testcases/bin" ] ||
92 echo "FATAL: Test suite not installed correctly"
93 echo "INFO: as root user type 'make ; make install'"
94 exit 1
97 [ -e $LTPTOOLS/ltp-pan ] ||
99 echo "FATAL: Test suite driver 'ltp-pan' not found"
100 echo "INFO: as root user type 'make ; make install'"
101 exit 1
105 version_of_ltp()
107 zcat /usr/share/doc/ltp-tools/changelog.gz | head -n 1
108 exit 0
111 usage()
113 cat <<-EOF >&2
115 usage: ./${0##*/} [ -a EMAIL_TO ] [ -c NUM_PROCS ] [ -C FAILCMDFILE ] [ -d TMPDIR ]
116 [ -D NUM_PROCS,NUM_FILES,NUM_BYTES,CLEAN_FLAG ] -e [ -f CMDFILES(,...) ] [ -g HTMLFILE]
117 [ -i NUM_PROCS ] [ -l LOGFILE ] [ -m NUM_PROCS,CHUNKS,BYTES,HANGUP_FLAG ]
118 -N -n [ -o OUTPUTFILE ] -p -q [ -r LTPROOT ] [ -s PATTERN ] [ -t DURATION ]
119 -v [ -w CMDFILEADDR ] [ -x INSTANCES ] [ -b DEVICE ] [-B DEVICE_FS_TYPE]
120 [ -F LOOPS,PERCENTAGE ]
122 -a EMAIL_TO EMAIL all your Reports to this E-mail Address
123 -c NUM_PROCS Run LTP under additional background CPU load
124 [NUM_PROCS = no. of processes creating the CPU Load by spinning over sqrt()
125 (Defaults to 1 when value)]
126 -C FAILCMDFILE Command file with all failed test cases.
127 -d TMPDIR Directory where temporary files will be created.
128 -D NUM_PROCS,NUM_FILES,NUM_BYTES,CLEAN_FLAG
129 Run LTP under additional background Load on Secondary Storage (Seperate by comma)
130 [NUM_PROCS = no. of processes creating Storage Load by spinning over write()]
131 [NUM_FILES = Write() to these many files (Defaults to 1 when value 0 or undefined)]
132 [NUM_BYTES = write these many bytes (defaults to 1GB, when value 0 or undefined)]
133 [CLEAN_FLAG = unlink file to which random data written, when value 1]
134 -e Prints the date of the current LTP release
135 -f CMDFILES Execute user defined list of testcases (separate with ',')
136 -F LOOPS,PERCENTAGE Induce PERCENTAGE Fault in the Kernel Subsystems, and, run each test for LOOPS loop
137 -g HTMLFILE Create an additional HTML output format
138 -h Help. Prints all available options.
139 -i NUM_PROCS Run LTP under additional background Load on IO Bus
140 [NUM_PROCS = no. of processes creating IO Bus Load by spinning over sync()]
141 -l LOGFILE Log results of test in a logfile.
142 -m NUM_PROCS,CHUNKS,BYTES,HANGUP_FLAG
143 Run LTP under additional background Load on Main memory (Seperate by comma)
144 [NUM_PROCS = no. of processes creating main Memory Load by spinning over malloc()]
145 [CHUNKS = malloc these many chunks (default is 1 when value 0 or undefined)]
146 [BYTES = malloc CHUNKS of BYTES bytes (default is 256MB when value 0 or undefined) ]
147 [HANGUP_FLAG = hang in a sleep loop after memory allocated, when value 1]
148 -M CHECK_TYPE
149 [CHECK_TYPE=1 => Full Memory Leak Check tracing children as well]
150 [CHECK_TYPE=2 => Thread Concurrency Check tracing children as well]
151 [CHECK_TYPE=3 => Full Memory Leak & Thread Concurrency Check tracing children as well]
152 -N Run all the networking tests.
153 -n Run LTP with network traffic in background.
154 -o OUTPUTFILE Redirect test output to a file.
155 -p Human readable format logfiles.
156 -q Print less verbose output to screen.
157 -r LTPROOT Fully qualified path where testsuite is installed.
158 -s PATTERN Only run test cases which match PATTERN.
159 -S SKIPFILE Skip tests specified in SKIPFILE
160 -t DURATION Execute the testsuite for given duration. Examples:
161 -t 60s = 60 seconds
162 -t 45m = 45 minutes
163 -t 24h = 24 hours
164 -t 2d = 2 days
165 -T REPETITION Execute the testsuite for REPETITION no. of times
166 -w CMDFILEADDR Uses wget to get the user's list of testcases.
167 -x INSTANCES Run multiple instances of this testsuite.
168 -b DEVICE Some tests require an unmounted block device
169 to run correctly.
170 -B DEVICE_FS_TYPE The file system of test block devices.
173 example: ./${0##*/} -c 2 -i 2 -m 2,4,10240,1 -D 2,10,10240,1 -p -q -l /tmp/result-log.$$ -o /tmp/result-output.$$ -C /tmp/result-failed.$$ -d ${PWD}
177 exit 0
180 main()
182 local CMDFILES=""
183 local PRETTY_PRT=""
184 local ALT_DIR_OUT=0
185 local ALT_DIR_RES=0
186 local ALT_HTML_OUT=0
187 local ALT_EMAIL_OUT=0
188 local RUN_NETEST=0
189 local RUN_REPEATED=0
190 local QUIET_MODE=""
191 local NETPIPE=0
192 local GENLOAD=0
193 local MEMSIZE=0
194 local DURATION=""
195 local CMDFILEADDR=""
196 local FAILCMDFILE=""
197 local INJECT_KERNEL_FAULT=""
198 local INJECT_KERNEL_FAULT_PERCENTAGE=""
199 local INJECT_FAULT_LOOPS_PER_TEST=""
200 local VALGRIND_CHECK=""
201 local VALGRIND_CHECK_TYPE=""
202 local LOGFILE_NAME=""
203 local LOGFILE=""
204 local OUTPUTFILE_NAME=""
205 local OUTPUTFILE=""
206 local HTMLFILE_NAME=""
207 local HTMLFILE=""
208 local EMAIL_TO=""
209 local SCENFILES=""
210 local TAG_RESTRICT_STRING=""
211 local PAN_COMMAND=""
212 version_date=`zcat /usr/share/doc/ltp-tools/changelog.gz | head -n 1 `
213 local DEFAULT_FILE_NAME_GENERATION_TIME=`date +"%Y_%b_%d-%Hh_%Mm_%Ss"`
215 while getopts a:c:C:d:D:f:F:ehi:g:l:m:M:Nno:pqr:s:S:t:T:w:x:b:B: arg
216 do case $arg in
217 a) EMAIL_TO=$OPTARG
218 ALT_EMAIL_OUT=1;;
220 NUM_PROCS=$(($OPTARG))
221 if [ "$NUM_PROCS" -eq 0 ]; then
222 # User Did not Define the Value ,or, User Defined Zero,
223 # hence, prevent from creating infinite processes
224 NUM_PROCS=1
226 $LTPROOT/testcases/bin/genload --cpu $NUM_PROCS >/dev/null 2>&1 &
227 GENLOAD=1 ;;
230 case $OPTARG in
232 FAILCMDFILE="-C $OPTARG" ;;
234 FAILCMDFILE="-C $RESULTSDIR/$OPTARG"
235 ALT_DIR_OUT=1 ;;
236 esac ;;
238 d) # convert the user path to absolute path.
239 export TMPBASE=`cd \`dirname ${OPTARG}\`; pwd`/`basename ${OPTARG}` ;;
241 D) NUM_PROCS=1; NUM_FILES=1; NUM_BYTES=$((1024 * 1024 * 1024)); CLEAN_FLAG=0
242 ARGUMENT_LIST=$OPTARG
243 TOTAL_ARGUMENTS=1 # Initial Assume
244 for ARGUMENT in `echo "$ARGUMENT_LIST" | sed 's/,/\n/g'` # Store all value in a Loop
246 case $TOTAL_ARGUMENTS in
247 1) NUM_PROCS="$ARGUMENT" ;;
248 2) NUM_FILES="$ARGUMENT" ;;
249 3) NUM_BYTES="$ARGUMENT" ;;
250 4) CLEAN_FLAG="$ARGUMENT" ;;
251 esac
252 TOTAL_ARGUMENTS=`expr $TOTAL_ARGUMENTS + 1`
253 done
254 # just to get the default values if the user passed 0
255 if [ "$NUM_PROCS" -eq 0 ]; then
256 NUM_PROCS=1
258 if [ "$NUM_FILES" -eq 0 ]; then
259 NUM_FILES=1
261 if [ "$NUM_BYTES" -eq 0 ]; then
262 NUM_BYTES=$((1024 * 1024 * 1024))
264 if [ "$CLEAN_FLAG" -ne 1 ]; then
265 CLEAN_FLAG=0
267 if [ "$CLEAN_FLAG" -eq 1 ]; then
268 # Do not unlink file in this case
269 $LTPROOT/testcases/bin/genload --hdd $NUM_PROCS --hdd-files \
270 $NUM_FILES --hdd-bytes $NUM_BYTES >/dev/null 2>&1 &
271 else
272 # Cleanup otherwise
273 $LTPROOT/testcases/bin/genload --hdd $NUM_PROCS --hdd-files \
274 $NUM_FILES --hdd-bytes $NUM_BYTES --hdd-noclean >/dev/null 2>&1 &
276 GENLOAD=1;;
278 e) # Print out the version of LTP
279 version_of_ltp
281 f) # Execute user defined set of testcases.
282 # Can be more then one file, just separate it with ',', like:
283 # -f nfs,commands,/tmp/testfile
284 CMDFILES=$OPTARG;;
285 F) INJECT_KERNEL_FAULT=1
286 #Seperate out the NO_OF_LOOPS & FAULT_PERCENTAGE
287 INJECT_FAULT_LOOPS_PER_TEST=`echo $OPTARG |cut -d',' -f1 | tr -d '\n' | tr -d ' '`
288 INJECT_KERNEL_FAULT_PERCENTAGE=`echo $OPTARG |cut -d',' -f2 | tr -d '\n' | tr -d ' '`
289 if [ ! $INJECT_FAULT_LOOPS_PER_TEST ]; then
290 echo "Loops not properly defined. Resorting to default 5..."
291 export INJECT_FAULT_LOOPS_PER_TEST=5
293 if [ ! $INJECT_KERNEL_FAULT_PERCENTAGE ]; then
294 echo "Fault Persentage not properly defined. Resorting to default 10..."
295 export INJECT_KERNEL_FAULT_PERCENTAGE=10
296 fi;;
297 g) HTMLFILE_NAME="$OPTARG"
298 case $OPTARG in
300 HTMLFILE="$OPTARG";;
302 HTMLFILE="$RESULTSDIR/$OPTARG";;
303 esac
304 ALT_DIR_OUT=1
305 ALT_HTML_OUT=1;;
306 h) usage;;
309 NUM_PROCS=$(($OPTARG))
310 if [ "$NUM_PROCS" -eq 0 ]; then
311 # User Did not Define the Value ,or, User Defined Zero,
312 # hence, prevent from creating infinite processes
313 NUM_PROCS=1
315 $LTPROOT/testcases/bin/genload --io $NUM_PROCS >/dev/null 2>&1 &
316 GENLOAD=1 ;;
319 LOGFILE_NAME="$OPTARG"
320 case $OPTARG in
322 LOGFILE="-l $OPTARG" ;;
324 LOGFILE="-l $RESULTSDIR/$OPTARG"
325 ALT_DIR_RES=1 ;;
326 esac ;;
328 m) NUM_PROCS=1; CHUNKS=1; BYTES=$((256 * 1024 * 1024)); HANGUP_FLAG=0
329 ARGUMENT_LIST=$OPTARG
330 TOTAL_ARGUMENTS=1 # Initial Assume
331 for ARGUMENT in `echo "$ARGUMENT_LIST" | sed 's/,/\n/g'` # Store all value in a Loop
333 case $TOTAL_ARGUMENTS in
334 1) NUM_PROCS="$ARGUMENT" ;;
335 2) CHUNKS="$ARGUMENT" ;;
336 3) BYTES="$ARGUMENT" ;;
337 4) HANGUP_FLAG="$ARGUMENT" ;;
338 esac
339 TOTAL_ARGUMENTS=`expr $TOTAL_ARGUMENTS + 1`
340 done
341 # just to get the default values if the user passed 0
342 if [ "$NUM_PROCS" -eq 0 ]; then
343 NUM_PROCS=1
345 if [ "$CHUNKS" -eq 0 ]; then
346 CHUNKS=1
348 if [ "$BYTES" -eq 0 ]; then
349 BYTES=$((256 * 1024 * 1024))
351 if [ "$HANGUP_FLAG" -ne 1 ]; then
352 HANGUP_FLAG=0
354 if [ "$HANGUP_FLAG" -eq 1 ]; then
355 # Hang in a Sleep loop after memory allocated
356 $LTPROOT/testcases/bin/genload --vm $NUM_PROCS --vm-chunks \
357 $CHUNKS --vm-bytes $BYTES --vm-hang >/dev/null 2>&1 &
358 else
359 # Otherwise Do not Hangup
360 $LTPROOT/testcases/bin/genload --vm $NUM_PROCS --vm-chunks \
361 $CHUNKS --vm-bytes $BYTES >/dev/null 2>&1 &
363 GENLOAD=1;;
365 VALGRIND_CHECK=1
366 VALGRIND_CHECK_TYPE="$OPTARG";;
368 N) RUN_NETEST=1;;
371 $LTPROOT/testcases/bin/netpipe.sh
372 NETPIPE=1;;
374 o) OUTPUTFILE_NAME="$OPTARG"
375 case $OPTARG in
377 OUTPUTFILE="-o $OPTARG";;
379 OUTPUTFILE="-o $RESULTSDIR/$OPTARG"
380 ALT_DIR_OUT=1 ;;
381 esac ;;
383 p) PRETTY_PRT=" -p ";;
385 q) QUIET_MODE=" -q ";;
387 r) LTPROOT=$OPTARG;;
389 s) TAG_RESTRICT_STRING=$OPTARG;;
391 S) case $OPTARG in
393 SKIPFILE=$OPTARG;;
395 SKIPFILE="$LTPROOT/$OPTARG";;
396 esac ;;
398 t) # In case you want to specify the time
399 # to run from the command line
400 # (2m = two minutes, 2h = two hours, etc)
401 DURATION="-t $OPTARG" ;;
403 T) # In case you want the testcases to runsequentially RUN_REPEATED times
404 RUN_REPEATED=$OPTARG;;
406 w) CMDFILEADDR=$OPTARG;;
408 x) # number of ltp's to run
409 cat <<-EOF >&1
410 WARNING: The use of -x can cause unpredictable failures, as a
411 result of concurrently running multiple tests designed
412 to be ran exclusively.
413 Pausing for 10 seconds..."
415 sleep 10
416 INSTANCES="-x $OPTARG";;
417 b) DEVICE=$OPTARG;;
418 B) DEVICE_FS_TYPE=$OPTARG;;
419 \?) usage;;
420 esac
421 done
423 ## It would be nice to create a default log file even if the user has not mentioned
424 if [ ! "$LOGFILE" ]; then ## User has not mentioned about Log File name
425 LOGFILE_NAME=$DEFAULT_FILE_NAME_GENERATION_TIME
426 LOGFILE="-l $LTPROOT/results/LTP_RUN_ON-$LOGFILE_NAME.log"
427 ALT_DIR_RES=1
428 PRETTY_PRT=" -p "
431 ## It would be nice if a Failed File is compulsorily created (gives User better Idea of Tests that failed)
433 if [ ! "$FAILCMDFILE" ]; then ## User has not mentioned about Failed File name
434 ALT_DIR_OUT=1
435 if [ ! "$OUTPUTFILE" ]; then ## User has not mentioned about Output File name either
436 if [ ! "$LOGFILE" ]; then ## User has not mentioned about Log File name either
437 FAILCMDFILE="-C $RESULTSDIR/LTP_RUN_ON-$FAILED_FILE_NAME.failed"
438 FAILED_FILE_NAME=$DEFAULT_FILE_NAME_GENERATION_TIME
439 else ## User Fortunately wanted a log file,
440 FAILED_FILE_NAME=`basename ${LOGFILE_NAME}` ## Extract log file name and use it to construct Failed file name
441 FAILCMDFILE="-C $RESULTSDIR/LTP_RUN_ON-$FAILED_FILE_NAME.failed"
443 else ## User Fortunately wanted a Output file
444 FAILED_FILE_NAME=`basename $OUTPUTFILE_NAME` ## Extract output file name and use it to construct Failed file name
445 FAILCMDFILE="-C $RESULTSDIR/LTP_RUN_ON-$FAILED_FILE_NAME.failed"
449 if [ "$ALT_HTML_OUT" -eq 1 ] ; then ## User wants the HTML version of the output
450 QUIET_MODE="" ## Suppressing this guy as it will prevent generation of proper output
451 ## which the HTML parser will require
452 if [ ! "$OUTPUTFILE" ]; then ## User has not mentioned about the Outputfile name, then we need to definitely generate one
453 OUTPUTFILE="-o $RESULTSDIR/LTP_RUN_ON-$OUTPUTFILE_NAME.output"
454 OUTPUTFILE_NAME=$DEFAULT_FILE_NAME_GENERATION_TIME
455 ALT_DIR_OUT=1
456 if [ ! "$HTMLFILE" ] ; then ## User has not mentioned HTML File name, We need to create one
457 HTMLFILE_NAME=`basename $OUTPUTFILE_NAME`
458 HTMLFILE="$RESULTSDIR/$HTMLFILE_NAME.html"
463 # If we need, create the output directory
464 [ "$ALT_DIR_OUT" -eq 1 ] && \
466 echo "INFO: creating $RESULTSDIR directory"
467 [ ! -d $RESULTSDIR ] && \
469 mkdir -p $RESULTSDIR || \
471 echo "ERROR: failed to create $RESULTSDIR"
472 exit 1
476 # If we need, create the results directory
477 [ "$ALT_DIR_RES" -eq 1 ] && \
479 echo "INFO: creating $RESULTSDIR directory"
480 [ ! -d $RESULTSDIR ] && \
482 mkdir -p $RESULTSDIR || \
484 echo "ERROR: failed to create $RESULTSDIR"
485 exit 1
490 # Added -m 777 for tests that call tst_tmpdir() and try to
491 # write to it as user nobody
492 mkdir -m 777 -p $TMPBASE || \
494 echo "FATAL: Unable to make temporary directory $TMPBASE"
495 exit 1
497 # use mktemp to create "safe" temporary directories
498 export TMPTEMPLATE="${TMPBASE}/ltp-XXXXXXXXXX"
499 TMP=`mktemp -d $TMPTEMPLATE` || \
501 echo "FATAL: Unable to make temporary directory: $TMP"
502 exit 1
504 export TMP
505 # To be invoked by tst_tmpdir()
506 # write to it as user nobody
507 export TMPDIR=$TMP
509 chmod 777 $TMP || \
511 echo "unable to chmod 777 $TMP ... aborting"
512 exit 1
515 cd $TMP || \
517 echo "could not cd ${TMP} ... exiting"
518 exit 1
521 ! [ -z $INSTANCES ] && \
523 INSTANCES="$INSTANCES -O ${TMP}"
526 [ "$RUN_NETEST" -eq 1 ] && \
528 [ -z "$RHOST" ] || [ -z "$PASSWD" ] && \
530 [ -z "$RHOST" ] && \
532 echo \
533 "INFO: Enter RHOST = 'name of the remote host machine'"
534 echo -n "-> "
535 read RHOST
538 [ -z "$PASSWD" ] && \
540 echo " "
541 echo \
542 "INFO: Enter PASSWD = 'root passwd of the remote host machine'"
543 echo -n "-> "
544 read PASSWD
546 export RHOST=$RHOST
547 export PASSWD=$PASSWD
548 echo "WARNING: security of $RHOST may be compromised"
552 # If user does not provide a command file select a default set of testcases
553 # to execute.
554 if [ -z "$CMDFILES" ] && [ -z "$CMDFILEADDR" ]
555 then
556 cat <<-EOF >&1
558 INFO: no command files were provided, using default,
559 system calls, memory management, IPC, scheduler
560 direct io, file system, math and pty tests will
561 now be executed
565 for SCENFILES in ${LTPROOT}/runtest/syscalls \
566 ${LTPROOT}/runtest/fs \
567 ${LTPROOT}/runtest/fsx \
568 ${LTPROOT}/runtest/dio \
569 ${LTPROOT}/runtest/io \
570 ${LTPROOT}/runtest/mm \
571 ${LTPROOT}/runtest/ipc \
572 ${LTPROOT}/runtest/sched \
573 ${LTPROOT}/runtest/math \
574 ${LTPROOT}/runtest/nptl \
575 ${LTPROOT}/runtest/pty \
576 ${LTPROOT}/runtest/containers \
577 ${LTPROOT}/runtest/fs_bind \
578 ${LTPROOT}/runtest/controllers \
579 ${LTPROOT}/runtest/filecaps \
580 ${LTPROOT}/runtest/cap_bounds \
581 ${LTPROOT}/runtest/fcntl-locktests \
582 ${LTPROOT}/runtest/connectors \
583 ${LTPROOT}/runtest/admin_tools \
584 ${LTPROOT}/runtest/timers \
585 ${LTPROOT}/runtest/power_management_tests \
586 ${LTPROOT}/runtest/numa \
587 ${LTPROOT}/runtest/hugetlb \
588 ${LTPROOT}/runtest/commands \
589 ${LTPROOT}/runtest/hyperthreading
591 [ -e "$SCENFILES" ] || \
593 echo "FATAL: missing scenario file $SCENFILES"
594 exit 1
597 cat $SCENFILES >> ${TMP}/alltests || \
599 echo "FATAL: unable to create command file"
600 exit 1
602 done
605 [ -n "$CMDFILES" ] && \
607 for SCENFILES in `echo "$CMDFILES" | sed 's/,/\n/g'`
609 [ -f "$SCENFILES" ] || SCENFILES="$LTPROOT/runtest/$SCENFILES"
610 cat "$SCENFILES" >> ${TMP}/alltests || \
612 echo "FATAL: unable to create command file"
613 exit 1
615 done
618 [ -n "$CMDFILEADDR" ] && \
620 wget -q "${CMDFILEADDR}" -O ${TMP}/wgetcmdfile
621 if [ $? -ne 0 ]; then
622 echo "FATAL: error while getting the command file with wget (address $CMDFILEADDR)"
623 exit 1
625 cat "${TMP}/wgetcmdfile" >> ${TMP}/alltests || \
627 echo "FATAL: unable to create command file"
628 exit 1
632 [ "$RUN_NETEST" -eq 1 ] && \
634 for SCENFILES in ${LTPROOT}/runtest/tcp_cmds \
635 ${LTPROOT}/runtest/multicast \
636 ${LTPROOT}/runtest/rpc \
637 ${LTPROOT}/runtest/nfs
639 [ -e "$SCENFILES" ] || \
641 echo "FATAL: missing scenario file $SCENFILES"
642 exit 1
645 cat "$SCENFILES" >> ${TMP}/alltests || \
647 echo "FATAL: unable to create command file"
648 exit 1
650 done
653 # The fsx-linux tests use the SCRATCHDEV environment variable as a location
654 # that can be reformatted and run on. Set SCRATCHDEV if you want to run
655 # these tests. As a safeguard, this is disabled.
656 unset SCRATCHDEV
657 [ -n "$SCRATCHDEV" ] && \
659 cat ${LTPROOT}/runtest/fsx >> ${TMP}/alltests ||
661 echo "FATAL: unable to create fsx-linux tests command file"
662 exit 1
666 # If enabled, execute only test cases that match the PATTERN
667 if [ -n "$TAG_RESTRICT_STRING" ]
668 then
669 mv -f ${TMP}/alltests ${TMP}/alltests.orig
670 grep $TAG_RESTRICT_STRING ${TMP}/alltests.orig > ${TMP}/alltests #Not worth checking return codes for this case
673 # Blacklist or skip tests if a SKIPFILE was specified with -S
674 if [ -n "$SKIPFILE" ]
675 then
676 for file in $( cat $SKIPFILE ); do
677 sed -i "/$file/d" ${TMP}/alltests
678 done
681 # check for required users and groups
682 ${LTPTOOLS}/IDcheck.sh &>/dev/null || \
684 echo "WARNING: required users and groups not present"
685 echo "WARNING: some test cases may fail"
688 # display versions of installed software
689 [ -z "$QUIET_MODE" ] && \
691 ${LTPTOOLS}/ver_linux || \
693 echo "WARNING: unable to display versions of software installed"
694 exit 1
698 if [ -n "$DEVICE" ]; then
699 sed -i "s|DEVICE|$DEVICE|" ${TMP}/alltests
700 else
701 echo "remove test cases which require the block device."
702 echo "You can specify it with option -b"
703 sed -i "/DEVICE/d" ${TMP}/alltests
706 if [ $? -ne 0 ]; then
707 echo "FATAL: error during prcessing alltests file by sed"
708 exit 1
711 if [ -n "$DEVICE" ]; then
712 mnt_pnt=`mktemp -d --tmpdir=${TMP} mnt_pnt.XXXXXX`
713 if [ -n "$DEVICE_FS_TYPE" ]; then
714 mount -t $DEVICE_FS_TYPE $DEVICE $mnt_pnt
715 else
716 mount $DEVICE $mnt_pnt
719 if [ $? -ne 0 ]; then
720 echo "FATAL: can't mount block device $DEVICE."
721 exit 1
724 if [ -z "$DEVICE_FS_TYPE" ]; then
725 DEVICE_FS_TYPE=`cat /proc/mounts | awk "{if (\\\$1 == \"$DEVICE\") print \\\$3; }"`
726 echo "determine file system $DEVICE_FS_TYPE on block device $DEVICE"
729 umount $DEVICE
730 if [ $? -ne 0 ]; then
731 echo "FATAL: can't umount $DEVICE"
732 exit 1
734 rm -rf $mnt_pnt
737 if [ -n "$DEVICE" ]; then
738 sed -i "s|DEVICE_FS_TYPE|$DEVICE_FS_TYPE|" ${TMP}/alltests
741 if [ $? -ne 0 ]; then
742 echo "FATAL: error during prcessing alltests file by sed"
743 exit 1
746 if [ $RUN_REPEATED -gt 1 ]; then # You need to specify at least more than 1 sequential run, else it runs default
747 echo "PAN will run these test cases $RUN_REPEATED times....."
748 echo "Test Tags will be Prepended with ITERATION NO.s....."
749 inc=1
750 sed -e '/^$/ d' -e 's/^[ ,\t]*//' -e '/^#/ d' < ${TMP}/alltests > ${TMP}/alltests.temp ##This removes all newlines, leading spaces, tabs, #
751 sed 's/^[0-9,a-z,A-Z]*/'"$inc"'_ITERATION_&/' < ${TMP}/alltests.temp > ${TMP}/alltests ## .temp is kept as Base file
752 while [ $inc -lt $RUN_REPEATED ] ; do
753 inc=`expr $inc + 1`
754 sed 's/^[0-9,a-z,A-Z]*/'"$inc"'_ITERATION_&/' < ${TMP}/alltests.temp >> ${TMP}/alltests #Keep appending with Iteration No.s
755 done
758 [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test start time: $(date)" ; }
759 PAN_COMMAND="${LTPTOOLS}/ltp-pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ \
760 -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE $FAILCMDFILE"
761 echo "COMMAND: $PAN_COMMAND"
762 if [ ! -z "$TAG_RESTRICT_STRING" ] ; then
763 echo "INFO: Restricted to $TAG_RESTRICT_STRING"
765 #$PAN_COMMAND #Duplicated code here, because otherwise if we fail, only "PAN_COMMAND" gets output
767 ## Display the Output/Log/Failed/HTML file names here
768 echo -e "LOG File: \c"
769 echo $LOGFILE | cut -b4-
771 if [ "$OUTPUTFILE" ]; then
772 echo -e "OUTPUT File: \c"
773 echo $OUTPUTFILE | cut -b4-
776 echo -e "FAILED COMMAND File: \c"
777 echo $FAILCMDFILE | cut -b4-
779 if [ "$HTMLFILE" ]; then
780 echo "HTML File: $HTMLFILE"
783 echo "Running tests......."
784 test_start_time=$(date)
786 # User wants testing with Kernel Fault Injection
787 if [ $INJECT_KERNEL_FAULT ] ; then
788 #See if Debugfs is mounted, and
789 #Fault Injection Framework available through Debugfs
790 if [ -d "/sys/kernel/debug/fail_io_timeout" -o \
791 -d "/sys/kernel/debug/fail_make_request" -o \
792 -d "/sys/kernel/debug/fail_page_alloc" -o \
793 -d "/sys/kernel/debug/failslab" ]; then
794 #If atleast one of the Framework is available
795 #Go ahead to Inject Fault & Create required
796 #Command Files for LTP run
797 echo Running tests with Fault Injection Enabled in the Kernel...
798 ${LTPTOOLS}/create_kernel_faults_in_loops_and_probability.pl\
799 ${TMP}/alltests $INJECT_FAULT_LOOPS_PER_TEST $INJECT_KERNEL_FAULT_PERCENTAGE > ${TMP}/alltests.tmp
800 cp ${TMP}/alltests.tmp ${TMP}/alltests
801 rm -rf ${TMP}/alltests.tmp
802 else
803 echo Fault Injection not enabled in the Kernel..
804 echo Running tests normally...
808 ## Valgrind Check will work only when Kernel Fault Injection is not expected,
809 ## We do not want to test Faults when valgrind is running
810 if [ $VALGRIND_CHECK ]; then
811 if [ ! $INJECT_KERNEL_FAULT ]; then
812 which valgrind || VALGRIND_CHECK_TYPE=XYZ
813 case $VALGRIND_CHECK_TYPE in
815 ${LTPTOOLS}/create_valgrind_check.pl ${TMP}/alltests 1 > ${TMP}/alltests.tmp
816 cp ${TMP}/alltests.tmp ${TMP}/alltests
817 rm -rf ${TMP}/alltests.tmp;;
819 ${LTPTOOLS}/create_valgrind_check.pl ${TMP}/alltests 2 > ${TMP}/alltests.tmp
820 cp ${TMP}/alltests.tmp ${TMP}/alltests
821 rm -rf ${TMP}/alltests.tmp;;
823 ${LTPTOOLS}/create_valgrind_check.pl ${TMP}/alltests 3 > ${TMP}/alltests.tmp
824 cp ${TMP}/alltests.tmp ${TMP}/alltests
825 rm -rf ${TMP}/alltests.tmp;;
826 *) echo "Invalid Memory Check Type, or, Valgrind is not available";;
827 esac
831 # Some tests need to run inside the "bin" directory.
832 cd "${LTPROOT}/testcases/bin"
833 ${LTPTOOLS}/pan/ltp-pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE $FAILCMDFILE
835 if [ $? -eq 0 ]; then
836 echo "INFO: ltp-pan reported all tests PASS"
837 VALUE=0
838 export LTP_EXIT_VALUE=0;
839 else
840 echo "INFO: ltp-pan reported some tests FAIL"
841 VALUE=1
842 export LTP_EXIT_VALUE=1;
844 echo "LTP Version: $version_date"
846 if [ "$ALT_HTML_OUT" -eq 1 ] ; then #User wants the HTML output to be created, it then needs to be generated
847 export LTP_VERSION=$version_date
848 export TEST_START_TIME=$test_start_time
849 export TEST_END_TIME=$(date)
850 OUTPUT_DIRECTORY=`echo $OUTPUTFILE | cut -c4-`
851 LOGS_DIRECTORY="$RESULTSDIR"
852 export TEST_OUTPUT_DIRECTORY="$RESULTSDIR"
853 export TEST_LOGS_DIRECTORY=$LOGS_DIRECTORY
854 echo "Generating HTML Output.....!!"
855 ( perl $LTPROOT/tools/genhtml.pl $LTPROOT/tools/html_report_header.txt test_start test_end test_output execution_status $OUTPUT_DIRECTORY > $HTMLFILE; )
856 echo "Generated HTML Output.....!!"
857 echo "Location: $HTMLFILE";
861 if [ "$ALT_EMAIL_OUT" -eq 1 ] ; then ## User wants reports to be e-mailed
862 if [ [ ! "$HTMLFILE_NAME" ] -o [ ! "$OUTPUTFILE_NAME" ] -o [ ! "$LOGFILE_NAME" ] ] ; then
863 ##User does not have output/logs/html-output, nothing to be mailed in this situation
864 echo "Nothing to be mailed here...."
865 else
866 TAR_FILE_NAME=LTP_RUN_$version_date$DEFAULT_FILE_NAME_GENERATION_TIME.tar
867 if [ "$HTMLFILE_NAME" ] ; then ## HTML file Exists
868 if [ "$ALT_HTML_OUT" -ne 1 ] ; then ## The HTML file path is absolute and not $RESULTSDIR
869 mkdir -p $RESULTSDIR ## We need to create this Directory
870 cp $HTMLFILE_NAME $RESULTSDIR/
873 if [ "$OUTPUTFILE_NAME" ] ; then ## Output file exists
874 if [ "$ALT_DIR_OUT" -ne 1 ] ; then ## The Output file path is absolute and not $RESULTSDIR
875 mkdir -p $RESULTSDIR ## We need to create this Directory
876 cp $OUTPUTFILE_NAME $RESULTSDIR/
879 if [ "$LOGFILE_NAME" ] ; then ## Log file exists
880 if [ "$ALT_DIR_RES" -ne 1 ] ; then ## The Log file path is absolute and not $RESULTSDIR
881 mkdir -p $RESULTSDIR ## We need to create this Directory
882 cp $LOGFILE_NAME $RESULTSDIR/
885 if [ -d $RESULTSDIR ] ; then
886 tar -cf ./$TAR_FILE_NAME $RESULTSDIR
887 if [ $? -eq 0 ]; then
888 echo "Created TAR File: ./$TAR_FILE_NAME successfully, added $RESULTSDIR"
889 else
890 echo "Cannot Create TAR File: ./$TAR_FILE_NAME for adding $RESULTSDIR"
893 if [ -d $RESULTSDIR ] ; then
894 tar -uf ./$TAR_FILE_NAME $RESULTSDIR
895 if [ $? -eq 0 ]; then
896 echo "Updated TAR File: ./$TAR_FILE_NAME successfully, added $RESULTSDIR"
897 else
898 echo "Cannot Update TAR File: ./$TAR_FILE_NAME for adding $RESULTSDIR"
901 if [ -e $LTPROOT/nohup.out ] ; then ## If User would have Chosen nohup to do ltprun
902 tar -uf ./$TAR_FILE_NAME $LTPROOT/nohup.out
903 if [ $? -eq 0 ]; then
904 echo "Updated TAR File: ./$TAR_FILE_NAME successfully, added $LTPROOT/nohup.out"
905 else
906 echo "Cannot Update TAR File: ./$TAR_FILE_NAME for adding $LTPROOT/nohup.out"
909 gzip ./$TAR_FILE_NAME ## gzip this guy
910 if [ $? -eq 0 ]; then
911 echo "Gunzipped TAR File: ./$TAR_FILE_NAME"
912 else
913 echo "Cannot Gunzip TAR File: ./$TAR_FILE_NAME"
915 if [ -e /usr/bin/mutt ] ; then ## This is a better mail client than others
916 echo "Starting mailing reports to: $EMAIL_TO, file: ./$TAR_FILE_NAME.gz"
917 mutt -a ./$TAR_FILE_NAME.gz -s "LTP Reports on $test_start_time" $EMAIL_TO < /dev/null
918 if [ $? -eq 0 ]; then
919 echo "Reports Successfully mailed to: $EMAIL_TO"
920 else
921 echo "Reports cannot be mailed to: $EMAIL_TO"
923 else ## Use our Ageold mail program
924 echo "Starting mailing reports to: $EMAIL_TO, file: ./$TAR_FILE_NAME.gz"
925 uuencode ./$TAR_FILE_NAME.gz $TAR_FILE_NAME.gz | mail $EMAIL_TO -s "LTP Reports on $test_start_time"
926 if [ $? -eq 0 ]; then
927 echo "Reports Successfully mailed to: $EMAIL_TO"
928 else
929 echo "Reports cannot be mailed to: $EMAIL_TO"
935 [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test end time: $(date)" ; }
937 [ "$GENLOAD" -eq 1 ] && { killall -9 genload >/dev/null 2>&1; }
938 [ "$NETPIPE" -eq 1 ] && { killall -9 NPtcp >/dev/null 2>&1; }
940 [ "$ALT_DIR_OUT" -eq 1 ] || [ "$ALT_DIR_RES" -eq 1 ] && \
942 cat <<-EOF >&1
944 ###############################################################"
946 Done executing testcases."
947 log result(s) is in $RESULTSDIR directory"
948 output/failed result(s) in $RESULTSDIR directory [If you did not provide Absolute Path]
949 LTP Version: $version_date
950 ###############################################################"
954 exit $VALUE
957 cleanup()
959 rm -rf ${TMP}
962 trap "cleanup" 0
963 setup
964 main "$@"