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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ## 19## ## 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 29# 30# History: Created runltplite script to run a subset of the LTP testsuite 31# 32# 33# 34# 35# 36# 37# 38# 39 40. "$(dirname $0)/runltp" 41 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 54 export LTP_DEV="" 55 export LTP_DEV_FS_TYPE="ext2" 56 57 [ -d $LTPROOT/testcases/bin ] || 58 { 59 echo "FATAL: LTP not installed correctly" 60 echo "INFO: Follow directions in INSTALL!" 61 exit 1 62 } 63 64 [ -e $LTPROOT/bin/ltp-pan ] || 65 { 66 echo "FATAL: Test suite driver 'ltp-pan' not found" 67 echo "INFO: Follow directions in INSTALL!" 68 exit 1 69 } 70} 71 72 73usage() 74{ 75 cat <<-EOF >&2 76 77 usage: ${0##*/} -c [-d TMPDIR] [-i # (in Mb)] 78 [ -l LOGFILE ] [ -o OUTPUTFILE ] [ -m # (in Mb)] -N -q 79 [ -r LTPROOT ] -v 80 81 -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. 87 -N Run all the networking tests. 88 -o OUTPUTFILE Redirect test output to a file. 89 -p Human readable format logfiles. 90 -q Print less verbose output to screen. 91 -r LTPROOT Fully qualified path where testsuite is installed. 92 -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. 95 96 example: ${0##*/} -i 1024 -m 128 -p -q -l /tmp/resultlog.$$ -d ${PWD} 97 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="" 118 local PRETTY_PRT="" 119 local TAG_RESTRICT_STRING="" 120 local PAN_COMMAND="" 121 122 local scenfile="" 123 124 while getopts c:d:hi:l:m:No:pqr:b:B: arg 125 do case $arg in 126 c) 127 NUM_PROCS=$(($OPTARG)) 128 $LTPROOT/testcases/bin/genload --cpu $NUM_PROCS >/dev/null 2>&1 & 129 GENLOAD=1 ;; 130 131 d) # append $$ to TMP, as it is recursively 132 # removed at end of script. 133 TMPBASE=$OPTARG 134 TMP="${TMPBASE}/ltp-$$" 135 export TMPDIR="$TMP";; 136 137 h) usage;; 138 139 i) 140 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 \ 143 >/dev/null 2>&1 & 144 GENLOAD=1 ;; 145 146 l) 147 148 [ ! -d $LTPROOT/results ] && \ 149 { 150 echo "INFO: creating $LTPROOT/results directory" 151 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" ;; 160 *) 161 LOGFILE="-l $LTPROOT/results/$OPTARG" 162 ALT_DIR=1 ;; 163 esac ;; 164 165 m) 166 MEMSIZE=$(($OPTARG * 1024 * 1024)) 167 $LTPROOT/testcases/bin/genload --vm 0 --vm-bytes $MEMSIZE \ 168 >/dev/null 2>&1 & 169 GENLOAD=1;; 170 171 N) RUN_NETEST=1;; 172 173 o) OUTPUTFILE="-o $OPTARG" ;; 174 175 p) PRETTY_PRT=" -p ";; 176 177 q) QUIET_MODE=" -q ";; 178 179 r) LTPROOT=$OPTARG;; 180 181 b) DEVICE=$OPTARG;; 182 183 B) LTP_DEV_FS_TYPE=$OPTARG;; 184 185 186 \?) usage;; 187 esac 188 done 189 190 191 mkdir -p $TMP || \ 192 { 193 echo "FATAL: Unable to make temporary directory $TMP" 194 exit 1 195 } 196 197 cd $TMP || \ 198 { 199 echo "could not cd ${TMP} ... exiting" 200 exit 1 201 } 202 203# Run Networking tests ? 204 205 [ "$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 } 230 231 # 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 242 243 if [ "$RUN_NETEST" -eq 1 ]; then 244 SCENARIO_LISTS="$SCENARIO_LISTS $LTPROOT/scenario_groups/network" 245 fi 246 247 # 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.$$ 252 (cat $SCENARIO_LISTS && touch "$cat_ok_sentinel") | \ 253 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 276 # The fsx-linux tests use the SCRATCHDEV environment variable as a location 277 # that can be reformatted and run on. Set SCRATCHDEV if you want to run 278 # 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 } 288 289 # 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 } 295 296 [ -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 } 309 310 # display versions of installed software 311 [ -z "$QUIET_MODE" ] && \ 312 { 313 ${LTPROOT}/ver_linux || \ 314 { 315 echo "WARNING: unable to display versions of software installed" 316 exit 1 317 } 318 } 319 320 set_block_device 321 322 [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test start time: $(date)" ; } 323 PAN_COMMAND="${LTPROOT}/bin/ltp-pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ \ 324 -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 332 # Some tests need to run inside the "bin" directory. 333 cd "${LTPROOT}/testcases/bin" 334 ${LTPROOT}/bin/ltp-pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ \ 335 -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE 336 337 if [ $? -eq 0 ]; then 338 echo "INFO: ltp-pan reported all tests PASS" 339 VALUE=0 340 else 341 echo "INFO: ltp-pan reported some tests FAIL" 342 VALUE=1 343 fi 344 cd .. 345 [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test end time: $(date)" ; } 346 347 [ "$GENLOAD" -eq 1 ] && { killall -9 genload ; } 348 [ "$NETPIPE" -eq 1 ] && { killall -9 NPtcp ; } 349 350 [ "$ALT_DIR" -eq 1 ] && \ 351 { 352 cat <<-EOF >&1 353 354 ###############################################################" 355 356 Done executing testcases." 357 result log is in the $LTPROOT/results directory" 358 359 ###############################################################" 360 361 EOF 362 } 363 exit $VALUE 364} 365 366cleanup() 367{ 368 rm -rf ${TMP} 369} 370 371trap "cleanup" 0 372setup 373main "$@" 374 375#vim: syntax=sh 376