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 | |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 60 | [ -e $LTPROOT/bin/ltp-pan ] || |
mridge | a9e3857 | 2005-04-19 15:48:26 +0000 | [diff] [blame] | 61 | { |
subrata_modak | 14390fd | 2009-05-19 09:39:11 +0000 | [diff] [blame] | 62 | echo "FATAL: Test suite driver 'ltp-pan' not found" |
mridge | a9e3857 | 2005-04-19 15:48:26 +0000 | [diff] [blame] | 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. |
mridge | a9e3857 | 2005-04-19 15:48:26 +0000 | [diff] [blame] | 88 | |
| 89 | example: ./${0##*/} -i 1024 -m 128 -p -q -l /tmp/resultlog.$$ -d ${PWD} |
| 90 | |
| 91 | |
| 92 | EOF |
| 93 | exit 0 |
| 94 | } |
| 95 | |
| 96 | |
| 97 | main() |
| 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="" |
| 111 | local SCENFILES="" |
| 112 | local PRETTY_PRT="" |
| 113 | local TAG_RESTRICT_STRING="" |
| 114 | local PAN_COMMAND="" |
| 115 | |
subrata_modak | 8266c29 | 2009-10-13 12:10:13 +0000 | [diff] [blame] | 116 | while getopts c:d:hi:l:m:No:pqr: arg |
mridge | a9e3857 | 2005-04-19 15:48:26 +0000 | [diff] [blame] | 117 | do case $arg in |
| 118 | c) |
| 119 | NUM_PROCS=$(($OPTARG)) |
| 120 | $LTPROOT/testcases/bin/genload --cpu $NUM_PROCS >/dev/null 2>&1 & |
| 121 | GENLOAD=1 ;; |
| 122 | |
| 123 | d) # append $$ to TMP, as it is recursively |
| 124 | # removed at end of script. |
| 125 | TMPBASE=$OPTARG |
| 126 | TMP="${TMPBASE}/ltp-$$" |
| 127 | export TMPDIR="$TMP";; |
| 128 | |
| 129 | h) usage;; |
| 130 | |
| 131 | i) |
| 132 | BYTESIZE=$(($OPTARG * 1024 * 1024)) |
| 133 | $LTPROOT/testcases/bin/genload --io 1 >/dev/null 2>&1 & |
| 134 | $LTPROOT/testcases/bin/genload --hdd 0 --hdd-bytes $BYTESIZE \ |
| 135 | >/dev/null 2>&1 & |
| 136 | GENLOAD=1 ;; |
| 137 | |
| 138 | l) |
| 139 | |
mridge | a9e3857 | 2005-04-19 15:48:26 +0000 | [diff] [blame] | 140 | [ ! -d $LTPROOT/results ] && \ |
| 141 | { |
uid311324 | adebaed | 2009-10-15 21:54:49 +0000 | [diff] [blame] | 142 | echo "INFO: creating $LTPROOT/results directory" |
mridge | a9e3857 | 2005-04-19 15:48:26 +0000 | [diff] [blame] | 143 | mkdir -p $LTPROOT/results || \ |
| 144 | { |
| 145 | echo "ERROR: failed to create $LTPROOT/results" |
| 146 | exit 1 |
| 147 | } |
| 148 | } |
| 149 | case $OPTARG in |
| 150 | /*) |
| 151 | LOGFILE="-l $OPTARG" ;; |
| 152 | *) |
| 153 | LOGFILE="-l $LTPROOT/results/$OPTARG" |
| 154 | ALT_DIR=1 ;; |
| 155 | esac ;; |
| 156 | |
| 157 | m) |
| 158 | MEMSIZE=$(($OPTARG * 1024 * 1024)) |
| 159 | $LTPROOT/testcases/bin/genload --vm 0 --vm-bytes $MEMSIZE \ |
| 160 | >/dev/null 2>&1 & |
| 161 | GENLOAD=1;; |
| 162 | |
| 163 | N) RUN_NETEST=1;; |
| 164 | |
| 165 | o) OUTPUTFILE="-o $OPTARG" ;; |
| 166 | |
| 167 | p) PRETTY_PRT=" -p ";; |
| 168 | |
| 169 | q) QUIET_MODE=" -q ";; |
| 170 | |
| 171 | r) LTPROOT=$OPTARG;; |
| 172 | |
mridge | a9e3857 | 2005-04-19 15:48:26 +0000 | [diff] [blame] | 173 | \?) usage;; |
| 174 | esac |
| 175 | done |
| 176 | |
| 177 | |
| 178 | mkdir -p $TMP || \ |
| 179 | { |
| 180 | echo "FATAL: Unable to make temporary directory $TMP" |
| 181 | exit 1 |
| 182 | } |
| 183 | |
| 184 | cd $TMP || \ |
| 185 | { |
| 186 | echo "could not cd ${TMP} ... exiting" |
| 187 | exit 1 |
| 188 | } |
| 189 | |
| 190 | # Run Networking tests ? |
| 191 | |
| 192 | [ "$RUN_NETEST" -eq 1 ] && \ |
| 193 | { |
| 194 | [ -z "$RHOST" ] || [ -z "$PASSWD" ] && \ |
| 195 | { |
| 196 | [ -z "$RHOST" ] && \ |
| 197 | { |
| 198 | echo \ |
| 199 | "INFO: Enter RHOST = 'name of the remote host machine'" |
| 200 | echo -n "-> " |
| 201 | read RHOST |
| 202 | } |
| 203 | |
| 204 | [ -z "$PASSWD" ] && \ |
| 205 | { |
| 206 | echo " " |
| 207 | echo \ |
| 208 | "INFO: Enter PASSWD = 'root passwd of the remote host machine'" |
| 209 | echo -n "-> " |
| 210 | read PASSWD |
| 211 | } |
| 212 | export RHOST=$RHOST |
| 213 | export PASSWD=$PASSWD |
| 214 | echo "WARNING: security of $RHOST may be compromised" |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | # If user does not provide a command file select a default set of testcases |
| 219 | # to execute. |
| 220 | if [ -f $CMDFILE ] || \ |
| 221 | CMDFILE="$LTPROOT/runtest/$CMDFILE" |
| 222 | then |
| 223 | cat $CMDFILE > ${TMP}/alltests || \ |
| 224 | { |
| 225 | echo "FATAL: Unable to create command file" |
| 226 | exit 1 |
| 227 | } |
| 228 | fi |
| 229 | |
| 230 | [ "$RUN_NETEST" -eq 1 ] && \ |
| 231 | { |
| 232 | for SCENFILES in ${LTPROOT}/runtest/tcp_cmds \ |
| 233 | ${LTPROOT}/runtest/multicast \ |
| 234 | ${LTPROOT}/runtest/rpc \ |
| 235 | ${LTPROOT}/runtest/nfs |
| 236 | do |
vapier | e42c4b2 | 2008-03-08 12:49:06 +0000 | [diff] [blame] | 237 | [ -e "$SCENFILES" ] || \ |
mridge | a9e3857 | 2005-04-19 15:48:26 +0000 | [diff] [blame] | 238 | { |
| 239 | echo "FATAL: missing scenario file $SCENFILES" |
| 240 | exit 1 |
| 241 | } |
| 242 | |
| 243 | cat $SCENFILES >> ${TMP}/alltests || \ |
| 244 | { |
| 245 | echo "FATAL: unable to create command file" |
| 246 | exit 1 |
| 247 | } |
| 248 | done |
| 249 | } |
| 250 | |
| 251 | # The fsx-linux tests use the SCRATCHDEV environment variable as a location |
| 252 | # that can be reformatted and run on. Set SCRATCHDEV if you want to run |
| 253 | # these tests. As a safeguard, this is disabled. |
| 254 | unset SCRATCHDEV |
| 255 | [ -n "$SCRATCHDEV" ] && \ |
| 256 | { |
| 257 | cat ${LTPROOT}/runtest/fsx >> ${TMP}/alltests || |
| 258 | { |
| 259 | echo "FATAL: unable to create fsx-linux tests command file" |
| 260 | exit 1 |
| 261 | } |
| 262 | } |
| 263 | |
| 264 | # check for required users and groups |
| 265 | ${LTPROOT}/IDcheck.sh &>/dev/null || \ |
| 266 | { |
| 267 | echo "WARNING: required users and groups not present" |
| 268 | echo "WARNING: some test cases may fail" |
| 269 | } |
| 270 | |
| 271 | |
| 272 | |
| 273 | # display versions of installed software |
| 274 | [ -z "$QUIET_MODE" ] && \ |
| 275 | { |
| 276 | ${LTPROOT}/ver_linux || \ |
| 277 | { |
| 278 | echo "WARNING: unable to display versions of software installed" |
| 279 | exit 1 |
| 280 | } |
| 281 | } |
| 282 | |
| 283 | [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test start time: $(date)" ; } |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 284 | PAN_COMMAND="${LTPROOT}/bin/ltp-pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ \ |
mridge | a9e3857 | 2005-04-19 15:48:26 +0000 | [diff] [blame] | 285 | -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE" |
| 286 | if [ ! -z "$VERBOSE_MODE" ] ; then |
| 287 | echo "COMMAND: $PAN_COMMAND" |
| 288 | if [ ! -z "$TAG_RESTRICT_STRING" ] ; then |
| 289 | echo "INFO: Restricted to $TAG_RESTRICT_STRING" |
| 290 | fi |
| 291 | fi |
| 292 | #$PAN_COMMAND #Duplicated code here, because otherwise if we fail, only "PAN_COMMAND" gets output |
subrata_modak | 724098e | 2009-03-19 08:49:18 +0000 | [diff] [blame] | 293 | # Some tests need to run inside the "bin" directory. |
| 294 | cd "${LTPROOT}/testcases/bin" |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 295 | ${LTPROOT}/bin/ltp-pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ \ |
mridge | a9e3857 | 2005-04-19 15:48:26 +0000 | [diff] [blame] | 296 | -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE |
| 297 | |
| 298 | if [ $? -eq 0 ]; then |
subrata_modak | 14390fd | 2009-05-19 09:39:11 +0000 | [diff] [blame] | 299 | echo "INFO: ltp-pan reported all tests PASS" |
mridge | a9e3857 | 2005-04-19 15:48:26 +0000 | [diff] [blame] | 300 | VALUE=0 |
| 301 | else |
subrata_modak | 14390fd | 2009-05-19 09:39:11 +0000 | [diff] [blame] | 302 | echo "INFO: ltp-pan reported some tests FAIL" |
mridge | a9e3857 | 2005-04-19 15:48:26 +0000 | [diff] [blame] | 303 | VALUE=1 |
| 304 | fi |
subrata_modak | 724098e | 2009-03-19 08:49:18 +0000 | [diff] [blame] | 305 | cd .. |
mridge | a9e3857 | 2005-04-19 15:48:26 +0000 | [diff] [blame] | 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 "$@" |