2 ################################################################################
4 ## Copyright (c) International Business Machines Corp., 2001 ##
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. ##
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. ##
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 ##
20 ################################################################################
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
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,
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 #################################################################################
76 echo "FATAL: unable to change directory to $(dirname $0)"
81 export PATH
="${PATH}:${LTPROOT}/testcases/bin"
83 [ -d "$LTPROOT/testcases/bin" ] ||
85 echo "FATAL: Test suite not installed correctly"
86 echo "INFO: as root user type 'make ; make install'"
90 [ -e "$LTPROOT/bin/ltp-pan" ] ||
92 echo "FATAL: Test suite driver 'ltp-pan' not found"
93 echo "INFO: as root user type 'make ; make install'"
100 cat "$LTPROOT/Version"
108 usage: ./${0##*/} [ -a EMAIL_TO ] [ -c NUM_PROCS ] [ -C FAILCMDFILE ] [ -d TMPDIR ]
109 [ -D NUM_PROCS,NUM_FILES,NUM_BYTES,CLEAN_FLAG ] -e [ -f CMDFILES(,...) ] [ -g HTMLFILE]
110 [ -i NUM_PROCS ] [ -l LOGFILE ] [ -m NUM_PROCS,CHUNKS,BYTES,HANGUP_FLAG ]
111 -N -n [ -o OUTPUTFILE ] -p -q [ -r LTPROOT ] [ -s PATTERN ] [ -t DURATION ]
112 -v [ -w CMDFILEADDR ] [ -x INSTANCES ] [ -b DEVICE ] [-B DEVICE_FS_TYPE]
113 [ -F LOOPS,PERCENTAGE ]
115 -a EMAIL_TO EMAIL all your Reports to this E-mail Address
116 -c NUM_PROCS Run LTP under additional background CPU load
117 [NUM_PROCS = no. of processes creating the CPU Load by spinning over sqrt()
118 (Defaults to 1 when value)]
119 -C FAILCMDFILE Command file with all failed test cases.
120 -d TMPDIR Directory where temporary files will be created.
121 -D NUM_PROCS,NUM_FILES,NUM_BYTES,CLEAN_FLAG
122 Run LTP under additional background Load on Secondary Storage (Seperate by comma)
123 [NUM_PROCS = no. of processes creating Storage Load by spinning over write()]
124 [NUM_FILES = Write() to these many files (Defaults to 1 when value 0 or undefined)]
125 [NUM_BYTES = write these many bytes (defaults to 1GB, when value 0 or undefined)]
126 [CLEAN_FLAG = unlink file to which random data written, when value 1]
127 -e Prints the date of the current LTP release
128 -f CMDFILES Execute user defined list of testcases (separate with ',')
129 -F LOOPS,PERCENTAGE Induce PERCENTAGE Fault in the Kernel Subsystems, and, run each test for LOOPS loop
130 -g HTMLFILE Create an additional HTML output format
131 -h Help. Prints all available options.
132 -i NUM_PROCS Run LTP under additional background Load on IO Bus
133 [NUM_PROCS = no. of processes creating IO Bus Load by spinning over sync()]
134 -l LOGFILE Log results of test in a logfile.
135 -m NUM_PROCS,CHUNKS,BYTES,HANGUP_FLAG
136 Run LTP under additional background Load on Main memory (Seperate by comma)
137 [NUM_PROCS = no. of processes creating main Memory Load by spinning over malloc()]
138 [CHUNKS = malloc these many chunks (default is 1 when value 0 or undefined)]
139 [BYTES = malloc CHUNKS of BYTES bytes (default is 256MB when value 0 or undefined) ]
140 [HANGUP_FLAG = hang in a sleep loop after memory allocated, when value 1]
142 [CHECK_TYPE=1 => Full Memory Leak Check tracing children as well]
143 [CHECK_TYPE=2 => Thread Concurrency Check tracing children as well]
144 [CHECK_TYPE=3 => Full Memory Leak & Thread Concurrency Check tracing children as well]
145 -N Run all the networking tests.
146 -n Run LTP with network traffic in background.
147 -o OUTPUTFILE Redirect test output to a file.
148 -p Human readable format logfiles.
149 -q Print less verbose output to screen.
150 -r LTPROOT Fully qualified path where testsuite is installed.
151 -s PATTERN Only run test cases which match PATTERN.
152 -S SKIPFILE Skip tests specified in SKIPFILE
153 -t DURATION Execute the testsuite for given duration. Examples:
158 -T REPETITION Execute the testsuite for REPETITION no. of times
159 -w CMDFILEADDR Uses wget to get the user's list of testcases.
160 -x INSTANCES Run multiple instances of this testsuite.
161 -b DEVICE Some tests require an unmounted block device
163 -B DEVICE_FS_TYPE The file system of test block devices.
166 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}
180 local ALT_EMAIL_OUT
=0
190 local INJECT_KERNEL_FAULT
=""
191 local INJECT_KERNEL_FAULT_PERCENTAGE
=""
192 local INJECT_FAULT_LOOPS_PER_TEST
=""
193 local VALGRIND_CHECK
=""
194 local VALGRIND_CHECK_TYPE
=""
195 local LOGFILE_NAME
=""
197 local OUTPUTFILE_NAME
=""
199 local HTMLFILE_NAME
=""
203 local TAG_RESTRICT_STRING
=""
205 local DEFAULT_FILE_NAME_GENERATION_TIME
=`date +"%Y_%b_%d-%Hh_%Mm_%Ss"`
206 version_date
=$
(cat "$LTPROOT/Version")
208 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
213 NUM_PROCS
=$
(($OPTARG))
214 if [ "$NUM_PROCS" -eq 0 ]; then
215 # User Did not Define the Value ,or, User Defined Zero,
216 # hence, prevent from creating infinite processes
219 $LTPROOT/testcases
/bin
/genload
--cpu $NUM_PROCS >/dev
/null
2>&1 &
225 FAILCMDFILE
="-C $OPTARG" ;;
227 FAILCMDFILE
="-C $LTPROOT/output/$OPTARG"
231 d
) # convert the user path to absolute path.
232 export TMPBASE
=`cd \`dirname ${OPTARG}\
`; pwd`/`basename ${OPTARG}` ;;
234 D
) NUM_PROCS
=1; NUM_FILES
=1; NUM_BYTES
=$
((1024 * 1024 * 1024)); CLEAN_FLAG
=0
235 ARGUMENT_LIST
=$OPTARG
236 TOTAL_ARGUMENTS
=1 # Initial Assume
237 for ARGUMENT
in `echo "$ARGUMENT_LIST" | sed 's/,/\n/g'` # Store all value in a Loop
239 case $TOTAL_ARGUMENTS in
240 1) NUM_PROCS
="$ARGUMENT" ;;
241 2) NUM_FILES
="$ARGUMENT" ;;
242 3) NUM_BYTES
="$ARGUMENT" ;;
243 4) CLEAN_FLAG
="$ARGUMENT" ;;
245 TOTAL_ARGUMENTS
=`expr $TOTAL_ARGUMENTS + 1`
247 # just to get the default values if the user passed 0
248 if [ "$NUM_PROCS" -eq 0 ]; then
251 if [ "$NUM_FILES" -eq 0 ]; then
254 if [ "$NUM_BYTES" -eq 0 ]; then
255 NUM_BYTES
=$
((1024 * 1024 * 1024))
257 if [ "$CLEAN_FLAG" -ne 1 ]; then
260 if [ "$CLEAN_FLAG" -eq 1 ]; then
261 # Do not unlink file in this case
262 $LTPROOT/testcases
/bin
/genload
--hdd $NUM_PROCS --hdd-files \
263 $NUM_FILES --hdd-bytes $NUM_BYTES >/dev
/null
2>&1 &
266 $LTPROOT/testcases
/bin
/genload
--hdd $NUM_PROCS --hdd-files \
267 $NUM_FILES --hdd-bytes $NUM_BYTES --hdd-noclean >/dev
/null
2>&1 &
271 e
) # Print out the version of LTP
274 f
) # Execute user defined set of testcases.
275 # Can be more then one file, just separate it with ',', like:
276 # -f nfs,commands,/tmp/testfile
278 F
) INJECT_KERNEL_FAULT
=1
279 #Seperate out the NO_OF_LOOPS & FAULT_PERCENTAGE
280 INJECT_FAULT_LOOPS_PER_TEST
=`echo $OPTARG |cut -d',' -f1 | tr -d '\n' | tr -d ' '`
281 INJECT_KERNEL_FAULT_PERCENTAGE
=`echo $OPTARG |cut -d',' -f2 | tr -d '\n' | tr -d ' '`
282 if [ ! $INJECT_FAULT_LOOPS_PER_TEST ]; then
283 echo "Loops not properly defined. Resorting to default 5..."
284 export INJECT_FAULT_LOOPS_PER_TEST
=5
286 if [ ! $INJECT_KERNEL_FAULT_PERCENTAGE ]; then
287 echo "Fault Persentage not properly defined. Resorting to default 10..."
288 export INJECT_KERNEL_FAULT_PERCENTAGE
=10
290 g
) HTMLFILE_NAME
="$OPTARG"
295 HTMLFILE
="$LTPROOT/output/$OPTARG";;
302 NUM_PROCS
=$
(($OPTARG))
303 if [ "$NUM_PROCS" -eq 0 ]; then
304 # User Did not Define the Value ,or, User Defined Zero,
305 # hence, prevent from creating infinite processes
308 $LTPROOT/testcases
/bin
/genload
--io $NUM_PROCS >/dev
/null
2>&1 &
312 LOGFILE_NAME
="$OPTARG"
315 LOGFILE
="-l $OPTARG" ;;
317 LOGFILE
="-l $LTPROOT/results/$OPTARG"
321 m
) NUM_PROCS
=1; CHUNKS
=1; BYTES
=$
((256 * 1024 * 1024)); HANGUP_FLAG
=0
322 ARGUMENT_LIST
=$OPTARG
323 TOTAL_ARGUMENTS
=1 # Initial Assume
324 for ARGUMENT
in `echo "$ARGUMENT_LIST" | sed 's/,/\n/g'` # Store all value in a Loop
326 case $TOTAL_ARGUMENTS in
327 1) NUM_PROCS
="$ARGUMENT" ;;
328 2) CHUNKS
="$ARGUMENT" ;;
329 3) BYTES
="$ARGUMENT" ;;
330 4) HANGUP_FLAG
="$ARGUMENT" ;;
332 TOTAL_ARGUMENTS
=`expr $TOTAL_ARGUMENTS + 1`
334 # just to get the default values if the user passed 0
335 if [ "$NUM_PROCS" -eq 0 ]; then
338 if [ "$CHUNKS" -eq 0 ]; then
341 if [ "$BYTES" -eq 0 ]; then
342 BYTES
=$
((256 * 1024 * 1024))
344 if [ "$HANGUP_FLAG" -ne 1 ]; then
347 if [ "$HANGUP_FLAG" -eq 1 ]; then
348 # Hang in a Sleep loop after memory allocated
349 $LTPROOT/testcases
/bin
/genload
--vm $NUM_PROCS --vm-chunks \
350 $CHUNKS --vm-bytes $BYTES --vm-hang >/dev
/null
2>&1 &
352 # Otherwise Do not Hangup
353 $LTPROOT/testcases
/bin
/genload
--vm $NUM_PROCS --vm-chunks \
354 $CHUNKS --vm-bytes $BYTES >/dev
/null
2>&1 &
359 VALGRIND_CHECK_TYPE
="$OPTARG";;
364 $LTPROOT/testcases
/bin
/netpipe.sh
367 o
) OUTPUTFILE_NAME
="$OPTARG"
370 OUTPUTFILE
="-o $OPTARG";;
372 OUTPUTFILE
="-o $LTPROOT/output/$OPTARG"
376 p
) PRETTY_PRT
=" -p ";;
378 q
) QUIET_MODE
=" -q ";;
382 s
) TAG_RESTRICT_STRING
=$OPTARG;;
388 SKIPFILE
="$LTPROOT/$OPTARG";;
391 t
) # In case you want to specify the time
392 # to run from the command line
393 # (2m = two minutes, 2h = two hours, etc)
394 DURATION
="-t $OPTARG" ;;
396 T
) # In case you want the testcases to runsequentially RUN_REPEATED times
397 RUN_REPEATED
=$OPTARG;;
399 w
) CMDFILEADDR
=$OPTARG;;
401 x
) # number of ltp's to run
403 WARNING: The use of -x can cause unpredictable failures, as a
404 result of concurrently running multiple tests designed
405 to be ran exclusively.
406 Pausing for 10 seconds..."
409 INSTANCES
="-x $OPTARG";;
411 B
) DEVICE_FS_TYPE
=$OPTARG;;
416 ## It would be nice to create a default log file even if the user has not mentioned
417 if [ ! "$LOGFILE" ]; then ## User has not mentioned about Log File name
418 LOGFILE_NAME
=$DEFAULT_FILE_NAME_GENERATION_TIME
419 LOGFILE
="-l $LTPROOT/results/LTP_RUN_ON-$LOGFILE_NAME.log"
424 ## It would be nice if a Failed File is compulsorily created (gives User better Idea of Tests that failed)
426 if [ ! "$FAILCMDFILE" ]; then ## User has not mentioned about Failed File name
428 if [ ! "$OUTPUTFILE" ]; then ## User has not mentioned about Output File name either
429 if [ ! "$LOGFILE" ]; then ## User has not mentioned about Log File name either
430 FAILED_FILE_NAME
=$DEFAULT_FILE_NAME_GENERATION_TIME
431 FAILCMDFILE
="-C $LTPROOT/output/LTP_RUN_ON-$FAILED_FILE_NAME.failed"
432 else ## User Fortunately wanted a log file,
433 FAILED_FILE_NAME
=`basename $LOGFILE_NAME` ## Extract log file name and use it to construct Failed file name
434 FAILCMDFILE
="-C $LTPROOT/output/LTP_RUN_ON-$FAILED_FILE_NAME.failed"
436 else ## User Fortunately wanted a Output file
437 FAILED_FILE_NAME
=`basename $OUTPUTFILE_NAME` ## Extract output file name and use it to construct Failed file name
438 FAILCMDFILE
="-C $LTPROOT/output/LTP_RUN_ON-$FAILED_FILE_NAME.failed"
442 if [ "$ALT_HTML_OUT" -eq 1 ] ; then ## User wants the HTML version of the output
443 QUIET_MODE
="" ## Suppressing this guy as it will prevent generation of proper output
444 ## which the HTML parser will require
445 if [ ! "$OUTPUTFILE" ]; then ## User has not mentioned about the Outputfile name, then we need to definitely generate one
446 OUTPUTFILE_NAME
=$DEFAULT_FILE_NAME_GENERATION_TIME
447 OUTPUTFILE
="-o $LTPROOT/output/LTP_RUN_ON-$OUTPUTFILE_NAME.output"
449 if [ ! "$HTMLFILE" ] ; then ## User has not mentioned HTML File name, We need to create one
450 HTMLFILE_NAME
=`basename $OUTPUTFILE_NAME`
451 HTMLFILE
="$LTPROOT/output/$HTMLFILE_NAME.html"
456 # If we need, create the output directory
457 [ "$ALT_DIR_OUT" -eq 1 ] && \
459 [ ! -d $LTPROOT/output
] && \
461 echo "INFO: creating $LTPROOT/output directory"
462 mkdir
-p $LTPROOT/output || \
464 echo "ERROR: failed to create $LTPROOT/output"
469 # If we need, create the results directory
470 [ "$ALT_DIR_RES" -eq 1 ] && \
472 echo "INFO: creating $LTPROOT/results directory"
473 [ ! -d $LTPROOT/results
] && \
475 mkdir
-p $LTPROOT/results || \
477 echo "ERROR: failed to create $LTPROOT/results"
483 # Added -m 777 for tests that call tst_tmpdir() and try to
484 # write to it as user nobody
485 mkdir
-m 777 -p $TMPBASE || \
487 echo "FATAL: Unable to make temporary directory $TMPBASE"
490 # use mktemp to create "safe" temporary directories
491 export TMPTEMPLATE
="${TMPBASE}/ltp-XXXXXXXXXX"
492 TMP
=`mktemp -d $TMPTEMPLATE` || \
494 echo "FATAL: Unable to make temporary directory: $TMP"
498 # To be invoked by tst_tmpdir()
499 # write to it as user nobody
504 echo "unable to chmod 777 $TMP ... aborting"
510 echo "could not cd ${TMP} ... exiting"
514 ! [ -z $INSTANCES ] && \
516 INSTANCES
="$INSTANCES -O ${TMP}"
519 [ "$RUN_NETEST" -eq 1 ] && \
521 [ -z "$RHOST" ] ||
[ -z "$PASSWD" ] && \
526 "INFO: Enter RHOST = 'name of the remote host machine'"
531 [ -z "$PASSWD" ] && \
535 "INFO: Enter PASSWD = 'root passwd of the remote host machine'"
540 export PASSWD
=$PASSWD
541 echo "WARNING: security of $RHOST may be compromised"
545 # If user does not provide a command file select a default set of testcases
547 if [ -z "$CMDFILES" ] && [ -z "$CMDFILEADDR" ]
551 INFO: no command files were provided, using default,
552 system calls, memory management, IPC, scheduler
553 direct io, file system, math and pty tests will
558 for SCENFILES
in ${LTPROOT}/runtest
/syscalls \
559 ${LTPROOT}/runtest
/fs \
560 ${LTPROOT}/runtest
/fsx \
561 ${LTPROOT}/runtest
/dio \
562 ${LTPROOT}/runtest
/io \
563 ${LTPROOT}/runtest
/mm \
564 ${LTPROOT}/runtest
/ipc \
565 ${LTPROOT}/runtest
/sched \
566 ${LTPROOT}/runtest
/math \
567 ${LTPROOT}/runtest
/nptl \
568 ${LTPROOT}/runtest
/pty \
569 ${LTPROOT}/runtest
/containers \
570 ${LTPROOT}/runtest
/fs_bind \
571 ${LTPROOT}/runtest
/controllers \
572 ${LTPROOT}/runtest
/filecaps \
573 ${LTPROOT}/runtest
/cap_bounds \
574 ${LTPROOT}/runtest
/fcntl-locktests \
575 ${LTPROOT}/runtest
/connectors \
576 ${LTPROOT}/runtest
/admin_tools \
577 ${LTPROOT}/runtest
/timers \
578 ${LTPROOT}/runtest
/power_management_tests \
579 ${LTPROOT}/runtest
/numa \
580 ${LTPROOT}/runtest
/hugetlb \
581 ${LTPROOT}/runtest
/commands \
582 ${LTPROOT}/runtest
/hyperthreading
584 [ -e "$SCENFILES" ] || \
586 echo "FATAL: missing scenario file $SCENFILES"
590 cat $SCENFILES >> ${TMP}/alltests || \
592 echo "FATAL: unable to create command file"
598 [ -n "$CMDFILES" ] && \
600 for SCENFILES
in `echo "$CMDFILES" | sed 's/,/\n/g'`
602 [ -f "$SCENFILES" ] || SCENFILES
="$LTPROOT/runtest/$SCENFILES"
603 cat "$SCENFILES" >> ${TMP}/alltests || \
605 echo "FATAL: unable to create command file"
611 [ -n "$CMDFILEADDR" ] && \
613 wget
-q "${CMDFILEADDR}" -O ${TMP}/wgetcmdfile
614 if [ $?
-ne 0 ]; then
615 echo "FATAL: error while getting the command file with wget (address $CMDFILEADDR)"
618 cat "${TMP}/wgetcmdfile" >> ${TMP}/alltests || \
620 echo "FATAL: unable to create command file"
625 [ "$RUN_NETEST" -eq 1 ] && \
627 for SCENFILES
in ${LTPROOT}/runtest
/tcp_cmds \
628 ${LTPROOT}/runtest
/multicast \
629 ${LTPROOT}/runtest
/rpc \
630 ${LTPROOT}/runtest
/nfs
632 [ -e "$SCENFILES" ] || \
634 echo "FATAL: missing scenario file $SCENFILES"
638 cat "$SCENFILES" >> ${TMP}/alltests || \
640 echo "FATAL: unable to create command file"
646 # The fsx-linux tests use the SCRATCHDEV environment variable as a location
647 # that can be reformatted and run on. Set SCRATCHDEV if you want to run
648 # these tests. As a safeguard, this is disabled.
650 [ -n "$SCRATCHDEV" ] && \
652 cat ${LTPROOT}/runtest
/fsx
>> ${TMP}/alltests ||
654 echo "FATAL: unable to create fsx-linux tests command file"
659 # If enabled, execute only test cases that match the PATTERN
660 if [ -n "$TAG_RESTRICT_STRING" ]
662 mv -f ${TMP}/alltests
${TMP}/alltests.orig
663 grep $TAG_RESTRICT_STRING ${TMP}/alltests.orig
> ${TMP}/alltests
#Not worth checking return codes for this case
666 # Blacklist or skip tests if a SKIPFILE was specified with -S
667 if [ -n "$SKIPFILE" ]
669 for file in $
( cat $SKIPFILE ); do
670 sed -i "/$file/d" ${TMP}/alltests
674 # check for required users and groups
675 ${LTPROOT}/IDcheck.sh
&>/dev
/null || \
677 echo "WARNING: required users and groups not present"
678 echo "WARNING: some test cases may fail"
681 # display versions of installed software
682 [ -z "$QUIET_MODE" ] && \
684 ${LTPROOT}/ver_linux || \
686 echo "WARNING: unable to display versions of software installed"
691 if [ -n "$DEVICE" ]; then
692 sed -i "s|DEVICE|$DEVICE|" ${TMP}/alltests
694 echo "remove test cases which require the block device."
695 echo "You can specify it with option -b"
696 sed -i "/DEVICE/d" ${TMP}/alltests
699 if [ $?
-ne 0 ]; then
700 echo "FATAL: error during prcessing alltests file by sed"
704 if [ -n "$DEVICE" ]; then
705 mnt_pnt
=`mktemp -d --tmpdir=${TMP} mnt_pnt.XXXXXX`
706 if [ -n "$DEVICE_FS_TYPE" ]; then
707 mount
-t $DEVICE_FS_TYPE $DEVICE $mnt_pnt
709 mount
$DEVICE $mnt_pnt
712 if [ $?
-ne 0 ]; then
713 echo "FATAL: can't mount block device $DEVICE."
717 if [ -z "$DEVICE_FS_TYPE" ]; then
718 DEVICE_FS_TYPE
=`cat /proc/mounts | awk "{if (\\\$1 == \"$DEVICE\") print \\\$3; }"`
719 echo "determine file system $DEVICE_FS_TYPE on block device $DEVICE"
723 if [ $?
-ne 0 ]; then
724 echo "FATAL: can't umount $DEVICE"
730 if [ -n "$DEVICE" ]; then
731 sed -i "s|DEVICE_FS_TYPE|$DEVICE_FS_TYPE|" ${TMP}/alltests
734 if [ $?
-ne 0 ]; then
735 echo "FATAL: error during prcessing alltests file by sed"
739 if [ $RUN_REPEATED -gt 1 ]; then # You need to specify at least more than 1 sequential run, else it runs default
740 echo "PAN will run these test cases $RUN_REPEATED times....."
741 echo "Test Tags will be Prepended with ITERATION NO.s....."
743 sed -e '/^$/ d' -e 's/^[ ,\t]*//' -e '/^#/ d' < ${TMP}/alltests
> ${TMP}/alltests.temp
##This removes all newlines, leading spaces, tabs, #
744 sed 's/^[0-9,a-z,A-Z]*/'"$inc"'_ITERATION_&/' < ${TMP}/alltests.temp
> ${TMP}/alltests
## .temp is kept as Base file
745 while [ $inc -lt $RUN_REPEATED ] ; do
747 sed 's/^[0-9,a-z,A-Z]*/'"$inc"'_ITERATION_&/' < ${TMP}/alltests.temp
>> ${TMP}/alltests
#Keep appending with Iteration No.s
751 [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test start time: $(date)" ; }
752 PAN_COMMAND
="${LTPROOT}/bin/ltp-pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ \
753 -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE $FAILCMDFILE"
754 echo "COMMAND: $PAN_COMMAND"
755 if [ ! -z "$TAG_RESTRICT_STRING" ] ; then
756 echo "INFO: Restricted to $TAG_RESTRICT_STRING"
758 #$PAN_COMMAND #Duplicated code here, because otherwise if we fail, only "PAN_COMMAND" gets output
760 ## Display the Output/Log/Failed/HTML file names here
761 echo -e "LOG File: \c"
762 echo $LOGFILE | cut
-b4-
764 if [ "$OUTPUTFILE" ]; then
765 echo -e "OUTPUT File: \c"
766 echo $OUTPUTFILE | cut
-b4-
769 echo -e "FAILED COMMAND File: \c"
770 echo $FAILCMDFILE | cut
-b4-
772 if [ "$HTMLFILE" ]; then
773 echo "HTML File: $HTMLFILE"
776 echo "Running tests......."
777 test_start_time
=$
(date)
779 # User wants testing with Kernel Fault Injection
780 if [ $INJECT_KERNEL_FAULT ] ; then
781 #See if Debugfs is mounted, and
782 #Fault Injection Framework available through Debugfs
783 if [ -d "/sys/kernel/debug/fail_io_timeout" -o \
784 -d "/sys/kernel/debug/fail_make_request" -o \
785 -d "/sys/kernel/debug/fail_page_alloc" -o \
786 -d "/sys/kernel/debug/failslab" ]; then
787 #If atleast one of the Framework is available
788 #Go ahead to Inject Fault & Create required
789 #Command Files for LTP run
790 echo Running tests with Fault Injection Enabled
in the Kernel...
791 ${LTPROOT}/tools
/create_kernel_faults_in_loops_and_probability.pl\
792 ${TMP}/alltests
$INJECT_FAULT_LOOPS_PER_TEST $INJECT_KERNEL_FAULT_PERCENTAGE > ${TMP}/alltests.tmp
793 cp ${TMP}/alltests.tmp
${TMP}/alltests
794 rm -rf ${TMP}/alltests.tmp
796 echo Fault Injection not enabled
in the Kernel..
797 echo Running tests normally...
801 ## Valgrind Check will work only when Kernel Fault Injection is not expected,
802 ## We do not want to test Faults when valgrind is running
803 if [ $VALGRIND_CHECK ]; then
804 if [ ! $INJECT_KERNEL_FAULT ]; then
805 which valgrind || VALGRIND_CHECK_TYPE
=XYZ
806 case $VALGRIND_CHECK_TYPE in
808 ${LTPROOT}/tools/create_valgrind_check.pl ${TMP}/alltests 1 > ${TMP}/alltests.tmp
809 cp ${TMP}/alltests.tmp
${TMP}/alltests
810 rm -rf ${TMP}/alltests.tmp
;;
812 ${LTPROOT}/tools/create_valgrind_check.pl ${TMP}/alltests 2 > ${TMP}/alltests.tmp
813 cp ${TMP}/alltests.tmp
${TMP}/alltests
814 rm -rf ${TMP}/alltests.tmp
;;
816 ${LTPROOT}/tools/create_valgrind_check.pl ${TMP}/alltests 3 > ${TMP}/alltests.tmp
817 cp ${TMP}/alltests.tmp
${TMP}/alltests
818 rm -rf ${TMP}/alltests.tmp
;;
819 *) echo "Invalid Memory Check Type, or, Valgrind is not available";;
824 # Some tests need to run inside the "bin" directory.
825 cd "${LTPROOT}/testcases/bin"
826 "${LTPROOT}/bin/ltp-pan" $QUIET_MODE -e -S $INSTANCES $DURATION -a $$
-n $$
$PRETTY_PRT -f ${TMP}/alltests
$LOGFILE $OUTPUTFILE $FAILCMDFILE
828 if [ $?
-eq 0 ]; then
829 echo "INFO: ltp-pan reported all tests PASS"
831 export LTP_EXIT_VALUE
=0;
833 echo "INFO: ltp-pan reported some tests FAIL"
835 export LTP_EXIT_VALUE
=1;
838 echo "LTP Version: $version_date"
840 if [ "$ALT_HTML_OUT" -eq 1 ] ; then #User wants the HTML output to be created, it then needs to be generated
841 export LTP_VERSION
=$version_date
842 export TEST_START_TIME
=$test_start_time
843 export TEST_END_TIME
=$
(date)
844 OUTPUT_DIRECTORY
=`echo $OUTPUTFILE | cut -c4-`
845 LOGS_DIRECTORY
="$LTPROOT/results"
846 export TEST_OUTPUT_DIRECTORY
="$LTPROOT/output"
847 export TEST_LOGS_DIRECTORY
=$LOGS_DIRECTORY
848 echo "Generating HTML Output.....!!"
849 ( perl
$LTPROOT/tools
/genhtml.pl
$LTPROOT/tools
/html_report_header.txt test_start test_end test_output execution_status
$OUTPUT_DIRECTORY > $HTMLFILE; )
850 echo "Generated HTML Output.....!!"
851 echo "Location: $HTMLFILE";
855 if [ "$ALT_EMAIL_OUT" -eq 1 ] ; then ## User wants reports to be e-mailed
856 if [ [ ! "$HTMLFILE_NAME" ] -o [ ! "$OUTPUTFILE_NAME" ] -o [ ! "$LOGFILE_NAME" ] ] ; then
857 ##User does not have output/logs/html-output, nothing to be mailed in this situation
858 echo "Nothing to be mailed here...."
860 TAR_FILE_NAME
=LTP_RUN_
$version_date$DEFAULT_FILE_NAME_GENERATION_TIME.
tar
861 if [ "$HTMLFILE_NAME" ] ; then ## HTML file Exists
862 if [ "$ALT_HTML_OUT" -ne 1 ] ; then ## The HTML file path is absolute and not $LTPROOT/output
863 mkdir
-p $LTPROOT/output
## We need to create this Directory
864 cp $HTMLFILE_NAME $LTPROOT/output
/
867 if [ "$OUTPUTFILE_NAME" ] ; then ## Output file exists
868 if [ "$ALT_DIR_OUT" -ne 1 ] ; then ## The Output file path is absolute and not $LTPROOT/output
869 mkdir
-p $LTPROOT/output
## We need to create this Directory
870 cp $OUTPUTFILE_NAME $LTPROOT/output
/
873 if [ "$LOGFILE_NAME" ] ; then ## Log file exists
874 if [ "$ALT_DIR_RES" -ne 1 ] ; then ## The Log file path is absolute and not $LTPROOT/results
875 mkdir
-p $LTPROOT/results
## We need to create this Directory
876 cp $LOGFILE_NAME $LTPROOT/results
/
879 if [ -d $LTPROOT/output
] ; then
880 tar -cf .
/$TAR_FILE_NAME $LTPROOT/output
881 if [ $?
-eq 0 ]; then
882 echo "Created TAR File: ./$TAR_FILE_NAME successfully, added $LTPROOT/output"
884 echo "Cannot Create TAR File: ./$TAR_FILE_NAME for adding $LTPROOT/output"
887 if [ -d $LTPROOT/results
] ; then
888 tar -uf .
/$TAR_FILE_NAME $LTPROOT/results
889 if [ $?
-eq 0 ]; then
890 echo "Updated TAR File: ./$TAR_FILE_NAME successfully, added $LTPROOT/results"
892 echo "Cannot Update TAR File: ./$TAR_FILE_NAME for adding $LTPROOT/results"
895 if [ -e $LTPROOT/nohup.out
] ; then ## If User would have Chosen nohup to do ltprun
896 tar -uf .
/$TAR_FILE_NAME $LTPROOT/nohup.out
897 if [ $?
-eq 0 ]; then
898 echo "Updated TAR File: ./$TAR_FILE_NAME successfully, added $LTPROOT/nohup.out"
900 echo "Cannot Update TAR File: ./$TAR_FILE_NAME for adding $LTPROOT/nohup.out"
903 gzip .
/$TAR_FILE_NAME ## gzip this guy
904 if [ $?
-eq 0 ]; then
905 echo "Gunzipped TAR File: ./$TAR_FILE_NAME"
907 echo "Cannot Gunzip TAR File: ./$TAR_FILE_NAME"
909 if [ -e /usr
/bin
/mutt
] ; then ## This is a better mail client than others
910 echo "Starting mailing reports to: $EMAIL_TO, file: ./$TAR_FILE_NAME.gz"
911 mutt
-a .
/$TAR_FILE_NAME.gz
-s "LTP Reports on $test_start_time" $EMAIL_TO < /dev
/null
912 if [ $?
-eq 0 ]; then
913 echo "Reports Successfully mailed to: $EMAIL_TO"
915 echo "Reports cannot be mailed to: $EMAIL_TO"
917 else ## Use our Ageold mail program
918 echo "Starting mailing reports to: $EMAIL_TO, file: ./$TAR_FILE_NAME.gz"
919 uuencode .
/$TAR_FILE_NAME.gz
$TAR_FILE_NAME.gz |
mail $EMAIL_TO -s "LTP Reports on $test_start_time"
920 if [ $?
-eq 0 ]; then
921 echo "Reports Successfully mailed to: $EMAIL_TO"
923 echo "Reports cannot be mailed to: $EMAIL_TO"
929 [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test end time: $(date)" ; }
931 [ "$GENLOAD" -eq 1 ] && { killall
-9 genload
>/dev
/null
2>&1; }
932 [ "$NETPIPE" -eq 1 ] && { killall
-9 NPtcp
>/dev
/null
2>&1; }
934 [ "$ALT_DIR_OUT" -eq 1 ] ||
[ "$ALT_DIR_RES" -eq 1 ] && \
938 ###############################################################"
940 Done executing testcases."
941 LTP Version: $version_date
942 ###############################################################"