blob: cb33bfa0c1a2978cf4f887d41409366e6a01a049 [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_modake099b2a2007-10-29 12:22:01 +000061#
subrata_modak6838ec32007-09-14 10:10:12 +000062#################################################################################
subrata_modakbc833d32007-07-25 10:12:02 +000063
plars4a120e82004-09-02 18:56:06 +000064
65
66setup()
67{
68 cd `dirname $0` || \
69 {
70 echo "FATAL: unable to change directory to $(dirname $0)"
71 exit 1
72 }
73 export LTPROOT=${PWD}
74 export TMPBASE="/tmp"
75 export TMP="${TMPBASE}/ltp-$$"
subrata_modak4a57fe82007-09-24 06:40:12 +000076 export TMPDIR="${TMP}"
plars4a120e82004-09-02 18:56:06 +000077 export PATH="${PATH}:${LTPROOT}/testcases/bin"
78
79 [ -d $LTPROOT/testcases/bin ] ||
80 {
81 echo "FATAL: Test suite not installed correctly"
82 echo "INFO: as root user type 'make ; make install'"
83 exit 1
84 }
85
86 [ -e $LTPROOT/pan/pan ] ||
87 {
88 echo "FATAL: Test suite driver 'pan' not found"
89 echo "INFO: as root user type 'make ; make install'"
90 exit 1
91 }
92}
93
mreed1091696422006-05-03 19:07:22 +000094version_of_ltp()
95{
subrata_modaka1fd64b2007-04-11 11:24:49 +000096 head -n 1 $LTPROOT/ChangeLog
97 exit 0
mreed1091696422006-05-03 19:07:22 +000098}
plars4a120e82004-09-02 18:56:06 +000099
100usage()
101{
102 cat <<-EOF >&2
103
subrata_modake099b2a2007-10-29 12:22:01 +0000104 usage: ./${0##*/} [ -c NUM_PROCS ] [ -C FAILCMDFILE ] [ -d TMPDIR ]
subrata_modake47fb352007-11-25 17:03:49 +0000105 [ -D NUM_PROCS,NUM_FILES,NUM_BYTES,CLEAN_FLAG ] -e [ -f CMDFILES(,...) ] [ -g HTMLFILE]
subrata_modake099b2a2007-10-29 12:22:01 +0000106 [ -i NUM_PROCS ] [ -l LOGFILE ] [ -m NUM_PROCS,CHUNKS,BYTES,HANGUP_FLAG ]
107 -N -n [ -o OUTPUTFILE ] -p -q [ -r LTPROOT ] [ -s PATTERN ] [ -t DURATION ]
108 -v [ -w CMDFILEADDR ] [ -x INSTANCES ]
plars4a120e82004-09-02 18:56:06 +0000109
subrata_modake099b2a2007-10-29 12:22:01 +0000110 -c NUM_PROCS Run LTP under additional background CPU load
111 [NUM_PROCS = no. of processes creating the CPU Load by spinning over sqrt()
112 (Defaults to 1 when value)]
subrata_modakbc833d32007-07-25 10:12:02 +0000113 -C FAILCMDFILE Command file with all failed test cases.
plars4a120e82004-09-02 18:56:06 +0000114 -d TMPDIR Directory where temporary files will be created.
subrata_modake099b2a2007-10-29 12:22:01 +0000115 -D NUM_PROCS,NUM_FILES,NUM_BYTES,CLEAN_FLAG
116 Run LTP under additional background Load on Secondary Storage (Seperate by comma)
117 [NUM_PROCS = no. of processes creating Storage Load by spinning over write()]
118 [NUM_FILES = Write() to these many files (Defaults to 1 when value 0 or undefined)]
119 [NUM_BYTES = write these many bytes (defaults to 1GB, when value 0 or undefined)]
120 [CLEAN_FLAG = unlink file to which random data written, when value 1]
mreed1091696422006-05-03 19:07:22 +0000121 -e Prints the date of the current LTP release
subrata_modakbc833d32007-07-25 10:12:02 +0000122 -f CMDFILES Execute user defined list of testcases (separate with ',')
subrata_modake47fb352007-11-25 17:03:49 +0000123 -g HTMLFILE Create an additional HTML output format
plars4a120e82004-09-02 18:56:06 +0000124 -h Help. Prints all available options.
subrata_modake099b2a2007-10-29 12:22:01 +0000125 -i NUM_PROCS Run LTP under additional background Load on IO Bus
126 [NUM_PROCS = no. of processes creating IO Bus Load by spinning over sync()]
plars4a120e82004-09-02 18:56:06 +0000127 -l LOGFILE Log results of test in a logfile.
subrata_modake099b2a2007-10-29 12:22:01 +0000128 -m NUM_PROCS,CHUNKS,BYTES,HANGUP_FLAG
129 Run LTP under additional background Load on Main memory (Seperate by comma)
130 [NUM_PROCS = no. of processes creating main Memory Load by spinning over malloc()]
131 [CHUNKS = malloc these many chunks (default is 1 when value 0 or undefined)]
132 [BYTES = malloc CHUNKS of BYTES bytes (default is 256MB when value 0 or undefined) ]
133 [HANGUP_FLAG = hang in a sleep loop after memory allocated, when value 1]
plars4a120e82004-09-02 18:56:06 +0000134 -N Run all the networking tests.
135 -n Run LTP with network traffic in background.
136 -o OUTPUTFILE Redirect test output to a file.
137 -p Human readable format logfiles.
138 -q Print less verbose output to screen.
139 -r LTPROOT Fully qualified path where testsuite is installed.
subrata_modaka1fd64b2007-04-11 11:24:49 +0000140 -s PATTERN Only run test cases which match PATTERN.
plars4a120e82004-09-02 18:56:06 +0000141 -t DURATION Execute the testsuite for given duration. Examples:
142 -t 60s = 60 seconds
143 -t 45m = 45 minutes
144 -t 24h = 24 hours
145 -t 2d = 2 days
robbiew7d43d772005-02-07 20:07:30 +0000146 -v Print more verbose output to screen.
subrata_modakbc833d32007-07-25 10:12:02 +0000147 -w CMDFILEADDR Uses wget to get the user's list of testcases.
plars4a120e82004-09-02 18:56:06 +0000148 -x INSTANCES Run multiple instances of this testsuite.
149
subrata_modake099b2a2007-10-29 12:22:01 +0000150 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 +0000151
plars4a120e82004-09-02 18:56:06 +0000152
153 EOF
154exit 0
155}
156
plars4a120e82004-09-02 18:56:06 +0000157main()
158{
subrata_modakbc833d32007-07-25 10:12:02 +0000159 local CMDFILES=""
plars4a120e82004-09-02 18:56:06 +0000160 local PRETTY_PRT=""
subrata_modak5d7deea2007-09-15 13:51:36 +0000161 local ALT_DIR_OUT=0
162 local ALT_DIR_RES=0
subrata_modake47fb352007-11-25 17:03:49 +0000163 local ALT_HTML_OUT=0
plars4a120e82004-09-02 18:56:06 +0000164 local RUN_NETEST=0
165 local QUIET_MODE=""
robbiew7d43d772005-02-07 20:07:30 +0000166 local VERBOSE_MODE=""
plars4a120e82004-09-02 18:56:06 +0000167 local NETPIPE=0
168 local GENLOAD=0
169 local MEMSIZE=0
170 local DURATION=""
subrata_modakbc833d32007-07-25 10:12:02 +0000171 local CMDFILEADDR=""
subrata_modake47fb352007-11-25 17:03:49 +0000172 local LOGFILE_NAME=""
plars4a120e82004-09-02 18:56:06 +0000173 local LOGFILE=""
subrata_modake47fb352007-11-25 17:03:49 +0000174 local OUTPUTFILE_NAME=""
175 local OUTPUTFILE=""
176 local HTMLFILE_NAME=""
177 local HTMLFILE=""
plars4a120e82004-09-02 18:56:06 +0000178 local SCENFILES=""
robbiew7d43d772005-02-07 20:07:30 +0000179 local TAG_RESTRICT_STRING=""
180 local PAN_COMMAND=""
mreed1091696422006-05-03 19:07:22 +0000181 version_date=`head -n 1 $LTPROOT/ChangeLog`
plars4a120e82004-09-02 18:56:06 +0000182
subrata_modake47fb352007-11-25 17:03:49 +0000183 while getopts c:C:d:D:f:ehi:g:l:m:Nno:pqr:s:t:vw:x: arg
plars4a120e82004-09-02 18:56:06 +0000184 do case $arg in
185 c)
subrata_modake099b2a2007-10-29 12:22:01 +0000186 NUM_PROCS=$(($OPTARG))
187 if [ "$NUM_PROCS" -eq 0 ]; then
188 # User Did not Define the Value ,or, User Defined Zero,
189 # hence, prevent from creating infinite processes
190 NUM_PROCS=1
191 fi
plars4a120e82004-09-02 18:56:06 +0000192 $LTPROOT/testcases/bin/genload --cpu $NUM_PROCS >/dev/null 2>&1 &
193 GENLOAD=1 ;;
subrata_modakbc833d32007-07-25 10:12:02 +0000194
subrata_modak5d7deea2007-09-15 13:51:36 +0000195 C)
subrata_modak6838ec32007-09-14 10:10:12 +0000196 case $OPTARG in
197 /*)
198 FAILCMDFILE="-C $OPTARG" ;;
199 *)
200 FAILCMDFILE="-C $LTPROOT/output/$OPTARG"
subrata_modak5d7deea2007-09-15 13:51:36 +0000201 ALT_DIR_OUT=1 ;;
subrata_modak6838ec32007-09-14 10:10:12 +0000202 esac ;;
plars4a120e82004-09-02 18:56:06 +0000203
204 d) # append $$ to TMP, as it is recursively
205 # removed at end of script.
subrata_modak4a57fe82007-09-24 06:40:12 +0000206 export TMPBASE=$OPTARG
207 export TMP="${TMPBASE}/ltp-$$"
robbiew538bc1a2005-03-11 19:26:14 +0000208 export TMPDIR="$TMP";;
subrata_modake099b2a2007-10-29 12:22:01 +0000209
210 D) NUM_PROCS=1; NUM_FILES=1; NUM_BYTES=$((1024 * 1024 * 1024)); CLEAN_FLAG=0
211 ARGUMENT_LIST=$(($OPTARG))
212 TOTAL_ARGUMENTS=1 # Initial Assume
213 for ARGUMENT in `echo "$ARGUMENT_LIST" | sed 's/,/\n/g'` # Store all value in a Loop
214 do
215 case $TOTAL_ARGUMENTS in
216 1) NUM_PROCS="$ARGUMENT" ;;
217 2) NUM_FILES="$ARGUMENT" ;;
218 3) NUM_BYTES="$ARGUMENT" ;;
219 4) CLEAN_FLAG="$ARGUMENT" ;;
220 esac
221 TOTAL_ARGUMENTS=`expr $TOTAL_ARGUMENTS + 1`
222 done
223 # just to get the default values if the user passed 0
224 if [ "$NUM_PROCS" -eq 0 ]; then
225 NUM_PROCS=1
226 fi
227 if [ "$NUM_FILES" -eq 0 ]; then
228 NUM_FILES=1
229 fi
230 if [ "$NUM_BYTES" -eq 0 ]; then
231 NUM_BYTES=$((1024 * 1024 * 1024))
232 fi
233 if [ "$CLEAN_FLAG" -ne 1 ]; then
234 CLEAN_FLAG=0
235 fi
236 if [ "$CLEAN_FLAG" -eq 1 ]; then
237 # Do not unlink file in this case
238 $LTPROOT/testcases/bin/genload --hdd $NUM_PROCS --hdd-files \
239 $NUM_FILES --hdd-bytes $NUM_BYTES >/dev/null 2>&1 &
240 else
241 # Cleanup otherwise
242 $LTPROOT/testcases/bin/genload --hdd $NUM_PROCS --hdd-files \
243 $NUM_FILES --hdd-bytes $NUM_BYTES --hdd-noclean >/dev/null 2>&1 &
244 fi
245 GENLOAD=1;;
246
mreed1091696422006-05-03 19:07:22 +0000247 e) # Print out the version of LTP
248 version_of_ltp
249 ;;
plars4a120e82004-09-02 18:56:06 +0000250 f) # Execute user defined set of testcases.
subrata_modakbc833d32007-07-25 10:12:02 +0000251 # Can be more then one file, just separate it with ',', like:
252 # -f nfs,commands,/tmp/testfile
253 CMDFILES=$OPTARG;;
subrata_modake47fb352007-11-25 17:03:49 +0000254 g) HTMLFILE_NAME="$OPTARG"
255 case $OPTARG in
256 /*)
257 HTMLFILE="$OPTARG";;
258 *)
259 HTMLFILE="$LTPROOT/output/$OPTARG"
260 ALT_DIR_OUT=1
261 ALT_HTML_OUT=1 ;;
262 esac ;;
plars4a120e82004-09-02 18:56:06 +0000263 h) usage;;
264
subrata_modake099b2a2007-10-29 12:22:01 +0000265 i)
266 NUM_PROCS=$(($OPTARG))
267 if [ "$NUM_PROCS" -eq 0 ]; then
268 # User Did not Define the Value ,or, User Defined Zero,
269 # hence, prevent from creating infinite processes
270 NUM_PROCS=1
271 fi
272 $LTPROOT/testcases/bin/genload --io $NUM_PROCS >/dev/null 2>&1 &
plars4a120e82004-09-02 18:56:06 +0000273 GENLOAD=1 ;;
274
275 l)
subrata_modak6838ec32007-09-14 10:10:12 +0000276 LOGFILE_NAME="$OPTARG"
plars4a120e82004-09-02 18:56:06 +0000277 case $OPTARG in
subrata_modak5d7deea2007-09-15 13:51:36 +0000278 /*)
plars4a120e82004-09-02 18:56:06 +0000279 LOGFILE="-l $OPTARG" ;;
280 *)
281 LOGFILE="-l $LTPROOT/results/$OPTARG"
subrata_modak5d7deea2007-09-15 13:51:36 +0000282 ALT_DIR_RES=1 ;;
plars4a120e82004-09-02 18:56:06 +0000283 esac ;;
284
subrata_modake099b2a2007-10-29 12:22:01 +0000285 m) NUM_PROCS=1; CHUNKS=1; BYTES=$((256 * 1024 * 1024)); HANGUP_FLAG=0
286 ARGUMENT_LIST=$(($OPTARG))
287 TOTAL_ARGUMENTS=1 # Initial Assume
288 for ARGUMENT in `echo "$ARGUMENT_LIST" | sed 's/,/\n/g'` # Store all value in a Loop
289 do
290 case $TOTAL_ARGUMENTS in
291 1) NUM_PROCS="$ARGUMENT" ;;
292 2) CHUNKS="$ARGUMENT" ;;
293 3) BYTES="$ARGUMENT" ;;
294 4) HANGUP_FLAG="$ARGUMENT" ;;
295 esac
296 TOTAL_ARGUMENTS=`expr $TOTAL_ARGUMENTS + 1`
297 done
298 # just to get the default values if the user passed 0
299 if [ "$NUM_PROCS" -eq 0 ]; then
300 NUM_PROCS=1
301 fi
302 if [ "$CHUNKS" -eq 0 ]; then
303 CHUNKS=1
304 fi
305 if [ "$BYTES" -eq 0 ]; then
306 BYTES=$((256 * 1024 * 1024))
307 fi
308 if [ "$HANGUP_FLAG" -ne 1 ]; then
309 HANGUP_FLAG=0
310 fi
311 if [ "$HANGUP_FLAG" -eq 1 ]; then
312 # Hang in a Sleep loop after memory allocated
313 $LTPROOT/testcases/bin/genload --vm $NUM_PROCS --vm-chunks \
314 $CHUNKS --vm-bytes $BYTES --vm-hang >/dev/null 2>&1 &
315 else
316 # Otherwise Do not Hangup
317 $LTPROOT/testcases/bin/genload --vm $NUM_PROCS --vm-chunks \
318 $CHUNKS --vm-bytes $BYTES >/dev/null 2>&1 &
319 fi
plars4a120e82004-09-02 18:56:06 +0000320 GENLOAD=1;;
321
322 N) RUN_NETEST=1;;
323
324 n)
325 $LTPROOT/testcases/bin/netpipe.sh
326 NETPIPE=1;;
327
subrata_modak6838ec32007-09-14 10:10:12 +0000328 o) OUTPUTFILE_NAME="$OPTARG"
subrata_modak6838ec32007-09-14 10:10:12 +0000329 case $OPTARG in
330 /*)
331 OUTPUTFILE="-o $OPTARG";;
332 *)
333 OUTPUTFILE="-o $LTPROOT/output/$OPTARG"
subrata_modak5d7deea2007-09-15 13:51:36 +0000334 ALT_DIR_OUT=1 ;;
subrata_modak6838ec32007-09-14 10:10:12 +0000335 esac ;;
plars4a120e82004-09-02 18:56:06 +0000336
337 p) PRETTY_PRT=" -p ";;
338
339 q) QUIET_MODE=" -q ";;
340
341 r) LTPROOT=$OPTARG;;
342
robbiew7d43d772005-02-07 20:07:30 +0000343 s) TAG_RESTRICT_STRING=$OPTARG;;
344
plars4a120e82004-09-02 18:56:06 +0000345 t) # In case you want to specify the time
346 # to run from the command line
347 # (2m = two minutes, 2h = two hours, etc)
348 DURATION="-t $OPTARG" ;;
349
robbiew7d43d772005-02-07 20:07:30 +0000350 v) VERBOSE_MODE=1;;
subrata_modakbc833d32007-07-25 10:12:02 +0000351
352 w) CMDFILEADDR=$OPTARG;;
robbiew7d43d772005-02-07 20:07:30 +0000353
plars4a120e82004-09-02 18:56:06 +0000354 x) # number of ltp's to run
355 cat <<-EOF >&1
356 WARNING: The use of -x can cause unpredictable failures, as a
357 result of concurrently running multiple tests designed
358 to be ran exclusively.
359 Pausing for 10 seconds..."
360 EOF
361 sleep 10
362 INSTANCES="-x $OPTARG -O ${TMP}";;
363
364 \?) usage;;
365 esac
366 done
subrata_modak6838ec32007-09-14 10:10:12 +0000367
368 ## It would be nice if a Failed File is compulsorily created (gives User better Idea of Tests that failed)
369
370 if [ ! "$FAILCMDFILE" ]; then ## User has not mentioned about Failed File name
subrata_modak5d7deea2007-09-15 13:51:36 +0000371 ALT_DIR_OUT=1
subrata_modak6838ec32007-09-14 10:10:12 +0000372 if [ ! "$OUTPUTFILE" ]; then ## User has not mentioned about Output File name either
373 if [ ! "$LOGFILE" ]; then ## User has not mentioned about Log File name either
374 FAILED_FILE_NAME=`date +"%Y_%b_%d-%Hh_%Mm_%Ss"`
375 FAILCMDFILE="-C $LTPROOT/output/LTP_RUN_ON-$FAILED_FILE_NAME.failed"
subrata_modak6838ec32007-09-14 10:10:12 +0000376 else ## User Fortunately wanted a log file,
377 FAILED_FILE_NAME=`basename $LOGFILE_NAME` ## Extract log file name and use it to construct Failed file name
378 FAILCMDFILE="-C $LTPROOT/output/LTP_RUN_ON-$FAILED_FILE_NAME.failed"
subrata_modak6838ec32007-09-14 10:10:12 +0000379 fi
380 else ## User Fortunately wanted a Output file
381 FAILED_FILE_NAME=`basename $OUTPUTFILE_NAME` ## Extract output file name and use it to construct Failed file name
382 FAILCMDFILE="-C $LTPROOT/output/LTP_RUN_ON-$FAILED_FILE_NAME.failed"
subrata_modak6838ec32007-09-14 10:10:12 +0000383 fi
384 fi
subrata_modaka1fd64b2007-04-11 11:24:49 +0000385
subrata_modake47fb352007-11-25 17:03:49 +0000386 if [ "$ALT_HTML_OUT" -eq 1 ] ; then ## User wnats the HTML version of the output
387 if [ ! "$OUTPUTFILE" ]; then ## User has not mentioned about the Outputfile name, then we need to definitely generate one
388 OUTPUTFILE_NAME=`date +"%Y_%b_%d-%Hh_%Mm_%Ss"`
389 OUTPUTFILE="-o $LTPROOT/output/LTP_RUN_ON-$OUTPUTFILE_NAME.output"
390
391 if [ ! "$HTMLFILE" ] ; then ## User has not mentioned HTML File name, We need to create one
392 HTMLFILE_NAME=`basename $OUTPUTFILE_NAME`
393 HTMLFILE="$LTPROOT/output/$HTMLFILE_NAME.html"
394 fi
395 fi
396 fi
397
subrata_modak5d7deea2007-09-15 13:51:36 +0000398 # If we need, create the output directory
399 [ "$ALT_DIR_OUT" -eq 1 ] && \
400 {
401 echo "INFO: creating $LTPROOT/output directory"
402 [ ! -d $LTPROOT/output ] && \
403 {
404 mkdir -p $LTPROOT/output || \
405 {
406 echo "ERROR: failed to create $LTPROOT/output"
407 exit 1
408 }
409 }
410 }
411 # If we need, create the results directory
412 [ "$ALT_DIR_RES" -eq 1 ] && \
413 {
414 echo "INFO: creating $LTPROOT/results directory"
415 [ ! -d $LTPROOT/results ] && \
416 {
417 mkdir -p $LTPROOT/results || \
418 {
419 echo "ERROR: failed to create $LTPROOT/results"
420 exit 1
421 }
422 }
423 }
424
subrata_modaka1fd64b2007-04-11 11:24:49 +0000425 # Added -m 777 for tests that call tst_tmpdir() and try to
426 # write to it as user nobody
427 mkdir -m 777 -p $TMP || \
plars4a120e82004-09-02 18:56:06 +0000428 {
robbiew7d43d772005-02-07 20:07:30 +0000429 echo "FATAL: Unable to make temporary directory $TMP"
plars4a120e82004-09-02 18:56:06 +0000430 exit 1
431 }
432
433 cd $TMP || \
434 {
435 echo "could not cd ${TMP} ... exiting"
436 exit 1
437 }
438
439 [ "$RUN_NETEST" -eq 1 ] && \
440 {
441 [ -z "$RHOST" ] || [ -z "$PASSWD" ] && \
442 {
443 [ -z "$RHOST" ] && \
444 {
445 echo \
446 "INFO: Enter RHOST = 'name of the remote host machine'"
447 echo -n "-> "
448 read RHOST
449 }
450
451 [ -z "$PASSWD" ] && \
452 {
453 echo " "
454 echo \
455 "INFO: Enter PASSWD = 'root passwd of the remote host machine'"
456 echo -n "-> "
457 read PASSWD
458 }
459 export RHOST=$RHOST
460 export PASSWD=$PASSWD
461 echo "WARNING: security of $RHOST may be compromised"
462 }
463 }
464
465 # If user does not provide a command file select a default set of testcases
466 # to execute.
subrata_modakbc833d32007-07-25 10:12:02 +0000467 if [ -z "$CMDFILES" ] && [ -z "$CMDFILEADDR" ]
plars4a120e82004-09-02 18:56:06 +0000468 then
subrata_modakbc833d32007-07-25 10:12:02 +0000469 cat <<-EOF >&1
plars4a120e82004-09-02 18:56:06 +0000470
471 INFO: no command files were provided, using default,
472 system calls, memory management, IPC, scheduler
473 direct io, file system, math and pty tests will
474 now be executed
475
476 EOF
477
subrata_modakbc833d32007-07-25 10:12:02 +0000478 for SCENFILES in ${LTPROOT}/runtest/syscalls ${LTPROOT}/runtest/fs \
plars4a120e82004-09-02 18:56:06 +0000479 ${LTPROOT}/runtest/fsx ${LTPROOT}/runtest/dio \
480 ${LTPROOT}/runtest/mm ${LTPROOT}/runtest/ipc \
481 ${LTPROOT}/runtest/sched ${LTPROOT}/runtest/math \
subrata_modak0c5f9702007-04-26 11:02:47 +0000482 ${LTPROOT}/runtest/nptl ${LTPROOT}/runtest/pty \
483 ${LTPROOT}/runtest/containers
plars4a120e82004-09-02 18:56:06 +0000484 do
485 [ -a "$SCENFILES" ] || \
486 {
487 echo "FATAL: missing scenario file $SCENFILES"
488 exit 1
489 }
490
491 cat $SCENFILES >> ${TMP}/alltests || \
492 {
493 echo "FATAL: unable to create command file"
494 exit 1
495 }
496 done
subrata_modakbc833d32007-07-25 10:12:02 +0000497 fi
498
499 [ -n "$CMDFILES" ] && \
500 {
501 for SCENFILES in `echo "$CMDFILES" | sed 's/,/\n/g'`
502 do
503 [ -f "$SCENFILES" ] || SCENFILES="$LTPROOT/runtest/$SCENFILES"
504 cat "$SCENFILES" >> ${TMP}/alltests || \
505 {
506 echo "FATAL: unable to create command file"
507 exit 1
508 }
509 done
510 }
511
512 [ -n "$CMDFILEADDR" ] && \
513 {
514 wget -q "${CMDFILEADDR}" -O ${TMP}/wgetcmdfile
515 if [ $? -ne 0 ]; then
516 echo "FATAL: error while getting the command file with wget (address $CMDFILEADDR)"
517 exit 1
518 fi
519 cat "${TMP}/wgetcmdfile" >> ${TMP}/alltests || \
plars4a120e82004-09-02 18:56:06 +0000520 {
subrata_modakbc833d32007-07-25 10:12:02 +0000521 echo "FATAL: unable to create command file"
plars4a120e82004-09-02 18:56:06 +0000522 exit 1
523 }
subrata_modakbc833d32007-07-25 10:12:02 +0000524 }
525
plars4a120e82004-09-02 18:56:06 +0000526 [ "$RUN_NETEST" -eq 1 ] && \
527 {
528 for SCENFILES in ${LTPROOT}/runtest/tcp_cmds \
529 ${LTPROOT}/runtest/multicast \
530 ${LTPROOT}/runtest/rpc \
531 ${LTPROOT}/runtest/nfs
532 do
533 [ -a "$SCENFILES" ] || \
534 {
535 echo "FATAL: missing scenario file $SCENFILES"
536 exit 1
537 }
538
subrata_modakbc833d32007-07-25 10:12:02 +0000539 cat "$SCENFILES" >> ${TMP}/alltests || \
plars4a120e82004-09-02 18:56:06 +0000540 {
541 echo "FATAL: unable to create command file"
542 exit 1
543 }
544 done
545 }
subrata_modakbc833d32007-07-25 10:12:02 +0000546
plars4a120e82004-09-02 18:56:06 +0000547 # The fsx-linux tests use the SCRATCHDEV environment variable as a location
548 # that can be reformatted and run on. Set SCRATCHDEV if you want to run
549 # these tests. As a safeguard, this is disabled.
550 unset SCRATCHDEV
551 [ -n "$SCRATCHDEV" ] && \
552 {
553 cat ${LTPROOT}/runtest/fsx >> ${TMP}/alltests ||
554 {
555 echo "FATAL: unable to create fsx-linux tests command file"
556 exit 1
557 }
558 }
subrata_modakbc833d32007-07-25 10:12:02 +0000559
560 # If enabled, execute only test cases that match the PATTERN
561 if [ -n "$TAG_RESTRICT_STRING" ]
562 then
563 mv -f ${TMP}/alltests ${TMP}/alltests.orig
564 grep $TAG_RESTRICT_STRING ${TMP}/alltests.orig > ${TMP}/alltests #Not worth checking return codes for this case
565 fi
plars4a120e82004-09-02 18:56:06 +0000566
567 # check for required users and groups
568 ${LTPROOT}/IDcheck.sh &>/dev/null || \
569 {
570 echo "WARNING: required users and groups not present"
571 echo "WARNING: some test cases may fail"
572 }
robbiew7d43d772005-02-07 20:07:30 +0000573
plars4a120e82004-09-02 18:56:06 +0000574 # display versions of installed software
575 [ -z "$QUIET_MODE" ] && \
576 {
577 ${LTPROOT}/ver_linux || \
578 {
579 echo "WARNING: unable to display versions of software installed"
580 exit 1
581 }
582 }
583
584 [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test start time: $(date)" ; }
robbiew7d43d772005-02-07 20:07:30 +0000585 PAN_COMMAND="${LTPROOT}/pan/pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ \
subrata_modakbc833d32007-07-25 10:12:02 +0000586 -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE $FAILCMDFILE"
robbiew7d43d772005-02-07 20:07:30 +0000587 if [ ! -z "$VERBOSE_MODE" ] ; then
588 echo "COMMAND: $PAN_COMMAND"
589 if [ ! -z "$TAG_RESTRICT_STRING" ] ; then
590 echo "INFO: Restricted to $TAG_RESTRICT_STRING"
591 fi
592 fi
593 #$PAN_COMMAND #Duplicated code here, because otherwise if we fail, only "PAN_COMMAND" gets output
subrata_modake47fb352007-11-25 17:03:49 +0000594 test_start_time=$(date)
plars4a120e82004-09-02 18:56:06 +0000595 ${LTPROOT}/pan/pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ \
subrata_modakbc833d32007-07-25 10:12:02 +0000596 -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE $FAILCMDFILE
plars4a120e82004-09-02 18:56:06 +0000597
598 if [ $? -eq 0 ]; then
599 echo "INFO: pan reported all tests PASS"
600 VALUE=0
subrata_modake47fb352007-11-25 17:03:49 +0000601 export LTP_EXIT_VALUE=0;
plars4a120e82004-09-02 18:56:06 +0000602 else
603 echo "INFO: pan reported some tests FAIL"
604 VALUE=1
subrata_modake47fb352007-11-25 17:03:49 +0000605 export LTP_EXIT_VALUE=1;
plars4a120e82004-09-02 18:56:06 +0000606 fi
mreed1091696422006-05-03 19:07:22 +0000607 echo "LTP Version: $version_date"
608
subrata_modake47fb352007-11-25 17:03:49 +0000609 if [ "$ALT_HTML_OUT" -eq 1 ] ; then #User wants the HTML output to be created, it then needs to be generated
610 export LTP_VERSION=$version_date
611 export TEST_START_TIME=$test_start_time
612 export TEST_END_TIME=$(date)
613 OUTPUT_DIRECTORY=`echo $OUTPUTFILE | cut -c4-`
614 LOGS_DIRECTORY="$LTPROOT/results"
615 export TEST_OUTPUT_DIRECTORY="$LTPROOT/output"
616 export TEST_LOGS_DIRECTORY=$LOGS_DIRECTORY
617 echo "Generating HTML Output.....!!"
618 ( perl $LTPROOT/tools/genhtml.pl $LTPROOT/tools/html_report_header.txt test_start test_end test_output execution_status $OUTPUT_DIRECTORY > $HTMLFILE; )
619 echo "Generated HTML Output.....!!"
620 echo "Location: $HTMLFILE";
621
622 fi
623
plars4a120e82004-09-02 18:56:06 +0000624 [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test end time: $(date)" ; }
625
subrata_modake099b2a2007-10-29 12:22:01 +0000626 [ "$GENLOAD" -eq 1 ] && { killall -9 genload >/dev/null 2>&1; }
627 [ "$NETPIPE" -eq 1 ] && { killall -9 NPtcp >/dev/null 2>&1; }
plars4a120e82004-09-02 18:56:06 +0000628
subrata_modak5d7deea2007-09-15 13:51:36 +0000629 [ "$ALT_DIR_OUT" -eq 1 ] || [ "$ALT_DIR_RES" -eq 1 ] && \
plars4a120e82004-09-02 18:56:06 +0000630 {
631 cat <<-EOF >&1
632
633 ###############################################################"
634
635 Done executing testcases."
subrata_modak6838ec32007-09-14 10:10:12 +0000636 log result(s) is in $LTPROOT/results directory"
637 output/failed result(s) in $LTPROOT/output directory [If you did not provide Absolute Path]
mreed1091696422006-05-03 19:07:22 +0000638 LTP Version: $version_date
plars4a120e82004-09-02 18:56:06 +0000639 ###############################################################"
640
641 EOF
642 }
643 exit $VALUE
644}
645
646cleanup()
647{
648 rm -rf ${TMP}
649}
650
651trap "cleanup" 0
652setup
653main "$@"