blob: 765f8d190fdad369bea1c2a1765a814620b146e0 [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
Cyril Hrubise8776ea2014-03-24 13:32:01 +010040. "$(dirname $0)/runltp"
mridgea9e38572005-04-19 15:48:26 +000041
42setup()
43{
44 cd `dirname $0` || \
45 {
46 echo "FATAL: unable to change directory to $(dirname $0)"
47 exit 1
48 }
49 export LTPROOT=${PWD}
50 export TMPBASE="/tmp"
51 export TMP="${TMPBASE}/ltp-$$"
52 export PATH="${PATH}:${LTPROOT}/testcases/bin"
53
Harald Weppner8bdf0a02014-03-03 14:10:07 -080054 export LTP_DEV=""
55 export LTP_DEV_FS_TYPE="ext2"
56
mridgea9e38572005-04-19 15:48:26 +000057 [ -d $LTPROOT/testcases/bin ] ||
58 {
Garrett Coopercf86b8b2010-11-16 21:46:41 -080059 echo "FATAL: LTP not installed correctly"
60 echo "INFO: Follow directions in INSTALL!"
mridgea9e38572005-04-19 15:48:26 +000061 exit 1
62 }
63
yaberauneyaef772532009-10-09 17:55:43 +000064 [ -e $LTPROOT/bin/ltp-pan ] ||
mridgea9e38572005-04-19 15:48:26 +000065 {
subrata_modak14390fd2009-05-19 09:39:11 +000066 echo "FATAL: Test suite driver 'ltp-pan' not found"
Garrett Coopercf86b8b2010-11-16 21:46:41 -080067 echo "INFO: Follow directions in INSTALL!"
mridgea9e38572005-04-19 15:48:26 +000068 exit 1
69 }
70}
71
72
Chris Dearman37550cf2012-10-17 19:54:01 -070073usage()
mridgea9e38572005-04-19 15:48:26 +000074{
75 cat <<-EOF >&2
76
Chris Dearman37550cf2012-10-17 19:54:01 -070077 usage: ${0##*/} -c [-d TMPDIR] [-i # (in Mb)]
78 [ -l LOGFILE ] [ -o OUTPUTFILE ] [ -m # (in Mb)] -N -q
79 [ -r LTPROOT ] -v
80
mridgea9e38572005-04-19 15:48:26 +000081 -c NUM_PROCS Run LTP under additional background CPU load.
82 -d TMPDIR Directory where temporary files will be created.
83 -h Help. Prints all available options.
84 -i # (in Mb) Run LTP with a _min_ IO load of # Mb in background.
85 -l LOGFILE Log results of test in a logfile.
86 -m # (in Mb) Run LTP with a _min_ memory load of # Mb in background.
Chris Dearman37550cf2012-10-17 19:54:01 -070087 -N Run all the networking tests.
mridgea9e38572005-04-19 15:48:26 +000088 -o OUTPUTFILE Redirect test output to a file.
Chris Dearman37550cf2012-10-17 19:54:01 -070089 -p Human readable format logfiles.
mridgea9e38572005-04-19 15:48:26 +000090 -q Print less verbose output to screen.
91 -r LTPROOT Fully qualified path where testsuite is installed.
Harald Weppner8bdf0a02014-03-03 14:10:07 -080092 -b DEVICE Some tests require an unmounted block device to run
93 correctly.
94 -B LTP_DEV_FS_TYPE The file system of test block devices.
mridgea9e38572005-04-19 15:48:26 +000095
Garrett Cooperf95875a2010-03-05 02:44:39 -080096 example: ${0##*/} -i 1024 -m 128 -p -q -l /tmp/resultlog.$$ -d ${PWD}
mridgea9e38572005-04-19 15:48:26 +000097
98
99 EOF
100exit 0
101}
102
103
104main()
105{
106 local CMDFILE="ltplite"
107 local PRETTY_PRT=""
108 local ALT_DIR=0
109 local RUN_NETEST=0
110 local QUIET_MODE=""
111 local VERBOSE_MODE=""
112 local NETPIPE=0
113 local GENLOAD=0
114 local MEMSIZE=0
115 local DURATION=""
116 local BYTESIZE=0
117 local LOGFILE=""
mridgea9e38572005-04-19 15:48:26 +0000118 local PRETTY_PRT=""
119 local TAG_RESTRICT_STRING=""
120 local PAN_COMMAND=""
121
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800122 local scenfile=""
123
Harald Weppner8bdf0a02014-03-03 14:10:07 -0800124 while getopts c:d:hi:l:m:No:pqr:b:B: arg
mridgea9e38572005-04-19 15:48:26 +0000125 do case $arg in
Chris Dearman37550cf2012-10-17 19:54:01 -0700126 c)
mridgea9e38572005-04-19 15:48:26 +0000127 NUM_PROCS=$(($OPTARG))
128 $LTPROOT/testcases/bin/genload --cpu $NUM_PROCS >/dev/null 2>&1 &
129 GENLOAD=1 ;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700130
131 d) # append $$ to TMP, as it is recursively
mridgea9e38572005-04-19 15:48:26 +0000132 # removed at end of script.
133 TMPBASE=$OPTARG
134 TMP="${TMPBASE}/ltp-$$"
135 export TMPDIR="$TMP";;
Chris Dearman37550cf2012-10-17 19:54:01 -0700136
mridgea9e38572005-04-19 15:48:26 +0000137 h) usage;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700138
139 i)
mridgea9e38572005-04-19 15:48:26 +0000140 BYTESIZE=$(($OPTARG * 1024 * 1024))
141 $LTPROOT/testcases/bin/genload --io 1 >/dev/null 2>&1 &
142 $LTPROOT/testcases/bin/genload --hdd 0 --hdd-bytes $BYTESIZE \
Chris Dearman37550cf2012-10-17 19:54:01 -0700143 >/dev/null 2>&1 &
mridgea9e38572005-04-19 15:48:26 +0000144 GENLOAD=1 ;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700145
146 l)
mridgea9e38572005-04-19 15:48:26 +0000147
mridgea9e38572005-04-19 15:48:26 +0000148 [ ! -d $LTPROOT/results ] && \
149 {
uid311324adebaed2009-10-15 21:54:49 +0000150 echo "INFO: creating $LTPROOT/results directory"
mridgea9e38572005-04-19 15:48:26 +0000151 mkdir -p $LTPROOT/results || \
152 {
153 echo "ERROR: failed to create $LTPROOT/results"
154 exit 1
155 }
156 }
157 case $OPTARG in
158 /*)
159 LOGFILE="-l $OPTARG" ;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700160 *)
mridgea9e38572005-04-19 15:48:26 +0000161 LOGFILE="-l $LTPROOT/results/$OPTARG"
162 ALT_DIR=1 ;;
163 esac ;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700164
165 m)
166 MEMSIZE=$(($OPTARG * 1024 * 1024))
mridgea9e38572005-04-19 15:48:26 +0000167 $LTPROOT/testcases/bin/genload --vm 0 --vm-bytes $MEMSIZE \
Chris Dearman37550cf2012-10-17 19:54:01 -0700168 >/dev/null 2>&1 &
mridgea9e38572005-04-19 15:48:26 +0000169 GENLOAD=1;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700170
mridgea9e38572005-04-19 15:48:26 +0000171 N) RUN_NETEST=1;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700172
mridgea9e38572005-04-19 15:48:26 +0000173 o) OUTPUTFILE="-o $OPTARG" ;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700174
mridgea9e38572005-04-19 15:48:26 +0000175 p) PRETTY_PRT=" -p ";;
Chris Dearman37550cf2012-10-17 19:54:01 -0700176
mridgea9e38572005-04-19 15:48:26 +0000177 q) QUIET_MODE=" -q ";;
Chris Dearman37550cf2012-10-17 19:54:01 -0700178
mridgea9e38572005-04-19 15:48:26 +0000179 r) LTPROOT=$OPTARG;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700180
Harald Weppner8bdf0a02014-03-03 14:10:07 -0800181 b) DEVICE=$OPTARG;;
182
183 B) LTP_DEV_FS_TYPE=$OPTARG;;
184
185
mridgea9e38572005-04-19 15:48:26 +0000186 \?) usage;;
187 esac
188 done
Chris Dearman37550cf2012-10-17 19:54:01 -0700189
190
mridgea9e38572005-04-19 15:48:26 +0000191 mkdir -p $TMP || \
192 {
193 echo "FATAL: Unable to make temporary directory $TMP"
194 exit 1
195 }
Chris Dearman37550cf2012-10-17 19:54:01 -0700196
mridgea9e38572005-04-19 15:48:26 +0000197 cd $TMP || \
198 {
199 echo "could not cd ${TMP} ... exiting"
200 exit 1
201 }
202
203# Run Networking tests ?
Chris Dearman37550cf2012-10-17 19:54:01 -0700204
mridgea9e38572005-04-19 15:48:26 +0000205 [ "$RUN_NETEST" -eq 1 ] && \
206 {
207 [ -z "$RHOST" ] || [ -z "$PASSWD" ] && \
208 {
209 [ -z "$RHOST" ] && \
210 {
211 echo \
212 "INFO: Enter RHOST = 'name of the remote host machine'"
213 echo -n "-> "
214 read RHOST
215 }
216
217 [ -z "$PASSWD" ] && \
218 {
219 echo " "
220 echo \
221 "INFO: Enter PASSWD = 'root passwd of the remote host machine'"
222 echo -n "-> "
223 read PASSWD
224 }
225 export RHOST=$RHOST
226 export PASSWD=$PASSWD
227 echo "WARNING: security of $RHOST may be compromised"
228 }
229 }
Chris Dearman37550cf2012-10-17 19:54:01 -0700230
mridgea9e38572005-04-19 15:48:26 +0000231 # If user does not provide a command file select a default set of testcases
232 # to execute.
233 if [ -f $CMDFILE ] || \
234 CMDFILE="$LTPROOT/runtest/$CMDFILE"
235 then
236 cat $CMDFILE > ${TMP}/alltests || \
237 {
238 echo "FATAL: Unable to create command file"
239 exit 1
240 }
241 fi
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800242
243 if [ "$RUN_NETEST" -eq 1 ]; then
Garrett Cooper89fde872010-11-16 22:38:08 -0800244 SCENARIO_LISTS="$SCENARIO_LISTS $LTPROOT/scenario_groups/network"
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800245 fi
Chris Dearman37550cf2012-10-17 19:54:01 -0700246
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800247 # DO NOT INDENT/DEDENT!
248 if [ -n "$SCENARIO_LISTS" ]; then
249 # Insurance to make sure that the first element in the pipe
250 # completed successfully.
251 cat_ok_sentinel=$TMP/cat_ok.$$
Garrett Cooper66d67b52010-11-16 22:42:48 -0800252 (cat $SCENARIO_LISTS && touch "$cat_ok_sentinel") | \
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800253 while read scenfile; do
254
255 scenfile=${LTPROOT}/runtest/$scenfile
256
257 # Skip over non-existent scenario files; things are
258 # robust enough now that the build will fail if these
259 # files don't exist.
260 [ -f "$scenfile" ] || continue
261
262 cat $scenfile >> "$TMP/alltests" || {
263 echo "FATAL: unable to append to command file"
264 rm -Rf "$TMP"
265 rm -f "$cat_ok_sentinel"
266 exit 1
267 }
268
269 done
270
271 rm -f "$cat_ok_sentinel"
272
273 fi
274 # ^^DO NOT INDENT/DEDENT!^^
275
mridgea9e38572005-04-19 15:48:26 +0000276 # The fsx-linux tests use the SCRATCHDEV environment variable as a location
Chris Dearman37550cf2012-10-17 19:54:01 -0700277 # that can be reformatted and run on. Set SCRATCHDEV if you want to run
mridgea9e38572005-04-19 15:48:26 +0000278 # these tests. As a safeguard, this is disabled.
279 unset SCRATCHDEV
280 [ -n "$SCRATCHDEV" ] && \
281 {
282 cat ${LTPROOT}/runtest/fsx >> ${TMP}/alltests ||
283 {
284 echo "FATAL: unable to create fsx-linux tests command file"
285 exit 1
286 }
287 }
Chris Dearman37550cf2012-10-17 19:54:01 -0700288
mridgea9e38572005-04-19 15:48:26 +0000289 # check for required users and groups
290 ${LTPROOT}/IDcheck.sh &>/dev/null || \
291 {
292 echo "WARNING: required users and groups not present"
293 echo "WARNING: some test cases may fail"
294 }
Chris Dearman37550cf2012-10-17 19:54:01 -0700295
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800296 [ -n "$CMDFILES" ] && \
297 {
298 for scenfile in `echo "$CMDFILES" | tr ',' ' '`
299 do
300 [ -f "$scenfile" ] || scenfile="$LTPROOT/runtest/$scenfile"
301 cat "$scenfile" >> ${TMP}/alltests || \
302 {
303 echo "FATAL: unable to create command file"
304 rm -Rf "$TMP"
305 exit 1
306 }
307 done
308 }
Chris Dearman37550cf2012-10-17 19:54:01 -0700309
mridgea9e38572005-04-19 15:48:26 +0000310 # display versions of installed software
311 [ -z "$QUIET_MODE" ] && \
Chris Dearman37550cf2012-10-17 19:54:01 -0700312 {
mridgea9e38572005-04-19 15:48:26 +0000313 ${LTPROOT}/ver_linux || \
314 {
315 echo "WARNING: unable to display versions of software installed"
316 exit 1
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800317 }
mridgea9e38572005-04-19 15:48:26 +0000318 }
319
Harald Weppner8bdf0a02014-03-03 14:10:07 -0800320 set_block_device
321
mridgea9e38572005-04-19 15:48:26 +0000322 [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test start time: $(date)" ; }
yaberauneyaef772532009-10-09 17:55:43 +0000323 PAN_COMMAND="${LTPROOT}/bin/ltp-pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ \
mridgea9e38572005-04-19 15:48:26 +0000324 -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE"
325 if [ ! -z "$VERBOSE_MODE" ] ; then
326 echo "COMMAND: $PAN_COMMAND"
327 if [ ! -z "$TAG_RESTRICT_STRING" ] ; then
328 echo "INFO: Restricted to $TAG_RESTRICT_STRING"
329 fi
330 fi
331 #$PAN_COMMAND #Duplicated code here, because otherwise if we fail, only "PAN_COMMAND" gets output
subrata_modak724098e2009-03-19 08:49:18 +0000332 # Some tests need to run inside the "bin" directory.
333 cd "${LTPROOT}/testcases/bin"
yaberauneyaef772532009-10-09 17:55:43 +0000334 ${LTPROOT}/bin/ltp-pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ \
mridgea9e38572005-04-19 15:48:26 +0000335 -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE
Chris Dearman37550cf2012-10-17 19:54:01 -0700336
mridgea9e38572005-04-19 15:48:26 +0000337 if [ $? -eq 0 ]; then
subrata_modak14390fd2009-05-19 09:39:11 +0000338 echo "INFO: ltp-pan reported all tests PASS"
mridgea9e38572005-04-19 15:48:26 +0000339 VALUE=0
340 else
subrata_modak14390fd2009-05-19 09:39:11 +0000341 echo "INFO: ltp-pan reported some tests FAIL"
mridgea9e38572005-04-19 15:48:26 +0000342 VALUE=1
343 fi
subrata_modak724098e2009-03-19 08:49:18 +0000344 cd ..
mridgea9e38572005-04-19 15:48:26 +0000345 [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test end time: $(date)" ; }
Chris Dearman37550cf2012-10-17 19:54:01 -0700346
mridgea9e38572005-04-19 15:48:26 +0000347 [ "$GENLOAD" -eq 1 ] && { killall -9 genload ; }
348 [ "$NETPIPE" -eq 1 ] && { killall -9 NPtcp ; }
Chris Dearman37550cf2012-10-17 19:54:01 -0700349
mridgea9e38572005-04-19 15:48:26 +0000350 [ "$ALT_DIR" -eq 1 ] && \
351 {
352 cat <<-EOF >&1
Chris Dearman37550cf2012-10-17 19:54:01 -0700353
mridgea9e38572005-04-19 15:48:26 +0000354 ###############################################################"
Chris Dearman37550cf2012-10-17 19:54:01 -0700355
mridgea9e38572005-04-19 15:48:26 +0000356 Done executing testcases."
357 result log is in the $LTPROOT/results directory"
Chris Dearman37550cf2012-10-17 19:54:01 -0700358
mridgea9e38572005-04-19 15:48:26 +0000359 ###############################################################"
Chris Dearman37550cf2012-10-17 19:54:01 -0700360
mridgea9e38572005-04-19 15:48:26 +0000361 EOF
362 }
363 exit $VALUE
364}
365
366cleanup()
367{
368 rm -rf ${TMP}
369}
370
371trap "cleanup" 0
372setup
373main "$@"
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800374
375#vim: syntax=sh