blob: bb8b63d2de4acb3cc13b040c32432fa0e774a108 [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
mreed1091696422006-05-03 19:07:22 +000066version_of_ltp()
67{
68head -n 1 $LTPROOT/ChangeLog
69exit 0
70}
plars4a120e82004-09-02 18:56:06 +000071
72usage()
73{
74 cat <<-EOF >&2
75
76 usage: ./${0##*/} -c [-d TMPDIR] [-f CMDFILE ] [-i # (in Mb)]
77 [ -l LOGFILE ] [ -o OUTPUTFILE ] [ -m # (in Mb)] -N -n -q
robbiew7d43d772005-02-07 20:07:30 +000078 [ -r LTPROOT ] [ -s PATTERN ] [ -t DURATION ] -v [ -x INSTANCES ]
plars4a120e82004-09-02 18:56:06 +000079
80 -c NUM_PROCS Run LTP under additional background CPU load.
81 -d TMPDIR Directory where temporary files will be created.
mreed1091696422006-05-03 19:07:22 +000082 -e Prints the date of the current LTP release
plars4a120e82004-09-02 18:56:06 +000083 -f CMDFILE Execute user defined list of testcases.
84 -h Help. Prints all available options.
85 -i # (in Mb) Run LTP with a _min_ IO load of # Mb in background.
86 -l LOGFILE Log results of test in a logfile.
87 -m # (in Mb) Run LTP with a _min_ memory load of # Mb in background.
88 -N Run all the networking tests.
89 -n Run LTP with network traffic in background.
90 -o OUTPUTFILE Redirect test output to a file.
91 -p Human readable format logfiles.
92 -q Print less verbose output to screen.
93 -r LTPROOT Fully qualified path where testsuite is installed.
robbiew7d43d772005-02-07 20:07:30 +000094 -s PATTERN Only run test cases which match PATTERN.
plars4a120e82004-09-02 18:56:06 +000095 -t DURATION Execute the testsuite for given duration. Examples:
96 -t 60s = 60 seconds
97 -t 45m = 45 minutes
98 -t 24h = 24 hours
99 -t 2d = 2 days
robbiew7d43d772005-02-07 20:07:30 +0000100 -v Print more verbose output to screen.
plars4a120e82004-09-02 18:56:06 +0000101 -x INSTANCES Run multiple instances of this testsuite.
102
103 example: ./${0##*/} -i 1024 -m 128 -p -q -l /tmp/resultlog.$$ -d ${PWD}
104
plars4a120e82004-09-02 18:56:06 +0000105
106 EOF
107exit 0
108}
109
110
111main()
112{
113 local CMDFILE=""
114 local PRETTY_PRT=""
115 local ALT_DIR=0
116 local RUN_NETEST=0
117 local QUIET_MODE=""
robbiew7d43d772005-02-07 20:07:30 +0000118 local VERBOSE_MODE=""
plars4a120e82004-09-02 18:56:06 +0000119 local NETPIPE=0
120 local GENLOAD=0
121 local MEMSIZE=0
122 local DURATION=""
123 local BYTESIZE=0
124 local LOGFILE=""
125 local SCENFILES=""
126 local PRETTY_PRT=""
robbiew7d43d772005-02-07 20:07:30 +0000127 local TAG_RESTRICT_STRING=""
128 local PAN_COMMAND=""
mreed1091696422006-05-03 19:07:22 +0000129 version_date=`head -n 1 $LTPROOT/ChangeLog`
plars4a120e82004-09-02 18:56:06 +0000130
mreed1091696422006-05-03 19:07:22 +0000131 while getopts c:d:f:ehi:l:m:Nno:pqr:s:t:vx: arg
plars4a120e82004-09-02 18:56:06 +0000132 do case $arg in
133 c)
134 NUM_PROCS=$(($OPTARG))
135 $LTPROOT/testcases/bin/genload --cpu $NUM_PROCS >/dev/null 2>&1 &
136 GENLOAD=1 ;;
137
138 d) # append $$ to TMP, as it is recursively
139 # removed at end of script.
140 TMPBASE=$OPTARG
robbiew58247a52005-01-19 18:44:42 +0000141 TMP="${TMPBASE}/ltp-$$"
robbiew538bc1a2005-03-11 19:26:14 +0000142 export TMPDIR="$TMP";;
mreed1091696422006-05-03 19:07:22 +0000143 e) # Print out the version of LTP
144 version_of_ltp
145 ;;
plars4a120e82004-09-02 18:56:06 +0000146 f) # Execute user defined set of testcases.
147 CMDFILE=$OPTARG;;
148
149 h) usage;;
150
151 i)
152 BYTESIZE=$(($OPTARG * 1024 * 1024))
153 $LTPROOT/testcases/bin/genload --io 1 >/dev/null 2>&1 &
154 $LTPROOT/testcases/bin/genload --hdd 0 --hdd-bytes $BYTESIZE \
155 >/dev/null 2>&1 &
156 GENLOAD=1 ;;
157
158 l)
159
160 echo "INFO: creating $LTPROOT/results directory"
161 [ ! -d $LTPROOT/results ] && \
162 {
163 mkdir -p $LTPROOT/results || \
164 {
165 echo "ERROR: failed to create $LTPROOT/results"
166 exit 1
167 }
168 }
169 case $OPTARG in
170 /*)
171 LOGFILE="-l $OPTARG" ;;
172 *)
173 LOGFILE="-l $LTPROOT/results/$OPTARG"
174 ALT_DIR=1 ;;
175 esac ;;
176
177 m)
178 MEMSIZE=$(($OPTARG * 1024 * 1024))
179 $LTPROOT/testcases/bin/genload --vm 0 --vm-bytes $MEMSIZE \
180 >/dev/null 2>&1 &
181 GENLOAD=1;;
182
183 N) RUN_NETEST=1;;
184
185 n)
186 $LTPROOT/testcases/bin/netpipe.sh
187 NETPIPE=1;;
188
189 o) OUTPUTFILE="-o $OPTARG" ;;
190
191 p) PRETTY_PRT=" -p ";;
192
193 q) QUIET_MODE=" -q ";;
194
195 r) LTPROOT=$OPTARG;;
196
robbiew7d43d772005-02-07 20:07:30 +0000197 s) TAG_RESTRICT_STRING=$OPTARG;;
198
plars4a120e82004-09-02 18:56:06 +0000199 t) # In case you want to specify the time
200 # to run from the command line
201 # (2m = two minutes, 2h = two hours, etc)
202 DURATION="-t $OPTARG" ;;
203
robbiew7d43d772005-02-07 20:07:30 +0000204 v) VERBOSE_MODE=1;;
205
plars4a120e82004-09-02 18:56:06 +0000206 x) # number of ltp's to run
207 cat <<-EOF >&1
208 WARNING: The use of -x can cause unpredictable failures, as a
209 result of concurrently running multiple tests designed
210 to be ran exclusively.
211 Pausing for 10 seconds..."
212 EOF
213 sleep 10
214 INSTANCES="-x $OPTARG -O ${TMP}";;
215
216 \?) usage;;
217 esac
218 done
219
robbiew7d43d772005-02-07 20:07:30 +0000220 if [ -n "$TAG_RESTRICT_STRING" ] ; then
221 if [ -n "$CMDFILE" ]; then
222 echo "FATAL -s and -f not supported together"
223 exit 1
224 fi
225 if [ "$RUN_NETEST" -eq 1 ]; then
226 echo "FATAL -s and -N not supported together"
227 exit 1
228 fi
229 fi
230
plars4a120e82004-09-02 18:56:06 +0000231 mkdir -p $TMP || \
232 {
robbiew7d43d772005-02-07 20:07:30 +0000233 echo "FATAL: Unable to make temporary directory $TMP"
plars4a120e82004-09-02 18:56:06 +0000234 exit 1
235 }
236
237 cd $TMP || \
238 {
239 echo "could not cd ${TMP} ... exiting"
240 exit 1
241 }
242
243 [ "$RUN_NETEST" -eq 1 ] && \
244 {
245 [ -z "$RHOST" ] || [ -z "$PASSWD" ] && \
246 {
247 [ -z "$RHOST" ] && \
248 {
249 echo \
250 "INFO: Enter RHOST = 'name of the remote host machine'"
251 echo -n "-> "
252 read RHOST
253 }
254
255 [ -z "$PASSWD" ] && \
256 {
257 echo " "
258 echo \
259 "INFO: Enter PASSWD = 'root passwd of the remote host machine'"
260 echo -n "-> "
261 read PASSWD
262 }
263 export RHOST=$RHOST
264 export PASSWD=$PASSWD
265 echo "WARNING: security of $RHOST may be compromised"
266 }
267 }
268
269 # If user does not provide a command file select a default set of testcases
270 # to execute.
271 if [ -z "$CMDFILE" ]
272 then
273 cat <<-EOF >&1
274
275 INFO: no command files were provided, using default,
276 system calls, memory management, IPC, scheduler
277 direct io, file system, math and pty tests will
278 now be executed
279
280 EOF
281
282 for SCENFILES in ${LTPROOT}/runtest/syscalls ${LTPROOT}/runtest/fs \
283 ${LTPROOT}/runtest/fsx ${LTPROOT}/runtest/dio \
284 ${LTPROOT}/runtest/mm ${LTPROOT}/runtest/ipc \
285 ${LTPROOT}/runtest/sched ${LTPROOT}/runtest/math \
286 ${LTPROOT}/runtest/nptl ${LTPROOT}/runtest/pty
287 do
288 [ -a "$SCENFILES" ] || \
289 {
290 echo "FATAL: missing scenario file $SCENFILES"
291 exit 1
292 }
293
robbiew7d43d772005-02-07 20:07:30 +0000294 if [ -z "$TAG_RESTRICT_STRING" ]
295 then
plars4a120e82004-09-02 18:56:06 +0000296 cat $SCENFILES >> ${TMP}/alltests || \
297 {
298 echo "FATAL: unable to create command file"
299 exit 1
300 }
robbiew7d43d772005-02-07 20:07:30 +0000301 else
302 grep $TAG_RESTRICT_STRING $SCENFILES >> ${TMP}/alltests #Not worth checking return codes for this case
303 fi
plars4a120e82004-09-02 18:56:06 +0000304 done
305 else
plarsdd7b4f62004-09-02 20:42:50 +0000306 [ -f $CMDFILE ] || \
307 CMDFILE="$LTPROOT/runtest/$CMDFILE"
plars4a120e82004-09-02 18:56:06 +0000308 cat $CMDFILE > ${TMP}/alltests || \
309 {
310 echo "FATAL: Unable to create command file"
311 exit 1
312 }
313 fi
314
315 [ "$RUN_NETEST" -eq 1 ] && \
316 {
317 for SCENFILES in ${LTPROOT}/runtest/tcp_cmds \
318 ${LTPROOT}/runtest/multicast \
319 ${LTPROOT}/runtest/rpc \
320 ${LTPROOT}/runtest/nfs
321 do
322 [ -a "$SCENFILES" ] || \
323 {
324 echo "FATAL: missing scenario file $SCENFILES"
325 exit 1
326 }
327
328 cat $SCENFILES >> ${TMP}/alltests || \
329 {
330 echo "FATAL: unable to create command file"
331 exit 1
332 }
333 done
334 }
335
336 # The fsx-linux tests use the SCRATCHDEV environment variable as a location
337 # that can be reformatted and run on. Set SCRATCHDEV if you want to run
338 # these tests. As a safeguard, this is disabled.
339 unset SCRATCHDEV
340 [ -n "$SCRATCHDEV" ] && \
341 {
342 cat ${LTPROOT}/runtest/fsx >> ${TMP}/alltests ||
343 {
344 echo "FATAL: unable to create fsx-linux tests command file"
345 exit 1
346 }
347 }
348
349 # check for required users and groups
350 ${LTPROOT}/IDcheck.sh &>/dev/null || \
351 {
352 echo "WARNING: required users and groups not present"
353 echo "WARNING: some test cases may fail"
354 }
355
robbiew7d43d772005-02-07 20:07:30 +0000356
357
plars4a120e82004-09-02 18:56:06 +0000358 # display versions of installed software
359 [ -z "$QUIET_MODE" ] && \
360 {
361 ${LTPROOT}/ver_linux || \
362 {
363 echo "WARNING: unable to display versions of software installed"
364 exit 1
365 }
366 }
367
368 [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test start time: $(date)" ; }
robbiew7d43d772005-02-07 20:07:30 +0000369 PAN_COMMAND="${LTPROOT}/pan/pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ \
370 -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE"
371 if [ ! -z "$VERBOSE_MODE" ] ; then
372 echo "COMMAND: $PAN_COMMAND"
373 if [ ! -z "$TAG_RESTRICT_STRING" ] ; then
374 echo "INFO: Restricted to $TAG_RESTRICT_STRING"
375 fi
376 fi
377 #$PAN_COMMAND #Duplicated code here, because otherwise if we fail, only "PAN_COMMAND" gets output
plars4a120e82004-09-02 18:56:06 +0000378 ${LTPROOT}/pan/pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ \
379 -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE
380
381 if [ $? -eq 0 ]; then
382 echo "INFO: pan reported all tests PASS"
383 VALUE=0
384 else
385 echo "INFO: pan reported some tests FAIL"
386 VALUE=1
387 fi
mreed1091696422006-05-03 19:07:22 +0000388 echo "LTP Version: $version_date"
389
plars4a120e82004-09-02 18:56:06 +0000390 [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test end time: $(date)" ; }
391
392 [ "$GENLOAD" -eq 1 ] && { killall -9 genload ; }
393 [ "$NETPIPE" -eq 1 ] && { killall -9 NPtcp ; }
394
395 [ "$ALT_DIR" -eq 1 ] && \
396 {
397 cat <<-EOF >&1
398
399 ###############################################################"
400
401 Done executing testcases."
402 result log is in the $LTPROOT/results directory"
mreed1091696422006-05-03 19:07:22 +0000403 LTP Version: $version_date
plars4a120e82004-09-02 18:56:06 +0000404 ###############################################################"
405
406 EOF
407 }
408 exit $VALUE
409}
410
411cleanup()
412{
413 rm -rf ${TMP}
414}
415
416trap "cleanup" 0
417setup
418main "$@"