mridge | a9e3857 | 2005-04-19 15:48:26 +0000 | [diff] [blame] | 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 |
| 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 | |
| 41 | setup() |
| 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 | { |
| 55 | echo "FATAL: Test suite not installed correctly" |
| 56 | echo "INFO: as root user type 'make ; make install'" |
| 57 | exit 1 |
| 58 | } |
| 59 | |
| 60 | [ -e $LTPROOT/pan/pan ] || |
| 61 | { |
| 62 | echo "FATAL: Test suite driver 'pan' not found" |
| 63 | echo "INFO: as root user type 'make ; make install'" |
| 64 | exit 1 |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | |
| 69 | usage() |
| 70 | { |
| 71 | cat <<-EOF >&2 |
| 72 | |
| 73 | usage: ./${0##*/} -c [-d TMPDIR] [-i # (in Mb)] |
| 74 | [ -l LOGFILE ] [ -o OUTPUTFILE ] [ -m # (in Mb)] -N -q |
| 75 | [ -r LTPROOT ] -v |
| 76 | |
| 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. |
| 88 | -v Print more verbose output to screen. |
| 89 | |
| 90 | example: ./${0##*/} -i 1024 -m 128 -p -q -l /tmp/resultlog.$$ -d ${PWD} |
| 91 | |
| 92 | |
| 93 | EOF |
| 94 | exit 0 |
| 95 | } |
| 96 | |
| 97 | |
| 98 | main() |
| 99 | { |
| 100 | local CMDFILE="ltplite" |
| 101 | local PRETTY_PRT="" |
| 102 | local ALT_DIR=0 |
| 103 | local RUN_NETEST=0 |
| 104 | local QUIET_MODE="" |
| 105 | local VERBOSE_MODE="" |
| 106 | local NETPIPE=0 |
| 107 | local GENLOAD=0 |
| 108 | local MEMSIZE=0 |
| 109 | local DURATION="" |
| 110 | local BYTESIZE=0 |
| 111 | local LOGFILE="" |
| 112 | local SCENFILES="" |
| 113 | local PRETTY_PRT="" |
| 114 | local TAG_RESTRICT_STRING="" |
| 115 | local PAN_COMMAND="" |
| 116 | |
mreed10 | 352a8ae | 2006-10-13 16:49:12 +0000 | [diff] [blame] | 117 | while getopts c:d:hi:l:m:No:pqr:v arg |
mridge | a9e3857 | 2005-04-19 15:48:26 +0000 | [diff] [blame] | 118 | do case $arg in |
| 119 | c) |
| 120 | NUM_PROCS=$(($OPTARG)) |
| 121 | $LTPROOT/testcases/bin/genload --cpu $NUM_PROCS >/dev/null 2>&1 & |
| 122 | GENLOAD=1 ;; |
| 123 | |
| 124 | d) # append $$ to TMP, as it is recursively |
| 125 | # removed at end of script. |
| 126 | TMPBASE=$OPTARG |
| 127 | TMP="${TMPBASE}/ltp-$$" |
| 128 | export TMPDIR="$TMP";; |
| 129 | |
| 130 | h) usage;; |
| 131 | |
| 132 | i) |
| 133 | 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 \ |
| 136 | >/dev/null 2>&1 & |
| 137 | GENLOAD=1 ;; |
| 138 | |
| 139 | l) |
| 140 | |
| 141 | echo "INFO: creating $LTPROOT/results directory" |
| 142 | [ ! -d $LTPROOT/results ] && \ |
| 143 | { |
| 144 | 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" ;; |
| 153 | *) |
| 154 | LOGFILE="-l $LTPROOT/results/$OPTARG" |
| 155 | ALT_DIR=1 ;; |
| 156 | esac ;; |
| 157 | |
| 158 | m) |
| 159 | MEMSIZE=$(($OPTARG * 1024 * 1024)) |
| 160 | $LTPROOT/testcases/bin/genload --vm 0 --vm-bytes $MEMSIZE \ |
| 161 | >/dev/null 2>&1 & |
| 162 | GENLOAD=1;; |
| 163 | |
| 164 | N) RUN_NETEST=1;; |
| 165 | |
| 166 | o) OUTPUTFILE="-o $OPTARG" ;; |
| 167 | |
| 168 | p) PRETTY_PRT=" -p ";; |
| 169 | |
| 170 | q) QUIET_MODE=" -q ";; |
| 171 | |
| 172 | r) LTPROOT=$OPTARG;; |
| 173 | |
| 174 | v) VERBOSE_MODE=1;; |
| 175 | |
| 176 | \?) usage;; |
| 177 | esac |
| 178 | done |
| 179 | |
| 180 | |
| 181 | mkdir -p $TMP || \ |
| 182 | { |
| 183 | echo "FATAL: Unable to make temporary directory $TMP" |
| 184 | exit 1 |
| 185 | } |
| 186 | |
| 187 | cd $TMP || \ |
| 188 | { |
| 189 | echo "could not cd ${TMP} ... exiting" |
| 190 | exit 1 |
| 191 | } |
| 192 | |
| 193 | # Run Networking tests ? |
| 194 | |
| 195 | [ "$RUN_NETEST" -eq 1 ] && \ |
| 196 | { |
| 197 | [ -z "$RHOST" ] || [ -z "$PASSWD" ] && \ |
| 198 | { |
| 199 | [ -z "$RHOST" ] && \ |
| 200 | { |
| 201 | echo \ |
| 202 | "INFO: Enter RHOST = 'name of the remote host machine'" |
| 203 | echo -n "-> " |
| 204 | read RHOST |
| 205 | } |
| 206 | |
| 207 | [ -z "$PASSWD" ] && \ |
| 208 | { |
| 209 | echo " " |
| 210 | echo \ |
| 211 | "INFO: Enter PASSWD = 'root passwd of the remote host machine'" |
| 212 | echo -n "-> " |
| 213 | read PASSWD |
| 214 | } |
| 215 | export RHOST=$RHOST |
| 216 | export PASSWD=$PASSWD |
| 217 | echo "WARNING: security of $RHOST may be compromised" |
| 218 | } |
| 219 | } |
| 220 | |
| 221 | # If user does not provide a command file select a default set of testcases |
| 222 | # to execute. |
| 223 | if [ -f $CMDFILE ] || \ |
| 224 | CMDFILE="$LTPROOT/runtest/$CMDFILE" |
| 225 | then |
| 226 | cat $CMDFILE > ${TMP}/alltests || \ |
| 227 | { |
| 228 | echo "FATAL: Unable to create command file" |
| 229 | exit 1 |
| 230 | } |
| 231 | fi |
| 232 | |
| 233 | [ "$RUN_NETEST" -eq 1 ] && \ |
| 234 | { |
| 235 | for SCENFILES in ${LTPROOT}/runtest/tcp_cmds \ |
| 236 | ${LTPROOT}/runtest/multicast \ |
| 237 | ${LTPROOT}/runtest/rpc \ |
| 238 | ${LTPROOT}/runtest/nfs |
| 239 | do |
vapier | e42c4b2 | 2008-03-08 12:49:06 +0000 | [diff] [blame] | 240 | [ -e "$SCENFILES" ] || \ |
mridge | a9e3857 | 2005-04-19 15:48:26 +0000 | [diff] [blame] | 241 | { |
| 242 | echo "FATAL: missing scenario file $SCENFILES" |
| 243 | exit 1 |
| 244 | } |
| 245 | |
| 246 | cat $SCENFILES >> ${TMP}/alltests || \ |
| 247 | { |
| 248 | echo "FATAL: unable to create command file" |
| 249 | exit 1 |
| 250 | } |
| 251 | done |
| 252 | } |
| 253 | |
| 254 | # The fsx-linux tests use the SCRATCHDEV environment variable as a location |
| 255 | # that can be reformatted and run on. Set SCRATCHDEV if you want to run |
| 256 | # these tests. As a safeguard, this is disabled. |
| 257 | unset SCRATCHDEV |
| 258 | [ -n "$SCRATCHDEV" ] && \ |
| 259 | { |
| 260 | cat ${LTPROOT}/runtest/fsx >> ${TMP}/alltests || |
| 261 | { |
| 262 | echo "FATAL: unable to create fsx-linux tests command file" |
| 263 | exit 1 |
| 264 | } |
| 265 | } |
| 266 | |
| 267 | # check for required users and groups |
| 268 | ${LTPROOT}/IDcheck.sh &>/dev/null || \ |
| 269 | { |
| 270 | echo "WARNING: required users and groups not present" |
| 271 | echo "WARNING: some test cases may fail" |
| 272 | } |
| 273 | |
| 274 | |
| 275 | |
| 276 | # display versions of installed software |
| 277 | [ -z "$QUIET_MODE" ] && \ |
| 278 | { |
| 279 | ${LTPROOT}/ver_linux || \ |
| 280 | { |
| 281 | echo "WARNING: unable to display versions of software installed" |
| 282 | exit 1 |
| 283 | } |
| 284 | } |
| 285 | |
| 286 | [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test start time: $(date)" ; } |
| 287 | PAN_COMMAND="${LTPROOT}/pan/pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ \ |
| 288 | -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE" |
| 289 | if [ ! -z "$VERBOSE_MODE" ] ; then |
| 290 | echo "COMMAND: $PAN_COMMAND" |
| 291 | if [ ! -z "$TAG_RESTRICT_STRING" ] ; then |
| 292 | echo "INFO: Restricted to $TAG_RESTRICT_STRING" |
| 293 | fi |
| 294 | fi |
| 295 | #$PAN_COMMAND #Duplicated code here, because otherwise if we fail, only "PAN_COMMAND" gets output |
| 296 | ${LTPROOT}/pan/pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ \ |
| 297 | -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE |
| 298 | |
| 299 | if [ $? -eq 0 ]; then |
| 300 | echo "INFO: pan reported all tests PASS" |
| 301 | VALUE=0 |
| 302 | else |
| 303 | echo "INFO: pan reported some tests FAIL" |
| 304 | VALUE=1 |
| 305 | fi |
| 306 | [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test end time: $(date)" ; } |
| 307 | |
| 308 | [ "$GENLOAD" -eq 1 ] && { killall -9 genload ; } |
| 309 | [ "$NETPIPE" -eq 1 ] && { killall -9 NPtcp ; } |
| 310 | |
| 311 | [ "$ALT_DIR" -eq 1 ] && \ |
| 312 | { |
| 313 | cat <<-EOF >&1 |
| 314 | |
| 315 | ###############################################################" |
| 316 | |
| 317 | Done executing testcases." |
| 318 | result log is in the $LTPROOT/results directory" |
| 319 | |
| 320 | ###############################################################" |
| 321 | |
| 322 | EOF |
| 323 | } |
| 324 | exit $VALUE |
| 325 | } |
| 326 | |
| 327 | cleanup() |
| 328 | { |
| 329 | rm -rf ${TMP} |
| 330 | } |
| 331 | |
| 332 | trap "cleanup" 0 |
| 333 | setup |
| 334 | main "$@" |