blob: d326b673dcca934af0580d67d7e15b91d1fed5e1 [file] [log] [blame]
alaffin802d3e32000-08-23 20:04:23 +00001#!/bin/sh
iyermanoj1d9a9632003-10-07 17:17:00 +00002################################################################################
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: runalltests.sh
22#
iyermanoj7a302092003-10-31 07:28:14 +000023# Description: This script can be used to run the testcase in the LTP suite,
iyermanoj1d9a9632003-10-07 17:17:00 +000024# by default it does not run all the testcases like the name
25# suggestes but all the tests can be run by using various
26# options that the script provides.
27#
28# Authors: Manoj Iyer - manjo@mail.utexas.edu
29# Robbe Williamson - robbiew@us.ibm.com
30#
31# History: Oct 07 2003 - Modified - Manoj Iyer
32# - use functions
33# - clean up on script exit
34# - error checking etc.
35#
iyermanoj7a302092003-10-31 07:28:14 +000036# Oct 08 2003 - Modified - Manoj Iyer
37# - fixed bug in creating results directory
38# - all checks should be enlclosed in " " to avoid bash error
39# - exit with error if pan is not found in pan directory
robbiew23796112003-02-05 16:28:37 +000040
alaffin802d3e32000-08-23 20:04:23 +000041
iyermanoj1d9a9632003-10-07 17:17:00 +000042setup()
43{
44 cd `dirname $0` || \
45 {
46 echo "FATAL: unable to change directory to $(dirname $0)"
47 exit 1
48 }
49 export LTPROOT=${PWD}
50 export TMPBASE="/tmp"
51 export TMP="${TMPBASE}/runalltests-$$"
52 export PATH="${PATH}:${LTPROOT}/testcases/bin"
martinjnfef097c2002-07-10 14:08:24 +000053
iyermanoj7a302092003-10-31 07:28:14 +000054 [ -d $LTPROOT/testcases/bin ] ||
iyermanoj1d9a9632003-10-07 17:17:00 +000055 {
56 echo "FATAL: Test suite not installed correctly"
57 echo "INFO: as root user type 'make ; make install'"
58 exit 1
59 }
iyermanoj7a302092003-10-31 07:28:14 +000060
61 [ -e $LTPROOT/pan/pan ] ||
62 {
63 echo "FATAL: Test suite driver 'pan' not found"
64 echo "INFO: as root user type 'make ; make install'"
65 exit 1
66 }
iyermanoj1d9a9632003-10-07 17:17:00 +000067}
68
alaffin802d3e32000-08-23 20:04:23 +000069
plarsd05638c2002-09-09 18:30:48 +000070usage()
71{
iyermanoj1d9a9632003-10-07 17:17:00 +000072 cat <<-EOF >&2
73
74 usage: ./${0##*/} -c [-d TMPDIR] [-f CMDFILE ] [-i # (in Mb)]
75 [ -l LOGFILE ] [ -o OUTPUTFILE ] [ -m # (in Mb)] -N -n -q
76 [ -r LTPROOT ] [ -t DURATION ] [ -x INSTANCES ]
iyermanoj0ceb9482002-12-15 22:49:34 +000077
plars392a4ae2004-05-14 19:44:46 +000078 -c NUM_PROCS Run LTP under additional background CPU load.
iyermanoj1d9a9632003-10-07 17:17:00 +000079 -d TMPDIR Directory where temporary files will be created.
80 -f CMDFILE Execute user defined list of testcases.
iyermanoj99d55702003-01-29 22:36:21 +000081 -h Help. Prints all available options.
iyermanoj1d9a9632003-10-07 17:17:00 +000082 -i # (in Mb) Run LTP with a _min_ IO load of # Mb in background.
83 -l LOGFILE Log results of test in a logfile.
84 -m # (in Mb) Run LTP with a _min_ memory load of # Mb in background.
robbiew23796112003-02-05 16:28:37 +000085 -N Run all the networking tests.
robbiew23796112003-02-05 16:28:37 +000086 -n Run LTP with network traffic in background.
iyermanoj1d9a9632003-10-07 17:17:00 +000087 -o OUTPUTFILE Redirect test output to a file.
iyermanoj6714bb12003-01-28 20:08:44 +000088 -p Human readable format logfiles.
iyermanoj1e77a292003-01-30 06:29:46 +000089 -q Print less verbose output to screen.
iyermanoj1d9a9632003-10-07 17:17:00 +000090 -r LTPROOT Fully qualified path where testsuite is installed.
91 -t DURATION Execute the testsuite for given duration. Examples:
robbiew458cc812003-03-25 17:00:24 +000092 -t 60s = 60 seconds
93 -t 45m = 45 minutes
94 -t 24h = 24 hours
95 -t 2d = 2 days
96
iyermanoj1d9a9632003-10-07 17:17:00 +000097 -x INSTANCES Run multiple instances of this testsuite.
plarsd05638c2002-09-09 18:30:48 +000098
robbiew797ab8c2003-02-04 21:04:14 +000099 example: ./${0##*/} -i 1024 -m 128 -p -q -l /tmp/resultlog.$$ -d ${PWD}
iyermanojb299a832003-03-27 09:21:33 +0000100
iyermanoj1d9a9632003-10-07 17:17:00 +0000101 NOTE: If you do not wish to learn these options use the
102 "runltp" program instead.
103
104 EOF
105exit 0
plarsd05638c2002-09-09 18:30:48 +0000106}
107
iyermanoj1d9a9632003-10-07 17:17:00 +0000108
109main()
110{
111 local CMDFILE=""
112 local PRETTY_PRT=""
113 local ALT_DIR=0
114 local RUN_NETEST=0
115 local QUIET_MODE=""
116 local NETPIPE=0
117 local GENLOAD=0
118 local MEMSIZE=0
robbiewe95f7412004-01-13 15:59:38 +0000119 local DURATION=""
iyermanoj1d9a9632003-10-07 17:17:00 +0000120 local BYTESIZE=0
121 local LOGFILE=""
122 local SCENFILES=""
123 local PRETTY_PRT=""
124
plars11e7ad92004-05-14 20:05:54 +0000125 while getopts c:d:f:hi:l:m:Nno:pqr:t:x: arg
iyermanoj1d9a9632003-10-07 17:17:00 +0000126 do case $arg in
127 c)
plars11e7ad92004-05-14 20:05:54 +0000128 NUM_PROCS=$(($OPTARG))
plars392a4ae2004-05-14 19:44:46 +0000129 $LTPROOT/testcases/bin/genload --cpu $NUM_PROCS >/dev/null 2>&1 &
iyermanoj1d9a9632003-10-07 17:17:00 +0000130 GENLOAD=1 ;;
131
132 d) # append $$ to TMP, as it is recursively
iyermanoj1e45bef2003-01-26 20:38:45 +0000133 # removed at end of script.
robbiew8cf59342003-08-12 21:14:53 +0000134 TMPBASE=$OPTARG
135 TMP="${TMPBASE}/runalltests-$$";;
iyermanoj1d9a9632003-10-07 17:17:00 +0000136 f) # Execute user defined set of testcases.
137 CMDFILE=$OPTARG;;
iyermanoj1e45bef2003-01-26 20:38:45 +0000138
iyermanoj1d9a9632003-10-07 17:17:00 +0000139 h) usage;;
140
141 i)
142 BYTESIZE=$(($OPTARG * 1024 * 1024))
plarsd8da48a2004-05-14 19:24:02 +0000143 $LTPROOT/testcases/bin/genload --io 1 >/dev/null 2>&1 &
144 $LTPROOT/testcases/bin/genload --hdd 0 --hdd-bytes $BYTESIZE \
iyermanoj1d9a9632003-10-07 17:17:00 +0000145 >/dev/null 2>&1 &
146 GENLOAD=1 ;;
147
148 l)
iyermanoj7a302092003-10-31 07:28:14 +0000149
plars81194652003-12-30 19:57:47 +0000150 echo "INFO: creating $LTPROOT/results directory"
iyermanoj7a302092003-10-31 07:28:14 +0000151 [ ! -d $LTPROOT/results ] && \
152 {
153 mkdir -p $LTPROOT/results || \
154 {
155 echo "ERROR: failed to create $LTPROOT/results"
156 exit 1
iyermanoj1d9a9632003-10-07 17:17:00 +0000157 }
iyermanoj7a302092003-10-31 07:28:14 +0000158 }
159 case $OPTARG in
plars81194652003-12-30 19:57:47 +0000160 /*)
161 LOGFILE="-l $OPTARG" ;;
iyermanoj7a302092003-10-31 07:28:14 +0000162 *)
iyermanoj1d9a9632003-10-07 17:17:00 +0000163 LOGFILE="-l $LTPROOT/results/$OPTARG"
164 ALT_DIR=1 ;;
165 esac ;;
166
167 m)
168 MEMSIZE=$(($OPTARG * 1024 * 1024))
plarsd8da48a2004-05-14 19:24:02 +0000169 $LTPROOT/testcases/bin/genload --vm 0 --vm-bytes $MEMSIZE \
iyermanoj1d9a9632003-10-07 17:17:00 +0000170 >/dev/null 2>&1 &
171 GENLOAD=1;;
172
173 N) RUN_NETEST=1;;
174
175 n)
plarsae2dd102003-12-30 21:12:27 +0000176 $LTPROOT/testcases/bin/netpipe.sh
iyermanoj1d9a9632003-10-07 17:17:00 +0000177 NETPIPE=1;;
178
179 o) OUTPUTFILE="-o $OPTARG" ;;
180
181 p) PRETTY_PRT=" -p ";;
182
183 q) QUIET_MODE=" -q ";;
184
185 r) LTPROOT=$OPTARG;;
186
187 t) # In case you want to specify the time
iyermanoj1e45bef2003-01-26 20:38:45 +0000188 # to run from the command line
189 # (2m = two minutes, 2h = two hours, etc)
iyermanoj1d9a9632003-10-07 17:17:00 +0000190 DURATION="-t $OPTARG" ;;
191
192 x) # number of ltp's to run
193 cat <<-EOF >&1
194 WARNING: The use of -x can cause unpredictable failures, as a
195 result of concurrently running multiple tests designed
196 to be ran exclusively.
197 Pausing for 10 seconds..."
198 EOF
199 sleep 10
200 INSTANCES="-x $OPTARG -O ${TMP}";;
201
202 \?) usage;;
203 esac
204 done
205
206 mkdir -p $TMP || \
207 {
208 echo "FATAL: Unable to make temporaty directory $TMP"
209 exit 1
210 }
211
212 cd $TMP || \
213 {
214 echo "could not cd ${TMP} ... exiting"
215 exit 1
216 }
217
iyermanoj7a302092003-10-31 07:28:14 +0000218 [ "$RUN_NETEST" -eq 1 ] && \
iyermanoj1d9a9632003-10-07 17:17:00 +0000219 {
iyermanoj7a302092003-10-31 07:28:14 +0000220 [ -z "$RHOST" ] || [ -z "$PASSWD" ] && \
iyermanoj1d9a9632003-10-07 17:17:00 +0000221 {
iyermanoj7a302092003-10-31 07:28:14 +0000222 [ -z "$RHOST" ] && \
iyermanoj1d9a9632003-10-07 17:17:00 +0000223 {
224 echo \
225 "INFO: Enter RHOST = 'name of the remote host machine'"
226 echo -n "-> "
227 read RHOST
228 }
iyermanoj0ceb9482002-12-15 22:49:34 +0000229
iyermanoj7a302092003-10-31 07:28:14 +0000230 [ -z "$PASSWD" ] && \
iyermanoj1d9a9632003-10-07 17:17:00 +0000231 {
232 echo " "
233 echo \
234 "INFO: Enter PASSWD = 'root passwd of the remote host machine'"
235 echo -n "-> "
236 read PASSWD
237 }
238 export RHOST=$RHOST
239 export PASSWD=$PASSWD
240 echo "WARNING: security of $RHOST may be compromised"
241 }
242 }
243
244 # If user does not provide a command file select a default set of testcases
245 # to execute.
iyermanoj7a302092003-10-31 07:28:14 +0000246 if [ -z "$CMDFILE" ]
iyermanoj1d9a9632003-10-07 17:17:00 +0000247 then
248 cat <<-EOF >&1
iyermanoj0ceb9482002-12-15 22:49:34 +0000249
iyermanoj1d9a9632003-10-07 17:17:00 +0000250 INFO: no command files were provided, using default,
251 system calls, memory management, IPC, scheduler
252 direct io, file system, math and pty tests will
253 now be executed
254
255 EOF
plarsd05638c2002-09-09 18:30:48 +0000256
iyermanoj1d9a9632003-10-07 17:17:00 +0000257 for SCENFILES in ${LTPROOT}/runtest/syscalls ${LTPROOT}/runtest/fs \
258 ${LTPROOT}/runtest/fsx ${LTPROOT}/runtest/dio \
259 ${LTPROOT}/runtest/mm ${LTPROOT}/runtest/ipc \
260 ${LTPROOT}/runtest/sched ${LTPROOT}/runtest/math \
robbiew24660052004-03-18 16:38:58 +0000261 ${LTPROOT}/runtest/nptl ${LTPROOT}/runtest/pty
iyermanoj1d9a9632003-10-07 17:17:00 +0000262 do
iyermanoj7a302092003-10-31 07:28:14 +0000263 [ -a "$SCENFILES" ] || \
iyermanoj1d9a9632003-10-07 17:17:00 +0000264 {
265 echo "FATAL: missing scenario file $SCENFILES"
266 exit 1
267 }
robbiew8cf59342003-08-12 21:14:53 +0000268
iyermanoj1d9a9632003-10-07 17:17:00 +0000269 cat $SCENFILES >> ${TMP}/alltests || \
270 {
271 echo "FATAL: unable to create command file"
272 exit 1
273 }
274 done
275 else
276 cat $CMDFILE > ${TMP}/alltests || \
277 {
278 echo "FATAL: Unable to create command file"
279 exit 1
280 }
281 fi
282
iyermanoj7a302092003-10-31 07:28:14 +0000283 [ "$RUN_NETEST" -eq 1 ] && \
iyermanoj1d9a9632003-10-07 17:17:00 +0000284 {
285 for SCENFILES in ${LTPROOT}/runtest/tcp_cmds \
286 ${LTPROOT}/runtest/multicast \
287 ${LTPROOT}/runtest/rpc \
288 ${LTPROOT}/runtest/nfs
289 do
iyermanoj7a302092003-10-31 07:28:14 +0000290 [ -a "$SCENFILES" ] || \
iyermanoj1d9a9632003-10-07 17:17:00 +0000291 {
292 echo "FATAL: missing scenario file $SCENFILES"
293 exit 1
294 }
295
296 cat $SCENFILES >> ${TMP}/alltests || \
297 {
298 echo "FATAL: unable to create command file"
299 exit 1
300 }
301 done
302 }
303
304 # The fsx-linux tests use the SCRATCHDEV environment variable as a location
305 # that can be reformatted and run on. Set SCRATCHDEV if you want to run
306 # these tests. As a safeguard, this is disabled.
307 unset SCRATCHDEV
308 [ -n "$SCRATCHDEV" ] && \
309 {
310 cat ${LTPROOT}/runtest/fsx >> ${TMP}/alltests ||
311 {
312 echo "FATAL: unable to create fsx-linux tests command file"
313 exit 1
314 }
315 }
316
317 # check for required users and groups
318 ${LTPROOT}/IDcheck.sh &>/dev/null || \
319 {
320 echo "WARNING: required users and groups not present"
321 echo "WARNING: some test cases may fail"
322 }
323
324 # display versions of installed software
iyermanoj7a302092003-10-31 07:28:14 +0000325 [ -z "$QUIET_MODE" ] && \
iyermanoj1d9a9632003-10-07 17:17:00 +0000326 {
327 ${LTPROOT}/ver_linux || \
328 {
329 echo "WARNING: unable to display versions of software installed"
330 exit 1
331 }
332 }
robbiew8cf59342003-08-12 21:14:53 +0000333
iyermanoj7a302092003-10-31 07:28:14 +0000334 [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test start time: $(date)" ; }
iyermanoj1d9a9632003-10-07 17:17:00 +0000335 ${LTPROOT}/pan/pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ \
336 -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE
337
338 if [ $? -eq 0 ]; then
339 echo "INFO: pan reported all tests PASS"
robbiew2e27e832004-04-20 15:30:27 +0000340 VALUE=0
iyermanoj1d9a9632003-10-07 17:17:00 +0000341 else
342 echo "INFO: pan reported some tests FAIL"
robbiew2e27e832004-04-20 15:30:27 +0000343 VALUE=1
iyermanoj1d9a9632003-10-07 17:17:00 +0000344 fi
iyermanoj7a302092003-10-31 07:28:14 +0000345 [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test end time: $(date)" ; }
iyermanoj1d9a9632003-10-07 17:17:00 +0000346
iyermanoj7a302092003-10-31 07:28:14 +0000347 [ "$GENLOAD" -eq 1 ] && { killall -9 genload ; }
348 [ "$NETPIPE" -eq 1 ] && { killall -9 NPtcp ; }
iyermanoj1d9a9632003-10-07 17:17:00 +0000349
iyermanoj7a302092003-10-31 07:28:14 +0000350 [ "$ALT_DIR" -eq 1 ] && \
iyermanoj1d9a9632003-10-07 17:17:00 +0000351 {
352 cat <<-EOF >&1
353
354 ###############################################################"
355
356 Done executing testcases."
357 result log is in the $LTPROOT/results directory"
358
359 ###############################################################"
360
361 EOF
362 }
robbiew2e27e832004-04-20 15:30:27 +0000363 exit $VALUE
iyermanoj1d9a9632003-10-07 17:17:00 +0000364}
alaffin802d3e32000-08-23 20:04:23 +0000365
iyermanoj1d9a9632003-10-07 17:17:00 +0000366cleanup()
367{
368 rm -rf ${TMP}
369}
alaffin879684a2000-09-20 18:41:17 +0000370
iyermanoj1d9a9632003-10-07 17:17:00 +0000371trap "cleanup" 0
372setup
373main "$@"