blob: 8edae47fe3f7d2e093abe5c93a3b484de751af09 [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
35# - all checks should be enlclosed in " " to avoid bash error
36# - exit with error if pan is not found in pan directory
37
38
39setup()
40{
41 cd `dirname $0` || \
42 {
43 echo "FATAL: unable to change directory to $(dirname $0)"
44 exit 1
45 }
46 export LTPROOT=${PWD}
47 export TMPBASE="/tmp"
48 export TMP="${TMPBASE}/ltp-$$"
49 export PATH="${PATH}:${LTPROOT}/testcases/bin"
50
51 [ -d $LTPROOT/testcases/bin ] ||
52 {
53 echo "FATAL: Test suite not installed correctly"
54 echo "INFO: as root user type 'make ; make install'"
55 exit 1
56 }
57
58 [ -e $LTPROOT/pan/pan ] ||
59 {
60 echo "FATAL: Test suite driver 'pan' not found"
61 echo "INFO: as root user type 'make ; make install'"
62 exit 1
63 }
64}
65
66
67usage()
68{
69 cat <<-EOF >&2
70
71 usage: ./${0##*/} -c [-d TMPDIR] [-f CMDFILE ] [-i # (in Mb)]
72 [ -l LOGFILE ] [ -o OUTPUTFILE ] [ -m # (in Mb)] -N -n -q
73 [ -r LTPROOT ] [ -t DURATION ] [ -x INSTANCES ]
74
75 -c NUM_PROCS Run LTP under additional background CPU load.
76 -d TMPDIR Directory where temporary files will be created.
77 -f CMDFILE Execute user defined list of testcases.
78 -h Help. Prints all available options.
79 -i # (in Mb) Run LTP with a _min_ IO load of # Mb in background.
80 -l LOGFILE Log results of test in a logfile.
81 -m # (in Mb) Run LTP with a _min_ memory load of # Mb in background.
82 -N Run all the networking tests.
83 -n Run LTP with network traffic in background.
84 -o OUTPUTFILE Redirect test output to a file.
85 -p Human readable format logfiles.
86 -q Print less verbose output to screen.
87 -r LTPROOT Fully qualified path where testsuite is installed.
88 -t DURATION Execute the testsuite for given duration. Examples:
89 -t 60s = 60 seconds
90 -t 45m = 45 minutes
91 -t 24h = 24 hours
92 -t 2d = 2 days
93
94 -x INSTANCES Run multiple instances of this testsuite.
95
96 example: ./${0##*/} -i 1024 -m 128 -p -q -l /tmp/resultlog.$$ -d ${PWD}
97
98 NOTE: If you do not wish to learn these options use the
99 "runltp" program instead.
100
101 EOF
102exit 0
103}
104
105
106main()
107{
108 local CMDFILE=""
109 local PRETTY_PRT=""
110 local ALT_DIR=0
111 local RUN_NETEST=0
112 local QUIET_MODE=""
113 local NETPIPE=0
114 local GENLOAD=0
115 local MEMSIZE=0
116 local DURATION=""
117 local BYTESIZE=0
118 local LOGFILE=""
119 local SCENFILES=""
120 local PRETTY_PRT=""
121
122 while getopts c:d:f:hi:l:m:Nno:pqr:t:x: arg
123 do case $arg in
124 c)
125 NUM_PROCS=$(($OPTARG))
126 $LTPROOT/testcases/bin/genload --cpu $NUM_PROCS >/dev/null 2>&1 &
127 GENLOAD=1 ;;
128
129 d) # append $$ to TMP, as it is recursively
130 # removed at end of script.
131 TMPBASE=$OPTARG
132 TMP="${TMPBASE}/ltp-$$";;
133 f) # Execute user defined set of testcases.
134 CMDFILE=$OPTARG;;
135
136 h) usage;;
137
138 i)
139 BYTESIZE=$(($OPTARG * 1024 * 1024))
140 $LTPROOT/testcases/bin/genload --io 1 >/dev/null 2>&1 &
141 $LTPROOT/testcases/bin/genload --hdd 0 --hdd-bytes $BYTESIZE \
142 >/dev/null 2>&1 &
143 GENLOAD=1 ;;
144
145 l)
146
147 echo "INFO: creating $LTPROOT/results directory"
148 [ ! -d $LTPROOT/results ] && \
149 {
150 mkdir -p $LTPROOT/results || \
151 {
152 echo "ERROR: failed to create $LTPROOT/results"
153 exit 1
154 }
155 }
156 case $OPTARG in
157 /*)
158 LOGFILE="-l $OPTARG" ;;
159 *)
160 LOGFILE="-l $LTPROOT/results/$OPTARG"
161 ALT_DIR=1 ;;
162 esac ;;
163
164 m)
165 MEMSIZE=$(($OPTARG * 1024 * 1024))
166 $LTPROOT/testcases/bin/genload --vm 0 --vm-bytes $MEMSIZE \
167 >/dev/null 2>&1 &
168 GENLOAD=1;;
169
170 N) RUN_NETEST=1;;
171
172 n)
173 $LTPROOT/testcases/bin/netpipe.sh
174 NETPIPE=1;;
175
176 o) OUTPUTFILE="-o $OPTARG" ;;
177
178 p) PRETTY_PRT=" -p ";;
179
180 q) QUIET_MODE=" -q ";;
181
182 r) LTPROOT=$OPTARG;;
183
184 t) # In case you want to specify the time
185 # to run from the command line
186 # (2m = two minutes, 2h = two hours, etc)
187 DURATION="-t $OPTARG" ;;
188
189 x) # number of ltp's to run
190 cat <<-EOF >&1
191 WARNING: The use of -x can cause unpredictable failures, as a
192 result of concurrently running multiple tests designed
193 to be ran exclusively.
194 Pausing for 10 seconds..."
195 EOF
196 sleep 10
197 INSTANCES="-x $OPTARG -O ${TMP}";;
198
199 \?) usage;;
200 esac
201 done
202
203 mkdir -p $TMP || \
204 {
205 echo "FATAL: Unable to make temporaty directory $TMP"
206 exit 1
207 }
208
209 cd $TMP || \
210 {
211 echo "could not cd ${TMP} ... exiting"
212 exit 1
213 }
214
215 [ "$RUN_NETEST" -eq 1 ] && \
216 {
217 [ -z "$RHOST" ] || [ -z "$PASSWD" ] && \
218 {
219 [ -z "$RHOST" ] && \
220 {
221 echo \
222 "INFO: Enter RHOST = 'name of the remote host machine'"
223 echo -n "-> "
224 read RHOST
225 }
226
227 [ -z "$PASSWD" ] && \
228 {
229 echo " "
230 echo \
231 "INFO: Enter PASSWD = 'root passwd of the remote host machine'"
232 echo -n "-> "
233 read PASSWD
234 }
235 export RHOST=$RHOST
236 export PASSWD=$PASSWD
237 echo "WARNING: security of $RHOST may be compromised"
238 }
239 }
240
241 # If user does not provide a command file select a default set of testcases
242 # to execute.
243 if [ -z "$CMDFILE" ]
244 then
245 cat <<-EOF >&1
246
247 INFO: no command files were provided, using default,
248 system calls, memory management, IPC, scheduler
249 direct io, file system, math and pty tests will
250 now be executed
251
252 EOF
253
254 for SCENFILES in ${LTPROOT}/runtest/syscalls ${LTPROOT}/runtest/fs \
255 ${LTPROOT}/runtest/fsx ${LTPROOT}/runtest/dio \
256 ${LTPROOT}/runtest/mm ${LTPROOT}/runtest/ipc \
257 ${LTPROOT}/runtest/sched ${LTPROOT}/runtest/math \
258 ${LTPROOT}/runtest/nptl ${LTPROOT}/runtest/pty
259 do
260 [ -a "$SCENFILES" ] || \
261 {
262 echo "FATAL: missing scenario file $SCENFILES"
263 exit 1
264 }
265
266 cat $SCENFILES >> ${TMP}/alltests || \
267 {
268 echo "FATAL: unable to create command file"
269 exit 1
270 }
271 done
272 else
273 cat $CMDFILE > ${TMP}/alltests || \
274 {
275 echo "FATAL: Unable to create command file"
276 exit 1
277 }
278 fi
279
280 [ "$RUN_NETEST" -eq 1 ] && \
281 {
282 for SCENFILES in ${LTPROOT}/runtest/tcp_cmds \
283 ${LTPROOT}/runtest/multicast \
284 ${LTPROOT}/runtest/rpc \
285 ${LTPROOT}/runtest/nfs
286 do
287 [ -a "$SCENFILES" ] || \
288 {
289 echo "FATAL: missing scenario file $SCENFILES"
290 exit 1
291 }
292
293 cat $SCENFILES >> ${TMP}/alltests || \
294 {
295 echo "FATAL: unable to create command file"
296 exit 1
297 }
298 done
299 }
300
301 # The fsx-linux tests use the SCRATCHDEV environment variable as a location
302 # that can be reformatted and run on. Set SCRATCHDEV if you want to run
303 # these tests. As a safeguard, this is disabled.
304 unset SCRATCHDEV
305 [ -n "$SCRATCHDEV" ] && \
306 {
307 cat ${LTPROOT}/runtest/fsx >> ${TMP}/alltests ||
308 {
309 echo "FATAL: unable to create fsx-linux tests command file"
310 exit 1
311 }
312 }
313
314 # check for required users and groups
315 ${LTPROOT}/IDcheck.sh &>/dev/null || \
316 {
317 echo "WARNING: required users and groups not present"
318 echo "WARNING: some test cases may fail"
319 }
320
321 # display versions of installed software
322 [ -z "$QUIET_MODE" ] && \
323 {
324 ${LTPROOT}/ver_linux || \
325 {
326 echo "WARNING: unable to display versions of software installed"
327 exit 1
328 }
329 }
330
331 [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test start time: $(date)" ; }
332 ${LTPROOT}/pan/pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ \
333 -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE
334
335 if [ $? -eq 0 ]; then
336 echo "INFO: pan reported all tests PASS"
337 VALUE=0
338 else
339 echo "INFO: pan reported some tests FAIL"
340 VALUE=1
341 fi
342 [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test end time: $(date)" ; }
343
344 [ "$GENLOAD" -eq 1 ] && { killall -9 genload ; }
345 [ "$NETPIPE" -eq 1 ] && { killall -9 NPtcp ; }
346
347 [ "$ALT_DIR" -eq 1 ] && \
348 {
349 cat <<-EOF >&1
350
351 ###############################################################"
352
353 Done executing testcases."
354 result log is in the $LTPROOT/results directory"
355
356 ###############################################################"
357
358 EOF
359 }
360 exit $VALUE
361}
362
363cleanup()
364{
365 rm -rf ${TMP}
366}
367
368trap "cleanup" 0
369setup
370main "$@"