plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | ################################################################################ |
| 3 | ## ## |
| 4 | ## Copyright (c) International Business Machines Corp., 2001 ## |
| 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: runltp |
| 22 | # |
| 23 | # Description: This script can be used to the tests in the LTP test suite |
| 24 | # |
| 25 | # Authors: Manoj Iyer - manjo@mail.utexas.edu |
| 26 | # Robbe Williamson - robbiew@us.ibm.com |
| 27 | # |
| 28 | # History: Oct 07 2003 - Modified - Manoj Iyer |
| 29 | # - use functions |
| 30 | # - clean up on script exit |
| 31 | # - error checking etc. |
| 32 | # |
| 33 | # Oct 08 2003 - Modified - Manoj Iyer |
| 34 | # - fixed bug in creating results directory |
| 35 | # - all checks should be enlclosed in " " to avoid bash error |
| 36 | # - exit with error if pan is not found in pan directory |
| 37 | |
| 38 | |
| 39 | setup() |
| 40 | { |
| 41 | cd `dirname $0` || \ |
| 42 | { |
| 43 | echo "FATAL: unable to change directory to $(dirname $0)" |
| 44 | exit 1 |
| 45 | } |
| 46 | export LTPROOT=${PWD} |
| 47 | export TMPBASE="/tmp" |
| 48 | export TMP="${TMPBASE}/ltp-$$" |
| 49 | export PATH="${PATH}:${LTPROOT}/testcases/bin" |
| 50 | |
| 51 | [ -d $LTPROOT/testcases/bin ] || |
| 52 | { |
| 53 | echo "FATAL: Test suite not installed correctly" |
| 54 | echo "INFO: as root user type 'make ; make install'" |
| 55 | exit 1 |
| 56 | } |
| 57 | |
| 58 | [ -e $LTPROOT/pan/pan ] || |
| 59 | { |
| 60 | echo "FATAL: Test suite driver 'pan' not found" |
| 61 | echo "INFO: as root user type 'make ; make install'" |
| 62 | exit 1 |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | |
| 67 | usage() |
| 68 | { |
| 69 | cat <<-EOF >&2 |
| 70 | |
| 71 | usage: ./${0##*/} -c [-d TMPDIR] [-f CMDFILE ] [-i # (in Mb)] |
| 72 | [ -l LOGFILE ] [ -o OUTPUTFILE ] [ -m # (in Mb)] -N -n -q |
robbiew | 7d43d77 | 2005-02-07 20:07:30 +0000 | [diff] [blame] | 73 | [ -r LTPROOT ] [ -s PATTERN ] [ -t DURATION ] -v [ -x INSTANCES ] |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 74 | |
| 75 | -c NUM_PROCS Run LTP under additional background CPU load. |
| 76 | -d TMPDIR Directory where temporary files will be created. |
| 77 | -f CMDFILE Execute user defined list of testcases. |
| 78 | -h Help. Prints all available options. |
| 79 | -i # (in Mb) Run LTP with a _min_ IO load of # Mb in background. |
| 80 | -l LOGFILE Log results of test in a logfile. |
| 81 | -m # (in Mb) Run LTP with a _min_ memory load of # Mb in background. |
| 82 | -N Run all the networking tests. |
| 83 | -n Run LTP with network traffic in background. |
| 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. |
robbiew | 7d43d77 | 2005-02-07 20:07:30 +0000 | [diff] [blame] | 88 | -s PATTERN Only run test cases which match PATTERN. |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 89 | -t DURATION Execute the testsuite for given duration. Examples: |
| 90 | -t 60s = 60 seconds |
| 91 | -t 45m = 45 minutes |
| 92 | -t 24h = 24 hours |
| 93 | -t 2d = 2 days |
robbiew | 7d43d77 | 2005-02-07 20:07:30 +0000 | [diff] [blame] | 94 | -v Print more verbose output to screen. |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 95 | -x INSTANCES Run multiple instances of this testsuite. |
| 96 | |
| 97 | example: ./${0##*/} -i 1024 -m 128 -p -q -l /tmp/resultlog.$$ -d ${PWD} |
| 98 | |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 99 | |
| 100 | EOF |
| 101 | exit 0 |
| 102 | } |
| 103 | |
| 104 | |
| 105 | main() |
| 106 | { |
| 107 | local CMDFILE="" |
| 108 | local PRETTY_PRT="" |
| 109 | local ALT_DIR=0 |
| 110 | local RUN_NETEST=0 |
| 111 | local QUIET_MODE="" |
robbiew | 7d43d77 | 2005-02-07 20:07:30 +0000 | [diff] [blame] | 112 | local VERBOSE_MODE="" |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 113 | local NETPIPE=0 |
| 114 | local GENLOAD=0 |
| 115 | local MEMSIZE=0 |
| 116 | local DURATION="" |
| 117 | local BYTESIZE=0 |
| 118 | local LOGFILE="" |
| 119 | local SCENFILES="" |
| 120 | local PRETTY_PRT="" |
robbiew | 7d43d77 | 2005-02-07 20:07:30 +0000 | [diff] [blame] | 121 | local TAG_RESTRICT_STRING="" |
| 122 | local PAN_COMMAND="" |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 123 | |
robbiew | 7d43d77 | 2005-02-07 20:07:30 +0000 | [diff] [blame] | 124 | while getopts c:d:f:hi:l:m:Nno:pqr:s:t:vx: arg |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 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 |
robbiew | 58247a5 | 2005-01-19 18:44:42 +0000 | [diff] [blame] | 134 | TMP="${TMPBASE}/ltp-$$" |
robbiew | 538bc1a | 2005-03-11 19:26:14 +0000 | [diff] [blame] | 135 | export TMPDIR="$TMP";; |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 136 | f) # Execute user defined set of testcases. |
| 137 | CMDFILE=$OPTARG;; |
| 138 | |
| 139 | h) usage;; |
| 140 | |
| 141 | i) |
| 142 | BYTESIZE=$(($OPTARG * 1024 * 1024)) |
| 143 | $LTPROOT/testcases/bin/genload --io 1 >/dev/null 2>&1 & |
| 144 | $LTPROOT/testcases/bin/genload --hdd 0 --hdd-bytes $BYTESIZE \ |
| 145 | >/dev/null 2>&1 & |
| 146 | GENLOAD=1 ;; |
| 147 | |
| 148 | l) |
| 149 | |
| 150 | echo "INFO: creating $LTPROOT/results directory" |
| 151 | [ ! -d $LTPROOT/results ] && \ |
| 152 | { |
| 153 | mkdir -p $LTPROOT/results || \ |
| 154 | { |
| 155 | echo "ERROR: failed to create $LTPROOT/results" |
| 156 | exit 1 |
| 157 | } |
| 158 | } |
| 159 | case $OPTARG in |
| 160 | /*) |
| 161 | LOGFILE="-l $OPTARG" ;; |
| 162 | *) |
| 163 | LOGFILE="-l $LTPROOT/results/$OPTARG" |
| 164 | ALT_DIR=1 ;; |
| 165 | esac ;; |
| 166 | |
| 167 | m) |
| 168 | MEMSIZE=$(($OPTARG * 1024 * 1024)) |
| 169 | $LTPROOT/testcases/bin/genload --vm 0 --vm-bytes $MEMSIZE \ |
| 170 | >/dev/null 2>&1 & |
| 171 | GENLOAD=1;; |
| 172 | |
| 173 | N) RUN_NETEST=1;; |
| 174 | |
| 175 | n) |
| 176 | $LTPROOT/testcases/bin/netpipe.sh |
| 177 | NETPIPE=1;; |
| 178 | |
| 179 | o) OUTPUTFILE="-o $OPTARG" ;; |
| 180 | |
| 181 | p) PRETTY_PRT=" -p ";; |
| 182 | |
| 183 | q) QUIET_MODE=" -q ";; |
| 184 | |
| 185 | r) LTPROOT=$OPTARG;; |
| 186 | |
robbiew | 7d43d77 | 2005-02-07 20:07:30 +0000 | [diff] [blame] | 187 | s) TAG_RESTRICT_STRING=$OPTARG;; |
| 188 | |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 189 | t) # In case you want to specify the time |
| 190 | # to run from the command line |
| 191 | # (2m = two minutes, 2h = two hours, etc) |
| 192 | DURATION="-t $OPTARG" ;; |
| 193 | |
robbiew | 7d43d77 | 2005-02-07 20:07:30 +0000 | [diff] [blame] | 194 | v) VERBOSE_MODE=1;; |
| 195 | |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 196 | x) # number of ltp's to run |
| 197 | cat <<-EOF >&1 |
| 198 | WARNING: The use of -x can cause unpredictable failures, as a |
| 199 | result of concurrently running multiple tests designed |
| 200 | to be ran exclusively. |
| 201 | Pausing for 10 seconds..." |
| 202 | EOF |
| 203 | sleep 10 |
| 204 | INSTANCES="-x $OPTARG -O ${TMP}";; |
| 205 | |
| 206 | \?) usage;; |
| 207 | esac |
| 208 | done |
| 209 | |
robbiew | 7d43d77 | 2005-02-07 20:07:30 +0000 | [diff] [blame] | 210 | if [ -n "$TAG_RESTRICT_STRING" ] ; then |
| 211 | if [ -n "$CMDFILE" ]; then |
| 212 | echo "FATAL -s and -f not supported together" |
| 213 | exit 1 |
| 214 | fi |
| 215 | if [ "$RUN_NETEST" -eq 1 ]; then |
| 216 | echo "FATAL -s and -N not supported together" |
| 217 | exit 1 |
| 218 | fi |
| 219 | fi |
| 220 | |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 221 | mkdir -p $TMP || \ |
| 222 | { |
robbiew | 7d43d77 | 2005-02-07 20:07:30 +0000 | [diff] [blame] | 223 | echo "FATAL: Unable to make temporary directory $TMP" |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 224 | exit 1 |
| 225 | } |
| 226 | |
| 227 | cd $TMP || \ |
| 228 | { |
| 229 | echo "could not cd ${TMP} ... exiting" |
| 230 | exit 1 |
| 231 | } |
| 232 | |
| 233 | [ "$RUN_NETEST" -eq 1 ] && \ |
| 234 | { |
| 235 | [ -z "$RHOST" ] || [ -z "$PASSWD" ] && \ |
| 236 | { |
| 237 | [ -z "$RHOST" ] && \ |
| 238 | { |
| 239 | echo \ |
| 240 | "INFO: Enter RHOST = 'name of the remote host machine'" |
| 241 | echo -n "-> " |
| 242 | read RHOST |
| 243 | } |
| 244 | |
| 245 | [ -z "$PASSWD" ] && \ |
| 246 | { |
| 247 | echo " " |
| 248 | echo \ |
| 249 | "INFO: Enter PASSWD = 'root passwd of the remote host machine'" |
| 250 | echo -n "-> " |
| 251 | read PASSWD |
| 252 | } |
| 253 | export RHOST=$RHOST |
| 254 | export PASSWD=$PASSWD |
| 255 | echo "WARNING: security of $RHOST may be compromised" |
| 256 | } |
| 257 | } |
| 258 | |
| 259 | # If user does not provide a command file select a default set of testcases |
| 260 | # to execute. |
| 261 | if [ -z "$CMDFILE" ] |
| 262 | then |
| 263 | cat <<-EOF >&1 |
| 264 | |
| 265 | INFO: no command files were provided, using default, |
| 266 | system calls, memory management, IPC, scheduler |
| 267 | direct io, file system, math and pty tests will |
| 268 | now be executed |
| 269 | |
| 270 | EOF |
| 271 | |
| 272 | for SCENFILES in ${LTPROOT}/runtest/syscalls ${LTPROOT}/runtest/fs \ |
| 273 | ${LTPROOT}/runtest/fsx ${LTPROOT}/runtest/dio \ |
| 274 | ${LTPROOT}/runtest/mm ${LTPROOT}/runtest/ipc \ |
| 275 | ${LTPROOT}/runtest/sched ${LTPROOT}/runtest/math \ |
| 276 | ${LTPROOT}/runtest/nptl ${LTPROOT}/runtest/pty |
| 277 | do |
| 278 | [ -a "$SCENFILES" ] || \ |
| 279 | { |
| 280 | echo "FATAL: missing scenario file $SCENFILES" |
| 281 | exit 1 |
| 282 | } |
| 283 | |
robbiew | 7d43d77 | 2005-02-07 20:07:30 +0000 | [diff] [blame] | 284 | if [ -z "$TAG_RESTRICT_STRING" ] |
| 285 | then |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 286 | cat $SCENFILES >> ${TMP}/alltests || \ |
| 287 | { |
| 288 | echo "FATAL: unable to create command file" |
| 289 | exit 1 |
| 290 | } |
robbiew | 7d43d77 | 2005-02-07 20:07:30 +0000 | [diff] [blame] | 291 | else |
| 292 | grep $TAG_RESTRICT_STRING $SCENFILES >> ${TMP}/alltests #Not worth checking return codes for this case |
| 293 | fi |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 294 | done |
| 295 | else |
plars | dd7b4f6 | 2004-09-02 20:42:50 +0000 | [diff] [blame] | 296 | [ -f $CMDFILE ] || \ |
| 297 | CMDFILE="$LTPROOT/runtest/$CMDFILE" |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 298 | cat $CMDFILE > ${TMP}/alltests || \ |
| 299 | { |
| 300 | echo "FATAL: Unable to create command file" |
| 301 | exit 1 |
| 302 | } |
| 303 | fi |
| 304 | |
| 305 | [ "$RUN_NETEST" -eq 1 ] && \ |
| 306 | { |
| 307 | for SCENFILES in ${LTPROOT}/runtest/tcp_cmds \ |
| 308 | ${LTPROOT}/runtest/multicast \ |
| 309 | ${LTPROOT}/runtest/rpc \ |
| 310 | ${LTPROOT}/runtest/nfs |
| 311 | do |
| 312 | [ -a "$SCENFILES" ] || \ |
| 313 | { |
| 314 | echo "FATAL: missing scenario file $SCENFILES" |
| 315 | exit 1 |
| 316 | } |
| 317 | |
| 318 | cat $SCENFILES >> ${TMP}/alltests || \ |
| 319 | { |
| 320 | echo "FATAL: unable to create command file" |
| 321 | exit 1 |
| 322 | } |
| 323 | done |
| 324 | } |
| 325 | |
| 326 | # The fsx-linux tests use the SCRATCHDEV environment variable as a location |
| 327 | # that can be reformatted and run on. Set SCRATCHDEV if you want to run |
| 328 | # these tests. As a safeguard, this is disabled. |
| 329 | unset SCRATCHDEV |
| 330 | [ -n "$SCRATCHDEV" ] && \ |
| 331 | { |
| 332 | cat ${LTPROOT}/runtest/fsx >> ${TMP}/alltests || |
| 333 | { |
| 334 | echo "FATAL: unable to create fsx-linux tests command file" |
| 335 | exit 1 |
| 336 | } |
| 337 | } |
| 338 | |
| 339 | # check for required users and groups |
| 340 | ${LTPROOT}/IDcheck.sh &>/dev/null || \ |
| 341 | { |
| 342 | echo "WARNING: required users and groups not present" |
| 343 | echo "WARNING: some test cases may fail" |
| 344 | } |
| 345 | |
robbiew | 7d43d77 | 2005-02-07 20:07:30 +0000 | [diff] [blame] | 346 | |
| 347 | |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 348 | # display versions of installed software |
| 349 | [ -z "$QUIET_MODE" ] && \ |
| 350 | { |
| 351 | ${LTPROOT}/ver_linux || \ |
| 352 | { |
| 353 | echo "WARNING: unable to display versions of software installed" |
| 354 | exit 1 |
| 355 | } |
| 356 | } |
| 357 | |
| 358 | [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test start time: $(date)" ; } |
robbiew | 7d43d77 | 2005-02-07 20:07:30 +0000 | [diff] [blame] | 359 | PAN_COMMAND="${LTPROOT}/pan/pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ \ |
| 360 | -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE" |
| 361 | if [ ! -z "$VERBOSE_MODE" ] ; then |
| 362 | echo "COMMAND: $PAN_COMMAND" |
| 363 | if [ ! -z "$TAG_RESTRICT_STRING" ] ; then |
| 364 | echo "INFO: Restricted to $TAG_RESTRICT_STRING" |
| 365 | fi |
| 366 | fi |
| 367 | #$PAN_COMMAND #Duplicated code here, because otherwise if we fail, only "PAN_COMMAND" gets output |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 368 | ${LTPROOT}/pan/pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ \ |
| 369 | -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE |
| 370 | |
| 371 | if [ $? -eq 0 ]; then |
| 372 | echo "INFO: pan reported all tests PASS" |
| 373 | VALUE=0 |
| 374 | else |
| 375 | echo "INFO: pan reported some tests FAIL" |
| 376 | VALUE=1 |
| 377 | fi |
| 378 | [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test end time: $(date)" ; } |
| 379 | |
| 380 | [ "$GENLOAD" -eq 1 ] && { killall -9 genload ; } |
| 381 | [ "$NETPIPE" -eq 1 ] && { killall -9 NPtcp ; } |
| 382 | |
| 383 | [ "$ALT_DIR" -eq 1 ] && \ |
| 384 | { |
| 385 | cat <<-EOF >&1 |
| 386 | |
| 387 | ###############################################################" |
| 388 | |
| 389 | Done executing testcases." |
| 390 | result log is in the $LTPROOT/results directory" |
| 391 | |
| 392 | ###############################################################" |
| 393 | |
| 394 | EOF |
| 395 | } |
| 396 | exit $VALUE |
| 397 | } |
| 398 | |
| 399 | cleanup() |
| 400 | { |
| 401 | rm -rf ${TMP} |
| 402 | } |
| 403 | |
| 404 | trap "cleanup" 0 |
| 405 | setup |
| 406 | main "$@" |