Merge commit 'upstream/20090531' into dfsg_clean
[ltp-debian.git] / runltplite.sh
blob5c2e03d86e93fc62cccba8ce464017baadc214ab
1 #!/bin/sh
2 ################################################################################
3 ## ##
4 ## Copyright (c) International Business Machines Corp., 2001,2005 ##
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: runltplite
23 # Description: This script can be used to run a subset the tests in the LTP test suite
24 # This script is typically used as a quick test to check an install base.
26 # Authors: Manoj Iyer - manoji@us.ibm.com
27 # Robbie Williamson - robbiew@us.ibm.com
28 # Marty Ridgeway - mridge@us.ibm.com
30 # History: Created runltplite script to run a subset of the LTP testsuite
41 setup()
43 cd `dirname $0` || \
45 echo "FATAL: unable to change directory to $(dirname $0)"
46 exit 1
48 export LTPROOT=${PWD}
49 export TMPBASE="/tmp"
50 export TMP="${TMPBASE}/ltp-$$"
51 export PATH="${PATH}:${LTPROOT}/testcases/bin"
53 [ -d $LTPROOT/testcases/bin ] ||
55 echo "FATAL: Test suite not installed correctly"
56 echo "INFO: as root user type 'make ; make install'"
57 exit 1
60 [ -e $LTPROOT/pan/ltp-pan ] ||
62 echo "FATAL: Test suite driver 'ltp-pan' not found"
63 echo "INFO: as root user type 'make ; make install'"
64 exit 1
69 usage()
71 cat <<-EOF >&2
73 usage: ./${0##*/} -c [-d TMPDIR] [-i # (in Mb)]
74 [ -l LOGFILE ] [ -o OUTPUTFILE ] [ -m # (in Mb)] -N -q
75 [ -r LTPROOT ] -v
77 -c NUM_PROCS Run LTP under additional background CPU load.
78 -d TMPDIR Directory where temporary files will be created.
79 -h Help. Prints all available options.
80 -i # (in Mb) Run LTP with a _min_ IO load of # Mb in background.
81 -l LOGFILE Log results of test in a logfile.
82 -m # (in Mb) Run LTP with a _min_ memory load of # Mb in background.
83 -N Run all the networking tests.
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 -v Print more verbose output to screen.
90 example: ./${0##*/} -i 1024 -m 128 -p -q -l /tmp/resultlog.$$ -d ${PWD}
93 EOF
94 exit 0
98 main()
100 local CMDFILE="ltplite"
101 local PRETTY_PRT=""
102 local ALT_DIR=0
103 local RUN_NETEST=0
104 local QUIET_MODE=""
105 local VERBOSE_MODE=""
106 local NETPIPE=0
107 local GENLOAD=0
108 local MEMSIZE=0
109 local DURATION=""
110 local BYTESIZE=0
111 local LOGFILE=""
112 local SCENFILES=""
113 local PRETTY_PRT=""
114 local TAG_RESTRICT_STRING=""
115 local PAN_COMMAND=""
117 while getopts c:d:hi:l:m:No:pqr:v arg
118 do case $arg in
120 NUM_PROCS=$(($OPTARG))
121 $LTPROOT/testcases/bin/genload --cpu $NUM_PROCS >/dev/null 2>&1 &
122 GENLOAD=1 ;;
124 d) # append $$ to TMP, as it is recursively
125 # removed at end of script.
126 TMPBASE=$OPTARG
127 TMP="${TMPBASE}/ltp-$$"
128 export TMPDIR="$TMP";;
130 h) usage;;
133 BYTESIZE=$(($OPTARG * 1024 * 1024))
134 $LTPROOT/testcases/bin/genload --io 1 >/dev/null 2>&1 &
135 $LTPROOT/testcases/bin/genload --hdd 0 --hdd-bytes $BYTESIZE \
136 >/dev/null 2>&1 &
137 GENLOAD=1 ;;
141 echo "INFO: creating $LTPROOT/results directory"
142 [ ! -d $LTPROOT/results ] && \
144 mkdir -p $LTPROOT/results || \
146 echo "ERROR: failed to create $LTPROOT/results"
147 exit 1
150 case $OPTARG in
152 LOGFILE="-l $OPTARG" ;;
154 LOGFILE="-l $LTPROOT/results/$OPTARG"
155 ALT_DIR=1 ;;
156 esac ;;
159 MEMSIZE=$(($OPTARG * 1024 * 1024))
160 $LTPROOT/testcases/bin/genload --vm 0 --vm-bytes $MEMSIZE \
161 >/dev/null 2>&1 &
162 GENLOAD=1;;
164 N) RUN_NETEST=1;;
166 o) OUTPUTFILE="-o $OPTARG" ;;
168 p) PRETTY_PRT=" -p ";;
170 q) QUIET_MODE=" -q ";;
172 r) LTPROOT=$OPTARG;;
174 v) VERBOSE_MODE=1;;
176 \?) usage;;
177 esac
178 done
181 mkdir -p $TMP || \
183 echo "FATAL: Unable to make temporary directory $TMP"
184 exit 1
187 cd $TMP || \
189 echo "could not cd ${TMP} ... exiting"
190 exit 1
193 # Run Networking tests ?
195 [ "$RUN_NETEST" -eq 1 ] && \
197 [ -z "$RHOST" ] || [ -z "$PASSWD" ] && \
199 [ -z "$RHOST" ] && \
201 echo \
202 "INFO: Enter RHOST = 'name of the remote host machine'"
203 echo -n "-> "
204 read RHOST
207 [ -z "$PASSWD" ] && \
209 echo " "
210 echo \
211 "INFO: Enter PASSWD = 'root passwd of the remote host machine'"
212 echo -n "-> "
213 read PASSWD
215 export RHOST=$RHOST
216 export PASSWD=$PASSWD
217 echo "WARNING: security of $RHOST may be compromised"
221 # If user does not provide a command file select a default set of testcases
222 # to execute.
223 if [ -f $CMDFILE ] || \
224 CMDFILE="$LTPROOT/runtest/$CMDFILE"
225 then
226 cat $CMDFILE > ${TMP}/alltests || \
228 echo "FATAL: Unable to create command file"
229 exit 1
233 [ "$RUN_NETEST" -eq 1 ] && \
235 for SCENFILES in ${LTPROOT}/runtest/tcp_cmds \
236 ${LTPROOT}/runtest/multicast \
237 ${LTPROOT}/runtest/rpc \
238 ${LTPROOT}/runtest/nfs
240 [ -e "$SCENFILES" ] || \
242 echo "FATAL: missing scenario file $SCENFILES"
243 exit 1
246 cat $SCENFILES >> ${TMP}/alltests || \
248 echo "FATAL: unable to create command file"
249 exit 1
251 done
254 # The fsx-linux tests use the SCRATCHDEV environment variable as a location
255 # that can be reformatted and run on. Set SCRATCHDEV if you want to run
256 # these tests. As a safeguard, this is disabled.
257 unset SCRATCHDEV
258 [ -n "$SCRATCHDEV" ] && \
260 cat ${LTPROOT}/runtest/fsx >> ${TMP}/alltests ||
262 echo "FATAL: unable to create fsx-linux tests command file"
263 exit 1
267 # check for required users and groups
268 ${LTPROOT}/IDcheck.sh &>/dev/null || \
270 echo "WARNING: required users and groups not present"
271 echo "WARNING: some test cases may fail"
276 # display versions of installed software
277 [ -z "$QUIET_MODE" ] && \
279 ${LTPROOT}/ver_linux || \
281 echo "WARNING: unable to display versions of software installed"
282 exit 1
286 [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test start time: $(date)" ; }
287 PAN_COMMAND="${LTPROOT}/pan/ltp-pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ \
288 -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE"
289 if [ ! -z "$VERBOSE_MODE" ] ; then
290 echo "COMMAND: $PAN_COMMAND"
291 if [ ! -z "$TAG_RESTRICT_STRING" ] ; then
292 echo "INFO: Restricted to $TAG_RESTRICT_STRING"
295 #$PAN_COMMAND #Duplicated code here, because otherwise if we fail, only "PAN_COMMAND" gets output
296 # Some tests need to run inside the "bin" directory.
297 cd "${LTPROOT}/testcases/bin"
298 ${LTPROOT}/pan/ltp-pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ \
299 -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE
301 if [ $? -eq 0 ]; then
302 echo "INFO: ltp-pan reported all tests PASS"
303 VALUE=0
304 else
305 echo "INFO: ltp-pan reported some tests FAIL"
306 VALUE=1
308 cd ..
309 [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test end time: $(date)" ; }
311 [ "$GENLOAD" -eq 1 ] && { killall -9 genload ; }
312 [ "$NETPIPE" -eq 1 ] && { killall -9 NPtcp ; }
314 [ "$ALT_DIR" -eq 1 ] && \
316 cat <<-EOF >&1
318 ###############################################################"
320 Done executing testcases."
321 result log is in the $LTPROOT/results directory"
323 ###############################################################"
327 exit $VALUE
330 cleanup()
332 rm -rf ${TMP}
335 trap "cleanup" 0
336 setup
337 main "$@"