Revert some unnecessary changes from upstream
[ltp-debian.git] / runltp
blob45e204080ee198497f9c78b7e31809c7df8d559c
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
66 # Debian changes:
68 # May 12 2004 - Modified Alastair McKinstry
69 # - changed directory, file locations for ltp package
71 #################################################################################
75 setup()
77 cd `dirname $0` || \
79 echo "FATAL: unable to change directory to $(dirname $0)"
80 exit 1
82 export LTPROOT=/usr/lib/ltp/tests/linux
83 export LTPTOOLS=/usr/lib/ltp/tools
84 export RESULTSDIR=/var/cache/ltp/results
85 export TMPBASE="/tmp"
86 export PATH="${PATH}:${LTPROOT}/testcases/bin"
88 [ -d $LTPROOT/testcases/bin ] ||
90 echo "FATAL: Test suite not installed correctly"
91 echo "INFO: as root user type 'make ; make install'"
92 exit 1
95 [ -e $LTPTOOLS/ltp-pan ] ||
97 echo "FATAL: Test suite driver 'ltp-pan' not found"
98 echo "INFO: as root user type 'make ; make install'"
99 exit 1
103 version_of_ltp()
105 zcat /usr/share/doc/ltp-tools/changelog.gz | head -n 1
106 exit 0
109 usage()
111 cat <<-EOF >&2
113 usage: ./${0##*/} [ -a EMAIL_TO ] [ -c NUM_PROCS ] [ -C FAILCMDFILE ] [ -d TMPDIR ]
114 [ -D NUM_PROCS,NUM_FILES,NUM_BYTES,CLEAN_FLAG ] -e [ -f CMDFILES(,...) ] [ -g HTMLFILE]
115 [ -i NUM_PROCS ] [ -l LOGFILE ] [ -m NUM_PROCS,CHUNKS,BYTES,HANGUP_FLAG ]
116 -N -n [ -o OUTPUTFILE ] -p -q [ -r LTPROOT ] [ -s PATTERN ] [ -t DURATION ]
117 -v [ -w CMDFILEADDR ] [ -x INSTANCES ] [ -b DEVICE ] [-B DEVICE_FS_TYPE]
119 -a EMAIL_TO EMAIL all your Reports to this E-mail Address
120 -c NUM_PROCS Run LTP under additional background CPU load
121 [NUM_PROCS = no. of processes creating the CPU Load by spinning over sqrt()
122 (Defaults to 1 when value)]
123 -C FAILCMDFILE Command file with all failed test cases.
124 -d TMPDIR Directory where temporary files will be created.
125 -D NUM_PROCS,NUM_FILES,NUM_BYTES,CLEAN_FLAG
126 Run LTP under additional background Load on Secondary Storage (Seperate by comma)
127 [NUM_PROCS = no. of processes creating Storage Load by spinning over write()]
128 [NUM_FILES = Write() to these many files (Defaults to 1 when value 0 or undefined)]
129 [NUM_BYTES = write these many bytes (defaults to 1GB, when value 0 or undefined)]
130 [CLEAN_FLAG = unlink file to which random data written, when value 1]
131 -e Prints the date of the current LTP release
132 -f CMDFILES Execute user defined list of testcases (separate with ',')
133 -g HTMLFILE Create an additional HTML output format
134 -h Help. Prints all available options.
135 -i NUM_PROCS Run LTP under additional background Load on IO Bus
136 [NUM_PROCS = no. of processes creating IO Bus Load by spinning over sync()]
137 -l LOGFILE Log results of test in a logfile.
138 -m NUM_PROCS,CHUNKS,BYTES,HANGUP_FLAG
139 Run LTP under additional background Load on Main memory (Seperate by comma)
140 [NUM_PROCS = no. of processes creating main Memory Load by spinning over malloc()]
141 [CHUNKS = malloc these many chunks (default is 1 when value 0 or undefined)]
142 [BYTES = malloc CHUNKS of BYTES bytes (default is 256MB when value 0 or undefined) ]
143 [HANGUP_FLAG = hang in a sleep loop after memory allocated, when value 1]
144 -N Run all the networking tests.
145 -n Run LTP with network traffic in background.
146 -o OUTPUTFILE Redirect test output to a file.
147 -p Human readable format logfiles.
148 -q Print less verbose output to screen.
149 -r LTPROOT Fully qualified path where testsuite is installed.
150 -s PATTERN Only run test cases which match PATTERN.
151 -t DURATION Execute the testsuite for given duration. Examples:
152 -t 60s = 60 seconds
153 -t 45m = 45 minutes
154 -t 24h = 24 hours
155 -t 2d = 2 days
156 -T REPETITION Execute the testsuite for REPETITION no. of times
157 -v Print more verbose output to screen.
158 -w CMDFILEADDR Uses wget to get the user's list of testcases.
159 -x INSTANCES Run multiple instances of this testsuite.
160 -b DEVICE Some tests require an unmounted block device
161 to run correctly.
162 -B DEVICE_FS_TYPE The file system of test block devices.
165 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}
169 exit 0
172 main()
174 local CMDFILES=""
175 local PRETTY_PRT=""
176 local ALT_DIR_OUT=0
177 local ALT_DIR_RES=0
178 local ALT_HTML_OUT=0
179 local ALT_EMAIL_OUT=0
180 local RUN_NETEST=0
181 local RUN_REPEATED=0
182 local QUIET_MODE=""
183 local VERBOSE_MODE=""
184 local NETPIPE=0
185 local GENLOAD=0
186 local MEMSIZE=0
187 local DURATION=""
188 local CMDFILEADDR=""
189 local FAILCMDFILE=""
190 local LOGFILE_NAME=""
191 local LOGFILE=""
192 local OUTPUTFILE_NAME=""
193 local OUTPUTFILE=""
194 local HTMLFILE_NAME=""
195 local HTMLFILE=""
196 local EMAIL_TO=""
197 local SCENFILES=""
198 local TAG_RESTRICT_STRING=""
199 local PAN_COMMAND=""
200 version_date=`zcat /usr/share/doc/ltp-tools/changelog.gz | head -n 1 `
201 local DEFAULT_FILE_NAME_GENERATION_TIME=`date +"%Y_%b_%d-%Hh_%Mm_%Ss"`
203 while getopts a:c:C:d:D:f:ehi:g:l:m:Nno:pqr:s:t:T:vw:x:b:B: arg
204 do case $arg in
205 a) EMAIL_TO=$OPTARG
206 ALT_EMAIL_OUT=1;;
208 NUM_PROCS=$(($OPTARG))
209 if [ "$NUM_PROCS" -eq 0 ]; then
210 # User Did not Define the Value ,or, User Defined Zero,
211 # hence, prevent from creating infinite processes
212 NUM_PROCS=1
214 $LTPROOT/testcases/bin/genload --cpu $NUM_PROCS >/dev/null 2>&1 &
215 GENLOAD=1 ;;
218 case $OPTARG in
220 FAILCMDFILE="-C $OPTARG" ;;
222 FAILCMDFILE="-C $RESULTSDIR/$OPTARG"
223 ALT_DIR_OUT=1 ;;
224 esac ;;
226 d) # convert the user path to absolute path.
227 export TMPBASE=`cd \`dirname ${OPTARG}\`; pwd`/`basename ${OPTARG}` ;;
229 D) NUM_PROCS=1; NUM_FILES=1; NUM_BYTES=$((1024 * 1024 * 1024)); CLEAN_FLAG=0
230 ARGUMENT_LIST=$OPTARG
231 TOTAL_ARGUMENTS=1 # Initial Assume
232 for ARGUMENT in `echo "$ARGUMENT_LIST" | sed 's/,/\n/g'` # Store all value in a Loop
234 case $TOTAL_ARGUMENTS in
235 1) NUM_PROCS="$ARGUMENT" ;;
236 2) NUM_FILES="$ARGUMENT" ;;
237 3) NUM_BYTES="$ARGUMENT" ;;
238 4) CLEAN_FLAG="$ARGUMENT" ;;
239 esac
240 TOTAL_ARGUMENTS=`expr $TOTAL_ARGUMENTS + 1`
241 done
242 # just to get the default values if the user passed 0
243 if [ "$NUM_PROCS" -eq 0 ]; then
244 NUM_PROCS=1
246 if [ "$NUM_FILES" -eq 0 ]; then
247 NUM_FILES=1
249 if [ "$NUM_BYTES" -eq 0 ]; then
250 NUM_BYTES=$((1024 * 1024 * 1024))
252 if [ "$CLEAN_FLAG" -ne 1 ]; then
253 CLEAN_FLAG=0
255 if [ "$CLEAN_FLAG" -eq 1 ]; then
256 # Do not unlink file in this case
257 $LTPROOT/testcases/bin/genload --hdd $NUM_PROCS --hdd-files \
258 $NUM_FILES --hdd-bytes $NUM_BYTES >/dev/null 2>&1 &
259 else
260 # Cleanup otherwise
261 $LTPROOT/testcases/bin/genload --hdd $NUM_PROCS --hdd-files \
262 $NUM_FILES --hdd-bytes $NUM_BYTES --hdd-noclean >/dev/null 2>&1 &
264 GENLOAD=1;;
266 e) # Print out the version of LTP
267 version_of_ltp
269 f) # Execute user defined set of testcases.
270 # Can be more then one file, just separate it with ',', like:
271 # -f nfs,commands,/tmp/testfile
272 CMDFILES=$OPTARG;;
273 g) HTMLFILE_NAME="$OPTARG"
274 case $OPTARG in
276 HTMLFILE="$OPTARG";;
278 HTMLFILE="$RESULTSDIR/$OPTARG";;
279 esac
280 ALT_DIR_OUT=1
281 ALT_HTML_OUT=1;;
282 h) usage;;
285 NUM_PROCS=$(($OPTARG))
286 if [ "$NUM_PROCS" -eq 0 ]; then
287 # User Did not Define the Value ,or, User Defined Zero,
288 # hence, prevent from creating infinite processes
289 NUM_PROCS=1
291 $LTPROOT/testcases/bin/genload --io $NUM_PROCS >/dev/null 2>&1 &
292 GENLOAD=1 ;;
295 LOGFILE_NAME="$OPTARG"
296 case $OPTARG in
298 LOGFILE="-l $OPTARG" ;;
300 LOGFILE="-l $RESULTSDIR/$OPTARG"
301 ALT_DIR_RES=1 ;;
302 esac ;;
304 m) NUM_PROCS=1; CHUNKS=1; BYTES=$((256 * 1024 * 1024)); HANGUP_FLAG=0
305 ARGUMENT_LIST=$OPTARG
306 TOTAL_ARGUMENTS=1 # Initial Assume
307 for ARGUMENT in `echo "$ARGUMENT_LIST" | sed 's/,/\n/g'` # Store all value in a Loop
309 case $TOTAL_ARGUMENTS in
310 1) NUM_PROCS="$ARGUMENT" ;;
311 2) CHUNKS="$ARGUMENT" ;;
312 3) BYTES="$ARGUMENT" ;;
313 4) HANGUP_FLAG="$ARGUMENT" ;;
314 esac
315 TOTAL_ARGUMENTS=`expr $TOTAL_ARGUMENTS + 1`
316 done
317 # just to get the default values if the user passed 0
318 if [ "$NUM_PROCS" -eq 0 ]; then
319 NUM_PROCS=1
321 if [ "$CHUNKS" -eq 0 ]; then
322 CHUNKS=1
324 if [ "$BYTES" -eq 0 ]; then
325 BYTES=$((256 * 1024 * 1024))
327 if [ "$HANGUP_FLAG" -ne 1 ]; then
328 HANGUP_FLAG=0
330 if [ "$HANGUP_FLAG" -eq 1 ]; then
331 # Hang in a Sleep loop after memory allocated
332 $LTPROOT/testcases/bin/genload --vm $NUM_PROCS --vm-chunks \
333 $CHUNKS --vm-bytes $BYTES --vm-hang >/dev/null 2>&1 &
334 else
335 # Otherwise Do not Hangup
336 $LTPROOT/testcases/bin/genload --vm $NUM_PROCS --vm-chunks \
337 $CHUNKS --vm-bytes $BYTES >/dev/null 2>&1 &
339 GENLOAD=1;;
341 N) RUN_NETEST=1;;
344 $LTPROOT/testcases/bin/netpipe.sh
345 NETPIPE=1;;
347 o) OUTPUTFILE_NAME="$OPTARG"
348 case $OPTARG in
350 OUTPUTFILE="-o $OPTARG";;
352 OUTPUTFILE="-o $RESULTSDIR/$OPTARG"
353 ALT_DIR_OUT=1 ;;
354 esac ;;
356 p) PRETTY_PRT=" -p ";;
358 q) QUIET_MODE=" -q ";;
360 r) LTPROOT=$OPTARG;;
362 s) TAG_RESTRICT_STRING=$OPTARG;;
364 t) # In case you want to specify the time
365 # to run from the command line
366 # (2m = two minutes, 2h = two hours, etc)
367 DURATION="-t $OPTARG" ;;
369 T) # In case you want the testcases to runsequentially RUN_REPEATED times
370 RUN_REPEATED=$OPTARG;;
372 v) VERBOSE_MODE=1;;
374 w) CMDFILEADDR=$OPTARG;;
376 x) # number of ltp's to run
377 cat <<-EOF >&1
378 WARNING: The use of -x can cause unpredictable failures, as a
379 result of concurrently running multiple tests designed
380 to be ran exclusively.
381 Pausing for 10 seconds..."
383 sleep 10
384 INSTANCES="-x $OPTARG";;
385 b) DEVICE=$OPTARG;;
386 B) DEVICE_FS_TYPE=$OPTARG;;
387 \?) usage;;
388 esac
389 done
391 ## It would be nice to create a default log file even if the user has not mentioned
392 if [ ! "$LOGFILE" ]; then ## User has not mentioned about Log File name
393 LOGFILE_NAME=$DEFAULT_FILE_NAME_GENERATION_TIME
394 LOGFILE="-l $LTPROOT/results/LTP_RUN_ON-$LOGFILE_NAME.log"
395 ALT_DIR_RES=1
396 PRETTY_PRT=" -p "
399 ## It would be nice if a Failed File is compulsorily created (gives User better Idea of Tests that failed)
401 if [ ! "$FAILCMDFILE" ]; then ## User has not mentioned about Failed File name
402 ALT_DIR_OUT=1
403 if [ ! "$OUTPUTFILE" ]; then ## User has not mentioned about Output File name either
404 if [ ! "$LOGFILE" ]; then ## User has not mentioned about Log File name either
405 FAILCMDFILE="-C $RESULTSDIR/LTP_RUN_ON-$FAILED_FILE_NAME.failed"
406 FAILED_FILE_NAME=$DEFAULT_FILE_NAME_GENERATION_TIME
407 else ## User Fortunately wanted a log file,
408 FAILED_FILE_NAME=`basename ${LOGFILE_NAME}` ## Extract log file name and use it to construct Failed file name
409 FAILCMDFILE="-C $RESULTSDIR/LTP_RUN_ON-$FAILED_FILE_NAME.failed"
411 else ## User Fortunately wanted a Output file
412 FAILED_FILE_NAME=`basename $OUTPUTFILE_NAME` ## Extract output file name and use it to construct Failed file name
413 FAILCMDFILE="-C $RESULTSDIR/LTP_RUN_ON-$FAILED_FILE_NAME.failed"
417 if [ "$ALT_HTML_OUT" -eq 1 ] ; then ## User wants the HTML version of the output
418 QUIET_MODE="" ## Suppressing this guy as it will prevent generation of proper output
419 ## which the HTML parser will require
420 if [ ! "$OUTPUTFILE" ]; then ## User has not mentioned about the Outputfile name, then we need to definitely generate one
421 OUTPUTFILE="-o $RESULTSDIR/LTP_RUN_ON-$OUTPUTFILE_NAME.output"
422 OUTPUTFILE_NAME=$DEFAULT_FILE_NAME_GENERATION_TIME
423 ALT_DIR_OUT=1
424 if [ ! "$HTMLFILE" ] ; then ## User has not mentioned HTML File name, We need to create one
425 HTMLFILE_NAME=`basename $OUTPUTFILE_NAME`
426 HTMLFILE="$RESULTSDIR/$HTMLFILE_NAME.html"
431 # If we need, create the output directory
432 [ "$ALT_DIR_OUT" -eq 1 ] && \
434 echo "INFO: creating $RESULTSDIR directory"
435 [ ! -d $RESULTSDIR ] && \
437 mkdir -p $RESULTSDIR || \
439 echo "ERROR: failed to create $RESULTSDIR"
440 exit 1
444 # If we need, create the results directory
445 [ "$ALT_DIR_RES" -eq 1 ] && \
447 echo "INFO: creating $RESULTSDIR directory"
448 [ ! -d $RESULTSDIR ] && \
450 mkdir -p $RESULTSDIR || \
452 echo "ERROR: failed to create $RESULTSDIR"
453 exit 1
458 # Added -m 777 for tests that call tst_tmpdir() and try to
459 # write to it as user nobody
460 mkdir -m 777 -p $TMPBASE || \
462 echo "FATAL: Unable to make temporary directory $TMPBASE"
463 exit 1
465 # use mktemp to create "safe" temporary directories
466 export TMPTEMPLATE="${TMPBASE}/ltp-XXXXXXXXXX"
467 TMP=`mktemp -d $TMPTEMPLATE` || \
469 echo "FATAL: Unable to make temporary directory: $TMP"
470 exit 1
472 export TMP
473 # To be invoked by tst_tmpdir()
474 # write to it as user nobody
475 export TMPDIR=$TMP
477 chmod 777 $TMP || \
479 echo "unable to chmod 777 $TMP ... aborting"
480 exit 1
483 cd $TMP || \
485 echo "could not cd ${TMP} ... exiting"
486 exit 1
489 ! [ -z $INSTANCES ] && \
491 INSTANCES="$INSTANCES -O ${TMP}"
494 [ "$RUN_NETEST" -eq 1 ] && \
496 [ -z "$RHOST" ] || [ -z "$PASSWD" ] && \
498 [ -z "$RHOST" ] && \
500 echo \
501 "INFO: Enter RHOST = 'name of the remote host machine'"
502 echo -n "-> "
503 read RHOST
506 [ -z "$PASSWD" ] && \
508 echo " "
509 echo \
510 "INFO: Enter PASSWD = 'root passwd of the remote host machine'"
511 echo -n "-> "
512 read PASSWD
514 export RHOST=$RHOST
515 export PASSWD=$PASSWD
516 echo "WARNING: security of $RHOST may be compromised"
520 # If user does not provide a command file select a default set of testcases
521 # to execute.
522 if [ -z "$CMDFILES" ] && [ -z "$CMDFILEADDR" ]
523 then
524 cat <<-EOF >&1
526 INFO: no command files were provided, using default,
527 system calls, memory management, IPC, scheduler
528 direct io, file system, math and pty tests will
529 now be executed
533 for SCENFILES in ${LTPROOT}/runtest/syscalls \
534 ${LTPROOT}/runtest/fs \
535 ${LTPROOT}/runtest/fsx \
536 ${LTPROOT}/runtest/dio \
537 ${LTPROOT}/runtest/io \
538 ${LTPROOT}/runtest/mm \
539 ${LTPROOT}/runtest/ipc \
540 ${LTPROOT}/runtest/sched \
541 ${LTPROOT}/runtest/math \
542 ${LTPROOT}/runtest/nptl \
543 ${LTPROOT}/runtest/pty \
544 ${LTPROOT}/runtest/containers \
545 ${LTPROOT}/runtest/fs_bind \
546 ${LTPROOT}/runtest/controllers \
547 ${LTPROOT}/runtest/filecaps \
548 ${LTPROOT}/runtest/cap_bounds \
549 ${LTPROOT}/runtest/fcntl-locktests \
550 ${LTPROOT}/runtest/connectors \
551 ${LTPROOT}/runtest/admin_tools \
552 ${LTPROOT}/runtest/timers \
553 ${LTPROOT}/runtest/power_management_tests \
554 ${LTPROOT}/runtest/numa \
555 ${LTPROOT}/runtest/hugetlb \
556 ${LTPROOT}/runtest/commands \
557 ${LTPROOT}/runtest/hyperthreading
559 [ -e "$SCENFILES" ] || \
561 echo "FATAL: missing scenario file $SCENFILES"
562 exit 1
565 cat $SCENFILES >> ${TMP}/alltests || \
567 echo "FATAL: unable to create command file"
568 exit 1
570 done
573 [ -n "$CMDFILES" ] && \
575 for SCENFILES in `echo "$CMDFILES" | sed 's/,/\n/g'`
577 [ -f "$SCENFILES" ] || SCENFILES="$LTPROOT/runtest/$SCENFILES"
578 cat "$SCENFILES" >> ${TMP}/alltests || \
580 echo "FATAL: unable to create command file"
581 exit 1
583 done
586 [ -n "$CMDFILEADDR" ] && \
588 wget -q "${CMDFILEADDR}" -O ${TMP}/wgetcmdfile
589 if [ $? -ne 0 ]; then
590 echo "FATAL: error while getting the command file with wget (address $CMDFILEADDR)"
591 exit 1
593 cat "${TMP}/wgetcmdfile" >> ${TMP}/alltests || \
595 echo "FATAL: unable to create command file"
596 exit 1
600 [ "$RUN_NETEST" -eq 1 ] && \
602 for SCENFILES in ${LTPROOT}/runtest/tcp_cmds \
603 ${LTPROOT}/runtest/multicast \
604 ${LTPROOT}/runtest/rpc \
605 ${LTPROOT}/runtest/nfs
607 [ -e "$SCENFILES" ] || \
609 echo "FATAL: missing scenario file $SCENFILES"
610 exit 1
613 cat "$SCENFILES" >> ${TMP}/alltests || \
615 echo "FATAL: unable to create command file"
616 exit 1
618 done
621 # The fsx-linux tests use the SCRATCHDEV environment variable as a location
622 # that can be reformatted and run on. Set SCRATCHDEV if you want to run
623 # these tests. As a safeguard, this is disabled.
624 unset SCRATCHDEV
625 [ -n "$SCRATCHDEV" ] && \
627 cat ${LTPROOT}/runtest/fsx >> ${TMP}/alltests ||
629 echo "FATAL: unable to create fsx-linux tests command file"
630 exit 1
634 # If enabled, execute only test cases that match the PATTERN
635 if [ -n "$TAG_RESTRICT_STRING" ]
636 then
637 mv -f ${TMP}/alltests ${TMP}/alltests.orig
638 grep $TAG_RESTRICT_STRING ${TMP}/alltests.orig > ${TMP}/alltests #Not worth checking return codes for this case
641 # check for required users and groups
642 ${LTPTOOLS}/IDcheck.sh &>/dev/null || \
644 echo "WARNING: required users and groups not present"
645 echo "WARNING: some test cases may fail"
648 # display versions of installed software
649 [ -z "$QUIET_MODE" ] && \
651 ${LTPTOOLS}/ver_linux || \
653 echo "WARNING: unable to display versions of software installed"
654 exit 1
658 if [ -n "$DEVICE" ]; then
659 sed -i "s|DEVICE|$DEVICE|" ${TMP}/alltests
660 else
661 echo "remove test cases which require the block device."
662 echo "You can specify it with option -b"
663 sed -i "/DEVICE/d" ${TMP}/alltests
666 if [ $? -ne 0 ]; then
667 echo "FATAL: error during prcessing alltests file by sed"
668 exit 1
671 if [ -n "$DEVICE" ]; then
672 mnt_pnt=`mktemp -d --tmpdir=${TMP} mnt_pnt.XXXXXX`
673 if [ -n "$DEVICE_FS_TYPE" ]; then
674 mount -t $DEVICE_FS_TYPE $DEVICE $mnt_pnt
675 else
676 mount $DEVICE $mnt_pnt
679 if [ $? -ne 0 ]; then
680 echo "FATAL: can't mount block device $DEVICE."
681 exit 1
684 if [ -z "$DEVICE_FS_TYPE" ]; then
685 DEVICE_FS_TYPE=`cat /proc/mounts | awk "{if (\\\$1 == \"$DEVICE\") print \\\$3; }"`
686 echo "determine file system $DEVICE_FS_TYPE on block device $DEVICE"
689 umount $DEVICE
690 if [ $? -ne 0 ]; then
691 echo "FATAL: can't umount $DEVICE"
692 exit 1
694 rm -rf $mnt_pnt
697 if [ -n "$DEVICE" ]; then
698 sed -i "s|DEVICE_FS_TYPE|$DEVICE_FS_TYPE|" ${TMP}/alltests
701 if [ $? -ne 0 ]; then
702 echo "FATAL: error during prcessing alltests file by sed"
703 exit 1
706 if [ $RUN_REPEATED -gt 1 ]; then # You need to specify at least more than 1 sequential run, else it runs default
707 echo "PAN will run these test cases $RUN_REPEATED times....."
708 echo "Test Tags will be Prepended with ITERATION NO.s....."
709 inc=1
710 sed -e '/^$/ d' -e 's/^[ ,\t]*//' -e '/^#/ d' < ${TMP}/alltests > ${TMP}/alltests.temp ##This removes all newlines, leading spaces, tabs, #
711 sed 's/^[0-9,a-z,A-Z]*/'"$inc"'_ITERATION_&/' < ${TMP}/alltests.temp > ${TMP}/alltests ## .temp is kept as Base file
712 while [ $inc -lt $RUN_REPEATED ] ; do
713 inc=`expr $inc + 1`
714 sed 's/^[0-9,a-z,A-Z]*/'"$inc"'_ITERATION_&/' < ${TMP}/alltests.temp >> ${TMP}/alltests #Keep appending with Iteration No.s
715 done
718 [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test start time: $(date)" ; }
719 PAN_COMMAND="${LTPTOOLS}/ltp-pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ \
720 -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE $FAILCMDFILE"
721 if [ ! -z "$VERBOSE_MODE" ] ; then
722 echo "COMMAND: $PAN_COMMAND"
723 if [ ! -z "$TAG_RESTRICT_STRING" ] ; then
724 echo "INFO: Restricted to $TAG_RESTRICT_STRING"
727 #$PAN_COMMAND #Duplicated code here, because otherwise if we fail, only "PAN_COMMAND" gets output
729 ## Display the Output/Log/Failed/HTML file names here
730 echo -e "LOG File: \c"
731 echo $LOGFILE | cut -b4-
733 if [ "$OUTPUTFILE" ]; then
734 echo -e "OUTPUT File: \c"
735 echo $OUTPUTFILE | cut -b4-
738 echo -e "FAILED COMMAND File: \c"
739 echo $FAILCMDFILE | cut -b4-
741 if [ "$HTMLFILE" ]; then
742 echo "HTML File: $HTMLFILE"
745 echo "Running tests......."
746 test_start_time=$(date)
747 ${LTPTOOLS}/ltp-pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE $FAILCMDFILE
749 if [ $? -eq 0 ]; then
750 echo "INFO: ltp-pan reported all tests PASS"
751 VALUE=0
752 export LTP_EXIT_VALUE=0;
753 else
754 echo "INFO: ltp-pan reported some tests FAIL"
755 VALUE=1
756 export LTP_EXIT_VALUE=1;
758 echo "LTP Version: $version_date"
760 if [ "$ALT_HTML_OUT" -eq 1 ] ; then #User wants the HTML output to be created, it then needs to be generated
761 export LTP_VERSION=$version_date
762 export TEST_START_TIME=$test_start_time
763 export TEST_END_TIME=$(date)
764 OUTPUT_DIRECTORY=`echo $OUTPUTFILE | cut -c4-`
765 LOGS_DIRECTORY="$RESULTSDIR"
766 export TEST_OUTPUT_DIRECTORY="$RESULTSDIR"
767 export TEST_LOGS_DIRECTORY=$LOGS_DIRECTORY
768 echo "Generating HTML Output.....!!"
769 ( perl $LTPROOT/tools/genhtml.pl $LTPROOT/tools/html_report_header.txt test_start test_end test_output execution_status $OUTPUT_DIRECTORY > $HTMLFILE; )
770 echo "Generated HTML Output.....!!"
771 echo "Location: $HTMLFILE";
775 if [ "$ALT_EMAIL_OUT" -eq 1 ] ; then ## User wants reports to be e-mailed
776 if [ [ ! "$HTMLFILE_NAME" ] -o [ ! "$OUTPUTFILE_NAME" ] -o [ ! "$LOGFILE_NAME" ] ] ; then
777 ##User does not have output/logs/html-output, nothing to be mailed in this situation
778 echo "Nothing to be mailed here...."
779 else
780 TAR_FILE_NAME=LTP_RUN_$version_date$DEFAULT_FILE_NAME_GENERATION_TIME.tar
781 if [ "$HTMLFILE_NAME" ] ; then ## HTML file Exists
782 if [ "$ALT_HTML_OUT" -ne 1 ] ; then ## The HTML file path is absolute and not $RESULTSDIR
783 mkdir -p $RESULTSDIR ## We need to create this Directory
784 cp $HTMLFILE_NAME $RESULTSDIR/
787 if [ "$OUTPUTFILE_NAME" ] ; then ## Output file exists
788 if [ "$ALT_DIR_OUT" -ne 1 ] ; then ## The Output file path is absolute and not $RESULTSDIR
789 mkdir -p $RESULTSDIR ## We need to create this Directory
790 cp $OUTPUTFILE_NAME $RESULTSDIR/
793 if [ "$LOGFILE_NAME" ] ; then ## Log file exists
794 if [ "$ALT_DIR_RES" -ne 1 ] ; then ## The Log file path is absolute and not $RESULTSDIR
795 mkdir -p $RESULTSDIR ## We need to create this Directory
796 cp $LOGFILE_NAME $RESULTSDIR/
799 if [ -d $RESULTSDIR ] ; then
800 tar -cf ./$TAR_FILE_NAME $RESULTSDIR
801 if [ $? -eq 0 ]; then
802 echo "Created TAR File: ./$TAR_FILE_NAME successfully, added $RESULTSDIR"
803 else
804 echo "Cannot Create TAR File: ./$TAR_FILE_NAME for adding $RESULTSDIR"
807 if [ -d $RESULTSDIR ] ; then
808 tar -uf ./$TAR_FILE_NAME $RESULTSDIR
809 if [ $? -eq 0 ]; then
810 echo "Updated TAR File: ./$TAR_FILE_NAME successfully, added $RESULTSDIR"
811 else
812 echo "Cannot Update TAR File: ./$TAR_FILE_NAME for adding $RESULTSDIR"
815 if [ -e $LTPROOT/nohup.out ] ; then ## If User would have Chosen nohup to do ltprun
816 tar -uf ./$TAR_FILE_NAME $LTPROOT/nohup.out
817 if [ $? -eq 0 ]; then
818 echo "Updated TAR File: ./$TAR_FILE_NAME successfully, added $LTPROOT/nohup.out"
819 else
820 echo "Cannot Update TAR File: ./$TAR_FILE_NAME for adding $LTPROOT/nohup.out"
823 gzip ./$TAR_FILE_NAME ## gzip this guy
824 if [ $? -eq 0 ]; then
825 echo "Gunzipped TAR File: ./$TAR_FILE_NAME"
826 else
827 echo "Cannot Gunzip TAR File: ./$TAR_FILE_NAME"
829 if [ -e /usr/bin/mutt ] ; then ## This is a better mail client than others
830 echo "Starting mailing reports to: $EMAIL_TO, file: ./$TAR_FILE_NAME.gz"
831 mutt -a ./$TAR_FILE_NAME.gz -s "LTP Reports on $test_start_time" $EMAIL_TO < /dev/null
832 if [ $? -eq 0 ]; then
833 echo "Reports Successfully mailed to: $EMAIL_TO"
834 else
835 echo "Reports cannot be mailed to: $EMAIL_TO"
837 else ## Use our Ageold mail program
838 echo "Starting mailing reports to: $EMAIL_TO, file: ./$TAR_FILE_NAME.gz"
839 uuencode ./$TAR_FILE_NAME.gz $TAR_FILE_NAME.gz | mail $EMAIL_TO -s "LTP Reports on $test_start_time"
840 if [ $? -eq 0 ]; then
841 echo "Reports Successfully mailed to: $EMAIL_TO"
842 else
843 echo "Reports cannot be mailed to: $EMAIL_TO"
849 [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test end time: $(date)" ; }
851 [ "$GENLOAD" -eq 1 ] && { killall -9 genload >/dev/null 2>&1; }
852 [ "$NETPIPE" -eq 1 ] && { killall -9 NPtcp >/dev/null 2>&1; }
854 [ "$ALT_DIR_OUT" -eq 1 ] || [ "$ALT_DIR_RES" -eq 1 ] && \
856 cat <<-EOF >&1
858 ###############################################################"
860 Done executing testcases."
861 log result(s) is in $RESULTSDIR directory"
862 output/failed result(s) in $RESULTSDIR directory [If you did not provide Absolute Path]
863 LTP Version: $version_date
864 ###############################################################"
868 exit $VALUE
871 cleanup()
873 rm -rf ${TMP}
876 trap "cleanup" 0
877 setup
878 main "$@"