blob: 7a8ac2878fb1ed58424f0d52c53b723e9c3bb11d [file] [log] [blame]
plars4a120e82004-09-02 18:56:06 +00001#!/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
22#
23# Description: This script can be used to the tests in the LTP test suite
24#
25# Authors: Manoj Iyer - manjo@mail.utexas.edu
26# Robbe Williamson - robbiew@us.ibm.com
27#
28# History: Oct 07 2003 - Modified - Manoj Iyer
29# - use functions
30# - clean up on script exit
31# - error checking etc.
32#
33# Oct 08 2003 - Modified - Manoj Iyer
34# - fixed bug in creating results directory
subrata_modaka1fd64b2007-04-11 11:24:49 +000035# - all checks should be enlclosed in " " to avoid bash error
subrata_modak14390fd2009-05-19 09:39:11 +000036# - exit with error if ltp-pan is not found in pan directory
subrata_modakbc833d32007-07-25 10:12:02 +000037#
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)
44#
45# Jul 23 2007 - Modified - Ricardo Salveti de Araujo
46# - added flag to get the command file that has all failed tests
subrata_modak6838ec32007-09-14 10:10:12 +000047#
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
52#
subrata_modak5d7deea2007-09-15 13:51:36 +000053# Sep 14 2007 - Modified - Ricardo Salveti de Araujo
54# - cleaning and removing duplicated code
55#
subrata_modake099b2a2007-10-29 12:22:01 +000056# Oct 27 2007 - Modified - Ricardo Salveti de Araujo and Subrata Modak
yaberauneya6d41cc32010-01-28 16:24:16 +000057# - better ways to integrate "ltp/tools/genload/stress" with "ltp/runltp"
subrata_modake47fb352007-11-25 17:03:49 +000058# 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
subrata_modakf376b482007-11-28 11:30:54 +000061# Nov 28 2007 - Modified - Subrata Modak
62# - Added a new option to mail back LTP reports
subrata_modak43938212008-05-19 08:48:46 +000063# May 19 2008 - Modified - Subrata Modak
64# - Added capability for default Log file generation
yaberauneya6d41cc32010-01-28 16:24:16 +000065# Aug 17 2009 - Modified - Subrata Modak
66# - Added Fault Injection generation Capability through -F Option
subrata_modake099b2a2007-10-29 12:22:01 +000067#
subrata_modak6838ec32007-09-14 10:10:12 +000068#################################################################################
subrata_modakbc833d32007-07-25 10:12:02 +000069
plars4a120e82004-09-02 18:56:06 +000070
71
72setup()
73{
yaberauneya6d41cc32010-01-28 16:24:16 +000074 cd `dirname $0` || \
75 {
76 echo "FATAL: unable to change directory to $(dirname $0)"
77 exit 1
78 }
79 export LTPROOT=${PWD}
plars4a120e82004-09-02 18:56:06 +000080 export TMPBASE="/tmp"
yaberauneya6d41cc32010-01-28 16:24:16 +000081 export PATH="${PATH}:${LTPROOT}/testcases/bin"
plars4a120e82004-09-02 18:56:06 +000082
yaberauneya6d41cc32010-01-28 16:24:16 +000083 [ -d "$LTPROOT/testcases/bin" ] ||
84 {
85 echo "FATAL: Test suite not installed correctly"
86 echo "INFO: as root user type 'make ; make install'"
87 exit 1
88 }
89
90 [ -e "$LTPROOT/bin/ltp-pan" ] ||
91 {
92 echo "FATAL: Test suite driver 'ltp-pan' not found"
93 echo "INFO: as root user type 'make ; make install'"
94 exit 1
95 }
plars4a120e82004-09-02 18:56:06 +000096}
97
mreed1091696422006-05-03 19:07:22 +000098version_of_ltp()
99{
yaberauneyaef772532009-10-09 17:55:43 +0000100 cat "$LTPROOT/Version"
yaberauneya6d41cc32010-01-28 16:24:16 +0000101 exit 0
mreed1091696422006-05-03 19:07:22 +0000102}
plars4a120e82004-09-02 18:56:06 +0000103
104usage()
105{
yaberauneya6d41cc32010-01-28 16:24:16 +0000106 cat <<-EOF >&2
plars4a120e82004-09-02 18:56:06 +0000107
Garrett Cooperf95875a2010-03-05 02:44:39 -0800108 usage: ${0##*/} [ -a EMAIL_TO ] [ -c NUM_PROCS ] [ -C FAILCMDFILE ] [ -d TMPDIR ]
subrata_modake47fb352007-11-25 17:03:49 +0000109 [ -D NUM_PROCS,NUM_FILES,NUM_BYTES,CLEAN_FLAG ] -e [ -f CMDFILES(,...) ] [ -g HTMLFILE]
subrata_modake099b2a2007-10-29 12:22:01 +0000110 [ -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 ]
subrata_modakd9fb3862008-12-29 11:25:36 +0000112 -v [ -w CMDFILEADDR ] [ -x INSTANCES ] [ -b DEVICE ] [-B DEVICE_FS_TYPE]
yaberauneya6d41cc32010-01-28 16:24:16 +0000113 [ -F LOOPS,PERCENTAGE ]
plars4a120e82004-09-02 18:56:06 +0000114
subrata_modak08dde6f2007-11-28 11:02:51 +0000115 -a EMAIL_TO EMAIL all your Reports to this E-mail Address
subrata_modake099b2a2007-10-29 12:22:01 +0000116 -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)]
subrata_modakbc833d32007-07-25 10:12:02 +0000119 -C FAILCMDFILE Command file with all failed test cases.
plars4a120e82004-09-02 18:56:06 +0000120 -d TMPDIR Directory where temporary files will be created.
subrata_modake099b2a2007-10-29 12:22:01 +0000121 -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]
mreed1091696422006-05-03 19:07:22 +0000127 -e Prints the date of the current LTP release
subrata_modakbc833d32007-07-25 10:12:02 +0000128 -f CMDFILES Execute user defined list of testcases (separate with ',')
yaberauneya6d41cc32010-01-28 16:24:16 +0000129 -F LOOPS,PERCENTAGE Induce PERCENTAGE Fault in the Kernel Subsystems, and, run each test for LOOPS loop
subrata_modake47fb352007-11-25 17:03:49 +0000130 -g HTMLFILE Create an additional HTML output format
plars4a120e82004-09-02 18:56:06 +0000131 -h Help. Prints all available options.
subrata_modake099b2a2007-10-29 12:22:01 +0000132 -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()]
Subrata Modakbd9d4402010-05-12 22:03:21 +0530134 -K DMESG_LOG_DIR
135 Log Kernel messages generated for each test cases inside this directory
plars4a120e82004-09-02 18:56:06 +0000136 -l LOGFILE Log results of test in a logfile.
subrata_modake099b2a2007-10-29 12:22:01 +0000137 -m NUM_PROCS,CHUNKS,BYTES,HANGUP_FLAG
138 Run LTP under additional background Load on Main memory (Seperate by comma)
139 [NUM_PROCS = no. of processes creating main Memory Load by spinning over malloc()]
140 [CHUNKS = malloc these many chunks (default is 1 when value 0 or undefined)]
141 [BYTES = malloc CHUNKS of BYTES bytes (default is 256MB when value 0 or undefined) ]
142 [HANGUP_FLAG = hang in a sleep loop after memory allocated, when value 1]
yaberauneya6d41cc32010-01-28 16:24:16 +0000143 -M CHECK_TYPE
144 [CHECK_TYPE=1 => Full Memory Leak Check tracing children as well]
145 [CHECK_TYPE=2 => Thread Concurrency Check tracing children as well]
146 [CHECK_TYPE=3 => Full Memory Leak & Thread Concurrency Check tracing children as well]
plars4a120e82004-09-02 18:56:06 +0000147 -N Run all the networking tests.
148 -n Run LTP with network traffic in background.
149 -o OUTPUTFILE Redirect test output to a file.
150 -p Human readable format logfiles.
151 -q Print less verbose output to screen.
152 -r LTPROOT Fully qualified path where testsuite is installed.
subrata_modaka1fd64b2007-04-11 11:24:49 +0000153 -s PATTERN Only run test cases which match PATTERN.
subrata_modak2f6c9812009-08-14 17:07:48 +0000154 -S SKIPFILE Skip tests specified in SKIPFILE
plars4a120e82004-09-02 18:56:06 +0000155 -t DURATION Execute the testsuite for given duration. Examples:
156 -t 60s = 60 seconds
157 -t 45m = 45 minutes
158 -t 24h = 24 hours
159 -t 2d = 2 days
subrata_modak8c138332008-01-28 11:19:32 +0000160 -T REPETITION Execute the testsuite for REPETITION no. of times
subrata_modakbc833d32007-07-25 10:12:02 +0000161 -w CMDFILEADDR Uses wget to get the user's list of testcases.
plars4a120e82004-09-02 18:56:06 +0000162 -x INSTANCES Run multiple instances of this testsuite.
subrata_modakd9fb3862008-12-29 11:25:36 +0000163 -b DEVICE Some tests require an unmounted block device
164 to run correctly.
165 -B DEVICE_FS_TYPE The file system of test block devices.
166
plars4a120e82004-09-02 18:56:06 +0000167
Garrett Cooperf95875a2010-03-05 02:44:39 -0800168 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}
plars4a120e82004-09-02 18:56:06 +0000169
plars4a120e82004-09-02 18:56:06 +0000170
yaberauneya6d41cc32010-01-28 16:24:16 +0000171 EOF
172exit 0
plars4a120e82004-09-02 18:56:06 +0000173}
174
plars4a120e82004-09-02 18:56:06 +0000175main()
176{
subrata_modakbc833d32007-07-25 10:12:02 +0000177 local CMDFILES=""
plars4a120e82004-09-02 18:56:06 +0000178 local PRETTY_PRT=""
subrata_modak5d7deea2007-09-15 13:51:36 +0000179 local ALT_DIR_OUT=0
180 local ALT_DIR_RES=0
subrata_modake47fb352007-11-25 17:03:49 +0000181 local ALT_HTML_OUT=0
subrata_modak08dde6f2007-11-28 11:02:51 +0000182 local ALT_EMAIL_OUT=0
Subrata Modakbd9d4402010-05-12 22:03:21 +0530183 local ALT_DMESG_OUT=0
plars4a120e82004-09-02 18:56:06 +0000184 local RUN_NETEST=0
subrata_modak8c138332008-01-28 11:19:32 +0000185 local RUN_REPEATED=0
yaberauneya6d41cc32010-01-28 16:24:16 +0000186 local QUIET_MODE=""
plars4a120e82004-09-02 18:56:06 +0000187 local NETPIPE=0
188 local GENLOAD=0
189 local MEMSIZE=0
190 local DURATION=""
subrata_modakbc833d32007-07-25 10:12:02 +0000191 local CMDFILEADDR=""
subrata_modak43938212008-05-19 08:48:46 +0000192 local FAILCMDFILE=""
yaberauneyaef772532009-10-09 17:55:43 +0000193 local INJECT_KERNEL_FAULT=""
194 local INJECT_KERNEL_FAULT_PERCENTAGE=""
195 local INJECT_FAULT_LOOPS_PER_TEST=""
196 local VALGRIND_CHECK=""
197 local VALGRIND_CHECK_TYPE=""
subrata_modake47fb352007-11-25 17:03:49 +0000198 local LOGFILE_NAME=""
plars4a120e82004-09-02 18:56:06 +0000199 local LOGFILE=""
subrata_modake47fb352007-11-25 17:03:49 +0000200 local OUTPUTFILE_NAME=""
201 local OUTPUTFILE=""
202 local HTMLFILE_NAME=""
203 local HTMLFILE=""
Subrata Modakbd9d4402010-05-12 22:03:21 +0530204 local DMESG_DIR=""
subrata_modak08dde6f2007-11-28 11:02:51 +0000205 local EMAIL_TO=""
plars4a120e82004-09-02 18:56:06 +0000206 local SCENFILES=""
robbiew7d43d772005-02-07 20:07:30 +0000207 local TAG_RESTRICT_STRING=""
208 local PAN_COMMAND=""
subrata_modak43938212008-05-19 08:48:46 +0000209 local DEFAULT_FILE_NAME_GENERATION_TIME=`date +"%Y_%b_%d-%Hh_%Mm_%Ss"`
yaberauneyaef772532009-10-09 17:55:43 +0000210 version_date=$(cat "$LTPROOT/Version")
plars4a120e82004-09-02 18:56:06 +0000211
Subrata Modakbd9d4402010-05-12 22:03:21 +0530212 while getopts a:c:C:d:D:f:F:ehi:K:g:l:m:M:Nno:pqr:s:S:t:T:w:x:b:B: arg
yaberauneya6d41cc32010-01-28 16:24:16 +0000213 do case $arg in
subrata_modak08dde6f2007-11-28 11:02:51 +0000214 a) EMAIL_TO=$OPTARG
215 ALT_EMAIL_OUT=1;;
plars4a120e82004-09-02 18:56:06 +0000216 c)
subrata_modake099b2a2007-10-29 12:22:01 +0000217 NUM_PROCS=$(($OPTARG))
218 if [ "$NUM_PROCS" -eq 0 ]; then
219 # User Did not Define the Value ,or, User Defined Zero,
220 # hence, prevent from creating infinite processes
221 NUM_PROCS=1
222 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000223 $LTPROOT/testcases/bin/genload --cpu $NUM_PROCS >/dev/null 2>&1 &
plars4a120e82004-09-02 18:56:06 +0000224 GENLOAD=1 ;;
subrata_modakbc833d32007-07-25 10:12:02 +0000225
subrata_modak5d7deea2007-09-15 13:51:36 +0000226 C)
subrata_modak6838ec32007-09-14 10:10:12 +0000227 case $OPTARG in
228 /*)
229 FAILCMDFILE="-C $OPTARG" ;;
230 *)
231 FAILCMDFILE="-C $LTPROOT/output/$OPTARG"
subrata_modak5d7deea2007-09-15 13:51:36 +0000232 ALT_DIR_OUT=1 ;;
subrata_modak6838ec32007-09-14 10:10:12 +0000233 esac ;;
plars4a120e82004-09-02 18:56:06 +0000234
subrata_modak5ee3e892008-10-21 13:17:56 +0000235 d) # convert the user path to absolute path.
yaberauneya6d41cc32010-01-28 16:24:16 +0000236 export TMPBASE=`cd \`dirname ${OPTARG}\`; pwd`/`basename ${OPTARG}` ;;
subrata_modake099b2a2007-10-29 12:22:01 +0000237
238 D) NUM_PROCS=1; NUM_FILES=1; NUM_BYTES=$((1024 * 1024 * 1024)); CLEAN_FLAG=0
subrata_modak548379d2008-08-20 09:15:49 +0000239 ARGUMENT_LIST=$OPTARG
subrata_modake099b2a2007-10-29 12:22:01 +0000240 TOTAL_ARGUMENTS=1 # Initial Assume
241 for ARGUMENT in `echo "$ARGUMENT_LIST" | sed 's/,/\n/g'` # Store all value in a Loop
242 do
243 case $TOTAL_ARGUMENTS in
yaberauneya6d41cc32010-01-28 16:24:16 +0000244 1) NUM_PROCS="$ARGUMENT" ;;
245 2) NUM_FILES="$ARGUMENT" ;;
246 3) NUM_BYTES="$ARGUMENT" ;;
247 4) CLEAN_FLAG="$ARGUMENT" ;;
subrata_modake099b2a2007-10-29 12:22:01 +0000248 esac
yaberauneya6d41cc32010-01-28 16:24:16 +0000249 TOTAL_ARGUMENTS=`expr $TOTAL_ARGUMENTS + 1`
subrata_modake099b2a2007-10-29 12:22:01 +0000250 done
251 # just to get the default values if the user passed 0
252 if [ "$NUM_PROCS" -eq 0 ]; then
253 NUM_PROCS=1
254 fi
255 if [ "$NUM_FILES" -eq 0 ]; then
256 NUM_FILES=1
257 fi
258 if [ "$NUM_BYTES" -eq 0 ]; then
259 NUM_BYTES=$((1024 * 1024 * 1024))
260 fi
261 if [ "$CLEAN_FLAG" -ne 1 ]; then
262 CLEAN_FLAG=0
263 fi
264 if [ "$CLEAN_FLAG" -eq 1 ]; then
265 # Do not unlink file in this case
yaberauneya6d41cc32010-01-28 16:24:16 +0000266 $LTPROOT/testcases/bin/genload --hdd $NUM_PROCS --hdd-files \
subrata_modake099b2a2007-10-29 12:22:01 +0000267 $NUM_FILES --hdd-bytes $NUM_BYTES >/dev/null 2>&1 &
268 else
269 # Cleanup otherwise
yaberauneya6d41cc32010-01-28 16:24:16 +0000270 $LTPROOT/testcases/bin/genload --hdd $NUM_PROCS --hdd-files \
subrata_modake099b2a2007-10-29 12:22:01 +0000271 $NUM_FILES --hdd-bytes $NUM_BYTES --hdd-noclean >/dev/null 2>&1 &
272 fi
273 GENLOAD=1;;
274
mreed1091696422006-05-03 19:07:22 +0000275 e) # Print out the version of LTP
276 version_of_ltp
yaberauneya6d41cc32010-01-28 16:24:16 +0000277 ;;
plars4a120e82004-09-02 18:56:06 +0000278 f) # Execute user defined set of testcases.
subrata_modakbc833d32007-07-25 10:12:02 +0000279 # Can be more then one file, just separate it with ',', like:
280 # -f nfs,commands,/tmp/testfile
281 CMDFILES=$OPTARG;;
yaberauneya6d41cc32010-01-28 16:24:16 +0000282 F) INJECT_KERNEL_FAULT=1
283 #Seperate out the NO_OF_LOOPS & FAULT_PERCENTAGE
284 INJECT_FAULT_LOOPS_PER_TEST=`echo $OPTARG |cut -d',' -f1 | tr -d '\n' | tr -d ' '`
285 INJECT_KERNEL_FAULT_PERCENTAGE=`echo $OPTARG |cut -d',' -f2 | tr -d '\n' | tr -d ' '`
286 if [ ! $INJECT_FAULT_LOOPS_PER_TEST ]; then
287 echo "Loops not properly defined. Resorting to default 5..."
288 export INJECT_FAULT_LOOPS_PER_TEST=5
289 fi
290 if [ ! $INJECT_KERNEL_FAULT_PERCENTAGE ]; then
291 echo "Fault Persentage not properly defined. Resorting to default 10..."
292 export INJECT_KERNEL_FAULT_PERCENTAGE=10
293 fi;;
subrata_modake47fb352007-11-25 17:03:49 +0000294 g) HTMLFILE_NAME="$OPTARG"
295 case $OPTARG in
296 /*)
297 HTMLFILE="$OPTARG";;
298 *)
subrata_modakd48c4d02008-01-23 12:59:40 +0000299 HTMLFILE="$LTPROOT/output/$OPTARG";;
300 esac
301 ALT_DIR_OUT=1
302 ALT_HTML_OUT=1;;
plars4a120e82004-09-02 18:56:06 +0000303 h) usage;;
304
subrata_modake099b2a2007-10-29 12:22:01 +0000305 i)
306 NUM_PROCS=$(($OPTARG))
307 if [ "$NUM_PROCS" -eq 0 ]; then
308 # User Did not Define the Value ,or, User Defined Zero,
309 # hence, prevent from creating infinite processes
310 NUM_PROCS=1
311 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000312 $LTPROOT/testcases/bin/genload --io $NUM_PROCS >/dev/null 2>&1 &
plars4a120e82004-09-02 18:56:06 +0000313 GENLOAD=1 ;;
314
Subrata Modakbd9d4402010-05-12 22:03:21 +0530315 K)
316 case $OPTARG in
317 /*)
318 DMESG_DIR="$OPTARG-dmesg-output-`echo $$-``date +%X | tr -d ' '`";;
319 *)
320 DMESG_DIR="$LTPROOT/output/$OPTARG-dmesg-output-`echo $$-``date +%X | tr -d ' '`";;
321 esac
322 mkdir -p $DMESG_DIR
323 ALT_DMESG_OUT=1;;
plars4a120e82004-09-02 18:56:06 +0000324 l)
subrata_modak6838ec32007-09-14 10:10:12 +0000325 LOGFILE_NAME="$OPTARG"
plars4a120e82004-09-02 18:56:06 +0000326 case $OPTARG in
subrata_modak5d7deea2007-09-15 13:51:36 +0000327 /*)
plars4a120e82004-09-02 18:56:06 +0000328 LOGFILE="-l $OPTARG" ;;
329 *)
330 LOGFILE="-l $LTPROOT/results/$OPTARG"
subrata_modak5d7deea2007-09-15 13:51:36 +0000331 ALT_DIR_RES=1 ;;
plars4a120e82004-09-02 18:56:06 +0000332 esac ;;
333
subrata_modake099b2a2007-10-29 12:22:01 +0000334 m) NUM_PROCS=1; CHUNKS=1; BYTES=$((256 * 1024 * 1024)); HANGUP_FLAG=0
subrata_modak29a96d82008-08-27 13:34:46 +0000335 ARGUMENT_LIST=$OPTARG
subrata_modake099b2a2007-10-29 12:22:01 +0000336 TOTAL_ARGUMENTS=1 # Initial Assume
337 for ARGUMENT in `echo "$ARGUMENT_LIST" | sed 's/,/\n/g'` # Store all value in a Loop
338 do
339 case $TOTAL_ARGUMENTS in
yaberauneya6d41cc32010-01-28 16:24:16 +0000340 1) NUM_PROCS="$ARGUMENT" ;;
341 2) CHUNKS="$ARGUMENT" ;;
342 3) BYTES="$ARGUMENT" ;;
343 4) HANGUP_FLAG="$ARGUMENT" ;;
subrata_modake099b2a2007-10-29 12:22:01 +0000344 esac
yaberauneya6d41cc32010-01-28 16:24:16 +0000345 TOTAL_ARGUMENTS=`expr $TOTAL_ARGUMENTS + 1`
subrata_modake099b2a2007-10-29 12:22:01 +0000346 done
347 # just to get the default values if the user passed 0
yaberauneya6d41cc32010-01-28 16:24:16 +0000348 if [ "$NUM_PROCS" -eq 0 ]; then
349 NUM_PROCS=1
350 fi
351 if [ "$CHUNKS" -eq 0 ]; then
352 CHUNKS=1
353 fi
354 if [ "$BYTES" -eq 0 ]; then
355 BYTES=$((256 * 1024 * 1024))
356 fi
357 if [ "$HANGUP_FLAG" -ne 1 ]; then
358 HANGUP_FLAG=0
359 fi
subrata_modake099b2a2007-10-29 12:22:01 +0000360 if [ "$HANGUP_FLAG" -eq 1 ]; then
361 # Hang in a Sleep loop after memory allocated
yaberauneya6d41cc32010-01-28 16:24:16 +0000362 $LTPROOT/testcases/bin/genload --vm $NUM_PROCS --vm-chunks \
subrata_modake099b2a2007-10-29 12:22:01 +0000363 $CHUNKS --vm-bytes $BYTES --vm-hang >/dev/null 2>&1 &
364 else
365 # Otherwise Do not Hangup
yaberauneya6d41cc32010-01-28 16:24:16 +0000366 $LTPROOT/testcases/bin/genload --vm $NUM_PROCS --vm-chunks \
subrata_modake099b2a2007-10-29 12:22:01 +0000367 $CHUNKS --vm-bytes $BYTES >/dev/null 2>&1 &
368 fi
plars4a120e82004-09-02 18:56:06 +0000369 GENLOAD=1;;
yaberauneya6d41cc32010-01-28 16:24:16 +0000370 M)
371 VALGRIND_CHECK=1
372 VALGRIND_CHECK_TYPE="$OPTARG";;
subrata_modak9c7072a2009-08-26 07:00:25 +0000373
plars4a120e82004-09-02 18:56:06 +0000374 N) RUN_NETEST=1;;
375
376 n)
yaberauneya6d41cc32010-01-28 16:24:16 +0000377 $LTPROOT/testcases/bin/netpipe.sh
plars4a120e82004-09-02 18:56:06 +0000378 NETPIPE=1;;
379
subrata_modak6838ec32007-09-14 10:10:12 +0000380 o) OUTPUTFILE_NAME="$OPTARG"
subrata_modak6838ec32007-09-14 10:10:12 +0000381 case $OPTARG in
382 /*)
383 OUTPUTFILE="-o $OPTARG";;
384 *)
385 OUTPUTFILE="-o $LTPROOT/output/$OPTARG"
subrata_modak5d7deea2007-09-15 13:51:36 +0000386 ALT_DIR_OUT=1 ;;
yaberauneya6d41cc32010-01-28 16:24:16 +0000387 esac ;;
plars4a120e82004-09-02 18:56:06 +0000388
389 p) PRETTY_PRT=" -p ";;
390
yaberauneya6d41cc32010-01-28 16:24:16 +0000391 q) QUIET_MODE=" -q ";;
plars4a120e82004-09-02 18:56:06 +0000392
393 r) LTPROOT=$OPTARG;;
394
robbiew7d43d772005-02-07 20:07:30 +0000395 s) TAG_RESTRICT_STRING=$OPTARG;;
subrata_modak2f6c9812009-08-14 17:07:48 +0000396
yaberauneya6d41cc32010-01-28 16:24:16 +0000397 S) case $OPTARG in
subrata_modak2f6c9812009-08-14 17:07:48 +0000398 /*)
399 SKIPFILE=$OPTARG;;
400 *)
401 SKIPFILE="$LTPROOT/$OPTARG";;
yaberauneya6d41cc32010-01-28 16:24:16 +0000402 esac ;;
robbiew7d43d772005-02-07 20:07:30 +0000403
plars4a120e82004-09-02 18:56:06 +0000404 t) # In case you want to specify the time
405 # to run from the command line
406 # (2m = two minutes, 2h = two hours, etc)
407 DURATION="-t $OPTARG" ;;
subrata_modak8c138332008-01-28 11:19:32 +0000408
409 T) # In case you want the testcases to runsequentially RUN_REPEATED times
410 RUN_REPEATED=$OPTARG;;
411
subrata_modakbc833d32007-07-25 10:12:02 +0000412 w) CMDFILEADDR=$OPTARG;;
robbiew7d43d772005-02-07 20:07:30 +0000413
plars4a120e82004-09-02 18:56:06 +0000414 x) # number of ltp's to run
yaberauneya6d41cc32010-01-28 16:24:16 +0000415 cat <<-EOF >&1
416 WARNING: The use of -x can cause unpredictable failures, as a
417 result of concurrently running multiple tests designed
418 to be ran exclusively.
419 Pausing for 10 seconds..."
420 EOF
plars4a120e82004-09-02 18:56:06 +0000421 sleep 10
yaberauneya6d41cc32010-01-28 16:24:16 +0000422 INSTANCES="-x $OPTARG";;
subrata_modakd9fb3862008-12-29 11:25:36 +0000423 b) DEVICE=$OPTARG;;
424 B) DEVICE_FS_TYPE=$OPTARG;;
plars4a120e82004-09-02 18:56:06 +0000425 \?) usage;;
426 esac
427 done
subrata_modak43938212008-05-19 08:48:46 +0000428
429 ## It would be nice to create a default log file even if the user has not mentioned
430 if [ ! "$LOGFILE" ]; then ## User has not mentioned about Log File name
431 LOGFILE_NAME=$DEFAULT_FILE_NAME_GENERATION_TIME
432 LOGFILE="-l $LTPROOT/results/LTP_RUN_ON-$LOGFILE_NAME.log"
433 ALT_DIR_RES=1
434 PRETTY_PRT=" -p "
435 fi
subrata_modak6838ec32007-09-14 10:10:12 +0000436
437 ## It would be nice if a Failed File is compulsorily created (gives User better Idea of Tests that failed)
438
yaberauneya6d41cc32010-01-28 16:24:16 +0000439 if [ ! "$FAILCMDFILE" ]; then ## User has not mentioned about Failed File name
subrata_modak5d7deea2007-09-15 13:51:36 +0000440 ALT_DIR_OUT=1
yaberauneya6d41cc32010-01-28 16:24:16 +0000441 if [ ! "$OUTPUTFILE" ]; then ## User has not mentioned about Output File name either
442 if [ ! "$LOGFILE" ]; then ## User has not mentioned about Log File name either
443 FAILED_FILE_NAME=$DEFAULT_FILE_NAME_GENERATION_TIME
444 FAILCMDFILE="-C $LTPROOT/output/LTP_RUN_ON-$FAILED_FILE_NAME.failed"
445 else ## User Fortunately wanted a log file,
446 FAILED_FILE_NAME=`basename $LOGFILE_NAME` ## Extract log file name and use it to construct Failed file name
447 FAILCMDFILE="-C $LTPROOT/output/LTP_RUN_ON-$FAILED_FILE_NAME.failed"
subrata_modak6838ec32007-09-14 10:10:12 +0000448 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000449 else ## User Fortunately wanted a Output file
450 FAILED_FILE_NAME=`basename $OUTPUTFILE_NAME` ## Extract output file name and use it to construct Failed file name
451 FAILCMDFILE="-C $LTPROOT/output/LTP_RUN_ON-$FAILED_FILE_NAME.failed"
subrata_modak6838ec32007-09-14 10:10:12 +0000452 fi
453 fi
subrata_modaka1fd64b2007-04-11 11:24:49 +0000454
subrata_modakd48c4d02008-01-23 12:59:40 +0000455 if [ "$ALT_HTML_OUT" -eq 1 ] ; then ## User wants the HTML version of the output
yaberauneya6d41cc32010-01-28 16:24:16 +0000456 QUIET_MODE="" ## Suppressing this guy as it will prevent generation of proper output
subrata_modakd48c4d02008-01-23 12:59:40 +0000457 ## which the HTML parser will require
yaberauneya6d41cc32010-01-28 16:24:16 +0000458 if [ ! "$OUTPUTFILE" ]; then ## User has not mentioned about the Outputfile name, then we need to definitely generate one
subrata_modak43938212008-05-19 08:48:46 +0000459 OUTPUTFILE_NAME=$DEFAULT_FILE_NAME_GENERATION_TIME
subrata_modake47fb352007-11-25 17:03:49 +0000460 OUTPUTFILE="-o $LTPROOT/output/LTP_RUN_ON-$OUTPUTFILE_NAME.output"
subrata_modak08dde6f2007-11-28 11:02:51 +0000461 ALT_DIR_OUT=1
yaberauneya6d41cc32010-01-28 16:24:16 +0000462 if [ ! "$HTMLFILE" ] ; then ## User has not mentioned HTML File name, We need to create one
463 HTMLFILE_NAME=`basename $OUTPUTFILE_NAME`
subrata_modake47fb352007-11-25 17:03:49 +0000464 HTMLFILE="$LTPROOT/output/$HTMLFILE_NAME.html"
465 fi
466 fi
467 fi
468
subrata_modak5d7deea2007-09-15 13:51:36 +0000469 # If we need, create the output directory
yaberauneya6d41cc32010-01-28 16:24:16 +0000470 [ "$ALT_DIR_OUT" -eq 1 ] && \
471 {
472 [ ! -d $LTPROOT/output ] && \
473 {
474 echo "INFO: creating $LTPROOT/output directory"
475 mkdir -p $LTPROOT/output || \
476 {
477 echo "ERROR: failed to create $LTPROOT/output"
478 exit 1
479 }
480 }
481 }
subrata_modak5d7deea2007-09-15 13:51:36 +0000482 # If we need, create the results directory
yaberauneya6d41cc32010-01-28 16:24:16 +0000483 [ "$ALT_DIR_RES" -eq 1 ] && \
484 {
485 echo "INFO: creating $LTPROOT/results directory"
486 [ ! -d $LTPROOT/results ] && \
487 {
488 mkdir -p $LTPROOT/results || \
489 {
490 echo "ERROR: failed to create $LTPROOT/results"
491 exit 1
492 }
493 }
494 }
subrata_modak5d7deea2007-09-15 13:51:36 +0000495
subrata_modaka1fd64b2007-04-11 11:24:49 +0000496 # Added -m 777 for tests that call tst_tmpdir() and try to
497 # write to it as user nobody
yaberauneya6d41cc32010-01-28 16:24:16 +0000498 mkdir -m 777 -p $TMPBASE || \
499 {
500 echo "FATAL: Unable to make temporary directory $TMPBASE"
501 exit 1
502 }
subrata_modak5ee3e892008-10-21 13:17:56 +0000503 # use mktemp to create "safe" temporary directories
504 export TMPTEMPLATE="${TMPBASE}/ltp-XXXXXXXXXX"
yaberauneya6d41cc32010-01-28 16:24:16 +0000505 TMP=`mktemp -d $TMPTEMPLATE` || \
506 {
507 echo "FATAL: Unable to make temporary directory: $TMP"
508 exit 1
509 }
510 export TMP
subrata_modak225cfbe2009-06-23 14:01:26 +0000511 # To be invoked by tst_tmpdir()
512 # write to it as user nobody
513 export TMPDIR=$TMP
subrata_modak6edfbda2008-10-17 12:25:48 +0000514
yaberauneya6d41cc32010-01-28 16:24:16 +0000515 chmod 777 $TMP || \
516 {
517 echo "unable to chmod 777 $TMP ... aborting"
518 exit 1
519 }
plars4a120e82004-09-02 18:56:06 +0000520
yaberauneya6d41cc32010-01-28 16:24:16 +0000521 cd $TMP || \
522 {
523 echo "could not cd ${TMP} ... exiting"
524 exit 1
525 }
plars4a120e82004-09-02 18:56:06 +0000526
yaberauneya6d41cc32010-01-28 16:24:16 +0000527 ! [ -z $INSTANCES ] && \
528 {
529 INSTANCES="$INSTANCES -O ${TMP}"
530 }
subrata_modak6edfbda2008-10-17 12:25:48 +0000531
yaberauneya6d41cc32010-01-28 16:24:16 +0000532 [ "$RUN_NETEST" -eq 1 ] && \
533 {
534 [ -z "$RHOST" ] || [ -z "$PASSWD" ] && \
535 {
536 [ -z "$RHOST" ] && \
537 {
plars4a120e82004-09-02 18:56:06 +0000538 echo \
539 "INFO: Enter RHOST = 'name of the remote host machine'"
540 echo -n "-> "
541 read RHOST
yaberauneya6d41cc32010-01-28 16:24:16 +0000542 }
plars4a120e82004-09-02 18:56:06 +0000543
yaberauneya6d41cc32010-01-28 16:24:16 +0000544 [ -z "$PASSWD" ] && \
545 {
546 echo " "
plars4a120e82004-09-02 18:56:06 +0000547 echo \
548 "INFO: Enter PASSWD = 'root passwd of the remote host machine'"
549 echo -n "-> "
550 read PASSWD
yaberauneya6d41cc32010-01-28 16:24:16 +0000551 }
plars4a120e82004-09-02 18:56:06 +0000552 export RHOST=$RHOST
553 export PASSWD=$PASSWD
yaberauneya6d41cc32010-01-28 16:24:16 +0000554 echo "WARNING: security of $RHOST may be compromised"
555 }
556 }
plars4a120e82004-09-02 18:56:06 +0000557
558 # If user does not provide a command file select a default set of testcases
559 # to execute.
yaberauneya6d41cc32010-01-28 16:24:16 +0000560 if [ -z "$CMDFILES" ] && [ -z "$CMDFILEADDR" ]
561 then
562 cat <<-EOF >&1
plars4a120e82004-09-02 18:56:06 +0000563
yaberauneya6d41cc32010-01-28 16:24:16 +0000564 INFO: no command files were provided, using default,
565 system calls, memory management, IPC, scheduler
566 direct io, file system, math and pty tests will
567 now be executed
568
569 EOF
plars4a120e82004-09-02 18:56:06 +0000570
yaberauneya6d41cc32010-01-28 16:24:16 +0000571 for SCENFILES in ${LTPROOT}/runtest/syscalls \
572 ${LTPROOT}/runtest/fs \
Subrata Modakca758b72010-05-18 01:28:14 +0530573 ${LTPROOT}/runtest/fs_perms_simple \
yaberauneya6d41cc32010-01-28 16:24:16 +0000574 ${LTPROOT}/runtest/fsx \
575 ${LTPROOT}/runtest/dio \
576 ${LTPROOT}/runtest/io \
577 ${LTPROOT}/runtest/mm \
578 ${LTPROOT}/runtest/ipc \
579 ${LTPROOT}/runtest/sched \
580 ${LTPROOT}/runtest/math \
581 ${LTPROOT}/runtest/nptl \
582 ${LTPROOT}/runtest/pty \
583 ${LTPROOT}/runtest/containers \
584 ${LTPROOT}/runtest/fs_bind \
585 ${LTPROOT}/runtest/controllers \
586 ${LTPROOT}/runtest/filecaps \
587 ${LTPROOT}/runtest/cap_bounds \
588 ${LTPROOT}/runtest/fcntl-locktests \
589 ${LTPROOT}/runtest/connectors \
590 ${LTPROOT}/runtest/admin_tools \
591 ${LTPROOT}/runtest/timers \
592 ${LTPROOT}/runtest/power_management_tests \
593 ${LTPROOT}/runtest/numa \
594 ${LTPROOT}/runtest/hugetlb \
595 ${LTPROOT}/runtest/commands \
596 ${LTPROOT}/runtest/hyperthreading
597 do
598 [ -e "$SCENFILES" ] || \
599 {
600 echo "FATAL: missing scenario file $SCENFILES"
601 exit 1
602 }
plars4a120e82004-09-02 18:56:06 +0000603
yaberauneya6d41cc32010-01-28 16:24:16 +0000604 cat $SCENFILES >> ${TMP}/alltests || \
605 {
606 echo "FATAL: unable to create command file"
607 exit 1
608 }
609 done
subrata_modakbc833d32007-07-25 10:12:02 +0000610 fi
611
yaberauneya6d41cc32010-01-28 16:24:16 +0000612 [ -n "$CMDFILES" ] && \
613 {
614 for SCENFILES in `echo "$CMDFILES" | sed 's/,/\n/g'`
615 do
616 [ -f "$SCENFILES" ] || SCENFILES="$LTPROOT/runtest/$SCENFILES"
617 cat "$SCENFILES" >> ${TMP}/alltests || \
618 {
619 echo "FATAL: unable to create command file"
620 exit 1
621 }
plars4a120e82004-09-02 18:56:06 +0000622 done
yaberauneya6d41cc32010-01-28 16:24:16 +0000623 }
624
625 [ -n "$CMDFILEADDR" ] && \
626 {
627 wget -q "${CMDFILEADDR}" -O ${TMP}/wgetcmdfile
628 if [ $? -ne 0 ]; then
629 echo "FATAL: error while getting the command file with wget (address $CMDFILEADDR)"
630 exit 1
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000631 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000632 cat "${TMP}/wgetcmdfile" >> ${TMP}/alltests || \
633 {
634 echo "FATAL: unable to create command file"
635 exit 1
636 }
637 }
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000638
yaberauneya6d41cc32010-01-28 16:24:16 +0000639 [ "$RUN_NETEST" -eq 1 ] && \
640 {
641 for SCENFILES in ${LTPROOT}/runtest/tcp_cmds \
642 ${LTPROOT}/runtest/multicast \
643 ${LTPROOT}/runtest/rpc \
644 ${LTPROOT}/runtest/nfs
645 do
646 [ -e "$SCENFILES" ] || \
647 {
648 echo "FATAL: missing scenario file $SCENFILES"
649 exit 1
650 }
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000651
yaberauneya6d41cc32010-01-28 16:24:16 +0000652 cat "$SCENFILES" >> ${TMP}/alltests || \
653 {
654 echo "FATAL: unable to create command file"
655 exit 1
656 }
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000657 done
yaberauneya6d41cc32010-01-28 16:24:16 +0000658 }
subrata_modakbc833d32007-07-25 10:12:02 +0000659
plars4a120e82004-09-02 18:56:06 +0000660 # The fsx-linux tests use the SCRATCHDEV environment variable as a location
661 # that can be reformatted and run on. Set SCRATCHDEV if you want to run
662 # these tests. As a safeguard, this is disabled.
663 unset SCRATCHDEV
yaberauneya6d41cc32010-01-28 16:24:16 +0000664 [ -n "$SCRATCHDEV" ] && \
665 {
666 cat ${LTPROOT}/runtest/fsx >> ${TMP}/alltests ||
667 {
668 echo "FATAL: unable to create fsx-linux tests command file"
669 exit 1
670 }
671 }
subrata_modakbc833d32007-07-25 10:12:02 +0000672
673 # If enabled, execute only test cases that match the PATTERN
yaberauneya6d41cc32010-01-28 16:24:16 +0000674 if [ -n "$TAG_RESTRICT_STRING" ]
675 then
676 mv -f ${TMP}/alltests ${TMP}/alltests.orig
677 grep $TAG_RESTRICT_STRING ${TMP}/alltests.orig > ${TMP}/alltests #Not worth checking return codes for this case
subrata_modakbc833d32007-07-25 10:12:02 +0000678 fi
subrata_modak2f6c9812009-08-14 17:07:48 +0000679
680 # Blacklist or skip tests if a SKIPFILE was specified with -S
yaberauneya6d41cc32010-01-28 16:24:16 +0000681 if [ -n "$SKIPFILE" ]
682 then
subrata_modak2f6c9812009-08-14 17:07:48 +0000683 for file in $( cat $SKIPFILE ); do
yaberauneya6d41cc32010-01-28 16:24:16 +0000684 sed -i "/$file/d" ${TMP}/alltests
subrata_modak2f6c9812009-08-14 17:07:48 +0000685 done
686 fi
plars4a120e82004-09-02 18:56:06 +0000687
688 # check for required users and groups
yaberauneya6d41cc32010-01-28 16:24:16 +0000689 ${LTPROOT}/IDcheck.sh &>/dev/null || \
690 {
691 echo "WARNING: required users and groups not present"
692 echo "WARNING: some test cases may fail"
693 }
694
plars4a120e82004-09-02 18:56:06 +0000695 # display versions of installed software
yaberauneya6d41cc32010-01-28 16:24:16 +0000696 [ -z "$QUIET_MODE" ] && \
697 {
698 ${LTPROOT}/ver_linux || \
699 {
700 echo "WARNING: unable to display versions of software installed"
701 exit 1
702 }
703 }
704
705 if [ -n "$DEVICE" ]; then
706 sed -i "s|DEVICE|$DEVICE|" ${TMP}/alltests
707 else
708 echo "remove test cases which require the block device."
709 echo "You can specify it with option -b"
710 sed -i "/DEVICE/d" ${TMP}/alltests
subrata_modakd9fb3862008-12-29 11:25:36 +0000711 fi
712
yaberauneya6d41cc32010-01-28 16:24:16 +0000713 if [ $? -ne 0 ]; then
714 echo "FATAL: error during prcessing alltests file by sed"
715 exit 1
716 fi
717
718 if [ -n "$DEVICE" ]; then
719 mnt_pnt=`mktemp -d --tmpdir=${TMP} mnt_pnt.XXXXXX`
subrata_modakd9fb3862008-12-29 11:25:36 +0000720 if [ -n "$DEVICE_FS_TYPE" ]; then
721 mount -t $DEVICE_FS_TYPE $DEVICE $mnt_pnt
722 else
723 mount $DEVICE $mnt_pnt
724 fi
725
726 if [ $? -ne 0 ]; then
yaberauneya6d41cc32010-01-28 16:24:16 +0000727 echo "FATAL: can't mount block device $DEVICE."
728 exit 1
subrata_modakd9fb3862008-12-29 11:25:36 +0000729 fi
730
731 if [ -z "$DEVICE_FS_TYPE" ]; then
yaberauneya6d41cc32010-01-28 16:24:16 +0000732 DEVICE_FS_TYPE=`cat /proc/mounts | awk "{if (\\\$1 == \"$DEVICE\") print \\\$3; }"`
733 echo "determine file system $DEVICE_FS_TYPE on block device $DEVICE"
subrata_modakd9fb3862008-12-29 11:25:36 +0000734 fi
735
yaberauneya6d41cc32010-01-28 16:24:16 +0000736 umount $DEVICE
737 if [ $? -ne 0 ]; then
738 echo "FATAL: can't umount $DEVICE"
739 exit 1
subrata_modakd9fb3862008-12-29 11:25:36 +0000740 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000741 rm -rf $mnt_pnt
subrata_modakd9fb3862008-12-29 11:25:36 +0000742 fi
743
yaberauneya6d41cc32010-01-28 16:24:16 +0000744 if [ -n "$DEVICE" ]; then
745 sed -i "s|DEVICE_FS_TYPE|$DEVICE_FS_TYPE|" ${TMP}/alltests
746 fi
747
748 if [ $? -ne 0 ]; then
749 echo "FATAL: error during prcessing alltests file by sed"
750 exit 1
subrata_modakd9fb3862008-12-29 11:25:36 +0000751 fi
752
subrata_modak8c138332008-01-28 11:19:32 +0000753 if [ $RUN_REPEATED -gt 1 ]; then # You need to specify at least more than 1 sequential run, else it runs default
yaberauneya6d41cc32010-01-28 16:24:16 +0000754 echo "PAN will run these test cases $RUN_REPEATED times....."
755 echo "Test Tags will be Prepended with ITERATION NO.s....."
756 inc=1
757 sed -e '/^$/ d' -e 's/^[ ,\t]*//' -e '/^#/ d' < ${TMP}/alltests > ${TMP}/alltests.temp ##This removes all newlines, leading spaces, tabs, #
758 sed 's/^[0-9,a-z,A-Z]*/'"$inc"'_ITERATION_&/' < ${TMP}/alltests.temp > ${TMP}/alltests ## .temp is kept as Base file
759 while [ $inc -lt $RUN_REPEATED ] ; do
760 inc=`expr $inc + 1`
761 sed 's/^[0-9,a-z,A-Z]*/'"$inc"'_ITERATION_&/' < ${TMP}/alltests.temp >> ${TMP}/alltests #Keep appending with Iteration No.s
762 done
subrata_modak8c138332008-01-28 11:19:32 +0000763 fi
764
yaberauneya6d41cc32010-01-28 16:24:16 +0000765 [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test start time: $(date)" ; }
766 PAN_COMMAND="${LTPROOT}/bin/ltp-pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ \
767 -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE $FAILCMDFILE"
768 echo "COMMAND: $PAN_COMMAND"
769 if [ ! -z "$TAG_RESTRICT_STRING" ] ; then
770 echo "INFO: Restricted to $TAG_RESTRICT_STRING"
robbiew7d43d772005-02-07 20:07:30 +0000771 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000772 #$PAN_COMMAND #Duplicated code here, because otherwise if we fail, only "PAN_COMMAND" gets output
773
subrata_modak43938212008-05-19 08:48:46 +0000774 ## Display the Output/Log/Failed/HTML file names here
yaberauneya6d41cc32010-01-28 16:24:16 +0000775 echo -e "LOG File: \c"
776 echo $LOGFILE | cut -b4-
subrata_modak43938212008-05-19 08:48:46 +0000777
yaberauneya6d41cc32010-01-28 16:24:16 +0000778 if [ "$OUTPUTFILE" ]; then
779 echo -e "OUTPUT File: \c"
780 echo $OUTPUTFILE | cut -b4-
subrata_modak43938212008-05-19 08:48:46 +0000781 fi
782
yaberauneya6d41cc32010-01-28 16:24:16 +0000783 echo -e "FAILED COMMAND File: \c"
784 echo $FAILCMDFILE | cut -b4-
785
786 if [ "$HTMLFILE" ]; then
787 echo "HTML File: $HTMLFILE"
788 fi
789
790 echo "Running tests......."
subrata_modake47fb352007-11-25 17:03:49 +0000791 test_start_time=$(date)
subrata_modak724098e2009-03-19 08:49:18 +0000792
yaberauneya6d41cc32010-01-28 16:24:16 +0000793 # User wants testing with Kernel Fault Injection
794 if [ $INJECT_KERNEL_FAULT ] ; then
795 #See if Debugfs is mounted, and
796 #Fault Injection Framework available through Debugfs
797 if [ -d "/sys/kernel/debug/fail_io_timeout" -o \
798 -d "/sys/kernel/debug/fail_make_request" -o \
799 -d "/sys/kernel/debug/fail_page_alloc" -o \
800 -d "/sys/kernel/debug/failslab" ]; then
801 #If atleast one of the Framework is available
802 #Go ahead to Inject Fault & Create required
803 #Command Files for LTP run
804 echo Running tests with Fault Injection Enabled in the Kernel...
805 ${LTPROOT}/tools/create_kernel_faults_in_loops_and_probability.pl\
806 ${TMP}/alltests $INJECT_FAULT_LOOPS_PER_TEST $INJECT_KERNEL_FAULT_PERCENTAGE > ${TMP}/alltests.tmp
807 cp ${TMP}/alltests.tmp ${TMP}/alltests
808 rm -rf ${TMP}/alltests.tmp
809 else
810 echo Fault Injection not enabled in the Kernel..
811 echo Running tests normally...
812 fi
813 fi
814
815 ## Valgrind Check will work only when Kernel Fault Injection is not expected,
816 ## We do not want to test Faults when valgrind is running
817 if [ $VALGRIND_CHECK ]; then
818 if [ ! $INJECT_KERNEL_FAULT ]; then
819 which valgrind || VALGRIND_CHECK_TYPE=XYZ
820 case $VALGRIND_CHECK_TYPE in
821 1)
822 ${LTPROOT}/tools/create_valgrind_check.pl ${TMP}/alltests 1 > ${TMP}/alltests.tmp
823 cp ${TMP}/alltests.tmp ${TMP}/alltests
824 rm -rf ${TMP}/alltests.tmp;;
825 2)
826 ${LTPROOT}/tools/create_valgrind_check.pl ${TMP}/alltests 2 > ${TMP}/alltests.tmp
827 cp ${TMP}/alltests.tmp ${TMP}/alltests
828 rm -rf ${TMP}/alltests.tmp;;
829 3)
830 ${LTPROOT}/tools/create_valgrind_check.pl ${TMP}/alltests 3 > ${TMP}/alltests.tmp
831 cp ${TMP}/alltests.tmp ${TMP}/alltests
832 rm -rf ${TMP}/alltests.tmp;;
833 *) echo "Invalid Memory Check Type, or, Valgrind is not available";;
834 esac
835 fi
836 fi
837
Subrata Modakbd9d4402010-05-12 22:03:21 +0530838 if [ $ALT_DMESG_OUT -eq 1 ] ; then
839 #We want to print dmesg output for each test,lets do the trick inside the script
840 echo Enabling dmesg output logging for each test...
841 ${LTPROOT}/bin/create_dmesg_entries_for_each_test.pl ${TMP}/alltests $DMESG_DIR > ${TMP}/alltests.tmp
842 cp ${TMP}/alltests.tmp ${TMP}/alltests
843 rm -rf ${TMP}/alltests.tmp
844 fi
subrata_modak724098e2009-03-19 08:49:18 +0000845 # Some tests need to run inside the "bin" directory.
846 cd "${LTPROOT}/testcases/bin"
yaberauneya6d41cc32010-01-28 16:24:16 +0000847 "${LTPROOT}/bin/ltp-pan" $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE $FAILCMDFILE
subrata_modakd48c4d02008-01-23 12:59:40 +0000848
plars4a120e82004-09-02 18:56:06 +0000849 if [ $? -eq 0 ]; then
yaberauneya6d41cc32010-01-28 16:24:16 +0000850 echo "INFO: ltp-pan reported all tests PASS"
851 VALUE=0
852 export LTP_EXIT_VALUE=0;
plars4a120e82004-09-02 18:56:06 +0000853 else
yaberauneya6d41cc32010-01-28 16:24:16 +0000854 echo "INFO: ltp-pan reported some tests FAIL"
855 VALUE=1
856 export LTP_EXIT_VALUE=1;
plars4a120e82004-09-02 18:56:06 +0000857 fi
subrata_modak724098e2009-03-19 08:49:18 +0000858 cd ..
yaberauneya6d41cc32010-01-28 16:24:16 +0000859 echo "LTP Version: $version_date"
mreed1091696422006-05-03 19:07:22 +0000860
subrata_modake47fb352007-11-25 17:03:49 +0000861 if [ "$ALT_HTML_OUT" -eq 1 ] ; then #User wants the HTML output to be created, it then needs to be generated
862 export LTP_VERSION=$version_date
863 export TEST_START_TIME=$test_start_time
864 export TEST_END_TIME=$(date)
yaberauneya6d41cc32010-01-28 16:24:16 +0000865 OUTPUT_DIRECTORY=`echo $OUTPUTFILE | cut -c4-`
subrata_modake47fb352007-11-25 17:03:49 +0000866 LOGS_DIRECTORY="$LTPROOT/results"
867 export TEST_OUTPUT_DIRECTORY="$LTPROOT/output"
868 export TEST_LOGS_DIRECTORY=$LOGS_DIRECTORY
yaberauneya6d41cc32010-01-28 16:24:16 +0000869 echo "Generating HTML Output.....!!"
Rishikesh K Rajakc2ce5362010-04-28 11:39:03 +0530870 ( perl $LTPROOT/bin/genhtml.pl $LTPROOT/tools/html_report_header.txt test_start test_end test_output execution_status $OUTPUT_DIRECTORY > $HTMLFILE; )
yaberauneya6d41cc32010-01-28 16:24:16 +0000871 echo "Generated HTML Output.....!!"
872 echo "Location: $HTMLFILE";
873
subrata_modake47fb352007-11-25 17:03:49 +0000874 fi
875
yaberauneya6d41cc32010-01-28 16:24:16 +0000876 if [ "$ALT_EMAIL_OUT" -eq 1 ] ; then ## User wants reports to be e-mailed
877 if [ [ ! "$HTMLFILE_NAME" ] -o [ ! "$OUTPUTFILE_NAME" ] -o [ ! "$LOGFILE_NAME" ] ] ; then
878 ##User does not have output/logs/html-output, nothing to be mailed in this situation
879 echo "Nothing to be mailed here...."
subrata_modak08dde6f2007-11-28 11:02:51 +0000880 else
subrata_modak43938212008-05-19 08:48:46 +0000881 TAR_FILE_NAME=LTP_RUN_$version_date$DEFAULT_FILE_NAME_GENERATION_TIME.tar
yaberauneya6d41cc32010-01-28 16:24:16 +0000882 if [ "$HTMLFILE_NAME" ] ; then ## HTML file Exists
883 if [ "$ALT_HTML_OUT" -ne 1 ] ; then ## The HTML file path is absolute and not $LTPROOT/output
884 mkdir -p $LTPROOT/output ## We need to create this Directory
885 cp $HTMLFILE_NAME $LTPROOT/output/
886 fi
subrata_modak08dde6f2007-11-28 11:02:51 +0000887 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000888 if [ "$OUTPUTFILE_NAME" ] ; then ## Output file exists
889 if [ "$ALT_DIR_OUT" -ne 1 ] ; then ## The Output file path is absolute and not $LTPROOT/output
890 mkdir -p $LTPROOT/output ## We need to create this Directory
891 cp $OUTPUTFILE_NAME $LTPROOT/output/
892 fi
subrata_modak08dde6f2007-11-28 11:02:51 +0000893 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000894 if [ "$LOGFILE_NAME" ] ; then ## Log file exists
895 if [ "$ALT_DIR_RES" -ne 1 ] ; then ## The Log file path is absolute and not $LTPROOT/results
896 mkdir -p $LTPROOT/results ## We need to create this Directory
897 cp $LOGFILE_NAME $LTPROOT/results/
898 fi
899 fi
900 if [ -d $LTPROOT/output ] ; then
901 tar -cf ./$TAR_FILE_NAME $LTPROOT/output
902 if [ $? -eq 0 ]; then
903 echo "Created TAR File: ./$TAR_FILE_NAME successfully, added $LTPROOT/output"
904 else
905 echo "Cannot Create TAR File: ./$TAR_FILE_NAME for adding $LTPROOT/output"
906 fi
907 fi
908 if [ -d $LTPROOT/results ] ; then
909 tar -uf ./$TAR_FILE_NAME $LTPROOT/results
910 if [ $? -eq 0 ]; then
911 echo "Updated TAR File: ./$TAR_FILE_NAME successfully, added $LTPROOT/results"
912 else
913 echo "Cannot Update TAR File: ./$TAR_FILE_NAME for adding $LTPROOT/results"
914 fi
915 fi
916 if [ -e $LTPROOT/nohup.out ] ; then ## If User would have Chosen nohup to do ltprun
917 tar -uf ./$TAR_FILE_NAME $LTPROOT/nohup.out
918 if [ $? -eq 0 ]; then
919 echo "Updated TAR File: ./$TAR_FILE_NAME successfully, added $LTPROOT/nohup.out"
920 else
921 echo "Cannot Update TAR File: ./$TAR_FILE_NAME for adding $LTPROOT/nohup.out"
922 fi
923 fi
924 gzip ./$TAR_FILE_NAME ## gzip this guy
925 if [ $? -eq 0 ]; then
926 echo "Gunzipped TAR File: ./$TAR_FILE_NAME"
subrata_modak08dde6f2007-11-28 11:02:51 +0000927 else
yaberauneya6d41cc32010-01-28 16:24:16 +0000928 echo "Cannot Gunzip TAR File: ./$TAR_FILE_NAME"
subrata_modak08dde6f2007-11-28 11:02:51 +0000929 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000930 if [ -e /usr/bin/mutt ] ; then ## This is a better mail client than others
931 echo "Starting mailing reports to: $EMAIL_TO, file: ./$TAR_FILE_NAME.gz"
932 mutt -a ./$TAR_FILE_NAME.gz -s "LTP Reports on $test_start_time" $EMAIL_TO < /dev/null
933 if [ $? -eq 0 ]; then
934 echo "Reports Successfully mailed to: $EMAIL_TO"
935 else
936 echo "Reports cannot be mailed to: $EMAIL_TO"
937 fi
938 else ## Use our Ageold mail program
939 echo "Starting mailing reports to: $EMAIL_TO, file: ./$TAR_FILE_NAME.gz"
940 uuencode ./$TAR_FILE_NAME.gz $TAR_FILE_NAME.gz | mail $EMAIL_TO -s "LTP Reports on $test_start_time"
941 if [ $? -eq 0 ]; then
942 echo "Reports Successfully mailed to: $EMAIL_TO"
943 else
944 echo "Reports cannot be mailed to: $EMAIL_TO"
945 fi
946 fi
subrata_modak08dde6f2007-11-28 11:02:51 +0000947 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000948 fi
subrata_modak08dde6f2007-11-28 11:02:51 +0000949
yaberauneya6d41cc32010-01-28 16:24:16 +0000950 [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test end time: $(date)" ; }
plars4a120e82004-09-02 18:56:06 +0000951
yaberauneya6d41cc32010-01-28 16:24:16 +0000952 [ "$GENLOAD" -eq 1 ] && { killall -9 genload >/dev/null 2>&1; }
953 [ "$NETPIPE" -eq 1 ] && { killall -9 NPtcp >/dev/null 2>&1; }
plars4a120e82004-09-02 18:56:06 +0000954
yaberauneya6d41cc32010-01-28 16:24:16 +0000955 [ "$ALT_DIR_OUT" -eq 1 ] || [ "$ALT_DIR_RES" -eq 1 ] && \
956 {
957 cat <<-EOF >&1
plars4a120e82004-09-02 18:56:06 +0000958
959 ###############################################################"
960
961 Done executing testcases."
mreed1091696422006-05-03 19:07:22 +0000962 LTP Version: $version_date
plars4a120e82004-09-02 18:56:06 +0000963 ###############################################################"
964
yaberauneya6d41cc32010-01-28 16:24:16 +0000965 EOF
966 }
967 exit $VALUE
plars4a120e82004-09-02 18:56:06 +0000968}
969
970cleanup()
971{
yaberauneya6d41cc32010-01-28 16:24:16 +0000972 rm -rf ${TMP}
plars4a120e82004-09-02 18:56:06 +0000973}
974
975trap "cleanup" 0
976setup
977main "$@"