blob: e00e88da47dc97169b6a2276844d7153a6d638ce [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_modak2817ce12008-01-23 13:45:03 +0000512 ${LTPROOT}/runtest/filecaps
plars4a120e82004-09-02 18:56:06 +0000513 do
vapiere42c4b22008-03-08 12:49:06 +0000514 [ -e "$SCENFILES" ] || \
plars4a120e82004-09-02 18:56:06 +0000515 {
516 echo "FATAL: missing scenario file $SCENFILES"
517 exit 1
518 }
519
520 cat $SCENFILES >> ${TMP}/alltests || \
521 {
522 echo "FATAL: unable to create command file"
523 exit 1
524 }
525 done
subrata_modakbc833d32007-07-25 10:12:02 +0000526 fi
527
528 [ -n "$CMDFILES" ] && \
529 {
530 for SCENFILES in `echo "$CMDFILES" | sed 's/,/\n/g'`
531 do
532 [ -f "$SCENFILES" ] || SCENFILES="$LTPROOT/runtest/$SCENFILES"
533 cat "$SCENFILES" >> ${TMP}/alltests || \
534 {
535 echo "FATAL: unable to create command file"
536 exit 1
537 }
538 done
539 }
540
541 [ -n "$CMDFILEADDR" ] && \
542 {
543 wget -q "${CMDFILEADDR}" -O ${TMP}/wgetcmdfile
544 if [ $? -ne 0 ]; then
545 echo "FATAL: error while getting the command file with wget (address $CMDFILEADDR)"
546 exit 1
547 fi
548 cat "${TMP}/wgetcmdfile" >> ${TMP}/alltests || \
plars4a120e82004-09-02 18:56:06 +0000549 {
subrata_modakbc833d32007-07-25 10:12:02 +0000550 echo "FATAL: unable to create command file"
plars4a120e82004-09-02 18:56:06 +0000551 exit 1
552 }
subrata_modakbc833d32007-07-25 10:12:02 +0000553 }
554
plars4a120e82004-09-02 18:56:06 +0000555 [ "$RUN_NETEST" -eq 1 ] && \
556 {
557 for SCENFILES in ${LTPROOT}/runtest/tcp_cmds \
558 ${LTPROOT}/runtest/multicast \
559 ${LTPROOT}/runtest/rpc \
560 ${LTPROOT}/runtest/nfs
561 do
vapiere42c4b22008-03-08 12:49:06 +0000562 [ -e "$SCENFILES" ] || \
plars4a120e82004-09-02 18:56:06 +0000563 {
564 echo "FATAL: missing scenario file $SCENFILES"
565 exit 1
566 }
567
subrata_modakbc833d32007-07-25 10:12:02 +0000568 cat "$SCENFILES" >> ${TMP}/alltests || \
plars4a120e82004-09-02 18:56:06 +0000569 {
570 echo "FATAL: unable to create command file"
571 exit 1
572 }
573 done
574 }
subrata_modakbc833d32007-07-25 10:12:02 +0000575
plars4a120e82004-09-02 18:56:06 +0000576 # The fsx-linux tests use the SCRATCHDEV environment variable as a location
577 # that can be reformatted and run on. Set SCRATCHDEV if you want to run
578 # these tests. As a safeguard, this is disabled.
579 unset SCRATCHDEV
580 [ -n "$SCRATCHDEV" ] && \
581 {
582 cat ${LTPROOT}/runtest/fsx >> ${TMP}/alltests ||
583 {
584 echo "FATAL: unable to create fsx-linux tests command file"
585 exit 1
586 }
587 }
subrata_modakbc833d32007-07-25 10:12:02 +0000588
589 # If enabled, execute only test cases that match the PATTERN
590 if [ -n "$TAG_RESTRICT_STRING" ]
591 then
592 mv -f ${TMP}/alltests ${TMP}/alltests.orig
593 grep $TAG_RESTRICT_STRING ${TMP}/alltests.orig > ${TMP}/alltests #Not worth checking return codes for this case
594 fi
plars4a120e82004-09-02 18:56:06 +0000595
596 # check for required users and groups
597 ${LTPROOT}/IDcheck.sh &>/dev/null || \
598 {
599 echo "WARNING: required users and groups not present"
600 echo "WARNING: some test cases may fail"
601 }
robbiew7d43d772005-02-07 20:07:30 +0000602
plars4a120e82004-09-02 18:56:06 +0000603 # display versions of installed software
604 [ -z "$QUIET_MODE" ] && \
605 {
606 ${LTPROOT}/ver_linux || \
607 {
608 echo "WARNING: unable to display versions of software installed"
609 exit 1
610 }
611 }
612
subrata_modak8c138332008-01-28 11:19:32 +0000613 if [ $RUN_REPEATED -gt 1 ]; then # You need to specify at least more than 1 sequential run, else it runs default
614 echo "PAN will run these test cases $RUN_REPEATED times....."
615 echo "Test Tags will be Prepended with ITERATION NO.s....."
616 inc=1
617 sed -e '/^$/ d' -e 's/^[ ,\t]*//' -e '/^#/ d' < ${TMP}/alltests > ${TMP}/alltests.temp ##This removes all newlines, leading spaces, tabs, #
618 sed 's/^[0-9,a-z,A-Z]*/'"$inc"'_ITERATION_&/' < ${TMP}/alltests.temp > ${TMP}/alltests ## .temp is kept as Base file
619 while [ $inc -lt $RUN_REPEATED ] ; do
620 inc=`expr $inc + 1`
621 sed 's/^[0-9,a-z,A-Z]*/'"$inc"'_ITERATION_&/' < ${TMP}/alltests.temp >> ${TMP}/alltests #Keep appending with Iteration No.s
622 done
623 fi
624
plars4a120e82004-09-02 18:56:06 +0000625 [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test start time: $(date)" ; }
robbiew7d43d772005-02-07 20:07:30 +0000626 PAN_COMMAND="${LTPROOT}/pan/pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ \
subrata_modakbc833d32007-07-25 10:12:02 +0000627 -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE $FAILCMDFILE"
robbiew7d43d772005-02-07 20:07:30 +0000628 if [ ! -z "$VERBOSE_MODE" ] ; then
629 echo "COMMAND: $PAN_COMMAND"
630 if [ ! -z "$TAG_RESTRICT_STRING" ] ; then
631 echo "INFO: Restricted to $TAG_RESTRICT_STRING"
632 fi
633 fi
634 #$PAN_COMMAND #Duplicated code here, because otherwise if we fail, only "PAN_COMMAND" gets output
subrata_modak43938212008-05-19 08:48:46 +0000635
636 ## Display the Output/Log/Failed/HTML file names here
637 echo -e "LOG File: \c"
638 echo $LOGFILE | cut -b4-
639
640 if [ "$OUTPUTFILE" ]; then
641 echo -e "OUTPUT File: \c"
642 echo $OUTPUTFILE | cut -b4-
643 fi
644
645 echo -e "FAILED COMMAND File: \c"
646 echo $FAILCMDFILE | cut -b4-
647
648 if [ "$HTMLFILE" ]; then
649 echo "HTML File: $HTMLFILE"
650 fi
651
652 echo "Running tests......."
subrata_modake47fb352007-11-25 17:03:49 +0000653 test_start_time=$(date)
subrata_modakd48c4d02008-01-23 12:59:40 +0000654 ${LTPROOT}/pan/pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE $FAILCMDFILE
655
plars4a120e82004-09-02 18:56:06 +0000656 if [ $? -eq 0 ]; then
657 echo "INFO: pan reported all tests PASS"
658 VALUE=0
subrata_modake47fb352007-11-25 17:03:49 +0000659 export LTP_EXIT_VALUE=0;
plars4a120e82004-09-02 18:56:06 +0000660 else
661 echo "INFO: pan reported some tests FAIL"
662 VALUE=1
subrata_modake47fb352007-11-25 17:03:49 +0000663 export LTP_EXIT_VALUE=1;
plars4a120e82004-09-02 18:56:06 +0000664 fi
mreed1091696422006-05-03 19:07:22 +0000665 echo "LTP Version: $version_date"
666
subrata_modake47fb352007-11-25 17:03:49 +0000667 if [ "$ALT_HTML_OUT" -eq 1 ] ; then #User wants the HTML output to be created, it then needs to be generated
668 export LTP_VERSION=$version_date
669 export TEST_START_TIME=$test_start_time
670 export TEST_END_TIME=$(date)
671 OUTPUT_DIRECTORY=`echo $OUTPUTFILE | cut -c4-`
672 LOGS_DIRECTORY="$LTPROOT/results"
673 export TEST_OUTPUT_DIRECTORY="$LTPROOT/output"
674 export TEST_LOGS_DIRECTORY=$LOGS_DIRECTORY
675 echo "Generating HTML Output.....!!"
676 ( perl $LTPROOT/tools/genhtml.pl $LTPROOT/tools/html_report_header.txt test_start test_end test_output execution_status $OUTPUT_DIRECTORY > $HTMLFILE; )
677 echo "Generated HTML Output.....!!"
678 echo "Location: $HTMLFILE";
679
680 fi
681
subrata_modak08dde6f2007-11-28 11:02:51 +0000682 if [ "$ALT_EMAIL_OUT" -eq 1 ] ; then ## User wants reports to be e-mailed
683 if [ [ ! "$HTMLFILE_NAME" ] -o [ ! "$OUTPUTFILE_NAME" ] -o [ ! "$LOGFILE_NAME" ] ] ; then
684 ##User does not have output/logs/html-output, nothing to be mailed in this situation
685 echo "Nothing to be mailed here...."
686 else
subrata_modak43938212008-05-19 08:48:46 +0000687 TAR_FILE_NAME=LTP_RUN_$version_date$DEFAULT_FILE_NAME_GENERATION_TIME.tar
subrata_modak08dde6f2007-11-28 11:02:51 +0000688 if [ "$HTMLFILE_NAME" ] ; then ## HTML file Exists
689 if [ "$ALT_HTML_OUT" -ne 1 ] ; then ## The HTML file path is absolute and not $LTPROOT/output
690 mkdir -p $LTPROOT/output ## We need to create this Directory
691 cp $HTMLFILE_NAME $LTPROOT/output/
692 fi
693 fi
694 if [ "$OUTPUTFILE_NAME" ] ; then ## Output file exists
695 if [ "$ALT_DIR_OUT" -ne 1 ] ; then ## The Output file path is absolute and not $LTPROOT/output
696 mkdir -p $LTPROOT/output ## We need to create this Directory
697 cp $OUTPUTFILE_NAME $LTPROOT/output/
698 fi
699 fi
700 if [ "$LOGFILE_NAME" ] ; then ## Log file exists
701 if [ "$ALT_DIR_RES" -ne 1 ] ; then ## The Log file path is absolute and not $LTPROOT/results
702 mkdir -p $LTPROOT/results ## We need to create this Directory
703 cp $LOGFILE_NAME $LTPROOT/results/
704 fi
705 fi
706 if [ -d $LTPROOT/output ] ; then
707 tar -cf ./$TAR_FILE_NAME $LTPROOT/output
708 if [ $? -eq 0 ]; then
709 echo "Created TAR File: ./$TAR_FILE_NAME successfully, added $LTPROOT/output"
710 else
711 echo "Cannot Create TAR File: ./$TAR_FILE_NAME for adding $LTPROOT/output"
712 fi
713 fi
714 if [ -d $LTPROOT/results ] ; then
715 tar -uf ./$TAR_FILE_NAME $LTPROOT/results
716 if [ $? -eq 0 ]; then
717 echo "Updated TAR File: ./$TAR_FILE_NAME successfully, added $LTPROOT/results"
718 else
719 echo "Cannot Update TAR File: ./$TAR_FILE_NAME for adding $LTPROOT/results"
720 fi
721 fi
722 if [ -e $LTPROOT/nohup.out ] ; then ## If User would have Chosen nohup to do ltprun
723 tar -uf ./$TAR_FILE_NAME $LTPROOT/nohup.out
724 if [ $? -eq 0 ]; then
725 echo "Updated TAR File: ./$TAR_FILE_NAME successfully, added $LTPROOT/nohup.out"
726 else
727 echo "Cannot Update TAR File: ./$TAR_FILE_NAME for adding $LTPROOT/nohup.out"
728 fi
729 fi
730 gzip ./$TAR_FILE_NAME ## gzip this guy
731 if [ $? -eq 0 ]; then
732 echo "Gunzipped TAR File: ./$TAR_FILE_NAME"
733 else
734 echo "Cannot Gunzip TAR File: ./$TAR_FILE_NAME"
735 fi
736 if [ -e /usr/bin/mutt ] ; then ## This is a better mail client than others
737 echo "Starting mailing reports to: $EMAIL_TO, file: ./$TAR_FILE_NAME.gz"
738 mutt -a ./$TAR_FILE_NAME.gz -s "LTP Reports on $test_start_time" $EMAIL_TO < /dev/null
739 if [ $? -eq 0 ]; then
740 echo "Reports Successfully mailed to: $EMAIL_TO"
741 else
742 echo "Reports cannot be mailed to: $EMAIL_TO"
743 fi
744 else ## Use our Ageold mail program
745 echo "Starting mailing reports to: $EMAIL_TO, file: ./$TAR_FILE_NAME.gz"
746 uuencode ./$TAR_FILE_NAME.gz $TAR_FILE_NAME.gz | mail $EMAIL_TO -s "LTP Reports on $test_start_time"
747 if [ $? -eq 0 ]; then
748 echo "Reports Successfully mailed to: $EMAIL_TO"
749 else
750 echo "Reports cannot be mailed to: $EMAIL_TO"
751 fi
752 fi
753 fi
754 fi
755
plars4a120e82004-09-02 18:56:06 +0000756 [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test end time: $(date)" ; }
757
subrata_modake099b2a2007-10-29 12:22:01 +0000758 [ "$GENLOAD" -eq 1 ] && { killall -9 genload >/dev/null 2>&1; }
759 [ "$NETPIPE" -eq 1 ] && { killall -9 NPtcp >/dev/null 2>&1; }
plars4a120e82004-09-02 18:56:06 +0000760
subrata_modak5d7deea2007-09-15 13:51:36 +0000761 [ "$ALT_DIR_OUT" -eq 1 ] || [ "$ALT_DIR_RES" -eq 1 ] && \
plars4a120e82004-09-02 18:56:06 +0000762 {
763 cat <<-EOF >&1
764
765 ###############################################################"
766
767 Done executing testcases."
mreed1091696422006-05-03 19:07:22 +0000768 LTP Version: $version_date
plars4a120e82004-09-02 18:56:06 +0000769 ###############################################################"
770
771 EOF
772 }
773 exit $VALUE
774}
775
776cleanup()
777{
778 rm -rf ${TMP}
779}
780
781trap "cleanup" 0
782setup
783main "$@"