Allow running utimensat test from a directory different from $LTPROOT/testcases/bin
[ltp-debian.git] / runltplite.sh
blob559ef92fd3024bb09816be38e9877491ea7432e7
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/bin/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.
89 example: ./${0##*/} -i 1024 -m 128 -p -q -l /tmp/resultlog.$$ -d ${PWD}
92 EOF
93 exit 0
97 main()
99 local CMDFILE="ltplite"
100 local PRETTY_PRT=""
101 local ALT_DIR=0
102 local RUN_NETEST=0
103 local QUIET_MODE=""
104 local VERBOSE_MODE=""
105 local NETPIPE=0
106 local GENLOAD=0
107 local MEMSIZE=0
108 local DURATION=""
109 local BYTESIZE=0
110 local LOGFILE=""
111 local SCENFILES=""
112 local PRETTY_PRT=""
113 local TAG_RESTRICT_STRING=""
114 local PAN_COMMAND=""
116 while getopts c:d:hi:l:m:No:pqr: arg
117 do case $arg in
119 NUM_PROCS=$(($OPTARG))
120 $LTPROOT/testcases/bin/genload --cpu $NUM_PROCS >/dev/null 2>&1 &
121 GENLOAD=1 ;;
123 d) # append $$ to TMP, as it is recursively
124 # removed at end of script.
125 TMPBASE=$OPTARG
126 TMP="${TMPBASE}/ltp-$$"
127 export TMPDIR="$TMP";;
129 h) usage;;
132 BYTESIZE=$(($OPTARG * 1024 * 1024))
133 $LTPROOT/testcases/bin/genload --io 1 >/dev/null 2>&1 &
134 $LTPROOT/testcases/bin/genload --hdd 0 --hdd-bytes $BYTESIZE \
135 >/dev/null 2>&1 &
136 GENLOAD=1 ;;
140 [ ! -d $LTPROOT/results ] && \
142 echo "INFO: creating $LTPROOT/results directory"
143 mkdir -p $LTPROOT/results || \
145 echo "ERROR: failed to create $LTPROOT/results"
146 exit 1
149 case $OPTARG in
151 LOGFILE="-l $OPTARG" ;;
153 LOGFILE="-l $LTPROOT/results/$OPTARG"
154 ALT_DIR=1 ;;
155 esac ;;
158 MEMSIZE=$(($OPTARG * 1024 * 1024))
159 $LTPROOT/testcases/bin/genload --vm 0 --vm-bytes $MEMSIZE \
160 >/dev/null 2>&1 &
161 GENLOAD=1;;
163 N) RUN_NETEST=1;;
165 o) OUTPUTFILE="-o $OPTARG" ;;
167 p) PRETTY_PRT=" -p ";;
169 q) QUIET_MODE=" -q ";;
171 r) LTPROOT=$OPTARG;;
173 \?) usage;;
174 esac
175 done
178 mkdir -p $TMP || \
180 echo "FATAL: Unable to make temporary directory $TMP"
181 exit 1
184 cd $TMP || \
186 echo "could not cd ${TMP} ... exiting"
187 exit 1
190 # Run Networking tests ?
192 [ "$RUN_NETEST" -eq 1 ] && \
194 [ -z "$RHOST" ] || [ -z "$PASSWD" ] && \
196 [ -z "$RHOST" ] && \
198 echo \
199 "INFO: Enter RHOST = 'name of the remote host machine'"
200 echo -n "-> "
201 read RHOST
204 [ -z "$PASSWD" ] && \
206 echo " "
207 echo \
208 "INFO: Enter PASSWD = 'root passwd of the remote host machine'"
209 echo -n "-> "
210 read PASSWD
212 export RHOST=$RHOST
213 export PASSWD=$PASSWD
214 echo "WARNING: security of $RHOST may be compromised"
218 # If user does not provide a command file select a default set of testcases
219 # to execute.
220 if [ -f $CMDFILE ] || \
221 CMDFILE="$LTPROOT/runtest/$CMDFILE"
222 then
223 cat $CMDFILE > ${TMP}/alltests || \
225 echo "FATAL: Unable to create command file"
226 exit 1
230 [ "$RUN_NETEST" -eq 1 ] && \
232 for SCENFILES in ${LTPROOT}/runtest/tcp_cmds \
233 ${LTPROOT}/runtest/multicast \
234 ${LTPROOT}/runtest/rpc \
235 ${LTPROOT}/runtest/nfs
237 [ -e "$SCENFILES" ] || \
239 echo "FATAL: missing scenario file $SCENFILES"
240 exit 1
243 cat $SCENFILES >> ${TMP}/alltests || \
245 echo "FATAL: unable to create command file"
246 exit 1
248 done
251 # The fsx-linux tests use the SCRATCHDEV environment variable as a location
252 # that can be reformatted and run on. Set SCRATCHDEV if you want to run
253 # these tests. As a safeguard, this is disabled.
254 unset SCRATCHDEV
255 [ -n "$SCRATCHDEV" ] && \
257 cat ${LTPROOT}/runtest/fsx >> ${TMP}/alltests ||
259 echo "FATAL: unable to create fsx-linux tests command file"
260 exit 1
264 # check for required users and groups
265 ${LTPROOT}/IDcheck.sh &>/dev/null || \
267 echo "WARNING: required users and groups not present"
268 echo "WARNING: some test cases may fail"
273 # display versions of installed software
274 [ -z "$QUIET_MODE" ] && \
276 ${LTPROOT}/ver_linux || \
278 echo "WARNING: unable to display versions of software installed"
279 exit 1
283 [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test start time: $(date)" ; }
284 PAN_COMMAND="${LTPROOT}/bin/ltp-pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ \
285 -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE"
286 if [ ! -z "$VERBOSE_MODE" ] ; then
287 echo "COMMAND: $PAN_COMMAND"
288 if [ ! -z "$TAG_RESTRICT_STRING" ] ; then
289 echo "INFO: Restricted to $TAG_RESTRICT_STRING"
292 #$PAN_COMMAND #Duplicated code here, because otherwise if we fail, only "PAN_COMMAND" gets output
293 # Some tests need to run inside the "bin" directory.
294 cd "${LTPROOT}/testcases/bin"
295 ${LTPROOT}/bin/ltp-pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ \
296 -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE
298 if [ $? -eq 0 ]; then
299 echo "INFO: ltp-pan reported all tests PASS"
300 VALUE=0
301 else
302 echo "INFO: ltp-pan reported some tests FAIL"
303 VALUE=1
305 cd ..
306 [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test end time: $(date)" ; }
308 [ "$GENLOAD" -eq 1 ] && { killall -9 genload ; }
309 [ "$NETPIPE" -eq 1 ] && { killall -9 NPtcp ; }
311 [ "$ALT_DIR" -eq 1 ] && \
313 cat <<-EOF >&1
315 ###############################################################"
317 Done executing testcases."
318 result log is in the $LTPROOT/results directory"
320 ###############################################################"
324 exit $VALUE
327 cleanup()
329 rm -rf ${TMP}
332 trap "cleanup" 0
333 setup
334 main "$@"