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 |
subrata_modak | a1fd64b | 2007-04-11 11:24:49 +0000 | [diff] [blame] | 35 | # - all checks should be enlclosed in " " to avoid bash error |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 36 | # - exit with error if pan is not found in pan directory |
subrata_modak | bc833d3 | 2007-07-25 10:12:02 +0000 | [diff] [blame] | 37 | # |
| 38 | # Jul 22 2007 - Modified - Ricardo Salveti de Araujo |
| 39 | # - added support to put more then one file at CMDLINE (-f) |
| 40 | # - added a new option, that the user can pass the address of |
| 41 | # the command file, and it'll use wget to get it (-w) |
| 42 | # - now -s does the grep at the selected command files (default, |
| 43 | # -f or -w) |
| 44 | # |
| 45 | # Jul 23 2007 - Modified - Ricardo Salveti de Araujo |
| 46 | # - added flag to get the command file that has all failed tests |
subrata_modak | 6838ec3 | 2007-09-14 10:10:12 +0000 | [diff] [blame] | 47 | # |
| 48 | # Sep 11 2007 - Modified - Subrata Modak |
| 49 | # - added option to create Failed File if it is not an absolute path |
| 50 | # - added option to create Output File if it is not an absolute path |
| 51 | # - added option to create Failed File compulsory, even if user has not mentioned it |
| 52 | # |
subrata_modak | 5d7deea | 2007-09-15 13:51:36 +0000 | [diff] [blame] | 53 | # Sep 14 2007 - Modified - Ricardo Salveti de Araujo |
| 54 | # - cleaning and removing duplicated code |
| 55 | # |
subrata_modak | e099b2a | 2007-10-29 12:22:01 +0000 | [diff] [blame] | 56 | # Oct 27 2007 - Modified - Ricardo Salveti de Araujo and Subrata Modak |
| 57 | # - better ways to integrate "ltp/tools/genload/stress" with "ltp/runltp" |
| 58 | # |
subrata_modak | 6838ec3 | 2007-09-14 10:10:12 +0000 | [diff] [blame] | 59 | ################################################################################# |
subrata_modak | bc833d3 | 2007-07-25 10:12:02 +0000 | [diff] [blame] | 60 | |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 61 | |
| 62 | |
| 63 | setup() |
| 64 | { |
| 65 | cd `dirname $0` || \ |
| 66 | { |
| 67 | echo "FATAL: unable to change directory to $(dirname $0)" |
| 68 | exit 1 |
| 69 | } |
| 70 | export LTPROOT=${PWD} |
| 71 | export TMPBASE="/tmp" |
| 72 | export TMP="${TMPBASE}/ltp-$$" |
subrata_modak | 4a57fe8 | 2007-09-24 06:40:12 +0000 | [diff] [blame] | 73 | export TMPDIR="${TMP}" |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 74 | export PATH="${PATH}:${LTPROOT}/testcases/bin" |
| 75 | |
| 76 | [ -d $LTPROOT/testcases/bin ] || |
| 77 | { |
| 78 | echo "FATAL: Test suite not installed correctly" |
| 79 | echo "INFO: as root user type 'make ; make install'" |
| 80 | exit 1 |
| 81 | } |
| 82 | |
| 83 | [ -e $LTPROOT/pan/pan ] || |
| 84 | { |
| 85 | echo "FATAL: Test suite driver 'pan' not found" |
| 86 | echo "INFO: as root user type 'make ; make install'" |
| 87 | exit 1 |
| 88 | } |
| 89 | } |
| 90 | |
mreed10 | 9169642 | 2006-05-03 19:07:22 +0000 | [diff] [blame] | 91 | version_of_ltp() |
| 92 | { |
subrata_modak | a1fd64b | 2007-04-11 11:24:49 +0000 | [diff] [blame] | 93 | head -n 1 $LTPROOT/ChangeLog |
| 94 | exit 0 |
mreed10 | 9169642 | 2006-05-03 19:07:22 +0000 | [diff] [blame] | 95 | } |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 96 | |
| 97 | usage() |
| 98 | { |
| 99 | cat <<-EOF >&2 |
| 100 | |
subrata_modak | e099b2a | 2007-10-29 12:22:01 +0000 | [diff] [blame] | 101 | usage: ./${0##*/} [ -c NUM_PROCS ] [ -C FAILCMDFILE ] [ -d TMPDIR ] |
| 102 | [ -D NUM_PROCS,NUM_FILES,NUM_BYTES,CLEAN_FLAG ] -e [ -f CMDFILES(,...) ] |
| 103 | [ -i NUM_PROCS ] [ -l LOGFILE ] [ -m NUM_PROCS,CHUNKS,BYTES,HANGUP_FLAG ] |
| 104 | -N -n [ -o OUTPUTFILE ] -p -q [ -r LTPROOT ] [ -s PATTERN ] [ -t DURATION ] |
| 105 | -v [ -w CMDFILEADDR ] [ -x INSTANCES ] |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 106 | |
subrata_modak | e099b2a | 2007-10-29 12:22:01 +0000 | [diff] [blame] | 107 | -c NUM_PROCS Run LTP under additional background CPU load |
| 108 | [NUM_PROCS = no. of processes creating the CPU Load by spinning over sqrt() |
| 109 | (Defaults to 1 when value)] |
subrata_modak | bc833d3 | 2007-07-25 10:12:02 +0000 | [diff] [blame] | 110 | -C FAILCMDFILE Command file with all failed test cases. |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 111 | -d TMPDIR Directory where temporary files will be created. |
subrata_modak | e099b2a | 2007-10-29 12:22:01 +0000 | [diff] [blame] | 112 | -D NUM_PROCS,NUM_FILES,NUM_BYTES,CLEAN_FLAG |
| 113 | Run LTP under additional background Load on Secondary Storage (Seperate by comma) |
| 114 | [NUM_PROCS = no. of processes creating Storage Load by spinning over write()] |
| 115 | [NUM_FILES = Write() to these many files (Defaults to 1 when value 0 or undefined)] |
| 116 | [NUM_BYTES = write these many bytes (defaults to 1GB, when value 0 or undefined)] |
| 117 | [CLEAN_FLAG = unlink file to which random data written, when value 1] |
mreed10 | 9169642 | 2006-05-03 19:07:22 +0000 | [diff] [blame] | 118 | -e Prints the date of the current LTP release |
subrata_modak | bc833d3 | 2007-07-25 10:12:02 +0000 | [diff] [blame] | 119 | -f CMDFILES Execute user defined list of testcases (separate with ',') |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 120 | -h Help. Prints all available options. |
subrata_modak | e099b2a | 2007-10-29 12:22:01 +0000 | [diff] [blame] | 121 | -i NUM_PROCS Run LTP under additional background Load on IO Bus |
| 122 | [NUM_PROCS = no. of processes creating IO Bus Load by spinning over sync()] |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 123 | -l LOGFILE Log results of test in a logfile. |
subrata_modak | e099b2a | 2007-10-29 12:22:01 +0000 | [diff] [blame] | 124 | -m NUM_PROCS,CHUNKS,BYTES,HANGUP_FLAG |
| 125 | Run LTP under additional background Load on Main memory (Seperate by comma) |
| 126 | [NUM_PROCS = no. of processes creating main Memory Load by spinning over malloc()] |
| 127 | [CHUNKS = malloc these many chunks (default is 1 when value 0 or undefined)] |
| 128 | [BYTES = malloc CHUNKS of BYTES bytes (default is 256MB when value 0 or undefined) ] |
| 129 | [HANGUP_FLAG = hang in a sleep loop after memory allocated, when value 1] |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 130 | -N Run all the networking tests. |
| 131 | -n Run LTP with network traffic in background. |
| 132 | -o OUTPUTFILE Redirect test output to a file. |
| 133 | -p Human readable format logfiles. |
| 134 | -q Print less verbose output to screen. |
| 135 | -r LTPROOT Fully qualified path where testsuite is installed. |
subrata_modak | a1fd64b | 2007-04-11 11:24:49 +0000 | [diff] [blame] | 136 | -s PATTERN Only run test cases which match PATTERN. |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 137 | -t DURATION Execute the testsuite for given duration. Examples: |
| 138 | -t 60s = 60 seconds |
| 139 | -t 45m = 45 minutes |
| 140 | -t 24h = 24 hours |
| 141 | -t 2d = 2 days |
robbiew | 7d43d77 | 2005-02-07 20:07:30 +0000 | [diff] [blame] | 142 | -v Print more verbose output to screen. |
subrata_modak | bc833d3 | 2007-07-25 10:12:02 +0000 | [diff] [blame] | 143 | -w CMDFILEADDR Uses wget to get the user's list of testcases. |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 144 | -x INSTANCES Run multiple instances of this testsuite. |
| 145 | |
subrata_modak | e099b2a | 2007-10-29 12:22:01 +0000 | [diff] [blame] | 146 | example: ./${0##*/} -c 2 -i 2 -m 2,4,10240,1 -D 2,10,10240,1 -p -q -l /tmp/result-log.$$ -o /tmp/result-output.$$ -C /tmp/result-failed.$$ -d ${PWD} |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 147 | |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 148 | |
| 149 | EOF |
| 150 | exit 0 |
| 151 | } |
| 152 | |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 153 | main() |
| 154 | { |
subrata_modak | bc833d3 | 2007-07-25 10:12:02 +0000 | [diff] [blame] | 155 | local CMDFILES="" |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 156 | local PRETTY_PRT="" |
subrata_modak | 5d7deea | 2007-09-15 13:51:36 +0000 | [diff] [blame] | 157 | local ALT_DIR_OUT=0 |
| 158 | local ALT_DIR_RES=0 |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 159 | local RUN_NETEST=0 |
| 160 | local QUIET_MODE="" |
robbiew | 7d43d77 | 2005-02-07 20:07:30 +0000 | [diff] [blame] | 161 | local VERBOSE_MODE="" |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 162 | local NETPIPE=0 |
| 163 | local GENLOAD=0 |
| 164 | local MEMSIZE=0 |
| 165 | local DURATION="" |
subrata_modak | bc833d3 | 2007-07-25 10:12:02 +0000 | [diff] [blame] | 166 | local CMDFILEADDR="" |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 167 | local LOGFILE="" |
| 168 | local SCENFILES="" |
robbiew | 7d43d77 | 2005-02-07 20:07:30 +0000 | [diff] [blame] | 169 | local TAG_RESTRICT_STRING="" |
| 170 | local PAN_COMMAND="" |
mreed10 | 9169642 | 2006-05-03 19:07:22 +0000 | [diff] [blame] | 171 | version_date=`head -n 1 $LTPROOT/ChangeLog` |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 172 | |
subrata_modak | e099b2a | 2007-10-29 12:22:01 +0000 | [diff] [blame] | 173 | while getopts c:C:d:D:f:ehi:l:m:Nno:pqr:s:t:vw:x: arg |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 174 | do case $arg in |
| 175 | c) |
subrata_modak | e099b2a | 2007-10-29 12:22:01 +0000 | [diff] [blame] | 176 | NUM_PROCS=$(($OPTARG)) |
| 177 | if [ "$NUM_PROCS" -eq 0 ]; then |
| 178 | # User Did not Define the Value ,or, User Defined Zero, |
| 179 | # hence, prevent from creating infinite processes |
| 180 | NUM_PROCS=1 |
| 181 | fi |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 182 | $LTPROOT/testcases/bin/genload --cpu $NUM_PROCS >/dev/null 2>&1 & |
| 183 | GENLOAD=1 ;; |
subrata_modak | bc833d3 | 2007-07-25 10:12:02 +0000 | [diff] [blame] | 184 | |
subrata_modak | 5d7deea | 2007-09-15 13:51:36 +0000 | [diff] [blame] | 185 | C) |
subrata_modak | 6838ec3 | 2007-09-14 10:10:12 +0000 | [diff] [blame] | 186 | case $OPTARG in |
| 187 | /*) |
| 188 | FAILCMDFILE="-C $OPTARG" ;; |
| 189 | *) |
| 190 | FAILCMDFILE="-C $LTPROOT/output/$OPTARG" |
subrata_modak | 5d7deea | 2007-09-15 13:51:36 +0000 | [diff] [blame] | 191 | ALT_DIR_OUT=1 ;; |
subrata_modak | 6838ec3 | 2007-09-14 10:10:12 +0000 | [diff] [blame] | 192 | esac ;; |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 193 | |
| 194 | d) # append $$ to TMP, as it is recursively |
| 195 | # removed at end of script. |
subrata_modak | 4a57fe8 | 2007-09-24 06:40:12 +0000 | [diff] [blame] | 196 | export TMPBASE=$OPTARG |
| 197 | export TMP="${TMPBASE}/ltp-$$" |
robbiew | 538bc1a | 2005-03-11 19:26:14 +0000 | [diff] [blame] | 198 | export TMPDIR="$TMP";; |
subrata_modak | e099b2a | 2007-10-29 12:22:01 +0000 | [diff] [blame] | 199 | |
| 200 | D) NUM_PROCS=1; NUM_FILES=1; NUM_BYTES=$((1024 * 1024 * 1024)); CLEAN_FLAG=0 |
| 201 | ARGUMENT_LIST=$(($OPTARG)) |
| 202 | TOTAL_ARGUMENTS=1 # Initial Assume |
| 203 | for ARGUMENT in `echo "$ARGUMENT_LIST" | sed 's/,/\n/g'` # Store all value in a Loop |
| 204 | do |
| 205 | case $TOTAL_ARGUMENTS in |
| 206 | 1) NUM_PROCS="$ARGUMENT" ;; |
| 207 | 2) NUM_FILES="$ARGUMENT" ;; |
| 208 | 3) NUM_BYTES="$ARGUMENT" ;; |
| 209 | 4) CLEAN_FLAG="$ARGUMENT" ;; |
| 210 | esac |
| 211 | TOTAL_ARGUMENTS=`expr $TOTAL_ARGUMENTS + 1` |
| 212 | done |
| 213 | # just to get the default values if the user passed 0 |
| 214 | if [ "$NUM_PROCS" -eq 0 ]; then |
| 215 | NUM_PROCS=1 |
| 216 | fi |
| 217 | if [ "$NUM_FILES" -eq 0 ]; then |
| 218 | NUM_FILES=1 |
| 219 | fi |
| 220 | if [ "$NUM_BYTES" -eq 0 ]; then |
| 221 | NUM_BYTES=$((1024 * 1024 * 1024)) |
| 222 | fi |
| 223 | if [ "$CLEAN_FLAG" -ne 1 ]; then |
| 224 | CLEAN_FLAG=0 |
| 225 | fi |
| 226 | if [ "$CLEAN_FLAG" -eq 1 ]; then |
| 227 | # Do not unlink file in this case |
| 228 | $LTPROOT/testcases/bin/genload --hdd $NUM_PROCS --hdd-files \ |
| 229 | $NUM_FILES --hdd-bytes $NUM_BYTES >/dev/null 2>&1 & |
| 230 | else |
| 231 | # Cleanup otherwise |
| 232 | $LTPROOT/testcases/bin/genload --hdd $NUM_PROCS --hdd-files \ |
| 233 | $NUM_FILES --hdd-bytes $NUM_BYTES --hdd-noclean >/dev/null 2>&1 & |
| 234 | fi |
| 235 | GENLOAD=1;; |
| 236 | |
mreed10 | 9169642 | 2006-05-03 19:07:22 +0000 | [diff] [blame] | 237 | e) # Print out the version of LTP |
| 238 | version_of_ltp |
| 239 | ;; |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 240 | f) # Execute user defined set of testcases. |
subrata_modak | bc833d3 | 2007-07-25 10:12:02 +0000 | [diff] [blame] | 241 | # Can be more then one file, just separate it with ',', like: |
| 242 | # -f nfs,commands,/tmp/testfile |
| 243 | CMDFILES=$OPTARG;; |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 244 | |
| 245 | h) usage;; |
| 246 | |
subrata_modak | e099b2a | 2007-10-29 12:22:01 +0000 | [diff] [blame] | 247 | i) |
| 248 | NUM_PROCS=$(($OPTARG)) |
| 249 | if [ "$NUM_PROCS" -eq 0 ]; then |
| 250 | # User Did not Define the Value ,or, User Defined Zero, |
| 251 | # hence, prevent from creating infinite processes |
| 252 | NUM_PROCS=1 |
| 253 | fi |
| 254 | $LTPROOT/testcases/bin/genload --io $NUM_PROCS >/dev/null 2>&1 & |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 255 | GENLOAD=1 ;; |
| 256 | |
| 257 | l) |
subrata_modak | 6838ec3 | 2007-09-14 10:10:12 +0000 | [diff] [blame] | 258 | LOGFILE_NAME="$OPTARG" |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 259 | case $OPTARG in |
subrata_modak | 5d7deea | 2007-09-15 13:51:36 +0000 | [diff] [blame] | 260 | /*) |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 261 | LOGFILE="-l $OPTARG" ;; |
| 262 | *) |
| 263 | LOGFILE="-l $LTPROOT/results/$OPTARG" |
subrata_modak | 5d7deea | 2007-09-15 13:51:36 +0000 | [diff] [blame] | 264 | ALT_DIR_RES=1 ;; |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 265 | esac ;; |
| 266 | |
subrata_modak | e099b2a | 2007-10-29 12:22:01 +0000 | [diff] [blame] | 267 | m) NUM_PROCS=1; CHUNKS=1; BYTES=$((256 * 1024 * 1024)); HANGUP_FLAG=0 |
| 268 | ARGUMENT_LIST=$(($OPTARG)) |
| 269 | TOTAL_ARGUMENTS=1 # Initial Assume |
| 270 | for ARGUMENT in `echo "$ARGUMENT_LIST" | sed 's/,/\n/g'` # Store all value in a Loop |
| 271 | do |
| 272 | case $TOTAL_ARGUMENTS in |
| 273 | 1) NUM_PROCS="$ARGUMENT" ;; |
| 274 | 2) CHUNKS="$ARGUMENT" ;; |
| 275 | 3) BYTES="$ARGUMENT" ;; |
| 276 | 4) HANGUP_FLAG="$ARGUMENT" ;; |
| 277 | esac |
| 278 | TOTAL_ARGUMENTS=`expr $TOTAL_ARGUMENTS + 1` |
| 279 | done |
| 280 | # just to get the default values if the user passed 0 |
| 281 | if [ "$NUM_PROCS" -eq 0 ]; then |
| 282 | NUM_PROCS=1 |
| 283 | fi |
| 284 | if [ "$CHUNKS" -eq 0 ]; then |
| 285 | CHUNKS=1 |
| 286 | fi |
| 287 | if [ "$BYTES" -eq 0 ]; then |
| 288 | BYTES=$((256 * 1024 * 1024)) |
| 289 | fi |
| 290 | if [ "$HANGUP_FLAG" -ne 1 ]; then |
| 291 | HANGUP_FLAG=0 |
| 292 | fi |
| 293 | if [ "$HANGUP_FLAG" -eq 1 ]; then |
| 294 | # Hang in a Sleep loop after memory allocated |
| 295 | $LTPROOT/testcases/bin/genload --vm $NUM_PROCS --vm-chunks \ |
| 296 | $CHUNKS --vm-bytes $BYTES --vm-hang >/dev/null 2>&1 & |
| 297 | else |
| 298 | # Otherwise Do not Hangup |
| 299 | $LTPROOT/testcases/bin/genload --vm $NUM_PROCS --vm-chunks \ |
| 300 | $CHUNKS --vm-bytes $BYTES >/dev/null 2>&1 & |
| 301 | fi |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 302 | GENLOAD=1;; |
| 303 | |
| 304 | N) RUN_NETEST=1;; |
| 305 | |
| 306 | n) |
| 307 | $LTPROOT/testcases/bin/netpipe.sh |
| 308 | NETPIPE=1;; |
| 309 | |
subrata_modak | 6838ec3 | 2007-09-14 10:10:12 +0000 | [diff] [blame] | 310 | o) OUTPUTFILE_NAME="$OPTARG" |
subrata_modak | 6838ec3 | 2007-09-14 10:10:12 +0000 | [diff] [blame] | 311 | case $OPTARG in |
| 312 | /*) |
| 313 | OUTPUTFILE="-o $OPTARG";; |
| 314 | *) |
| 315 | OUTPUTFILE="-o $LTPROOT/output/$OPTARG" |
subrata_modak | 5d7deea | 2007-09-15 13:51:36 +0000 | [diff] [blame] | 316 | ALT_DIR_OUT=1 ;; |
subrata_modak | 6838ec3 | 2007-09-14 10:10:12 +0000 | [diff] [blame] | 317 | esac ;; |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 318 | |
| 319 | p) PRETTY_PRT=" -p ";; |
| 320 | |
| 321 | q) QUIET_MODE=" -q ";; |
| 322 | |
| 323 | r) LTPROOT=$OPTARG;; |
| 324 | |
robbiew | 7d43d77 | 2005-02-07 20:07:30 +0000 | [diff] [blame] | 325 | s) TAG_RESTRICT_STRING=$OPTARG;; |
| 326 | |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 327 | t) # In case you want to specify the time |
| 328 | # to run from the command line |
| 329 | # (2m = two minutes, 2h = two hours, etc) |
| 330 | DURATION="-t $OPTARG" ;; |
| 331 | |
robbiew | 7d43d77 | 2005-02-07 20:07:30 +0000 | [diff] [blame] | 332 | v) VERBOSE_MODE=1;; |
subrata_modak | bc833d3 | 2007-07-25 10:12:02 +0000 | [diff] [blame] | 333 | |
| 334 | w) CMDFILEADDR=$OPTARG;; |
robbiew | 7d43d77 | 2005-02-07 20:07:30 +0000 | [diff] [blame] | 335 | |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 336 | x) # number of ltp's to run |
| 337 | cat <<-EOF >&1 |
| 338 | WARNING: The use of -x can cause unpredictable failures, as a |
| 339 | result of concurrently running multiple tests designed |
| 340 | to be ran exclusively. |
| 341 | Pausing for 10 seconds..." |
| 342 | EOF |
| 343 | sleep 10 |
| 344 | INSTANCES="-x $OPTARG -O ${TMP}";; |
| 345 | |
| 346 | \?) usage;; |
| 347 | esac |
| 348 | done |
subrata_modak | 6838ec3 | 2007-09-14 10:10:12 +0000 | [diff] [blame] | 349 | |
| 350 | ## It would be nice if a Failed File is compulsorily created (gives User better Idea of Tests that failed) |
| 351 | |
| 352 | if [ ! "$FAILCMDFILE" ]; then ## User has not mentioned about Failed File name |
| 353 | echo Inside Failed File Name not Mentioned |
subrata_modak | 5d7deea | 2007-09-15 13:51:36 +0000 | [diff] [blame] | 354 | ALT_DIR_OUT=1 |
subrata_modak | 6838ec3 | 2007-09-14 10:10:12 +0000 | [diff] [blame] | 355 | if [ ! "$OUTPUTFILE" ]; then ## User has not mentioned about Output File name either |
| 356 | if [ ! "$LOGFILE" ]; then ## User has not mentioned about Log File name either |
| 357 | FAILED_FILE_NAME=`date +"%Y_%b_%d-%Hh_%Mm_%Ss"` |
| 358 | FAILCMDFILE="-C $LTPROOT/output/LTP_RUN_ON-$FAILED_FILE_NAME.failed" |
subrata_modak | 6838ec3 | 2007-09-14 10:10:12 +0000 | [diff] [blame] | 359 | else ## User Fortunately wanted a log file, |
| 360 | FAILED_FILE_NAME=`basename $LOGFILE_NAME` ## Extract log file name and use it to construct Failed file name |
| 361 | FAILCMDFILE="-C $LTPROOT/output/LTP_RUN_ON-$FAILED_FILE_NAME.failed" |
subrata_modak | 6838ec3 | 2007-09-14 10:10:12 +0000 | [diff] [blame] | 362 | fi |
| 363 | else ## User Fortunately wanted a Output file |
| 364 | FAILED_FILE_NAME=`basename $OUTPUTFILE_NAME` ## Extract output file name and use it to construct Failed file name |
| 365 | FAILCMDFILE="-C $LTPROOT/output/LTP_RUN_ON-$FAILED_FILE_NAME.failed" |
subrata_modak | 6838ec3 | 2007-09-14 10:10:12 +0000 | [diff] [blame] | 366 | fi |
| 367 | fi |
subrata_modak | a1fd64b | 2007-04-11 11:24:49 +0000 | [diff] [blame] | 368 | |
subrata_modak | 5d7deea | 2007-09-15 13:51:36 +0000 | [diff] [blame] | 369 | # If we need, create the output directory |
| 370 | [ "$ALT_DIR_OUT" -eq 1 ] && \ |
| 371 | { |
| 372 | echo "INFO: creating $LTPROOT/output directory" |
| 373 | [ ! -d $LTPROOT/output ] && \ |
| 374 | { |
| 375 | mkdir -p $LTPROOT/output || \ |
| 376 | { |
| 377 | echo "ERROR: failed to create $LTPROOT/output" |
| 378 | exit 1 |
| 379 | } |
| 380 | } |
| 381 | } |
| 382 | # If we need, create the results directory |
| 383 | [ "$ALT_DIR_RES" -eq 1 ] && \ |
| 384 | { |
| 385 | echo "INFO: creating $LTPROOT/results directory" |
| 386 | [ ! -d $LTPROOT/results ] && \ |
| 387 | { |
| 388 | mkdir -p $LTPROOT/results || \ |
| 389 | { |
| 390 | echo "ERROR: failed to create $LTPROOT/results" |
| 391 | exit 1 |
| 392 | } |
| 393 | } |
| 394 | } |
| 395 | |
subrata_modak | a1fd64b | 2007-04-11 11:24:49 +0000 | [diff] [blame] | 396 | # Added -m 777 for tests that call tst_tmpdir() and try to |
| 397 | # write to it as user nobody |
| 398 | mkdir -m 777 -p $TMP || \ |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 399 | { |
robbiew | 7d43d77 | 2005-02-07 20:07:30 +0000 | [diff] [blame] | 400 | echo "FATAL: Unable to make temporary directory $TMP" |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 401 | exit 1 |
| 402 | } |
| 403 | |
| 404 | cd $TMP || \ |
| 405 | { |
| 406 | echo "could not cd ${TMP} ... exiting" |
| 407 | exit 1 |
| 408 | } |
| 409 | |
| 410 | [ "$RUN_NETEST" -eq 1 ] && \ |
| 411 | { |
| 412 | [ -z "$RHOST" ] || [ -z "$PASSWD" ] && \ |
| 413 | { |
| 414 | [ -z "$RHOST" ] && \ |
| 415 | { |
| 416 | echo \ |
| 417 | "INFO: Enter RHOST = 'name of the remote host machine'" |
| 418 | echo -n "-> " |
| 419 | read RHOST |
| 420 | } |
| 421 | |
| 422 | [ -z "$PASSWD" ] && \ |
| 423 | { |
| 424 | echo " " |
| 425 | echo \ |
| 426 | "INFO: Enter PASSWD = 'root passwd of the remote host machine'" |
| 427 | echo -n "-> " |
| 428 | read PASSWD |
| 429 | } |
| 430 | export RHOST=$RHOST |
| 431 | export PASSWD=$PASSWD |
| 432 | echo "WARNING: security of $RHOST may be compromised" |
| 433 | } |
| 434 | } |
| 435 | |
| 436 | # If user does not provide a command file select a default set of testcases |
| 437 | # to execute. |
subrata_modak | bc833d3 | 2007-07-25 10:12:02 +0000 | [diff] [blame] | 438 | if [ -z "$CMDFILES" ] && [ -z "$CMDFILEADDR" ] |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 439 | then |
subrata_modak | bc833d3 | 2007-07-25 10:12:02 +0000 | [diff] [blame] | 440 | cat <<-EOF >&1 |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 441 | |
| 442 | INFO: no command files were provided, using default, |
| 443 | system calls, memory management, IPC, scheduler |
| 444 | direct io, file system, math and pty tests will |
| 445 | now be executed |
| 446 | |
| 447 | EOF |
| 448 | |
subrata_modak | bc833d3 | 2007-07-25 10:12:02 +0000 | [diff] [blame] | 449 | for SCENFILES in ${LTPROOT}/runtest/syscalls ${LTPROOT}/runtest/fs \ |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 450 | ${LTPROOT}/runtest/fsx ${LTPROOT}/runtest/dio \ |
| 451 | ${LTPROOT}/runtest/mm ${LTPROOT}/runtest/ipc \ |
| 452 | ${LTPROOT}/runtest/sched ${LTPROOT}/runtest/math \ |
subrata_modak | 0c5f970 | 2007-04-26 11:02:47 +0000 | [diff] [blame] | 453 | ${LTPROOT}/runtest/nptl ${LTPROOT}/runtest/pty \ |
| 454 | ${LTPROOT}/runtest/containers |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 455 | do |
| 456 | [ -a "$SCENFILES" ] || \ |
| 457 | { |
| 458 | echo "FATAL: missing scenario file $SCENFILES" |
| 459 | exit 1 |
| 460 | } |
| 461 | |
| 462 | cat $SCENFILES >> ${TMP}/alltests || \ |
| 463 | { |
| 464 | echo "FATAL: unable to create command file" |
| 465 | exit 1 |
| 466 | } |
| 467 | done |
subrata_modak | bc833d3 | 2007-07-25 10:12:02 +0000 | [diff] [blame] | 468 | fi |
| 469 | |
| 470 | [ -n "$CMDFILES" ] && \ |
| 471 | { |
| 472 | for SCENFILES in `echo "$CMDFILES" | sed 's/,/\n/g'` |
| 473 | do |
| 474 | [ -f "$SCENFILES" ] || SCENFILES="$LTPROOT/runtest/$SCENFILES" |
| 475 | cat "$SCENFILES" >> ${TMP}/alltests || \ |
| 476 | { |
| 477 | echo "FATAL: unable to create command file" |
| 478 | exit 1 |
| 479 | } |
| 480 | done |
| 481 | } |
| 482 | |
| 483 | [ -n "$CMDFILEADDR" ] && \ |
| 484 | { |
| 485 | wget -q "${CMDFILEADDR}" -O ${TMP}/wgetcmdfile |
| 486 | if [ $? -ne 0 ]; then |
| 487 | echo "FATAL: error while getting the command file with wget (address $CMDFILEADDR)" |
| 488 | exit 1 |
| 489 | fi |
| 490 | cat "${TMP}/wgetcmdfile" >> ${TMP}/alltests || \ |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 491 | { |
subrata_modak | bc833d3 | 2007-07-25 10:12:02 +0000 | [diff] [blame] | 492 | echo "FATAL: unable to create command file" |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 493 | exit 1 |
| 494 | } |
subrata_modak | bc833d3 | 2007-07-25 10:12:02 +0000 | [diff] [blame] | 495 | } |
| 496 | |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 497 | [ "$RUN_NETEST" -eq 1 ] && \ |
| 498 | { |
| 499 | for SCENFILES in ${LTPROOT}/runtest/tcp_cmds \ |
| 500 | ${LTPROOT}/runtest/multicast \ |
| 501 | ${LTPROOT}/runtest/rpc \ |
| 502 | ${LTPROOT}/runtest/nfs |
| 503 | do |
| 504 | [ -a "$SCENFILES" ] || \ |
| 505 | { |
| 506 | echo "FATAL: missing scenario file $SCENFILES" |
| 507 | exit 1 |
| 508 | } |
| 509 | |
subrata_modak | bc833d3 | 2007-07-25 10:12:02 +0000 | [diff] [blame] | 510 | cat "$SCENFILES" >> ${TMP}/alltests || \ |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 511 | { |
| 512 | echo "FATAL: unable to create command file" |
| 513 | exit 1 |
| 514 | } |
| 515 | done |
| 516 | } |
subrata_modak | bc833d3 | 2007-07-25 10:12:02 +0000 | [diff] [blame] | 517 | |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 518 | # The fsx-linux tests use the SCRATCHDEV environment variable as a location |
| 519 | # that can be reformatted and run on. Set SCRATCHDEV if you want to run |
| 520 | # these tests. As a safeguard, this is disabled. |
| 521 | unset SCRATCHDEV |
| 522 | [ -n "$SCRATCHDEV" ] && \ |
| 523 | { |
| 524 | cat ${LTPROOT}/runtest/fsx >> ${TMP}/alltests || |
| 525 | { |
| 526 | echo "FATAL: unable to create fsx-linux tests command file" |
| 527 | exit 1 |
| 528 | } |
| 529 | } |
subrata_modak | bc833d3 | 2007-07-25 10:12:02 +0000 | [diff] [blame] | 530 | |
| 531 | # If enabled, execute only test cases that match the PATTERN |
| 532 | if [ -n "$TAG_RESTRICT_STRING" ] |
| 533 | then |
| 534 | mv -f ${TMP}/alltests ${TMP}/alltests.orig |
| 535 | grep $TAG_RESTRICT_STRING ${TMP}/alltests.orig > ${TMP}/alltests #Not worth checking return codes for this case |
| 536 | fi |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 537 | |
| 538 | # check for required users and groups |
| 539 | ${LTPROOT}/IDcheck.sh &>/dev/null || \ |
| 540 | { |
| 541 | echo "WARNING: required users and groups not present" |
| 542 | echo "WARNING: some test cases may fail" |
| 543 | } |
robbiew | 7d43d77 | 2005-02-07 20:07:30 +0000 | [diff] [blame] | 544 | |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 545 | # display versions of installed software |
| 546 | [ -z "$QUIET_MODE" ] && \ |
| 547 | { |
| 548 | ${LTPROOT}/ver_linux || \ |
| 549 | { |
| 550 | echo "WARNING: unable to display versions of software installed" |
| 551 | exit 1 |
| 552 | } |
| 553 | } |
| 554 | |
| 555 | [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test start time: $(date)" ; } |
robbiew | 7d43d77 | 2005-02-07 20:07:30 +0000 | [diff] [blame] | 556 | PAN_COMMAND="${LTPROOT}/pan/pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ \ |
subrata_modak | bc833d3 | 2007-07-25 10:12:02 +0000 | [diff] [blame] | 557 | -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE $FAILCMDFILE" |
robbiew | 7d43d77 | 2005-02-07 20:07:30 +0000 | [diff] [blame] | 558 | if [ ! -z "$VERBOSE_MODE" ] ; then |
| 559 | echo "COMMAND: $PAN_COMMAND" |
| 560 | if [ ! -z "$TAG_RESTRICT_STRING" ] ; then |
| 561 | echo "INFO: Restricted to $TAG_RESTRICT_STRING" |
| 562 | fi |
| 563 | fi |
| 564 | #$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] | 565 | ${LTPROOT}/pan/pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ \ |
subrata_modak | bc833d3 | 2007-07-25 10:12:02 +0000 | [diff] [blame] | 566 | -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE $FAILCMDFILE |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 567 | |
| 568 | if [ $? -eq 0 ]; then |
| 569 | echo "INFO: pan reported all tests PASS" |
| 570 | VALUE=0 |
| 571 | else |
| 572 | echo "INFO: pan reported some tests FAIL" |
| 573 | VALUE=1 |
| 574 | fi |
mreed10 | 9169642 | 2006-05-03 19:07:22 +0000 | [diff] [blame] | 575 | echo "LTP Version: $version_date" |
| 576 | |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 577 | [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test end time: $(date)" ; } |
| 578 | |
subrata_modak | e099b2a | 2007-10-29 12:22:01 +0000 | [diff] [blame] | 579 | [ "$GENLOAD" -eq 1 ] && { killall -9 genload >/dev/null 2>&1; } |
| 580 | [ "$NETPIPE" -eq 1 ] && { killall -9 NPtcp >/dev/null 2>&1; } |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 581 | |
subrata_modak | 5d7deea | 2007-09-15 13:51:36 +0000 | [diff] [blame] | 582 | [ "$ALT_DIR_OUT" -eq 1 ] || [ "$ALT_DIR_RES" -eq 1 ] && \ |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 583 | { |
| 584 | cat <<-EOF >&1 |
| 585 | |
| 586 | ###############################################################" |
| 587 | |
| 588 | Done executing testcases." |
subrata_modak | 6838ec3 | 2007-09-14 10:10:12 +0000 | [diff] [blame] | 589 | log result(s) is in $LTPROOT/results directory" |
| 590 | output/failed result(s) in $LTPROOT/output directory [If you did not provide Absolute Path] |
mreed10 | 9169642 | 2006-05-03 19:07:22 +0000 | [diff] [blame] | 591 | LTP Version: $version_date |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 592 | ###############################################################" |
| 593 | |
| 594 | EOF |
| 595 | } |
| 596 | exit $VALUE |
| 597 | } |
| 598 | |
| 599 | cleanup() |
| 600 | { |
| 601 | rm -rf ${TMP} |
| 602 | } |
| 603 | |
| 604 | trap "cleanup" 0 |
| 605 | setup |
| 606 | main "$@" |