blob: d30014afa497767ba6efb13f5c5a0a3669afa701 [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
robbiew797ab8c2003-02-04 21:04:14 +000078 -c 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
125 while getopts cd:f:hi:l:m:Nno:pqr:t:x: arg
126 do case $arg in
127 c)
plarsd8da48a2004-05-14 19:24:02 +0000128 $LTPROOT/testcases/bin/genload --cpu 1 >/dev/null 2>&1 &
iyermanoj1d9a9632003-10-07 17:17:00 +0000129 GENLOAD=1 ;;
130
131 d) # append $$ to TMP, as it is recursively
iyermanoj1e45bef2003-01-26 20:38:45 +0000132 # removed at end of script.
robbiew8cf59342003-08-12 21:14:53 +0000133 TMPBASE=$OPTARG
134 TMP="${TMPBASE}/runalltests-$$";;
iyermanoj1d9a9632003-10-07 17:17:00 +0000135 f) # Execute user defined set of testcases.
136 CMDFILE=$OPTARG;;
iyermanoj1e45bef2003-01-26 20:38:45 +0000137
iyermanoj1d9a9632003-10-07 17:17:00 +0000138 h) usage;;
139
140 i)
141 BYTESIZE=$(($OPTARG * 1024 * 1024))
plarsd8da48a2004-05-14 19:24:02 +0000142 $LTPROOT/testcases/bin/genload --io 1 >/dev/null 2>&1 &
143 $LTPROOT/testcases/bin/genload --hdd 0 --hdd-bytes $BYTESIZE \
iyermanoj1d9a9632003-10-07 17:17:00 +0000144 >/dev/null 2>&1 &
145 GENLOAD=1 ;;
146
147 l)
iyermanoj7a302092003-10-31 07:28:14 +0000148
plars81194652003-12-30 19:57:47 +0000149 echo "INFO: creating $LTPROOT/results directory"
iyermanoj7a302092003-10-31 07:28:14 +0000150 [ ! -d $LTPROOT/results ] && \
151 {
152 mkdir -p $LTPROOT/results || \
153 {
154 echo "ERROR: failed to create $LTPROOT/results"
155 exit 1
iyermanoj1d9a9632003-10-07 17:17:00 +0000156 }
iyermanoj7a302092003-10-31 07:28:14 +0000157 }
158 case $OPTARG in
plars81194652003-12-30 19:57:47 +0000159 /*)
160 LOGFILE="-l $OPTARG" ;;
iyermanoj7a302092003-10-31 07:28:14 +0000161 *)
iyermanoj1d9a9632003-10-07 17:17:00 +0000162 LOGFILE="-l $LTPROOT/results/$OPTARG"
163 ALT_DIR=1 ;;
164 esac ;;
165
166 m)
167 MEMSIZE=$(($OPTARG * 1024 * 1024))
plarsd8da48a2004-05-14 19:24:02 +0000168 $LTPROOT/testcases/bin/genload --vm 0 --vm-bytes $MEMSIZE \
iyermanoj1d9a9632003-10-07 17:17:00 +0000169 >/dev/null 2>&1 &
170 GENLOAD=1;;
171
172 N) RUN_NETEST=1;;
173
174 n)
plarsae2dd102003-12-30 21:12:27 +0000175 $LTPROOT/testcases/bin/netpipe.sh
iyermanoj1d9a9632003-10-07 17:17:00 +0000176 NETPIPE=1;;
177
178 o) OUTPUTFILE="-o $OPTARG" ;;
179
180 p) PRETTY_PRT=" -p ";;
181
182 q) QUIET_MODE=" -q ";;
183
184 r) LTPROOT=$OPTARG;;
185
186 t) # In case you want to specify the time
iyermanoj1e45bef2003-01-26 20:38:45 +0000187 # to run from the command line
188 # (2m = two minutes, 2h = two hours, etc)
iyermanoj1d9a9632003-10-07 17:17:00 +0000189 DURATION="-t $OPTARG" ;;
190
191 x) # number of ltp's to run
192 cat <<-EOF >&1
193 WARNING: The use of -x can cause unpredictable failures, as a
194 result of concurrently running multiple tests designed
195 to be ran exclusively.
196 Pausing for 10 seconds..."
197 EOF
198 sleep 10
199 INSTANCES="-x $OPTARG -O ${TMP}";;
200
201 \?) usage;;
202 esac
203 done
204
205 mkdir -p $TMP || \
206 {
207 echo "FATAL: Unable to make temporaty directory $TMP"
208 exit 1
209 }
210
211 cd $TMP || \
212 {
213 echo "could not cd ${TMP} ... exiting"
214 exit 1
215 }
216
iyermanoj7a302092003-10-31 07:28:14 +0000217 [ "$RUN_NETEST" -eq 1 ] && \
iyermanoj1d9a9632003-10-07 17:17:00 +0000218 {
iyermanoj7a302092003-10-31 07:28:14 +0000219 [ -z "$RHOST" ] || [ -z "$PASSWD" ] && \
iyermanoj1d9a9632003-10-07 17:17:00 +0000220 {
iyermanoj7a302092003-10-31 07:28:14 +0000221 [ -z "$RHOST" ] && \
iyermanoj1d9a9632003-10-07 17:17:00 +0000222 {
223 echo \
224 "INFO: Enter RHOST = 'name of the remote host machine'"
225 echo -n "-> "
226 read RHOST
227 }
iyermanoj0ceb9482002-12-15 22:49:34 +0000228
iyermanoj7a302092003-10-31 07:28:14 +0000229 [ -z "$PASSWD" ] && \
iyermanoj1d9a9632003-10-07 17:17:00 +0000230 {
231 echo " "
232 echo \
233 "INFO: Enter PASSWD = 'root passwd of the remote host machine'"
234 echo -n "-> "
235 read PASSWD
236 }
237 export RHOST=$RHOST
238 export PASSWD=$PASSWD
239 echo "WARNING: security of $RHOST may be compromised"
240 }
241 }
242
243 # If user does not provide a command file select a default set of testcases
244 # to execute.
iyermanoj7a302092003-10-31 07:28:14 +0000245 if [ -z "$CMDFILE" ]
iyermanoj1d9a9632003-10-07 17:17:00 +0000246 then
247 cat <<-EOF >&1
iyermanoj0ceb9482002-12-15 22:49:34 +0000248
iyermanoj1d9a9632003-10-07 17:17:00 +0000249 INFO: no command files were provided, using default,
250 system calls, memory management, IPC, scheduler
251 direct io, file system, math and pty tests will
252 now be executed
253
254 EOF
plarsd05638c2002-09-09 18:30:48 +0000255
iyermanoj1d9a9632003-10-07 17:17:00 +0000256 for SCENFILES in ${LTPROOT}/runtest/syscalls ${LTPROOT}/runtest/fs \
257 ${LTPROOT}/runtest/fsx ${LTPROOT}/runtest/dio \
258 ${LTPROOT}/runtest/mm ${LTPROOT}/runtest/ipc \
259 ${LTPROOT}/runtest/sched ${LTPROOT}/runtest/math \
robbiew24660052004-03-18 16:38:58 +0000260 ${LTPROOT}/runtest/nptl ${LTPROOT}/runtest/pty
iyermanoj1d9a9632003-10-07 17:17:00 +0000261 do
iyermanoj7a302092003-10-31 07:28:14 +0000262 [ -a "$SCENFILES" ] || \
iyermanoj1d9a9632003-10-07 17:17:00 +0000263 {
264 echo "FATAL: missing scenario file $SCENFILES"
265 exit 1
266 }
robbiew8cf59342003-08-12 21:14:53 +0000267
iyermanoj1d9a9632003-10-07 17:17:00 +0000268 cat $SCENFILES >> ${TMP}/alltests || \
269 {
270 echo "FATAL: unable to create command file"
271 exit 1
272 }
273 done
274 else
275 cat $CMDFILE > ${TMP}/alltests || \
276 {
277 echo "FATAL: Unable to create command file"
278 exit 1
279 }
280 fi
281
iyermanoj7a302092003-10-31 07:28:14 +0000282 [ "$RUN_NETEST" -eq 1 ] && \
iyermanoj1d9a9632003-10-07 17:17:00 +0000283 {
284 for SCENFILES in ${LTPROOT}/runtest/tcp_cmds \
285 ${LTPROOT}/runtest/multicast \
286 ${LTPROOT}/runtest/rpc \
287 ${LTPROOT}/runtest/nfs
288 do
iyermanoj7a302092003-10-31 07:28:14 +0000289 [ -a "$SCENFILES" ] || \
iyermanoj1d9a9632003-10-07 17:17:00 +0000290 {
291 echo "FATAL: missing scenario file $SCENFILES"
292 exit 1
293 }
294
295 cat $SCENFILES >> ${TMP}/alltests || \
296 {
297 echo "FATAL: unable to create command file"
298 exit 1
299 }
300 done
301 }
302
303 # The fsx-linux tests use the SCRATCHDEV environment variable as a location
304 # that can be reformatted and run on. Set SCRATCHDEV if you want to run
305 # these tests. As a safeguard, this is disabled.
306 unset SCRATCHDEV
307 [ -n "$SCRATCHDEV" ] && \
308 {
309 cat ${LTPROOT}/runtest/fsx >> ${TMP}/alltests ||
310 {
311 echo "FATAL: unable to create fsx-linux tests command file"
312 exit 1
313 }
314 }
315
316 # check for required users and groups
317 ${LTPROOT}/IDcheck.sh &>/dev/null || \
318 {
319 echo "WARNING: required users and groups not present"
320 echo "WARNING: some test cases may fail"
321 }
322
323 # display versions of installed software
iyermanoj7a302092003-10-31 07:28:14 +0000324 [ -z "$QUIET_MODE" ] && \
iyermanoj1d9a9632003-10-07 17:17:00 +0000325 {
326 ${LTPROOT}/ver_linux || \
327 {
328 echo "WARNING: unable to display versions of software installed"
329 exit 1
330 }
331 }
robbiew8cf59342003-08-12 21:14:53 +0000332
iyermanoj7a302092003-10-31 07:28:14 +0000333 [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test start time: $(date)" ; }
iyermanoj1d9a9632003-10-07 17:17:00 +0000334 ${LTPROOT}/pan/pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ \
335 -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE
336
337 if [ $? -eq 0 ]; then
338 echo "INFO: pan reported all tests PASS"
robbiew2e27e832004-04-20 15:30:27 +0000339 VALUE=0
iyermanoj1d9a9632003-10-07 17:17:00 +0000340 else
341 echo "INFO: pan reported some tests FAIL"
robbiew2e27e832004-04-20 15:30:27 +0000342 VALUE=1
iyermanoj1d9a9632003-10-07 17:17:00 +0000343 fi
iyermanoj7a302092003-10-31 07:28:14 +0000344 [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test end time: $(date)" ; }
iyermanoj1d9a9632003-10-07 17:17:00 +0000345
iyermanoj7a302092003-10-31 07:28:14 +0000346 [ "$GENLOAD" -eq 1 ] && { killall -9 genload ; }
347 [ "$NETPIPE" -eq 1 ] && { killall -9 NPtcp ; }
iyermanoj1d9a9632003-10-07 17:17:00 +0000348
iyermanoj7a302092003-10-31 07:28:14 +0000349 [ "$ALT_DIR" -eq 1 ] && \
iyermanoj1d9a9632003-10-07 17:17:00 +0000350 {
351 cat <<-EOF >&1
352
353 ###############################################################"
354
355 Done executing testcases."
356 result log is in the $LTPROOT/results directory"
357
358 ###############################################################"
359
360 EOF
361 }
robbiew2e27e832004-04-20 15:30:27 +0000362 exit $VALUE
iyermanoj1d9a9632003-10-07 17:17:00 +0000363}
alaffin802d3e32000-08-23 20:04:23 +0000364
iyermanoj1d9a9632003-10-07 17:17:00 +0000365cleanup()
366{
367 rm -rf ${TMP}
368}
alaffin879684a2000-09-20 18:41:17 +0000369
iyermanoj1d9a9632003-10-07 17:17:00 +0000370trap "cleanup" 0
371setup
372main "$@"