blob: 2572d0924137f678bcce7bb7f9e91ed9afe40f7e [file] [log] [blame]
mridgea9e38572005-04-19 15:48:26 +00001#!/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 ##
Wanlong Gao4548c6c2012-10-19 18:03:36 +080018## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ##
mridgea9e38572005-04-19 15:48:26 +000019## ##
20################################################################################
21# File: runltplite
22#
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.
25#
26# Authors: Manoj Iyer - manoji@us.ibm.com
27# Robbie Williamson - robbiew@us.ibm.com
28# Marty Ridgeway - mridge@us.ibm.com
Chris Dearman37550cf2012-10-17 19:54:01 -070029#
mridgea9e38572005-04-19 15:48:26 +000030# History: Created runltplite script to run a subset of the LTP testsuite
Chris Dearman37550cf2012-10-17 19:54:01 -070031#
32#
33#
34#
35#
36#
37#
38#
mridgea9e38572005-04-19 15:48:26 +000039
40
41setup()
42{
43 cd `dirname $0` || \
44 {
45 echo "FATAL: unable to change directory to $(dirname $0)"
46 exit 1
47 }
48 export LTPROOT=${PWD}
49 export TMPBASE="/tmp"
50 export TMP="${TMPBASE}/ltp-$$"
51 export PATH="${PATH}:${LTPROOT}/testcases/bin"
52
53 [ -d $LTPROOT/testcases/bin ] ||
54 {
Garrett Coopercf86b8b2010-11-16 21:46:41 -080055 echo "FATAL: LTP not installed correctly"
56 echo "INFO: Follow directions in INSTALL!"
mridgea9e38572005-04-19 15:48:26 +000057 exit 1
58 }
59
yaberauneyaef772532009-10-09 17:55:43 +000060 [ -e $LTPROOT/bin/ltp-pan ] ||
mridgea9e38572005-04-19 15:48:26 +000061 {
subrata_modak14390fd2009-05-19 09:39:11 +000062 echo "FATAL: Test suite driver 'ltp-pan' not found"
Garrett Coopercf86b8b2010-11-16 21:46:41 -080063 echo "INFO: Follow directions in INSTALL!"
mridgea9e38572005-04-19 15:48:26 +000064 exit 1
65 }
66}
67
68
Chris Dearman37550cf2012-10-17 19:54:01 -070069usage()
mridgea9e38572005-04-19 15:48:26 +000070{
71 cat <<-EOF >&2
72
Chris Dearman37550cf2012-10-17 19:54:01 -070073 usage: ${0##*/} -c [-d TMPDIR] [-i # (in Mb)]
74 [ -l LOGFILE ] [ -o OUTPUTFILE ] [ -m # (in Mb)] -N -q
75 [ -r LTPROOT ] -v
76
mridgea9e38572005-04-19 15:48:26 +000077 -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.
Chris Dearman37550cf2012-10-17 19:54:01 -070083 -N Run all the networking tests.
mridgea9e38572005-04-19 15:48:26 +000084 -o OUTPUTFILE Redirect test output to a file.
Chris Dearman37550cf2012-10-17 19:54:01 -070085 -p Human readable format logfiles.
mridgea9e38572005-04-19 15:48:26 +000086 -q Print less verbose output to screen.
87 -r LTPROOT Fully qualified path where testsuite is installed.
mridgea9e38572005-04-19 15:48:26 +000088
Garrett Cooperf95875a2010-03-05 02:44:39 -080089 example: ${0##*/} -i 1024 -m 128 -p -q -l /tmp/resultlog.$$ -d ${PWD}
mridgea9e38572005-04-19 15:48:26 +000090
91
92 EOF
93exit 0
94}
95
96
97main()
98{
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=""
mridgea9e38572005-04-19 15:48:26 +0000111 local PRETTY_PRT=""
112 local TAG_RESTRICT_STRING=""
113 local PAN_COMMAND=""
114
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800115 local scenfile=""
116
subrata_modak8266c292009-10-13 12:10:13 +0000117 while getopts c:d:hi:l:m:No:pqr: arg
mridgea9e38572005-04-19 15:48:26 +0000118 do case $arg in
Chris Dearman37550cf2012-10-17 19:54:01 -0700119 c)
mridgea9e38572005-04-19 15:48:26 +0000120 NUM_PROCS=$(($OPTARG))
121 $LTPROOT/testcases/bin/genload --cpu $NUM_PROCS >/dev/null 2>&1 &
122 GENLOAD=1 ;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700123
124 d) # append $$ to TMP, as it is recursively
mridgea9e38572005-04-19 15:48:26 +0000125 # removed at end of script.
126 TMPBASE=$OPTARG
127 TMP="${TMPBASE}/ltp-$$"
128 export TMPDIR="$TMP";;
Chris Dearman37550cf2012-10-17 19:54:01 -0700129
mridgea9e38572005-04-19 15:48:26 +0000130 h) usage;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700131
132 i)
mridgea9e38572005-04-19 15:48:26 +0000133 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 \
Chris Dearman37550cf2012-10-17 19:54:01 -0700136 >/dev/null 2>&1 &
mridgea9e38572005-04-19 15:48:26 +0000137 GENLOAD=1 ;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700138
139 l)
mridgea9e38572005-04-19 15:48:26 +0000140
mridgea9e38572005-04-19 15:48:26 +0000141 [ ! -d $LTPROOT/results ] && \
142 {
uid311324adebaed2009-10-15 21:54:49 +0000143 echo "INFO: creating $LTPROOT/results directory"
mridgea9e38572005-04-19 15:48:26 +0000144 mkdir -p $LTPROOT/results || \
145 {
146 echo "ERROR: failed to create $LTPROOT/results"
147 exit 1
148 }
149 }
150 case $OPTARG in
151 /*)
152 LOGFILE="-l $OPTARG" ;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700153 *)
mridgea9e38572005-04-19 15:48:26 +0000154 LOGFILE="-l $LTPROOT/results/$OPTARG"
155 ALT_DIR=1 ;;
156 esac ;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700157
158 m)
159 MEMSIZE=$(($OPTARG * 1024 * 1024))
mridgea9e38572005-04-19 15:48:26 +0000160 $LTPROOT/testcases/bin/genload --vm 0 --vm-bytes $MEMSIZE \
Chris Dearman37550cf2012-10-17 19:54:01 -0700161 >/dev/null 2>&1 &
mridgea9e38572005-04-19 15:48:26 +0000162 GENLOAD=1;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700163
mridgea9e38572005-04-19 15:48:26 +0000164 N) RUN_NETEST=1;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700165
mridgea9e38572005-04-19 15:48:26 +0000166 o) OUTPUTFILE="-o $OPTARG" ;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700167
mridgea9e38572005-04-19 15:48:26 +0000168 p) PRETTY_PRT=" -p ";;
Chris Dearman37550cf2012-10-17 19:54:01 -0700169
mridgea9e38572005-04-19 15:48:26 +0000170 q) QUIET_MODE=" -q ";;
Chris Dearman37550cf2012-10-17 19:54:01 -0700171
mridgea9e38572005-04-19 15:48:26 +0000172 r) LTPROOT=$OPTARG;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700173
mridgea9e38572005-04-19 15:48:26 +0000174 \?) usage;;
175 esac
176 done
Chris Dearman37550cf2012-10-17 19:54:01 -0700177
178
mridgea9e38572005-04-19 15:48:26 +0000179 mkdir -p $TMP || \
180 {
181 echo "FATAL: Unable to make temporary directory $TMP"
182 exit 1
183 }
Chris Dearman37550cf2012-10-17 19:54:01 -0700184
mridgea9e38572005-04-19 15:48:26 +0000185 cd $TMP || \
186 {
187 echo "could not cd ${TMP} ... exiting"
188 exit 1
189 }
190
191# Run Networking tests ?
Chris Dearman37550cf2012-10-17 19:54:01 -0700192
mridgea9e38572005-04-19 15:48:26 +0000193 [ "$RUN_NETEST" -eq 1 ] && \
194 {
195 [ -z "$RHOST" ] || [ -z "$PASSWD" ] && \
196 {
197 [ -z "$RHOST" ] && \
198 {
199 echo \
200 "INFO: Enter RHOST = 'name of the remote host machine'"
201 echo -n "-> "
202 read RHOST
203 }
204
205 [ -z "$PASSWD" ] && \
206 {
207 echo " "
208 echo \
209 "INFO: Enter PASSWD = 'root passwd of the remote host machine'"
210 echo -n "-> "
211 read PASSWD
212 }
213 export RHOST=$RHOST
214 export PASSWD=$PASSWD
215 echo "WARNING: security of $RHOST may be compromised"
216 }
217 }
Chris Dearman37550cf2012-10-17 19:54:01 -0700218
mridgea9e38572005-04-19 15:48:26 +0000219 # If user does not provide a command file select a default set of testcases
220 # to execute.
221 if [ -f $CMDFILE ] || \
222 CMDFILE="$LTPROOT/runtest/$CMDFILE"
223 then
224 cat $CMDFILE > ${TMP}/alltests || \
225 {
226 echo "FATAL: Unable to create command file"
227 exit 1
228 }
229 fi
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800230
231 if [ "$RUN_NETEST" -eq 1 ]; then
Garrett Cooper89fde872010-11-16 22:38:08 -0800232 SCENARIO_LISTS="$SCENARIO_LISTS $LTPROOT/scenario_groups/network"
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800233 fi
Chris Dearman37550cf2012-10-17 19:54:01 -0700234
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800235 # DO NOT INDENT/DEDENT!
236 if [ -n "$SCENARIO_LISTS" ]; then
237 # Insurance to make sure that the first element in the pipe
238 # completed successfully.
239 cat_ok_sentinel=$TMP/cat_ok.$$
Garrett Cooper66d67b52010-11-16 22:42:48 -0800240 (cat $SCENARIO_LISTS && touch "$cat_ok_sentinel") | \
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800241 while read scenfile; do
242
243 scenfile=${LTPROOT}/runtest/$scenfile
244
245 # Skip over non-existent scenario files; things are
246 # robust enough now that the build will fail if these
247 # files don't exist.
248 [ -f "$scenfile" ] || continue
249
250 cat $scenfile >> "$TMP/alltests" || {
251 echo "FATAL: unable to append to command file"
252 rm -Rf "$TMP"
253 rm -f "$cat_ok_sentinel"
254 exit 1
255 }
256
257 done
258
259 rm -f "$cat_ok_sentinel"
260
261 fi
262 # ^^DO NOT INDENT/DEDENT!^^
263
mridgea9e38572005-04-19 15:48:26 +0000264 # The fsx-linux tests use the SCRATCHDEV environment variable as a location
Chris Dearman37550cf2012-10-17 19:54:01 -0700265 # that can be reformatted and run on. Set SCRATCHDEV if you want to run
mridgea9e38572005-04-19 15:48:26 +0000266 # these tests. As a safeguard, this is disabled.
267 unset SCRATCHDEV
268 [ -n "$SCRATCHDEV" ] && \
269 {
270 cat ${LTPROOT}/runtest/fsx >> ${TMP}/alltests ||
271 {
272 echo "FATAL: unable to create fsx-linux tests command file"
273 exit 1
274 }
275 }
Chris Dearman37550cf2012-10-17 19:54:01 -0700276
mridgea9e38572005-04-19 15:48:26 +0000277 # check for required users and groups
278 ${LTPROOT}/IDcheck.sh &>/dev/null || \
279 {
280 echo "WARNING: required users and groups not present"
281 echo "WARNING: some test cases may fail"
282 }
Chris Dearman37550cf2012-10-17 19:54:01 -0700283
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800284 [ -n "$CMDFILES" ] && \
285 {
286 for scenfile in `echo "$CMDFILES" | tr ',' ' '`
287 do
288 [ -f "$scenfile" ] || scenfile="$LTPROOT/runtest/$scenfile"
289 cat "$scenfile" >> ${TMP}/alltests || \
290 {
291 echo "FATAL: unable to create command file"
292 rm -Rf "$TMP"
293 exit 1
294 }
295 done
296 }
Chris Dearman37550cf2012-10-17 19:54:01 -0700297
mridgea9e38572005-04-19 15:48:26 +0000298 # display versions of installed software
299 [ -z "$QUIET_MODE" ] && \
Chris Dearman37550cf2012-10-17 19:54:01 -0700300 {
mridgea9e38572005-04-19 15:48:26 +0000301 ${LTPROOT}/ver_linux || \
302 {
303 echo "WARNING: unable to display versions of software installed"
304 exit 1
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800305 }
mridgea9e38572005-04-19 15:48:26 +0000306 }
307
308 [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test start time: $(date)" ; }
yaberauneyaef772532009-10-09 17:55:43 +0000309 PAN_COMMAND="${LTPROOT}/bin/ltp-pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ \
mridgea9e38572005-04-19 15:48:26 +0000310 -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE"
311 if [ ! -z "$VERBOSE_MODE" ] ; then
312 echo "COMMAND: $PAN_COMMAND"
313 if [ ! -z "$TAG_RESTRICT_STRING" ] ; then
314 echo "INFO: Restricted to $TAG_RESTRICT_STRING"
315 fi
316 fi
317 #$PAN_COMMAND #Duplicated code here, because otherwise if we fail, only "PAN_COMMAND" gets output
subrata_modak724098e2009-03-19 08:49:18 +0000318 # Some tests need to run inside the "bin" directory.
319 cd "${LTPROOT}/testcases/bin"
yaberauneyaef772532009-10-09 17:55:43 +0000320 ${LTPROOT}/bin/ltp-pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ \
mridgea9e38572005-04-19 15:48:26 +0000321 -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE
Chris Dearman37550cf2012-10-17 19:54:01 -0700322
mridgea9e38572005-04-19 15:48:26 +0000323 if [ $? -eq 0 ]; then
subrata_modak14390fd2009-05-19 09:39:11 +0000324 echo "INFO: ltp-pan reported all tests PASS"
mridgea9e38572005-04-19 15:48:26 +0000325 VALUE=0
326 else
subrata_modak14390fd2009-05-19 09:39:11 +0000327 echo "INFO: ltp-pan reported some tests FAIL"
mridgea9e38572005-04-19 15:48:26 +0000328 VALUE=1
329 fi
subrata_modak724098e2009-03-19 08:49:18 +0000330 cd ..
mridgea9e38572005-04-19 15:48:26 +0000331 [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test end time: $(date)" ; }
Chris Dearman37550cf2012-10-17 19:54:01 -0700332
mridgea9e38572005-04-19 15:48:26 +0000333 [ "$GENLOAD" -eq 1 ] && { killall -9 genload ; }
334 [ "$NETPIPE" -eq 1 ] && { killall -9 NPtcp ; }
Chris Dearman37550cf2012-10-17 19:54:01 -0700335
mridgea9e38572005-04-19 15:48:26 +0000336 [ "$ALT_DIR" -eq 1 ] && \
337 {
338 cat <<-EOF >&1
Chris Dearman37550cf2012-10-17 19:54:01 -0700339
mridgea9e38572005-04-19 15:48:26 +0000340 ###############################################################"
Chris Dearman37550cf2012-10-17 19:54:01 -0700341
mridgea9e38572005-04-19 15:48:26 +0000342 Done executing testcases."
343 result log is in the $LTPROOT/results directory"
Chris Dearman37550cf2012-10-17 19:54:01 -0700344
mridgea9e38572005-04-19 15:48:26 +0000345 ###############################################################"
Chris Dearman37550cf2012-10-17 19:54:01 -0700346
mridgea9e38572005-04-19 15:48:26 +0000347 EOF
348 }
349 exit $VALUE
350}
351
352cleanup()
353{
354 rm -rf ${TMP}
355}
356
357trap "cleanup" 0
358setup
359main "$@"
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800360
361#vim: syntax=sh