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