blob: 9313649ffdbac2d92e5991f88aca7de0a2e33c6e [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.
Satheesh Rajendranfa12e222016-07-15 00:37:14 +053092 -S SKIPFILE Skip tests specified in SKIPFILE.
Harald Weppner8bdf0a02014-03-03 14:10:07 -080093 -b DEVICE Some tests require an unmounted block device to run
94 correctly.
95 -B LTP_DEV_FS_TYPE The file system of test block devices.
mridgea9e38572005-04-19 15:48:26 +000096
Garrett Cooperf95875a2010-03-05 02:44:39 -080097 example: ${0##*/} -i 1024 -m 128 -p -q -l /tmp/resultlog.$$ -d ${PWD}
mridgea9e38572005-04-19 15:48:26 +000098
99
100 EOF
101exit 0
102}
103
104
105main()
106{
107 local CMDFILE="ltplite"
108 local PRETTY_PRT=""
109 local ALT_DIR=0
110 local RUN_NETEST=0
111 local QUIET_MODE=""
112 local VERBOSE_MODE=""
113 local NETPIPE=0
114 local GENLOAD=0
115 local MEMSIZE=0
116 local DURATION=""
117 local BYTESIZE=0
118 local LOGFILE=""
mridgea9e38572005-04-19 15:48:26 +0000119 local PRETTY_PRT=""
120 local TAG_RESTRICT_STRING=""
121 local PAN_COMMAND=""
122
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800123 local scenfile=""
124
Wanlong Gaoa3469022016-07-29 16:44:12 +0800125 while getopts c:d:hi:l:m:No:pqr:S:b:B: arg
mridgea9e38572005-04-19 15:48:26 +0000126 do case $arg in
Chris Dearman37550cf2012-10-17 19:54:01 -0700127 c)
mridgea9e38572005-04-19 15:48:26 +0000128 NUM_PROCS=$(($OPTARG))
129 $LTPROOT/testcases/bin/genload --cpu $NUM_PROCS >/dev/null 2>&1 &
130 GENLOAD=1 ;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700131
132 d) # append $$ to TMP, as it is recursively
mridgea9e38572005-04-19 15:48:26 +0000133 # removed at end of script.
134 TMPBASE=$OPTARG
135 TMP="${TMPBASE}/ltp-$$"
136 export TMPDIR="$TMP";;
Chris Dearman37550cf2012-10-17 19:54:01 -0700137
mridgea9e38572005-04-19 15:48:26 +0000138 h) usage;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700139
140 i)
mridgea9e38572005-04-19 15:48:26 +0000141 BYTESIZE=$(($OPTARG * 1024 * 1024))
142 $LTPROOT/testcases/bin/genload --io 1 >/dev/null 2>&1 &
143 $LTPROOT/testcases/bin/genload --hdd 0 --hdd-bytes $BYTESIZE \
Chris Dearman37550cf2012-10-17 19:54:01 -0700144 >/dev/null 2>&1 &
mridgea9e38572005-04-19 15:48:26 +0000145 GENLOAD=1 ;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700146
147 l)
mridgea9e38572005-04-19 15:48:26 +0000148
mridgea9e38572005-04-19 15:48:26 +0000149 [ ! -d $LTPROOT/results ] && \
150 {
uid311324adebaed2009-10-15 21:54:49 +0000151 echo "INFO: creating $LTPROOT/results directory"
mridgea9e38572005-04-19 15:48:26 +0000152 mkdir -p $LTPROOT/results || \
153 {
154 echo "ERROR: failed to create $LTPROOT/results"
155 exit 1
156 }
157 }
158 case $OPTARG in
159 /*)
160 LOGFILE="-l $OPTARG" ;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700161 *)
mridgea9e38572005-04-19 15:48:26 +0000162 LOGFILE="-l $LTPROOT/results/$OPTARG"
163 ALT_DIR=1 ;;
164 esac ;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700165
166 m)
167 MEMSIZE=$(($OPTARG * 1024 * 1024))
mridgea9e38572005-04-19 15:48:26 +0000168 $LTPROOT/testcases/bin/genload --vm 0 --vm-bytes $MEMSIZE \
Chris Dearman37550cf2012-10-17 19:54:01 -0700169 >/dev/null 2>&1 &
mridgea9e38572005-04-19 15:48:26 +0000170 GENLOAD=1;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700171
mridgea9e38572005-04-19 15:48:26 +0000172 N) RUN_NETEST=1;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700173
mridgea9e38572005-04-19 15:48:26 +0000174 o) OUTPUTFILE="-o $OPTARG" ;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700175
mridgea9e38572005-04-19 15:48:26 +0000176 p) PRETTY_PRT=" -p ";;
Chris Dearman37550cf2012-10-17 19:54:01 -0700177
mridgea9e38572005-04-19 15:48:26 +0000178 q) QUIET_MODE=" -q ";;
Chris Dearman37550cf2012-10-17 19:54:01 -0700179
mridgea9e38572005-04-19 15:48:26 +0000180 r) LTPROOT=$OPTARG;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700181
Satheesh Rajendranfa12e222016-07-15 00:37:14 +0530182 S) case $OPTARG in
183 /*)
184 SKIPFILE=$OPTARG;;
185 *)
186 SKIPFILE="$LTPROOT/$OPTARG";;
187 esac ;;
188
Harald Weppner8bdf0a02014-03-03 14:10:07 -0800189 b) DEVICE=$OPTARG;;
190
191 B) LTP_DEV_FS_TYPE=$OPTARG;;
192
193
mridgea9e38572005-04-19 15:48:26 +0000194 \?) usage;;
195 esac
196 done
Chris Dearman37550cf2012-10-17 19:54:01 -0700197
198
mridgea9e38572005-04-19 15:48:26 +0000199 mkdir -p $TMP || \
200 {
201 echo "FATAL: Unable to make temporary directory $TMP"
202 exit 1
203 }
Chris Dearman37550cf2012-10-17 19:54:01 -0700204
mridgea9e38572005-04-19 15:48:26 +0000205 cd $TMP || \
206 {
207 echo "could not cd ${TMP} ... exiting"
208 exit 1
209 }
210
211# Run Networking tests ?
Chris Dearman37550cf2012-10-17 19:54:01 -0700212
mridgea9e38572005-04-19 15:48:26 +0000213 [ "$RUN_NETEST" -eq 1 ] && \
214 {
215 [ -z "$RHOST" ] || [ -z "$PASSWD" ] && \
216 {
217 [ -z "$RHOST" ] && \
218 {
219 echo \
220 "INFO: Enter RHOST = 'name of the remote host machine'"
221 echo -n "-> "
222 read RHOST
223 }
224
225 [ -z "$PASSWD" ] && \
226 {
227 echo " "
228 echo \
229 "INFO: Enter PASSWD = 'root passwd of the remote host machine'"
230 echo -n "-> "
231 read PASSWD
232 }
233 export RHOST=$RHOST
234 export PASSWD=$PASSWD
235 echo "WARNING: security of $RHOST may be compromised"
236 }
237 }
Chris Dearman37550cf2012-10-17 19:54:01 -0700238
mridgea9e38572005-04-19 15:48:26 +0000239 # If user does not provide a command file select a default set of testcases
240 # to execute.
241 if [ -f $CMDFILE ] || \
242 CMDFILE="$LTPROOT/runtest/$CMDFILE"
243 then
244 cat $CMDFILE > ${TMP}/alltests || \
245 {
246 echo "FATAL: Unable to create command file"
247 exit 1
248 }
249 fi
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800250
251 if [ "$RUN_NETEST" -eq 1 ]; then
Garrett Cooper89fde872010-11-16 22:38:08 -0800252 SCENARIO_LISTS="$SCENARIO_LISTS $LTPROOT/scenario_groups/network"
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800253 fi
Chris Dearman37550cf2012-10-17 19:54:01 -0700254
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800255 # DO NOT INDENT/DEDENT!
256 if [ -n "$SCENARIO_LISTS" ]; then
257 # Insurance to make sure that the first element in the pipe
258 # completed successfully.
259 cat_ok_sentinel=$TMP/cat_ok.$$
Garrett Cooper66d67b52010-11-16 22:42:48 -0800260 (cat $SCENARIO_LISTS && touch "$cat_ok_sentinel") | \
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800261 while read scenfile; do
262
263 scenfile=${LTPROOT}/runtest/$scenfile
264
265 # Skip over non-existent scenario files; things are
266 # robust enough now that the build will fail if these
267 # files don't exist.
268 [ -f "$scenfile" ] || continue
269
270 cat $scenfile >> "$TMP/alltests" || {
271 echo "FATAL: unable to append to command file"
272 rm -Rf "$TMP"
273 rm -f "$cat_ok_sentinel"
274 exit 1
275 }
276
277 done
278
279 rm -f "$cat_ok_sentinel"
280
281 fi
282 # ^^DO NOT INDENT/DEDENT!^^
283
mridgea9e38572005-04-19 15:48:26 +0000284 # The fsx-linux tests use the SCRATCHDEV environment variable as a location
Chris Dearman37550cf2012-10-17 19:54:01 -0700285 # that can be reformatted and run on. Set SCRATCHDEV if you want to run
mridgea9e38572005-04-19 15:48:26 +0000286 # these tests. As a safeguard, this is disabled.
287 unset SCRATCHDEV
288 [ -n "$SCRATCHDEV" ] && \
289 {
290 cat ${LTPROOT}/runtest/fsx >> ${TMP}/alltests ||
291 {
292 echo "FATAL: unable to create fsx-linux tests command file"
293 exit 1
294 }
295 }
Chris Dearman37550cf2012-10-17 19:54:01 -0700296
mridgea9e38572005-04-19 15:48:26 +0000297 # check for required users and groups
Petr Vorel2bf20942016-11-29 09:22:37 +0100298 ${LTPROOT}/IDcheck.sh >/dev/null 2>&1 || \
mridgea9e38572005-04-19 15:48:26 +0000299 {
300 echo "WARNING: required users and groups not present"
301 echo "WARNING: some test cases may fail"
302 }
Chris Dearman37550cf2012-10-17 19:54:01 -0700303
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800304 [ -n "$CMDFILES" ] && \
305 {
306 for scenfile in `echo "$CMDFILES" | tr ',' ' '`
307 do
308 [ -f "$scenfile" ] || scenfile="$LTPROOT/runtest/$scenfile"
309 cat "$scenfile" >> ${TMP}/alltests || \
310 {
311 echo "FATAL: unable to create command file"
312 rm -Rf "$TMP"
313 exit 1
314 }
315 done
316 }
Chris Dearman37550cf2012-10-17 19:54:01 -0700317
Satheesh Rajendranfa12e222016-07-15 00:37:14 +0530318 # Blacklist or skip tests if a SKIPFILE was specified with -S
319 if [ -n "$SKIPFILE" ]
320 then
321 for file in $( cat $SKIPFILE ); do
322 sed -i "/^$file[ \t]/d" ${TMP}/alltests
323 done
324 fi
325
mridgea9e38572005-04-19 15:48:26 +0000326 # display versions of installed software
327 [ -z "$QUIET_MODE" ] && \
Chris Dearman37550cf2012-10-17 19:54:01 -0700328 {
mridgea9e38572005-04-19 15:48:26 +0000329 ${LTPROOT}/ver_linux || \
330 {
331 echo "WARNING: unable to display versions of software installed"
332 exit 1
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800333 }
mridgea9e38572005-04-19 15:48:26 +0000334 }
335
Harald Weppner8bdf0a02014-03-03 14:10:07 -0800336 set_block_device
337
mridgea9e38572005-04-19 15:48:26 +0000338 [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test start time: $(date)" ; }
yaberauneyaef772532009-10-09 17:55:43 +0000339 PAN_COMMAND="${LTPROOT}/bin/ltp-pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ \
mridgea9e38572005-04-19 15:48:26 +0000340 -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE"
341 if [ ! -z "$VERBOSE_MODE" ] ; then
342 echo "COMMAND: $PAN_COMMAND"
343 if [ ! -z "$TAG_RESTRICT_STRING" ] ; then
344 echo "INFO: Restricted to $TAG_RESTRICT_STRING"
345 fi
346 fi
347 #$PAN_COMMAND #Duplicated code here, because otherwise if we fail, only "PAN_COMMAND" gets output
subrata_modak724098e2009-03-19 08:49:18 +0000348 # Some tests need to run inside the "bin" directory.
349 cd "${LTPROOT}/testcases/bin"
yaberauneyaef772532009-10-09 17:55:43 +0000350 ${LTPROOT}/bin/ltp-pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ \
mridgea9e38572005-04-19 15:48:26 +0000351 -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE
Chris Dearman37550cf2012-10-17 19:54:01 -0700352
mridgea9e38572005-04-19 15:48:26 +0000353 if [ $? -eq 0 ]; then
subrata_modak14390fd2009-05-19 09:39:11 +0000354 echo "INFO: ltp-pan reported all tests PASS"
mridgea9e38572005-04-19 15:48:26 +0000355 VALUE=0
356 else
subrata_modak14390fd2009-05-19 09:39:11 +0000357 echo "INFO: ltp-pan reported some tests FAIL"
mridgea9e38572005-04-19 15:48:26 +0000358 VALUE=1
359 fi
subrata_modak724098e2009-03-19 08:49:18 +0000360 cd ..
mridgea9e38572005-04-19 15:48:26 +0000361 [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test end time: $(date)" ; }
Chris Dearman37550cf2012-10-17 19:54:01 -0700362
mridgea9e38572005-04-19 15:48:26 +0000363 [ "$GENLOAD" -eq 1 ] && { killall -9 genload ; }
364 [ "$NETPIPE" -eq 1 ] && { killall -9 NPtcp ; }
Chris Dearman37550cf2012-10-17 19:54:01 -0700365
mridgea9e38572005-04-19 15:48:26 +0000366 [ "$ALT_DIR" -eq 1 ] && \
367 {
368 cat <<-EOF >&1
Chris Dearman37550cf2012-10-17 19:54:01 -0700369
mridgea9e38572005-04-19 15:48:26 +0000370 ###############################################################"
Chris Dearman37550cf2012-10-17 19:54:01 -0700371
mridgea9e38572005-04-19 15:48:26 +0000372 Done executing testcases."
373 result log is in the $LTPROOT/results directory"
Chris Dearman37550cf2012-10-17 19:54:01 -0700374
mridgea9e38572005-04-19 15:48:26 +0000375 ###############################################################"
Chris Dearman37550cf2012-10-17 19:54:01 -0700376
mridgea9e38572005-04-19 15:48:26 +0000377 EOF
378 }
379 exit $VALUE
380}
381
382cleanup()
383{
384 rm -rf ${TMP}
385}
386
387trap "cleanup" 0
388setup
389main "$@"
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800390
391#vim: syntax=sh