blob: 353205295a9dd10dbc722e2b6db67c3d132eaaf2 [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
plars4a120e82004-09-02 18:56:06 +000036# - exit with error if 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
57# - 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
subrata_modake099b2a2007-10-29 12:22:01 +000065#
subrata_modak6838ec32007-09-14 10:10:12 +000066#################################################################################
subrata_modakbc833d32007-07-25 10:12:02 +000067
plars4a120e82004-09-02 18:56:06 +000068
69
70setup()
71{
72 cd `dirname $0` || \
73 {
74 echo "FATAL: unable to change directory to $(dirname $0)"
75 exit 1
76 }
77 export LTPROOT=${PWD}
78 export TMPBASE="/tmp"
79 export TMP="${TMPBASE}/ltp-$$"
subrata_modak4a57fe82007-09-24 06:40:12 +000080 export TMPDIR="${TMP}"
plars4a120e82004-09-02 18:56:06 +000081 export PATH="${PATH}:${LTPROOT}/testcases/bin"
82
83 [ -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/pan/pan ] ||
91 {
92 echo "FATAL: Test suite driver 'pan' not found"
93 echo "INFO: as root user type 'make ; make install'"
94 exit 1
95 }
96}
97
mreed1091696422006-05-03 19:07:22 +000098version_of_ltp()
99{
subrata_modaka1fd64b2007-04-11 11:24:49 +0000100 head -n 1 $LTPROOT/ChangeLog
101 exit 0
mreed1091696422006-05-03 19:07:22 +0000102}
plars4a120e82004-09-02 18:56:06 +0000103
104usage()
105{
106 cat <<-EOF >&2
107
subrata_modakf376b482007-11-28 11:30:54 +0000108 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 ]
112 -v [ -w CMDFILEADDR ] [ -x INSTANCES ]
plars4a120e82004-09-02 18:56:06 +0000113
subrata_modak08dde6f2007-11-28 11:02:51 +0000114 -a EMAIL_TO EMAIL all your Reports to this E-mail Address
subrata_modake099b2a2007-10-29 12:22:01 +0000115 -c NUM_PROCS Run LTP under additional background CPU load
116 [NUM_PROCS = no. of processes creating the CPU Load by spinning over sqrt()
117 (Defaults to 1 when value)]
subrata_modakbc833d32007-07-25 10:12:02 +0000118 -C FAILCMDFILE Command file with all failed test cases.
plars4a120e82004-09-02 18:56:06 +0000119 -d TMPDIR Directory where temporary files will be created.
subrata_modake099b2a2007-10-29 12:22:01 +0000120 -D NUM_PROCS,NUM_FILES,NUM_BYTES,CLEAN_FLAG
121 Run LTP under additional background Load on Secondary Storage (Seperate by comma)
122 [NUM_PROCS = no. of processes creating Storage Load by spinning over write()]
123 [NUM_FILES = Write() to these many files (Defaults to 1 when value 0 or undefined)]
124 [NUM_BYTES = write these many bytes (defaults to 1GB, when value 0 or undefined)]
125 [CLEAN_FLAG = unlink file to which random data written, when value 1]
mreed1091696422006-05-03 19:07:22 +0000126 -e Prints the date of the current LTP release
subrata_modakbc833d32007-07-25 10:12:02 +0000127 -f CMDFILES Execute user defined list of testcases (separate with ',')
subrata_modake47fb352007-11-25 17:03:49 +0000128 -g HTMLFILE Create an additional HTML output format
plars4a120e82004-09-02 18:56:06 +0000129 -h Help. Prints all available options.
subrata_modake099b2a2007-10-29 12:22:01 +0000130 -i NUM_PROCS Run LTP under additional background Load on IO Bus
131 [NUM_PROCS = no. of processes creating IO Bus Load by spinning over sync()]
plars4a120e82004-09-02 18:56:06 +0000132 -l LOGFILE Log results of test in a logfile.
subrata_modake099b2a2007-10-29 12:22:01 +0000133 -m NUM_PROCS,CHUNKS,BYTES,HANGUP_FLAG
134 Run LTP under additional background Load on Main memory (Seperate by comma)
135 [NUM_PROCS = no. of processes creating main Memory Load by spinning over malloc()]
136 [CHUNKS = malloc these many chunks (default is 1 when value 0 or undefined)]
137 [BYTES = malloc CHUNKS of BYTES bytes (default is 256MB when value 0 or undefined) ]
138 [HANGUP_FLAG = hang in a sleep loop after memory allocated, when value 1]
plars4a120e82004-09-02 18:56:06 +0000139 -N Run all the networking tests.
140 -n Run LTP with network traffic in background.
141 -o OUTPUTFILE Redirect test output to a file.
142 -p Human readable format logfiles.
143 -q Print less verbose output to screen.
144 -r LTPROOT Fully qualified path where testsuite is installed.
subrata_modaka1fd64b2007-04-11 11:24:49 +0000145 -s PATTERN Only run test cases which match PATTERN.
plars4a120e82004-09-02 18:56:06 +0000146 -t DURATION Execute the testsuite for given duration. Examples:
147 -t 60s = 60 seconds
148 -t 45m = 45 minutes
149 -t 24h = 24 hours
150 -t 2d = 2 days
subrata_modak8c138332008-01-28 11:19:32 +0000151 -T REPETITION Execute the testsuite for REPETITION no. of times
robbiew7d43d772005-02-07 20:07:30 +0000152 -v Print more verbose output to screen.
subrata_modakbc833d32007-07-25 10:12:02 +0000153 -w CMDFILEADDR Uses wget to get the user's list of testcases.
plars4a120e82004-09-02 18:56:06 +0000154 -x INSTANCES Run multiple instances of this testsuite.
155
subrata_modake099b2a2007-10-29 12:22:01 +0000156 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 +0000157
plars4a120e82004-09-02 18:56:06 +0000158
159 EOF
160exit 0
161}
162
plars4a120e82004-09-02 18:56:06 +0000163main()
164{
subrata_modakbc833d32007-07-25 10:12:02 +0000165 local CMDFILES=""
plars4a120e82004-09-02 18:56:06 +0000166 local PRETTY_PRT=""
subrata_modak5d7deea2007-09-15 13:51:36 +0000167 local ALT_DIR_OUT=0
168 local ALT_DIR_RES=0
subrata_modake47fb352007-11-25 17:03:49 +0000169 local ALT_HTML_OUT=0
subrata_modak08dde6f2007-11-28 11:02:51 +0000170 local ALT_EMAIL_OUT=0
plars4a120e82004-09-02 18:56:06 +0000171 local RUN_NETEST=0
subrata_modak8c138332008-01-28 11:19:32 +0000172 local RUN_REPEATED=0
plars4a120e82004-09-02 18:56:06 +0000173 local QUIET_MODE=""
robbiew7d43d772005-02-07 20:07:30 +0000174 local VERBOSE_MODE=""
plars4a120e82004-09-02 18:56:06 +0000175 local NETPIPE=0
176 local GENLOAD=0
177 local MEMSIZE=0
178 local DURATION=""
subrata_modakbc833d32007-07-25 10:12:02 +0000179 local CMDFILEADDR=""
subrata_modak43938212008-05-19 08:48:46 +0000180 local FAILCMDFILE=""
subrata_modake47fb352007-11-25 17:03:49 +0000181 local LOGFILE_NAME=""
plars4a120e82004-09-02 18:56:06 +0000182 local LOGFILE=""
subrata_modake47fb352007-11-25 17:03:49 +0000183 local OUTPUTFILE_NAME=""
184 local OUTPUTFILE=""
185 local HTMLFILE_NAME=""
186 local HTMLFILE=""
subrata_modak08dde6f2007-11-28 11:02:51 +0000187 local EMAIL_TO=""
plars4a120e82004-09-02 18:56:06 +0000188 local SCENFILES=""
robbiew7d43d772005-02-07 20:07:30 +0000189 local TAG_RESTRICT_STRING=""
190 local PAN_COMMAND=""
subrata_modak43938212008-05-19 08:48:46 +0000191 local DEFAULT_FILE_NAME_GENERATION_TIME=`date +"%Y_%b_%d-%Hh_%Mm_%Ss"`
mreed1091696422006-05-03 19:07:22 +0000192 version_date=`head -n 1 $LTPROOT/ChangeLog`
plars4a120e82004-09-02 18:56:06 +0000193
subrata_modak8c138332008-01-28 11:19:32 +0000194 while getopts a:c:C:d:D:f:ehi:g:l:m:Nno:pqr:s:t:T:vw:x: arg
plars4a120e82004-09-02 18:56:06 +0000195 do case $arg in
subrata_modak08dde6f2007-11-28 11:02:51 +0000196 a) EMAIL_TO=$OPTARG
197 ALT_EMAIL_OUT=1;;
plars4a120e82004-09-02 18:56:06 +0000198 c)
subrata_modake099b2a2007-10-29 12:22:01 +0000199 NUM_PROCS=$(($OPTARG))
200 if [ "$NUM_PROCS" -eq 0 ]; then
201 # User Did not Define the Value ,or, User Defined Zero,
202 # hence, prevent from creating infinite processes
203 NUM_PROCS=1
204 fi
plars4a120e82004-09-02 18:56:06 +0000205 $LTPROOT/testcases/bin/genload --cpu $NUM_PROCS >/dev/null 2>&1 &
206 GENLOAD=1 ;;
subrata_modakbc833d32007-07-25 10:12:02 +0000207
subrata_modak5d7deea2007-09-15 13:51:36 +0000208 C)
subrata_modak6838ec32007-09-14 10:10:12 +0000209 case $OPTARG in
210 /*)
211 FAILCMDFILE="-C $OPTARG" ;;
212 *)
213 FAILCMDFILE="-C $LTPROOT/output/$OPTARG"
subrata_modak5d7deea2007-09-15 13:51:36 +0000214 ALT_DIR_OUT=1 ;;
subrata_modak6838ec32007-09-14 10:10:12 +0000215 esac ;;
plars4a120e82004-09-02 18:56:06 +0000216
217 d) # append $$ to TMP, as it is recursively
218 # removed at end of script.
subrata_modak4a57fe82007-09-24 06:40:12 +0000219 export TMPBASE=$OPTARG
220 export TMP="${TMPBASE}/ltp-$$"
robbiew538bc1a2005-03-11 19:26:14 +0000221 export TMPDIR="$TMP";;
subrata_modake099b2a2007-10-29 12:22:01 +0000222
223 D) NUM_PROCS=1; NUM_FILES=1; NUM_BYTES=$((1024 * 1024 * 1024)); CLEAN_FLAG=0
224 ARGUMENT_LIST=$(($OPTARG))
225 TOTAL_ARGUMENTS=1 # Initial Assume
226 for ARGUMENT in `echo "$ARGUMENT_LIST" | sed 's/,/\n/g'` # Store all value in a Loop
227 do
228 case $TOTAL_ARGUMENTS in
229 1) NUM_PROCS="$ARGUMENT" ;;
230 2) NUM_FILES="$ARGUMENT" ;;
231 3) NUM_BYTES="$ARGUMENT" ;;
232 4) CLEAN_FLAG="$ARGUMENT" ;;
233 esac
234 TOTAL_ARGUMENTS=`expr $TOTAL_ARGUMENTS + 1`
235 done
236 # just to get the default values if the user passed 0
237 if [ "$NUM_PROCS" -eq 0 ]; then
238 NUM_PROCS=1
239 fi
240 if [ "$NUM_FILES" -eq 0 ]; then
241 NUM_FILES=1
242 fi
243 if [ "$NUM_BYTES" -eq 0 ]; then
244 NUM_BYTES=$((1024 * 1024 * 1024))
245 fi
246 if [ "$CLEAN_FLAG" -ne 1 ]; then
247 CLEAN_FLAG=0
248 fi
249 if [ "$CLEAN_FLAG" -eq 1 ]; then
250 # Do not unlink file in this case
251 $LTPROOT/testcases/bin/genload --hdd $NUM_PROCS --hdd-files \
252 $NUM_FILES --hdd-bytes $NUM_BYTES >/dev/null 2>&1 &
253 else
254 # Cleanup otherwise
255 $LTPROOT/testcases/bin/genload --hdd $NUM_PROCS --hdd-files \
256 $NUM_FILES --hdd-bytes $NUM_BYTES --hdd-noclean >/dev/null 2>&1 &
257 fi
258 GENLOAD=1;;
259
mreed1091696422006-05-03 19:07:22 +0000260 e) # Print out the version of LTP
261 version_of_ltp
262 ;;
plars4a120e82004-09-02 18:56:06 +0000263 f) # Execute user defined set of testcases.
subrata_modakbc833d32007-07-25 10:12:02 +0000264 # Can be more then one file, just separate it with ',', like:
265 # -f nfs,commands,/tmp/testfile
266 CMDFILES=$OPTARG;;
subrata_modake47fb352007-11-25 17:03:49 +0000267 g) HTMLFILE_NAME="$OPTARG"
268 case $OPTARG in
269 /*)
270 HTMLFILE="$OPTARG";;
271 *)
subrata_modakd48c4d02008-01-23 12:59:40 +0000272 HTMLFILE="$LTPROOT/output/$OPTARG";;
273 esac
274 ALT_DIR_OUT=1
275 ALT_HTML_OUT=1;;
plars4a120e82004-09-02 18:56:06 +0000276 h) usage;;
277
subrata_modake099b2a2007-10-29 12:22:01 +0000278 i)
279 NUM_PROCS=$(($OPTARG))
280 if [ "$NUM_PROCS" -eq 0 ]; then
281 # User Did not Define the Value ,or, User Defined Zero,
282 # hence, prevent from creating infinite processes
283 NUM_PROCS=1
284 fi
285 $LTPROOT/testcases/bin/genload --io $NUM_PROCS >/dev/null 2>&1 &
plars4a120e82004-09-02 18:56:06 +0000286 GENLOAD=1 ;;
287
288 l)
subrata_modak6838ec32007-09-14 10:10:12 +0000289 LOGFILE_NAME="$OPTARG"
plars4a120e82004-09-02 18:56:06 +0000290 case $OPTARG in
subrata_modak5d7deea2007-09-15 13:51:36 +0000291 /*)
plars4a120e82004-09-02 18:56:06 +0000292 LOGFILE="-l $OPTARG" ;;
293 *)
294 LOGFILE="-l $LTPROOT/results/$OPTARG"
subrata_modak5d7deea2007-09-15 13:51:36 +0000295 ALT_DIR_RES=1 ;;
plars4a120e82004-09-02 18:56:06 +0000296 esac ;;
297
subrata_modake099b2a2007-10-29 12:22:01 +0000298 m) NUM_PROCS=1; CHUNKS=1; BYTES=$((256 * 1024 * 1024)); HANGUP_FLAG=0
299 ARGUMENT_LIST=$(($OPTARG))
300 TOTAL_ARGUMENTS=1 # Initial Assume
301 for ARGUMENT in `echo "$ARGUMENT_LIST" | sed 's/,/\n/g'` # Store all value in a Loop
302 do
303 case $TOTAL_ARGUMENTS in
304 1) NUM_PROCS="$ARGUMENT" ;;
305 2) CHUNKS="$ARGUMENT" ;;
306 3) BYTES="$ARGUMENT" ;;
307 4) HANGUP_FLAG="$ARGUMENT" ;;
308 esac
309 TOTAL_ARGUMENTS=`expr $TOTAL_ARGUMENTS + 1`
310 done
311 # just to get the default values if the user passed 0
312 if [ "$NUM_PROCS" -eq 0 ]; then
313 NUM_PROCS=1
314 fi
315 if [ "$CHUNKS" -eq 0 ]; then
316 CHUNKS=1
317 fi
318 if [ "$BYTES" -eq 0 ]; then
319 BYTES=$((256 * 1024 * 1024))
320 fi
321 if [ "$HANGUP_FLAG" -ne 1 ]; then
322 HANGUP_FLAG=0
323 fi
324 if [ "$HANGUP_FLAG" -eq 1 ]; then
325 # Hang in a Sleep loop after memory allocated
326 $LTPROOT/testcases/bin/genload --vm $NUM_PROCS --vm-chunks \
327 $CHUNKS --vm-bytes $BYTES --vm-hang >/dev/null 2>&1 &
328 else
329 # Otherwise Do not Hangup
330 $LTPROOT/testcases/bin/genload --vm $NUM_PROCS --vm-chunks \
331 $CHUNKS --vm-bytes $BYTES >/dev/null 2>&1 &
332 fi
plars4a120e82004-09-02 18:56:06 +0000333 GENLOAD=1;;
334
335 N) RUN_NETEST=1;;
336
337 n)
338 $LTPROOT/testcases/bin/netpipe.sh
339 NETPIPE=1;;
340
subrata_modak6838ec32007-09-14 10:10:12 +0000341 o) OUTPUTFILE_NAME="$OPTARG"
subrata_modak6838ec32007-09-14 10:10:12 +0000342 case $OPTARG in
343 /*)
344 OUTPUTFILE="-o $OPTARG";;
345 *)
346 OUTPUTFILE="-o $LTPROOT/output/$OPTARG"
subrata_modak5d7deea2007-09-15 13:51:36 +0000347 ALT_DIR_OUT=1 ;;
subrata_modak6838ec32007-09-14 10:10:12 +0000348 esac ;;
plars4a120e82004-09-02 18:56:06 +0000349
350 p) PRETTY_PRT=" -p ";;
351
352 q) QUIET_MODE=" -q ";;
353
354 r) LTPROOT=$OPTARG;;
355
robbiew7d43d772005-02-07 20:07:30 +0000356 s) TAG_RESTRICT_STRING=$OPTARG;;
357
plars4a120e82004-09-02 18:56:06 +0000358 t) # In case you want to specify the time
359 # to run from the command line
360 # (2m = two minutes, 2h = two hours, etc)
361 DURATION="-t $OPTARG" ;;
subrata_modak8c138332008-01-28 11:19:32 +0000362
363 T) # In case you want the testcases to runsequentially RUN_REPEATED times
364 RUN_REPEATED=$OPTARG;;
365
robbiew7d43d772005-02-07 20:07:30 +0000366 v) VERBOSE_MODE=1;;
subrata_modakbc833d32007-07-25 10:12:02 +0000367
368 w) CMDFILEADDR=$OPTARG;;
robbiew7d43d772005-02-07 20:07:30 +0000369
plars4a120e82004-09-02 18:56:06 +0000370 x) # number of ltp's to run
371 cat <<-EOF >&1
372 WARNING: The use of -x can cause unpredictable failures, as a
373 result of concurrently running multiple tests designed
374 to be ran exclusively.
375 Pausing for 10 seconds..."
376 EOF
377 sleep 10
378 INSTANCES="-x $OPTARG -O ${TMP}";;
379
380 \?) usage;;
381 esac
382 done
subrata_modak43938212008-05-19 08:48:46 +0000383
384 ## It would be nice to create a default log file even if the user has not mentioned
385 if [ ! "$LOGFILE" ]; then ## User has not mentioned about Log File name
386 LOGFILE_NAME=$DEFAULT_FILE_NAME_GENERATION_TIME
387 LOGFILE="-l $LTPROOT/results/LTP_RUN_ON-$LOGFILE_NAME.log"
388 ALT_DIR_RES=1
389 PRETTY_PRT=" -p "
390 fi
subrata_modak6838ec32007-09-14 10:10:12 +0000391
392 ## It would be nice if a Failed File is compulsorily created (gives User better Idea of Tests that failed)
393
394 if [ ! "$FAILCMDFILE" ]; then ## User has not mentioned about Failed File name
subrata_modak5d7deea2007-09-15 13:51:36 +0000395 ALT_DIR_OUT=1
subrata_modak6838ec32007-09-14 10:10:12 +0000396 if [ ! "$OUTPUTFILE" ]; then ## User has not mentioned about Output File name either
397 if [ ! "$LOGFILE" ]; then ## User has not mentioned about Log File name either
subrata_modak43938212008-05-19 08:48:46 +0000398 FAILED_FILE_NAME=$DEFAULT_FILE_NAME_GENERATION_TIME
subrata_modak6838ec32007-09-14 10:10:12 +0000399 FAILCMDFILE="-C $LTPROOT/output/LTP_RUN_ON-$FAILED_FILE_NAME.failed"
subrata_modak6838ec32007-09-14 10:10:12 +0000400 else ## User Fortunately wanted a log file,
401 FAILED_FILE_NAME=`basename $LOGFILE_NAME` ## Extract log file name and use it to construct Failed file name
402 FAILCMDFILE="-C $LTPROOT/output/LTP_RUN_ON-$FAILED_FILE_NAME.failed"
subrata_modak6838ec32007-09-14 10:10:12 +0000403 fi
404 else ## User Fortunately wanted a Output file
405 FAILED_FILE_NAME=`basename $OUTPUTFILE_NAME` ## Extract output file name and use it to construct Failed file name
406 FAILCMDFILE="-C $LTPROOT/output/LTP_RUN_ON-$FAILED_FILE_NAME.failed"
subrata_modak6838ec32007-09-14 10:10:12 +0000407 fi
408 fi
subrata_modaka1fd64b2007-04-11 11:24:49 +0000409
subrata_modakd48c4d02008-01-23 12:59:40 +0000410 if [ "$ALT_HTML_OUT" -eq 1 ] ; then ## User wants the HTML version of the output
411 QUIET_MODE="" ## Suppressing this guy as it will prevent generation of proper output
412 ## which the HTML parser will require
subrata_modake47fb352007-11-25 17:03:49 +0000413 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 +0000414 OUTPUTFILE_NAME=$DEFAULT_FILE_NAME_GENERATION_TIME
subrata_modake47fb352007-11-25 17:03:49 +0000415 OUTPUTFILE="-o $LTPROOT/output/LTP_RUN_ON-$OUTPUTFILE_NAME.output"
subrata_modak08dde6f2007-11-28 11:02:51 +0000416 ALT_DIR_OUT=1
subrata_modake47fb352007-11-25 17:03:49 +0000417 if [ ! "$HTMLFILE" ] ; then ## User has not mentioned HTML File name, We need to create one
418 HTMLFILE_NAME=`basename $OUTPUTFILE_NAME`
419 HTMLFILE="$LTPROOT/output/$HTMLFILE_NAME.html"
420 fi
421 fi
422 fi
423
subrata_modak5d7deea2007-09-15 13:51:36 +0000424 # If we need, create the output directory
425 [ "$ALT_DIR_OUT" -eq 1 ] && \
426 {
427 echo "INFO: creating $LTPROOT/output directory"
428 [ ! -d $LTPROOT/output ] && \
429 {
430 mkdir -p $LTPROOT/output || \
431 {
432 echo "ERROR: failed to create $LTPROOT/output"
433 exit 1
434 }
435 }
436 }
437 # If we need, create the results directory
438 [ "$ALT_DIR_RES" -eq 1 ] && \
439 {
440 echo "INFO: creating $LTPROOT/results directory"
441 [ ! -d $LTPROOT/results ] && \
442 {
443 mkdir -p $LTPROOT/results || \
444 {
445 echo "ERROR: failed to create $LTPROOT/results"
446 exit 1
447 }
448 }
449 }
450
subrata_modaka1fd64b2007-04-11 11:24:49 +0000451 # Added -m 777 for tests that call tst_tmpdir() and try to
452 # write to it as user nobody
453 mkdir -m 777 -p $TMP || \
plars4a120e82004-09-02 18:56:06 +0000454 {
robbiew7d43d772005-02-07 20:07:30 +0000455 echo "FATAL: Unable to make temporary directory $TMP"
plars4a120e82004-09-02 18:56:06 +0000456 exit 1
457 }
458
459 cd $TMP || \
460 {
461 echo "could not cd ${TMP} ... exiting"
462 exit 1
463 }
464
465 [ "$RUN_NETEST" -eq 1 ] && \
466 {
467 [ -z "$RHOST" ] || [ -z "$PASSWD" ] && \
468 {
469 [ -z "$RHOST" ] && \
470 {
471 echo \
472 "INFO: Enter RHOST = 'name of the remote host machine'"
473 echo -n "-> "
474 read RHOST
475 }
476
477 [ -z "$PASSWD" ] && \
478 {
479 echo " "
480 echo \
481 "INFO: Enter PASSWD = 'root passwd of the remote host machine'"
482 echo -n "-> "
483 read PASSWD
484 }
485 export RHOST=$RHOST
486 export PASSWD=$PASSWD
487 echo "WARNING: security of $RHOST may be compromised"
488 }
489 }
490
491 # If user does not provide a command file select a default set of testcases
492 # to execute.
subrata_modakbc833d32007-07-25 10:12:02 +0000493 if [ -z "$CMDFILES" ] && [ -z "$CMDFILEADDR" ]
plars4a120e82004-09-02 18:56:06 +0000494 then
subrata_modakbc833d32007-07-25 10:12:02 +0000495 cat <<-EOF >&1
plars4a120e82004-09-02 18:56:06 +0000496
497 INFO: no command files were provided, using default,
498 system calls, memory management, IPC, scheduler
499 direct io, file system, math and pty tests will
500 now be executed
501
502 EOF
503
subrata_modakbc833d32007-07-25 10:12:02 +0000504 for SCENFILES in ${LTPROOT}/runtest/syscalls ${LTPROOT}/runtest/fs \
plars4a120e82004-09-02 18:56:06 +0000505 ${LTPROOT}/runtest/fsx ${LTPROOT}/runtest/dio \
506 ${LTPROOT}/runtest/mm ${LTPROOT}/runtest/ipc \
507 ${LTPROOT}/runtest/sched ${LTPROOT}/runtest/math \
subrata_modak0c5f9702007-04-26 11:02:47 +0000508 ${LTPROOT}/runtest/nptl ${LTPROOT}/runtest/pty \
subrata_modak2817ce12008-01-23 13:45:03 +0000509 ${LTPROOT}/runtest/containers \
subrata_modak1d1937a2008-05-13 10:44:02 +0000510 ${LTPROOT}/runtest/fs_bind \
subrata_modakdce1a722008-02-28 15:50:18 +0000511 ${LTPROOT}/runtest/controllers \
subrata_modakaad9c3b2008-05-23 10:20:10 +0000512 ${LTPROOT}/runtest/filecaps \
513 ${LTPROOT}/runtest/fcntl-locktests
plars4a120e82004-09-02 18:56:06 +0000514 do
vapiere42c4b22008-03-08 12:49:06 +0000515 [ -e "$SCENFILES" ] || \
plars4a120e82004-09-02 18:56:06 +0000516 {
517 echo "FATAL: missing scenario file $SCENFILES"
518 exit 1
519 }
520
521 cat $SCENFILES >> ${TMP}/alltests || \
522 {
523 echo "FATAL: unable to create command file"
524 exit 1
525 }
526 done
subrata_modakbc833d32007-07-25 10:12:02 +0000527 fi
528
529 [ -n "$CMDFILES" ] && \
530 {
531 for SCENFILES in `echo "$CMDFILES" | sed 's/,/\n/g'`
532 do
533 [ -f "$SCENFILES" ] || SCENFILES="$LTPROOT/runtest/$SCENFILES"
534 cat "$SCENFILES" >> ${TMP}/alltests || \
535 {
536 echo "FATAL: unable to create command file"
537 exit 1
538 }
539 done
540 }
541
542 [ -n "$CMDFILEADDR" ] && \
543 {
544 wget -q "${CMDFILEADDR}" -O ${TMP}/wgetcmdfile
545 if [ $? -ne 0 ]; then
546 echo "FATAL: error while getting the command file with wget (address $CMDFILEADDR)"
547 exit 1
548 fi
549 cat "${TMP}/wgetcmdfile" >> ${TMP}/alltests || \
plars4a120e82004-09-02 18:56:06 +0000550 {
subrata_modakbc833d32007-07-25 10:12:02 +0000551 echo "FATAL: unable to create command file"
plars4a120e82004-09-02 18:56:06 +0000552 exit 1
553 }
subrata_modakbc833d32007-07-25 10:12:02 +0000554 }
555
plars4a120e82004-09-02 18:56:06 +0000556 [ "$RUN_NETEST" -eq 1 ] && \
557 {
558 for SCENFILES in ${LTPROOT}/runtest/tcp_cmds \
559 ${LTPROOT}/runtest/multicast \
560 ${LTPROOT}/runtest/rpc \
561 ${LTPROOT}/runtest/nfs
562 do
vapiere42c4b22008-03-08 12:49:06 +0000563 [ -e "$SCENFILES" ] || \
plars4a120e82004-09-02 18:56:06 +0000564 {
565 echo "FATAL: missing scenario file $SCENFILES"
566 exit 1
567 }
568
subrata_modakbc833d32007-07-25 10:12:02 +0000569 cat "$SCENFILES" >> ${TMP}/alltests || \
plars4a120e82004-09-02 18:56:06 +0000570 {
571 echo "FATAL: unable to create command file"
572 exit 1
573 }
574 done
575 }
subrata_modakbc833d32007-07-25 10:12:02 +0000576
plars4a120e82004-09-02 18:56:06 +0000577 # The fsx-linux tests use the SCRATCHDEV environment variable as a location
578 # that can be reformatted and run on. Set SCRATCHDEV if you want to run
579 # these tests. As a safeguard, this is disabled.
580 unset SCRATCHDEV
581 [ -n "$SCRATCHDEV" ] && \
582 {
583 cat ${LTPROOT}/runtest/fsx >> ${TMP}/alltests ||
584 {
585 echo "FATAL: unable to create fsx-linux tests command file"
586 exit 1
587 }
588 }
subrata_modakbc833d32007-07-25 10:12:02 +0000589
590 # If enabled, execute only test cases that match the PATTERN
591 if [ -n "$TAG_RESTRICT_STRING" ]
592 then
593 mv -f ${TMP}/alltests ${TMP}/alltests.orig
594 grep $TAG_RESTRICT_STRING ${TMP}/alltests.orig > ${TMP}/alltests #Not worth checking return codes for this case
595 fi
plars4a120e82004-09-02 18:56:06 +0000596
597 # check for required users and groups
598 ${LTPROOT}/IDcheck.sh &>/dev/null || \
599 {
600 echo "WARNING: required users and groups not present"
601 echo "WARNING: some test cases may fail"
602 }
robbiew7d43d772005-02-07 20:07:30 +0000603
plars4a120e82004-09-02 18:56:06 +0000604 # display versions of installed software
605 [ -z "$QUIET_MODE" ] && \
606 {
607 ${LTPROOT}/ver_linux || \
608 {
609 echo "WARNING: unable to display versions of software installed"
610 exit 1
611 }
612 }
613
subrata_modak8c138332008-01-28 11:19:32 +0000614 if [ $RUN_REPEATED -gt 1 ]; then # You need to specify at least more than 1 sequential run, else it runs default
615 echo "PAN will run these test cases $RUN_REPEATED times....."
616 echo "Test Tags will be Prepended with ITERATION NO.s....."
617 inc=1
618 sed -e '/^$/ d' -e 's/^[ ,\t]*//' -e '/^#/ d' < ${TMP}/alltests > ${TMP}/alltests.temp ##This removes all newlines, leading spaces, tabs, #
619 sed 's/^[0-9,a-z,A-Z]*/'"$inc"'_ITERATION_&/' < ${TMP}/alltests.temp > ${TMP}/alltests ## .temp is kept as Base file
620 while [ $inc -lt $RUN_REPEATED ] ; do
621 inc=`expr $inc + 1`
622 sed 's/^[0-9,a-z,A-Z]*/'"$inc"'_ITERATION_&/' < ${TMP}/alltests.temp >> ${TMP}/alltests #Keep appending with Iteration No.s
623 done
624 fi
625
plars4a120e82004-09-02 18:56:06 +0000626 [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test start time: $(date)" ; }
robbiew7d43d772005-02-07 20:07:30 +0000627 PAN_COMMAND="${LTPROOT}/pan/pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ \
subrata_modakbc833d32007-07-25 10:12:02 +0000628 -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE $FAILCMDFILE"
robbiew7d43d772005-02-07 20:07:30 +0000629 if [ ! -z "$VERBOSE_MODE" ] ; then
630 echo "COMMAND: $PAN_COMMAND"
631 if [ ! -z "$TAG_RESTRICT_STRING" ] ; then
632 echo "INFO: Restricted to $TAG_RESTRICT_STRING"
633 fi
634 fi
635 #$PAN_COMMAND #Duplicated code here, because otherwise if we fail, only "PAN_COMMAND" gets output
subrata_modak43938212008-05-19 08:48:46 +0000636
637 ## Display the Output/Log/Failed/HTML file names here
638 echo -e "LOG File: \c"
639 echo $LOGFILE | cut -b4-
640
641 if [ "$OUTPUTFILE" ]; then
642 echo -e "OUTPUT File: \c"
643 echo $OUTPUTFILE | cut -b4-
644 fi
645
646 echo -e "FAILED COMMAND File: \c"
647 echo $FAILCMDFILE | cut -b4-
648
649 if [ "$HTMLFILE" ]; then
650 echo "HTML File: $HTMLFILE"
651 fi
652
653 echo "Running tests......."
subrata_modake47fb352007-11-25 17:03:49 +0000654 test_start_time=$(date)
subrata_modakd48c4d02008-01-23 12:59:40 +0000655 ${LTPROOT}/pan/pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE $FAILCMDFILE
656
plars4a120e82004-09-02 18:56:06 +0000657 if [ $? -eq 0 ]; then
658 echo "INFO: pan reported all tests PASS"
659 VALUE=0
subrata_modake47fb352007-11-25 17:03:49 +0000660 export LTP_EXIT_VALUE=0;
plars4a120e82004-09-02 18:56:06 +0000661 else
662 echo "INFO: pan reported some tests FAIL"
663 VALUE=1
subrata_modake47fb352007-11-25 17:03:49 +0000664 export LTP_EXIT_VALUE=1;
plars4a120e82004-09-02 18:56:06 +0000665 fi
mreed1091696422006-05-03 19:07:22 +0000666 echo "LTP Version: $version_date"
667
subrata_modake47fb352007-11-25 17:03:49 +0000668 if [ "$ALT_HTML_OUT" -eq 1 ] ; then #User wants the HTML output to be created, it then needs to be generated
669 export LTP_VERSION=$version_date
670 export TEST_START_TIME=$test_start_time
671 export TEST_END_TIME=$(date)
672 OUTPUT_DIRECTORY=`echo $OUTPUTFILE | cut -c4-`
673 LOGS_DIRECTORY="$LTPROOT/results"
674 export TEST_OUTPUT_DIRECTORY="$LTPROOT/output"
675 export TEST_LOGS_DIRECTORY=$LOGS_DIRECTORY
676 echo "Generating HTML Output.....!!"
677 ( perl $LTPROOT/tools/genhtml.pl $LTPROOT/tools/html_report_header.txt test_start test_end test_output execution_status $OUTPUT_DIRECTORY > $HTMLFILE; )
678 echo "Generated HTML Output.....!!"
679 echo "Location: $HTMLFILE";
680
681 fi
682
subrata_modak08dde6f2007-11-28 11:02:51 +0000683 if [ "$ALT_EMAIL_OUT" -eq 1 ] ; then ## User wants reports to be e-mailed
684 if [ [ ! "$HTMLFILE_NAME" ] -o [ ! "$OUTPUTFILE_NAME" ] -o [ ! "$LOGFILE_NAME" ] ] ; then
685 ##User does not have output/logs/html-output, nothing to be mailed in this situation
686 echo "Nothing to be mailed here...."
687 else
subrata_modak43938212008-05-19 08:48:46 +0000688 TAR_FILE_NAME=LTP_RUN_$version_date$DEFAULT_FILE_NAME_GENERATION_TIME.tar
subrata_modak08dde6f2007-11-28 11:02:51 +0000689 if [ "$HTMLFILE_NAME" ] ; then ## HTML file Exists
690 if [ "$ALT_HTML_OUT" -ne 1 ] ; then ## The HTML file path is absolute and not $LTPROOT/output
691 mkdir -p $LTPROOT/output ## We need to create this Directory
692 cp $HTMLFILE_NAME $LTPROOT/output/
693 fi
694 fi
695 if [ "$OUTPUTFILE_NAME" ] ; then ## Output file exists
696 if [ "$ALT_DIR_OUT" -ne 1 ] ; then ## The Output file path is absolute and not $LTPROOT/output
697 mkdir -p $LTPROOT/output ## We need to create this Directory
698 cp $OUTPUTFILE_NAME $LTPROOT/output/
699 fi
700 fi
701 if [ "$LOGFILE_NAME" ] ; then ## Log file exists
702 if [ "$ALT_DIR_RES" -ne 1 ] ; then ## The Log file path is absolute and not $LTPROOT/results
703 mkdir -p $LTPROOT/results ## We need to create this Directory
704 cp $LOGFILE_NAME $LTPROOT/results/
705 fi
706 fi
707 if [ -d $LTPROOT/output ] ; then
708 tar -cf ./$TAR_FILE_NAME $LTPROOT/output
709 if [ $? -eq 0 ]; then
710 echo "Created TAR File: ./$TAR_FILE_NAME successfully, added $LTPROOT/output"
711 else
712 echo "Cannot Create TAR File: ./$TAR_FILE_NAME for adding $LTPROOT/output"
713 fi
714 fi
715 if [ -d $LTPROOT/results ] ; then
716 tar -uf ./$TAR_FILE_NAME $LTPROOT/results
717 if [ $? -eq 0 ]; then
718 echo "Updated TAR File: ./$TAR_FILE_NAME successfully, added $LTPROOT/results"
719 else
720 echo "Cannot Update TAR File: ./$TAR_FILE_NAME for adding $LTPROOT/results"
721 fi
722 fi
723 if [ -e $LTPROOT/nohup.out ] ; then ## If User would have Chosen nohup to do ltprun
724 tar -uf ./$TAR_FILE_NAME $LTPROOT/nohup.out
725 if [ $? -eq 0 ]; then
726 echo "Updated TAR File: ./$TAR_FILE_NAME successfully, added $LTPROOT/nohup.out"
727 else
728 echo "Cannot Update TAR File: ./$TAR_FILE_NAME for adding $LTPROOT/nohup.out"
729 fi
730 fi
731 gzip ./$TAR_FILE_NAME ## gzip this guy
732 if [ $? -eq 0 ]; then
733 echo "Gunzipped TAR File: ./$TAR_FILE_NAME"
734 else
735 echo "Cannot Gunzip TAR File: ./$TAR_FILE_NAME"
736 fi
737 if [ -e /usr/bin/mutt ] ; then ## This is a better mail client than others
738 echo "Starting mailing reports to: $EMAIL_TO, file: ./$TAR_FILE_NAME.gz"
739 mutt -a ./$TAR_FILE_NAME.gz -s "LTP Reports on $test_start_time" $EMAIL_TO < /dev/null
740 if [ $? -eq 0 ]; then
741 echo "Reports Successfully mailed to: $EMAIL_TO"
742 else
743 echo "Reports cannot be mailed to: $EMAIL_TO"
744 fi
745 else ## Use our Ageold mail program
746 echo "Starting mailing reports to: $EMAIL_TO, file: ./$TAR_FILE_NAME.gz"
747 uuencode ./$TAR_FILE_NAME.gz $TAR_FILE_NAME.gz | mail $EMAIL_TO -s "LTP Reports on $test_start_time"
748 if [ $? -eq 0 ]; then
749 echo "Reports Successfully mailed to: $EMAIL_TO"
750 else
751 echo "Reports cannot be mailed to: $EMAIL_TO"
752 fi
753 fi
754 fi
755 fi
756
plars4a120e82004-09-02 18:56:06 +0000757 [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test end time: $(date)" ; }
758
subrata_modake099b2a2007-10-29 12:22:01 +0000759 [ "$GENLOAD" -eq 1 ] && { killall -9 genload >/dev/null 2>&1; }
760 [ "$NETPIPE" -eq 1 ] && { killall -9 NPtcp >/dev/null 2>&1; }
plars4a120e82004-09-02 18:56:06 +0000761
subrata_modak5d7deea2007-09-15 13:51:36 +0000762 [ "$ALT_DIR_OUT" -eq 1 ] || [ "$ALT_DIR_RES" -eq 1 ] && \
plars4a120e82004-09-02 18:56:06 +0000763 {
764 cat <<-EOF >&1
765
766 ###############################################################"
767
768 Done executing testcases."
mreed1091696422006-05-03 19:07:22 +0000769 LTP Version: $version_date
plars4a120e82004-09-02 18:56:06 +0000770 ###############################################################"
771
772 EOF
773 }
774 exit $VALUE
775}
776
777cleanup()
778{
779 rm -rf ${TMP}
780}
781
782trap "cleanup" 0
783setup
784main "$@"