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 | f376b48 | 2007-11-28 11:30:54 +0000 | [diff] [blame] | 61 | # Nov 28 2007 - Modified - Subrata Modak |
| 62 | # - Added a new option to mail back LTP reports |
subrata_modak | 4393821 | 2008-05-19 08:48:46 +0000 | [diff] [blame] | 63 | # May 19 2008 - Modified - Subrata Modak |
| 64 | # - Added capability for default Log file generation |
subrata_modak | e099b2a | 2007-10-29 12:22:01 +0000 | [diff] [blame] | 65 | # |
subrata_modak | 6838ec3 | 2007-09-14 10:10:12 +0000 | [diff] [blame] | 66 | ################################################################################# |
subrata_modak | bc833d3 | 2007-07-25 10:12:02 +0000 | [diff] [blame] | 67 | |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 68 | |
| 69 | |
| 70 | setup() |
| 71 | { |
| 72 | cd `dirname $0` || \ |
| 73 | { |
| 74 | echo "FATAL: unable to change directory to $(dirname $0)" |
| 75 | exit 1 |
| 76 | } |
| 77 | export LTPROOT=${PWD} |
| 78 | export TMPBASE="/tmp" |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 79 | export PATH="${PATH}:${LTPROOT}/testcases/bin" |
| 80 | |
| 81 | [ -d $LTPROOT/testcases/bin ] || |
| 82 | { |
| 83 | echo "FATAL: Test suite not installed correctly" |
| 84 | echo "INFO: as root user type 'make ; make install'" |
| 85 | exit 1 |
| 86 | } |
| 87 | |
| 88 | [ -e $LTPROOT/pan/pan ] || |
| 89 | { |
| 90 | echo "FATAL: Test suite driver 'pan' not found" |
| 91 | echo "INFO: as root user type 'make ; make install'" |
| 92 | exit 1 |
| 93 | } |
| 94 | } |
| 95 | |
mreed10 | 9169642 | 2006-05-03 19:07:22 +0000 | [diff] [blame] | 96 | version_of_ltp() |
| 97 | { |
subrata_modak | a1fd64b | 2007-04-11 11:24:49 +0000 | [diff] [blame] | 98 | head -n 1 $LTPROOT/ChangeLog |
| 99 | exit 0 |
mreed10 | 9169642 | 2006-05-03 19:07:22 +0000 | [diff] [blame] | 100 | } |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 101 | |
| 102 | usage() |
| 103 | { |
| 104 | cat <<-EOF >&2 |
| 105 | |
subrata_modak | f376b48 | 2007-11-28 11:30:54 +0000 | [diff] [blame] | 106 | usage: ./${0##*/} [ -a EMAIL_TO ] [ -c NUM_PROCS ] [ -C FAILCMDFILE ] [ -d TMPDIR ] |
subrata_modak | e47fb35 | 2007-11-25 17:03:49 +0000 | [diff] [blame] | 107 | [ -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] | 108 | [ -i NUM_PROCS ] [ -l LOGFILE ] [ -m NUM_PROCS,CHUNKS,BYTES,HANGUP_FLAG ] |
| 109 | -N -n [ -o OUTPUTFILE ] -p -q [ -r LTPROOT ] [ -s PATTERN ] [ -t DURATION ] |
| 110 | -v [ -w CMDFILEADDR ] [ -x INSTANCES ] |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 111 | |
subrata_modak | 08dde6f | 2007-11-28 11:02:51 +0000 | [diff] [blame] | 112 | -a EMAIL_TO EMAIL all your Reports to this E-mail Address |
subrata_modak | e099b2a | 2007-10-29 12:22:01 +0000 | [diff] [blame] | 113 | -c NUM_PROCS Run LTP under additional background CPU load |
| 114 | [NUM_PROCS = no. of processes creating the CPU Load by spinning over sqrt() |
| 115 | (Defaults to 1 when value)] |
subrata_modak | bc833d3 | 2007-07-25 10:12:02 +0000 | [diff] [blame] | 116 | -C FAILCMDFILE Command file with all failed test cases. |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 117 | -d TMPDIR Directory where temporary files will be created. |
subrata_modak | e099b2a | 2007-10-29 12:22:01 +0000 | [diff] [blame] | 118 | -D NUM_PROCS,NUM_FILES,NUM_BYTES,CLEAN_FLAG |
| 119 | Run LTP under additional background Load on Secondary Storage (Seperate by comma) |
| 120 | [NUM_PROCS = no. of processes creating Storage Load by spinning over write()] |
| 121 | [NUM_FILES = Write() to these many files (Defaults to 1 when value 0 or undefined)] |
| 122 | [NUM_BYTES = write these many bytes (defaults to 1GB, when value 0 or undefined)] |
| 123 | [CLEAN_FLAG = unlink file to which random data written, when value 1] |
mreed10 | 9169642 | 2006-05-03 19:07:22 +0000 | [diff] [blame] | 124 | -e Prints the date of the current LTP release |
subrata_modak | bc833d3 | 2007-07-25 10:12:02 +0000 | [diff] [blame] | 125 | -f CMDFILES Execute user defined list of testcases (separate with ',') |
subrata_modak | e47fb35 | 2007-11-25 17:03:49 +0000 | [diff] [blame] | 126 | -g HTMLFILE Create an additional HTML output format |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 127 | -h Help. Prints all available options. |
subrata_modak | e099b2a | 2007-10-29 12:22:01 +0000 | [diff] [blame] | 128 | -i NUM_PROCS Run LTP under additional background Load on IO Bus |
| 129 | [NUM_PROCS = no. of processes creating IO Bus Load by spinning over sync()] |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 130 | -l LOGFILE Log results of test in a logfile. |
subrata_modak | e099b2a | 2007-10-29 12:22:01 +0000 | [diff] [blame] | 131 | -m NUM_PROCS,CHUNKS,BYTES,HANGUP_FLAG |
| 132 | Run LTP under additional background Load on Main memory (Seperate by comma) |
| 133 | [NUM_PROCS = no. of processes creating main Memory Load by spinning over malloc()] |
| 134 | [CHUNKS = malloc these many chunks (default is 1 when value 0 or undefined)] |
| 135 | [BYTES = malloc CHUNKS of BYTES bytes (default is 256MB when value 0 or undefined) ] |
| 136 | [HANGUP_FLAG = hang in a sleep loop after memory allocated, when value 1] |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 137 | -N Run all the networking tests. |
| 138 | -n Run LTP with network traffic in background. |
| 139 | -o OUTPUTFILE Redirect test output to a file. |
| 140 | -p Human readable format logfiles. |
| 141 | -q Print less verbose output to screen. |
| 142 | -r LTPROOT Fully qualified path where testsuite is installed. |
subrata_modak | a1fd64b | 2007-04-11 11:24:49 +0000 | [diff] [blame] | 143 | -s PATTERN Only run test cases which match PATTERN. |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 144 | -t DURATION Execute the testsuite for given duration. Examples: |
| 145 | -t 60s = 60 seconds |
| 146 | -t 45m = 45 minutes |
| 147 | -t 24h = 24 hours |
| 148 | -t 2d = 2 days |
subrata_modak | 8c13833 | 2008-01-28 11:19:32 +0000 | [diff] [blame] | 149 | -T REPETITION Execute the testsuite for REPETITION no. of times |
robbiew | 7d43d77 | 2005-02-07 20:07:30 +0000 | [diff] [blame] | 150 | -v Print more verbose output to screen. |
subrata_modak | bc833d3 | 2007-07-25 10:12:02 +0000 | [diff] [blame] | 151 | -w CMDFILEADDR Uses wget to get the user's list of testcases. |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 152 | -x INSTANCES Run multiple instances of this testsuite. |
| 153 | |
subrata_modak | e099b2a | 2007-10-29 12:22:01 +0000 | [diff] [blame] | 154 | 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] | 155 | |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 156 | |
| 157 | EOF |
| 158 | exit 0 |
| 159 | } |
| 160 | |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 161 | main() |
| 162 | { |
subrata_modak | bc833d3 | 2007-07-25 10:12:02 +0000 | [diff] [blame] | 163 | local CMDFILES="" |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 164 | local PRETTY_PRT="" |
subrata_modak | 5d7deea | 2007-09-15 13:51:36 +0000 | [diff] [blame] | 165 | local ALT_DIR_OUT=0 |
| 166 | local ALT_DIR_RES=0 |
subrata_modak | e47fb35 | 2007-11-25 17:03:49 +0000 | [diff] [blame] | 167 | local ALT_HTML_OUT=0 |
subrata_modak | 08dde6f | 2007-11-28 11:02:51 +0000 | [diff] [blame] | 168 | local ALT_EMAIL_OUT=0 |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 169 | local RUN_NETEST=0 |
subrata_modak | 8c13833 | 2008-01-28 11:19:32 +0000 | [diff] [blame] | 170 | local RUN_REPEATED=0 |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 171 | local QUIET_MODE="" |
robbiew | 7d43d77 | 2005-02-07 20:07:30 +0000 | [diff] [blame] | 172 | local VERBOSE_MODE="" |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 173 | local NETPIPE=0 |
| 174 | local GENLOAD=0 |
| 175 | local MEMSIZE=0 |
| 176 | local DURATION="" |
subrata_modak | bc833d3 | 2007-07-25 10:12:02 +0000 | [diff] [blame] | 177 | local CMDFILEADDR="" |
subrata_modak | 4393821 | 2008-05-19 08:48:46 +0000 | [diff] [blame] | 178 | local FAILCMDFILE="" |
subrata_modak | e47fb35 | 2007-11-25 17:03:49 +0000 | [diff] [blame] | 179 | local LOGFILE_NAME="" |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 180 | local LOGFILE="" |
subrata_modak | e47fb35 | 2007-11-25 17:03:49 +0000 | [diff] [blame] | 181 | local OUTPUTFILE_NAME="" |
| 182 | local OUTPUTFILE="" |
| 183 | local HTMLFILE_NAME="" |
| 184 | local HTMLFILE="" |
subrata_modak | 08dde6f | 2007-11-28 11:02:51 +0000 | [diff] [blame] | 185 | local EMAIL_TO="" |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 186 | local SCENFILES="" |
robbiew | 7d43d77 | 2005-02-07 20:07:30 +0000 | [diff] [blame] | 187 | local TAG_RESTRICT_STRING="" |
| 188 | local PAN_COMMAND="" |
subrata_modak | 4393821 | 2008-05-19 08:48:46 +0000 | [diff] [blame] | 189 | local DEFAULT_FILE_NAME_GENERATION_TIME=`date +"%Y_%b_%d-%Hh_%Mm_%Ss"` |
mreed10 | 9169642 | 2006-05-03 19:07:22 +0000 | [diff] [blame] | 190 | version_date=`head -n 1 $LTPROOT/ChangeLog` |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 191 | |
subrata_modak | 8c13833 | 2008-01-28 11:19:32 +0000 | [diff] [blame] | 192 | while getopts a:c:C:d:D:f:ehi:g:l:m:Nno:pqr:s:t:T:vw:x: arg |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 193 | do case $arg in |
subrata_modak | 08dde6f | 2007-11-28 11:02:51 +0000 | [diff] [blame] | 194 | a) EMAIL_TO=$OPTARG |
| 195 | ALT_EMAIL_OUT=1;; |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 196 | c) |
subrata_modak | e099b2a | 2007-10-29 12:22:01 +0000 | [diff] [blame] | 197 | NUM_PROCS=$(($OPTARG)) |
| 198 | if [ "$NUM_PROCS" -eq 0 ]; then |
| 199 | # User Did not Define the Value ,or, User Defined Zero, |
| 200 | # hence, prevent from creating infinite processes |
| 201 | NUM_PROCS=1 |
| 202 | fi |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 203 | $LTPROOT/testcases/bin/genload --cpu $NUM_PROCS >/dev/null 2>&1 & |
| 204 | GENLOAD=1 ;; |
subrata_modak | bc833d3 | 2007-07-25 10:12:02 +0000 | [diff] [blame] | 205 | |
subrata_modak | 5d7deea | 2007-09-15 13:51:36 +0000 | [diff] [blame] | 206 | C) |
subrata_modak | 6838ec3 | 2007-09-14 10:10:12 +0000 | [diff] [blame] | 207 | case $OPTARG in |
| 208 | /*) |
| 209 | FAILCMDFILE="-C $OPTARG" ;; |
| 210 | *) |
| 211 | FAILCMDFILE="-C $LTPROOT/output/$OPTARG" |
subrata_modak | 5d7deea | 2007-09-15 13:51:36 +0000 | [diff] [blame] | 212 | ALT_DIR_OUT=1 ;; |
subrata_modak | 6838ec3 | 2007-09-14 10:10:12 +0000 | [diff] [blame] | 213 | esac ;; |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 214 | |
subrata_modak | 5ee3e89 | 2008-10-21 13:17:56 +0000 | [diff] [blame] | 215 | d) # convert the user path to absolute path. |
| 216 | export TMPBASE=`cd \`dirname ${OPTARG}\`; pwd`/`basename ${OPTARG}` ;; |
subrata_modak | e099b2a | 2007-10-29 12:22:01 +0000 | [diff] [blame] | 217 | |
| 218 | D) NUM_PROCS=1; NUM_FILES=1; NUM_BYTES=$((1024 * 1024 * 1024)); CLEAN_FLAG=0 |
subrata_modak | 548379d | 2008-08-20 09:15:49 +0000 | [diff] [blame] | 219 | ARGUMENT_LIST=$OPTARG |
subrata_modak | e099b2a | 2007-10-29 12:22:01 +0000 | [diff] [blame] | 220 | TOTAL_ARGUMENTS=1 # Initial Assume |
| 221 | for ARGUMENT in `echo "$ARGUMENT_LIST" | sed 's/,/\n/g'` # Store all value in a Loop |
| 222 | do |
| 223 | case $TOTAL_ARGUMENTS in |
| 224 | 1) NUM_PROCS="$ARGUMENT" ;; |
| 225 | 2) NUM_FILES="$ARGUMENT" ;; |
| 226 | 3) NUM_BYTES="$ARGUMENT" ;; |
| 227 | 4) CLEAN_FLAG="$ARGUMENT" ;; |
| 228 | esac |
| 229 | TOTAL_ARGUMENTS=`expr $TOTAL_ARGUMENTS + 1` |
| 230 | done |
| 231 | # just to get the default values if the user passed 0 |
| 232 | if [ "$NUM_PROCS" -eq 0 ]; then |
| 233 | NUM_PROCS=1 |
| 234 | fi |
| 235 | if [ "$NUM_FILES" -eq 0 ]; then |
| 236 | NUM_FILES=1 |
| 237 | fi |
| 238 | if [ "$NUM_BYTES" -eq 0 ]; then |
| 239 | NUM_BYTES=$((1024 * 1024 * 1024)) |
| 240 | fi |
| 241 | if [ "$CLEAN_FLAG" -ne 1 ]; then |
| 242 | CLEAN_FLAG=0 |
| 243 | fi |
| 244 | if [ "$CLEAN_FLAG" -eq 1 ]; then |
| 245 | # Do not unlink file in this case |
| 246 | $LTPROOT/testcases/bin/genload --hdd $NUM_PROCS --hdd-files \ |
| 247 | $NUM_FILES --hdd-bytes $NUM_BYTES >/dev/null 2>&1 & |
| 248 | else |
| 249 | # Cleanup otherwise |
| 250 | $LTPROOT/testcases/bin/genload --hdd $NUM_PROCS --hdd-files \ |
| 251 | $NUM_FILES --hdd-bytes $NUM_BYTES --hdd-noclean >/dev/null 2>&1 & |
| 252 | fi |
| 253 | GENLOAD=1;; |
| 254 | |
mreed10 | 9169642 | 2006-05-03 19:07:22 +0000 | [diff] [blame] | 255 | e) # Print out the version of LTP |
| 256 | version_of_ltp |
| 257 | ;; |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 258 | f) # Execute user defined set of testcases. |
subrata_modak | bc833d3 | 2007-07-25 10:12:02 +0000 | [diff] [blame] | 259 | # Can be more then one file, just separate it with ',', like: |
| 260 | # -f nfs,commands,/tmp/testfile |
| 261 | CMDFILES=$OPTARG;; |
subrata_modak | e47fb35 | 2007-11-25 17:03:49 +0000 | [diff] [blame] | 262 | g) HTMLFILE_NAME="$OPTARG" |
| 263 | case $OPTARG in |
| 264 | /*) |
| 265 | HTMLFILE="$OPTARG";; |
| 266 | *) |
subrata_modak | d48c4d0 | 2008-01-23 12:59:40 +0000 | [diff] [blame] | 267 | HTMLFILE="$LTPROOT/output/$OPTARG";; |
| 268 | esac |
| 269 | ALT_DIR_OUT=1 |
| 270 | ALT_HTML_OUT=1;; |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 271 | h) usage;; |
| 272 | |
subrata_modak | e099b2a | 2007-10-29 12:22:01 +0000 | [diff] [blame] | 273 | i) |
| 274 | NUM_PROCS=$(($OPTARG)) |
| 275 | if [ "$NUM_PROCS" -eq 0 ]; then |
| 276 | # User Did not Define the Value ,or, User Defined Zero, |
| 277 | # hence, prevent from creating infinite processes |
| 278 | NUM_PROCS=1 |
| 279 | fi |
| 280 | $LTPROOT/testcases/bin/genload --io $NUM_PROCS >/dev/null 2>&1 & |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 281 | GENLOAD=1 ;; |
| 282 | |
| 283 | l) |
subrata_modak | 6838ec3 | 2007-09-14 10:10:12 +0000 | [diff] [blame] | 284 | LOGFILE_NAME="$OPTARG" |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 285 | case $OPTARG in |
subrata_modak | 5d7deea | 2007-09-15 13:51:36 +0000 | [diff] [blame] | 286 | /*) |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 287 | LOGFILE="-l $OPTARG" ;; |
| 288 | *) |
| 289 | LOGFILE="-l $LTPROOT/results/$OPTARG" |
subrata_modak | 5d7deea | 2007-09-15 13:51:36 +0000 | [diff] [blame] | 290 | ALT_DIR_RES=1 ;; |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 291 | esac ;; |
| 292 | |
subrata_modak | e099b2a | 2007-10-29 12:22:01 +0000 | [diff] [blame] | 293 | m) NUM_PROCS=1; CHUNKS=1; BYTES=$((256 * 1024 * 1024)); HANGUP_FLAG=0 |
subrata_modak | 29a96d8 | 2008-08-27 13:34:46 +0000 | [diff] [blame] | 294 | ARGUMENT_LIST=$OPTARG |
subrata_modak | e099b2a | 2007-10-29 12:22:01 +0000 | [diff] [blame] | 295 | TOTAL_ARGUMENTS=1 # Initial Assume |
| 296 | for ARGUMENT in `echo "$ARGUMENT_LIST" | sed 's/,/\n/g'` # Store all value in a Loop |
| 297 | do |
| 298 | case $TOTAL_ARGUMENTS in |
| 299 | 1) NUM_PROCS="$ARGUMENT" ;; |
| 300 | 2) CHUNKS="$ARGUMENT" ;; |
| 301 | 3) BYTES="$ARGUMENT" ;; |
| 302 | 4) HANGUP_FLAG="$ARGUMENT" ;; |
| 303 | esac |
| 304 | TOTAL_ARGUMENTS=`expr $TOTAL_ARGUMENTS + 1` |
| 305 | done |
| 306 | # just to get the default values if the user passed 0 |
| 307 | if [ "$NUM_PROCS" -eq 0 ]; then |
| 308 | NUM_PROCS=1 |
| 309 | fi |
| 310 | if [ "$CHUNKS" -eq 0 ]; then |
| 311 | CHUNKS=1 |
| 312 | fi |
| 313 | if [ "$BYTES" -eq 0 ]; then |
| 314 | BYTES=$((256 * 1024 * 1024)) |
| 315 | fi |
| 316 | if [ "$HANGUP_FLAG" -ne 1 ]; then |
| 317 | HANGUP_FLAG=0 |
| 318 | fi |
| 319 | if [ "$HANGUP_FLAG" -eq 1 ]; then |
| 320 | # Hang in a Sleep loop after memory allocated |
| 321 | $LTPROOT/testcases/bin/genload --vm $NUM_PROCS --vm-chunks \ |
| 322 | $CHUNKS --vm-bytes $BYTES --vm-hang >/dev/null 2>&1 & |
| 323 | else |
| 324 | # Otherwise Do not Hangup |
| 325 | $LTPROOT/testcases/bin/genload --vm $NUM_PROCS --vm-chunks \ |
| 326 | $CHUNKS --vm-bytes $BYTES >/dev/null 2>&1 & |
| 327 | fi |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 328 | GENLOAD=1;; |
| 329 | |
| 330 | N) RUN_NETEST=1;; |
| 331 | |
| 332 | n) |
| 333 | $LTPROOT/testcases/bin/netpipe.sh |
| 334 | NETPIPE=1;; |
| 335 | |
subrata_modak | 6838ec3 | 2007-09-14 10:10:12 +0000 | [diff] [blame] | 336 | o) OUTPUTFILE_NAME="$OPTARG" |
subrata_modak | 6838ec3 | 2007-09-14 10:10:12 +0000 | [diff] [blame] | 337 | case $OPTARG in |
| 338 | /*) |
| 339 | OUTPUTFILE="-o $OPTARG";; |
| 340 | *) |
| 341 | OUTPUTFILE="-o $LTPROOT/output/$OPTARG" |
subrata_modak | 5d7deea | 2007-09-15 13:51:36 +0000 | [diff] [blame] | 342 | ALT_DIR_OUT=1 ;; |
subrata_modak | 6838ec3 | 2007-09-14 10:10:12 +0000 | [diff] [blame] | 343 | esac ;; |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 344 | |
| 345 | p) PRETTY_PRT=" -p ";; |
| 346 | |
| 347 | q) QUIET_MODE=" -q ";; |
| 348 | |
| 349 | r) LTPROOT=$OPTARG;; |
| 350 | |
robbiew | 7d43d77 | 2005-02-07 20:07:30 +0000 | [diff] [blame] | 351 | s) TAG_RESTRICT_STRING=$OPTARG;; |
| 352 | |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 353 | t) # In case you want to specify the time |
| 354 | # to run from the command line |
| 355 | # (2m = two minutes, 2h = two hours, etc) |
| 356 | DURATION="-t $OPTARG" ;; |
subrata_modak | 8c13833 | 2008-01-28 11:19:32 +0000 | [diff] [blame] | 357 | |
| 358 | T) # In case you want the testcases to runsequentially RUN_REPEATED times |
| 359 | RUN_REPEATED=$OPTARG;; |
| 360 | |
robbiew | 7d43d77 | 2005-02-07 20:07:30 +0000 | [diff] [blame] | 361 | v) VERBOSE_MODE=1;; |
subrata_modak | bc833d3 | 2007-07-25 10:12:02 +0000 | [diff] [blame] | 362 | |
| 363 | w) CMDFILEADDR=$OPTARG;; |
robbiew | 7d43d77 | 2005-02-07 20:07:30 +0000 | [diff] [blame] | 364 | |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 365 | x) # number of ltp's to run |
| 366 | cat <<-EOF >&1 |
| 367 | WARNING: The use of -x can cause unpredictable failures, as a |
| 368 | result of concurrently running multiple tests designed |
| 369 | to be ran exclusively. |
| 370 | Pausing for 10 seconds..." |
| 371 | EOF |
| 372 | sleep 10 |
subrata_modak | 6edfbda | 2008-10-17 12:25:48 +0000 | [diff] [blame] | 373 | INSTANCES="-x $OPTARG";; |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 374 | |
| 375 | \?) usage;; |
| 376 | esac |
| 377 | done |
subrata_modak | 4393821 | 2008-05-19 08:48:46 +0000 | [diff] [blame] | 378 | |
| 379 | ## It would be nice to create a default log file even if the user has not mentioned |
| 380 | if [ ! "$LOGFILE" ]; then ## User has not mentioned about Log File name |
| 381 | LOGFILE_NAME=$DEFAULT_FILE_NAME_GENERATION_TIME |
| 382 | LOGFILE="-l $LTPROOT/results/LTP_RUN_ON-$LOGFILE_NAME.log" |
| 383 | ALT_DIR_RES=1 |
| 384 | PRETTY_PRT=" -p " |
| 385 | fi |
subrata_modak | 6838ec3 | 2007-09-14 10:10:12 +0000 | [diff] [blame] | 386 | |
| 387 | ## It would be nice if a Failed File is compulsorily created (gives User better Idea of Tests that failed) |
| 388 | |
| 389 | if [ ! "$FAILCMDFILE" ]; then ## User has not mentioned about Failed File name |
subrata_modak | 5d7deea | 2007-09-15 13:51:36 +0000 | [diff] [blame] | 390 | ALT_DIR_OUT=1 |
subrata_modak | 6838ec3 | 2007-09-14 10:10:12 +0000 | [diff] [blame] | 391 | if [ ! "$OUTPUTFILE" ]; then ## User has not mentioned about Output File name either |
| 392 | if [ ! "$LOGFILE" ]; then ## User has not mentioned about Log File name either |
subrata_modak | 4393821 | 2008-05-19 08:48:46 +0000 | [diff] [blame] | 393 | FAILED_FILE_NAME=$DEFAULT_FILE_NAME_GENERATION_TIME |
subrata_modak | 6838ec3 | 2007-09-14 10:10:12 +0000 | [diff] [blame] | 394 | FAILCMDFILE="-C $LTPROOT/output/LTP_RUN_ON-$FAILED_FILE_NAME.failed" |
subrata_modak | 6838ec3 | 2007-09-14 10:10:12 +0000 | [diff] [blame] | 395 | else ## User Fortunately wanted a log file, |
| 396 | FAILED_FILE_NAME=`basename $LOGFILE_NAME` ## Extract log file name and use it to construct Failed file name |
| 397 | FAILCMDFILE="-C $LTPROOT/output/LTP_RUN_ON-$FAILED_FILE_NAME.failed" |
subrata_modak | 6838ec3 | 2007-09-14 10:10:12 +0000 | [diff] [blame] | 398 | fi |
| 399 | else ## User Fortunately wanted a Output file |
| 400 | FAILED_FILE_NAME=`basename $OUTPUTFILE_NAME` ## Extract output file name and use it to construct Failed file name |
| 401 | FAILCMDFILE="-C $LTPROOT/output/LTP_RUN_ON-$FAILED_FILE_NAME.failed" |
subrata_modak | 6838ec3 | 2007-09-14 10:10:12 +0000 | [diff] [blame] | 402 | fi |
| 403 | fi |
subrata_modak | a1fd64b | 2007-04-11 11:24:49 +0000 | [diff] [blame] | 404 | |
subrata_modak | d48c4d0 | 2008-01-23 12:59:40 +0000 | [diff] [blame] | 405 | if [ "$ALT_HTML_OUT" -eq 1 ] ; then ## User wants the HTML version of the output |
| 406 | QUIET_MODE="" ## Suppressing this guy as it will prevent generation of proper output |
| 407 | ## which the HTML parser will require |
subrata_modak | e47fb35 | 2007-11-25 17:03:49 +0000 | [diff] [blame] | 408 | if [ ! "$OUTPUTFILE" ]; then ## User has not mentioned about the Outputfile name, then we need to definitely generate one |
subrata_modak | 4393821 | 2008-05-19 08:48:46 +0000 | [diff] [blame] | 409 | OUTPUTFILE_NAME=$DEFAULT_FILE_NAME_GENERATION_TIME |
subrata_modak | e47fb35 | 2007-11-25 17:03:49 +0000 | [diff] [blame] | 410 | OUTPUTFILE="-o $LTPROOT/output/LTP_RUN_ON-$OUTPUTFILE_NAME.output" |
subrata_modak | 08dde6f | 2007-11-28 11:02:51 +0000 | [diff] [blame] | 411 | ALT_DIR_OUT=1 |
subrata_modak | e47fb35 | 2007-11-25 17:03:49 +0000 | [diff] [blame] | 412 | if [ ! "$HTMLFILE" ] ; then ## User has not mentioned HTML File name, We need to create one |
| 413 | HTMLFILE_NAME=`basename $OUTPUTFILE_NAME` |
| 414 | HTMLFILE="$LTPROOT/output/$HTMLFILE_NAME.html" |
| 415 | fi |
| 416 | fi |
| 417 | fi |
| 418 | |
subrata_modak | 5d7deea | 2007-09-15 13:51:36 +0000 | [diff] [blame] | 419 | # If we need, create the output directory |
| 420 | [ "$ALT_DIR_OUT" -eq 1 ] && \ |
| 421 | { |
| 422 | echo "INFO: creating $LTPROOT/output directory" |
| 423 | [ ! -d $LTPROOT/output ] && \ |
| 424 | { |
| 425 | mkdir -p $LTPROOT/output || \ |
| 426 | { |
| 427 | echo "ERROR: failed to create $LTPROOT/output" |
| 428 | exit 1 |
| 429 | } |
| 430 | } |
| 431 | } |
| 432 | # If we need, create the results directory |
| 433 | [ "$ALT_DIR_RES" -eq 1 ] && \ |
| 434 | { |
| 435 | echo "INFO: creating $LTPROOT/results directory" |
| 436 | [ ! -d $LTPROOT/results ] && \ |
| 437 | { |
| 438 | mkdir -p $LTPROOT/results || \ |
| 439 | { |
| 440 | echo "ERROR: failed to create $LTPROOT/results" |
| 441 | exit 1 |
| 442 | } |
| 443 | } |
| 444 | } |
| 445 | |
subrata_modak | a1fd64b | 2007-04-11 11:24:49 +0000 | [diff] [blame] | 446 | # Added -m 777 for tests that call tst_tmpdir() and try to |
| 447 | # write to it as user nobody |
subrata_modak | 5ee3e89 | 2008-10-21 13:17:56 +0000 | [diff] [blame] | 448 | mkdir -m 777 -p $TMPBASE || \ |
| 449 | { |
| 450 | echo "FATAL: Unable to make temporary directory $TMPBASE" |
| 451 | exit 1 |
| 452 | } |
| 453 | # use mktemp to create "safe" temporary directories |
| 454 | export TMPTEMPLATE="${TMPBASE}/ltp-XXXXXXXXXX" |
subrata_modak | 6edfbda | 2008-10-17 12:25:48 +0000 | [diff] [blame] | 455 | TMP=`mktemp -d $TMPTEMPLATE` || \ |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 456 | { |
subrata_modak | 6edfbda | 2008-10-17 12:25:48 +0000 | [diff] [blame] | 457 | echo "FATAL: Unable to make temporary directory: $TMP" |
| 458 | exit 1 |
| 459 | } |
| 460 | export TMP |
subrata_modak | 5ee3e89 | 2008-10-21 13:17:56 +0000 | [diff] [blame] | 461 | # To be evoked by tst_tmpdir() |
| 462 | # write to it as user nobody |
| 463 | export TMPDIR="/tmp" |
subrata_modak | 6edfbda | 2008-10-17 12:25:48 +0000 | [diff] [blame] | 464 | |
| 465 | chmod 777 $TMP || \ |
| 466 | { |
| 467 | echo "unable to chmod 777 $TMP ... aborting" |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 468 | exit 1 |
| 469 | } |
| 470 | |
| 471 | cd $TMP || \ |
| 472 | { |
| 473 | echo "could not cd ${TMP} ... exiting" |
| 474 | exit 1 |
| 475 | } |
| 476 | |
subrata_modak | 6edfbda | 2008-10-17 12:25:48 +0000 | [diff] [blame] | 477 | ! [ -z $INSTANCES ] && \ |
| 478 | { |
| 479 | INSTANCES="$INSTANCES -O ${TMP}" |
| 480 | } |
| 481 | |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 482 | [ "$RUN_NETEST" -eq 1 ] && \ |
| 483 | { |
| 484 | [ -z "$RHOST" ] || [ -z "$PASSWD" ] && \ |
| 485 | { |
| 486 | [ -z "$RHOST" ] && \ |
| 487 | { |
| 488 | echo \ |
| 489 | "INFO: Enter RHOST = 'name of the remote host machine'" |
| 490 | echo -n "-> " |
| 491 | read RHOST |
| 492 | } |
| 493 | |
| 494 | [ -z "$PASSWD" ] && \ |
| 495 | { |
| 496 | echo " " |
| 497 | echo \ |
| 498 | "INFO: Enter PASSWD = 'root passwd of the remote host machine'" |
| 499 | echo -n "-> " |
| 500 | read PASSWD |
| 501 | } |
| 502 | export RHOST=$RHOST |
| 503 | export PASSWD=$PASSWD |
| 504 | echo "WARNING: security of $RHOST may be compromised" |
| 505 | } |
| 506 | } |
| 507 | |
| 508 | # If user does not provide a command file select a default set of testcases |
| 509 | # to execute. |
subrata_modak | bc833d3 | 2007-07-25 10:12:02 +0000 | [diff] [blame] | 510 | if [ -z "$CMDFILES" ] && [ -z "$CMDFILEADDR" ] |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 511 | then |
subrata_modak | bc833d3 | 2007-07-25 10:12:02 +0000 | [diff] [blame] | 512 | cat <<-EOF >&1 |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 513 | |
| 514 | INFO: no command files were provided, using default, |
| 515 | system calls, memory management, IPC, scheduler |
| 516 | direct io, file system, math and pty tests will |
| 517 | now be executed |
| 518 | |
| 519 | EOF |
| 520 | |
subrata_modak | 58c9d11 | 2008-10-23 13:31:35 +0000 | [diff] [blame] | 521 | for SCENFILES in ${LTPROOT}/runtest/syscalls \ |
| 522 | ${LTPROOT}/runtest/fs \ |
| 523 | ${LTPROOT}/runtest/fsx \ |
| 524 | ${LTPROOT}/runtest/dio \ |
| 525 | ${LTPROOT}/runtest/mm \ |
| 526 | ${LTPROOT}/runtest/ipc \ |
| 527 | ${LTPROOT}/runtest/sched \ |
| 528 | ${LTPROOT}/runtest/math \ |
| 529 | ${LTPROOT}/runtest/nptl \ |
| 530 | ${LTPROOT}/runtest/pty \ |
| 531 | ${LTPROOT}/runtest/containers \ |
| 532 | ${LTPROOT}/runtest/fs_bind \ |
| 533 | ${LTPROOT}/runtest/controllers \ |
| 534 | ${LTPROOT}/runtest/filecaps \ |
| 535 | ${LTPROOT}/runtest/fcntl-locktests \ |
| 536 | ${LTPROOT}/runtest/connectors \ |
| 537 | ${LTPROOT}/runtest/admin_tools \ |
| 538 | ${LTPROOT}/runtest/timers \ |
subrata_modak | 5340744 | 2008-10-29 09:46:03 +0000 | [diff] [blame] | 539 | ${LTPROOT}/runtest/power_management_tests \ |
subrata_modak | 00310c4 | 2008-10-29 15:43:51 +0000 | [diff] [blame] | 540 | ${LTPROOT}/runtest/numa \ |
| 541 | ${LTPROOT}/runtest/hugetlb |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 542 | do |
vapier | e42c4b2 | 2008-03-08 12:49:06 +0000 | [diff] [blame] | 543 | [ -e "$SCENFILES" ] || \ |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 544 | { |
| 545 | echo "FATAL: missing scenario file $SCENFILES" |
| 546 | exit 1 |
| 547 | } |
| 548 | |
| 549 | cat $SCENFILES >> ${TMP}/alltests || \ |
| 550 | { |
| 551 | echo "FATAL: unable to create command file" |
| 552 | exit 1 |
| 553 | } |
| 554 | done |
subrata_modak | bc833d3 | 2007-07-25 10:12:02 +0000 | [diff] [blame] | 555 | fi |
| 556 | |
| 557 | [ -n "$CMDFILES" ] && \ |
| 558 | { |
| 559 | for SCENFILES in `echo "$CMDFILES" | sed 's/,/\n/g'` |
| 560 | do |
| 561 | [ -f "$SCENFILES" ] || SCENFILES="$LTPROOT/runtest/$SCENFILES" |
| 562 | cat "$SCENFILES" >> ${TMP}/alltests || \ |
| 563 | { |
| 564 | echo "FATAL: unable to create command file" |
| 565 | exit 1 |
| 566 | } |
| 567 | done |
| 568 | } |
| 569 | |
| 570 | [ -n "$CMDFILEADDR" ] && \ |
| 571 | { |
| 572 | wget -q "${CMDFILEADDR}" -O ${TMP}/wgetcmdfile |
| 573 | if [ $? -ne 0 ]; then |
| 574 | echo "FATAL: error while getting the command file with wget (address $CMDFILEADDR)" |
| 575 | exit 1 |
| 576 | fi |
| 577 | cat "${TMP}/wgetcmdfile" >> ${TMP}/alltests || \ |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 578 | { |
subrata_modak | bc833d3 | 2007-07-25 10:12:02 +0000 | [diff] [blame] | 579 | echo "FATAL: unable to create command file" |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 580 | exit 1 |
| 581 | } |
subrata_modak | bc833d3 | 2007-07-25 10:12:02 +0000 | [diff] [blame] | 582 | } |
| 583 | |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 584 | [ "$RUN_NETEST" -eq 1 ] && \ |
| 585 | { |
| 586 | for SCENFILES in ${LTPROOT}/runtest/tcp_cmds \ |
| 587 | ${LTPROOT}/runtest/multicast \ |
| 588 | ${LTPROOT}/runtest/rpc \ |
| 589 | ${LTPROOT}/runtest/nfs |
| 590 | do |
vapier | e42c4b2 | 2008-03-08 12:49:06 +0000 | [diff] [blame] | 591 | [ -e "$SCENFILES" ] || \ |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 592 | { |
| 593 | echo "FATAL: missing scenario file $SCENFILES" |
| 594 | exit 1 |
| 595 | } |
| 596 | |
subrata_modak | bc833d3 | 2007-07-25 10:12:02 +0000 | [diff] [blame] | 597 | cat "$SCENFILES" >> ${TMP}/alltests || \ |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 598 | { |
| 599 | echo "FATAL: unable to create command file" |
| 600 | exit 1 |
| 601 | } |
| 602 | done |
| 603 | } |
subrata_modak | bc833d3 | 2007-07-25 10:12:02 +0000 | [diff] [blame] | 604 | |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 605 | # The fsx-linux tests use the SCRATCHDEV environment variable as a location |
| 606 | # that can be reformatted and run on. Set SCRATCHDEV if you want to run |
| 607 | # these tests. As a safeguard, this is disabled. |
| 608 | unset SCRATCHDEV |
| 609 | [ -n "$SCRATCHDEV" ] && \ |
| 610 | { |
| 611 | cat ${LTPROOT}/runtest/fsx >> ${TMP}/alltests || |
| 612 | { |
| 613 | echo "FATAL: unable to create fsx-linux tests command file" |
| 614 | exit 1 |
| 615 | } |
| 616 | } |
subrata_modak | bc833d3 | 2007-07-25 10:12:02 +0000 | [diff] [blame] | 617 | |
| 618 | # If enabled, execute only test cases that match the PATTERN |
| 619 | if [ -n "$TAG_RESTRICT_STRING" ] |
| 620 | then |
| 621 | mv -f ${TMP}/alltests ${TMP}/alltests.orig |
| 622 | grep $TAG_RESTRICT_STRING ${TMP}/alltests.orig > ${TMP}/alltests #Not worth checking return codes for this case |
| 623 | fi |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 624 | |
| 625 | # check for required users and groups |
| 626 | ${LTPROOT}/IDcheck.sh &>/dev/null || \ |
| 627 | { |
| 628 | echo "WARNING: required users and groups not present" |
| 629 | echo "WARNING: some test cases may fail" |
| 630 | } |
robbiew | 7d43d77 | 2005-02-07 20:07:30 +0000 | [diff] [blame] | 631 | |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 632 | # display versions of installed software |
| 633 | [ -z "$QUIET_MODE" ] && \ |
| 634 | { |
| 635 | ${LTPROOT}/ver_linux || \ |
| 636 | { |
| 637 | echo "WARNING: unable to display versions of software installed" |
| 638 | exit 1 |
| 639 | } |
| 640 | } |
| 641 | |
subrata_modak | 8c13833 | 2008-01-28 11:19:32 +0000 | [diff] [blame] | 642 | if [ $RUN_REPEATED -gt 1 ]; then # You need to specify at least more than 1 sequential run, else it runs default |
| 643 | echo "PAN will run these test cases $RUN_REPEATED times....." |
| 644 | echo "Test Tags will be Prepended with ITERATION NO.s....." |
| 645 | inc=1 |
| 646 | sed -e '/^$/ d' -e 's/^[ ,\t]*//' -e '/^#/ d' < ${TMP}/alltests > ${TMP}/alltests.temp ##This removes all newlines, leading spaces, tabs, # |
| 647 | sed 's/^[0-9,a-z,A-Z]*/'"$inc"'_ITERATION_&/' < ${TMP}/alltests.temp > ${TMP}/alltests ## .temp is kept as Base file |
| 648 | while [ $inc -lt $RUN_REPEATED ] ; do |
| 649 | inc=`expr $inc + 1` |
| 650 | sed 's/^[0-9,a-z,A-Z]*/'"$inc"'_ITERATION_&/' < ${TMP}/alltests.temp >> ${TMP}/alltests #Keep appending with Iteration No.s |
| 651 | done |
| 652 | fi |
| 653 | |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 654 | [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test start time: $(date)" ; } |
robbiew | 7d43d77 | 2005-02-07 20:07:30 +0000 | [diff] [blame] | 655 | PAN_COMMAND="${LTPROOT}/pan/pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ \ |
subrata_modak | bc833d3 | 2007-07-25 10:12:02 +0000 | [diff] [blame] | 656 | -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE $FAILCMDFILE" |
robbiew | 7d43d77 | 2005-02-07 20:07:30 +0000 | [diff] [blame] | 657 | if [ ! -z "$VERBOSE_MODE" ] ; then |
| 658 | echo "COMMAND: $PAN_COMMAND" |
| 659 | if [ ! -z "$TAG_RESTRICT_STRING" ] ; then |
| 660 | echo "INFO: Restricted to $TAG_RESTRICT_STRING" |
| 661 | fi |
| 662 | fi |
| 663 | #$PAN_COMMAND #Duplicated code here, because otherwise if we fail, only "PAN_COMMAND" gets output |
subrata_modak | 4393821 | 2008-05-19 08:48:46 +0000 | [diff] [blame] | 664 | |
| 665 | ## Display the Output/Log/Failed/HTML file names here |
| 666 | echo -e "LOG File: \c" |
| 667 | echo $LOGFILE | cut -b4- |
| 668 | |
| 669 | if [ "$OUTPUTFILE" ]; then |
| 670 | echo -e "OUTPUT File: \c" |
| 671 | echo $OUTPUTFILE | cut -b4- |
| 672 | fi |
| 673 | |
| 674 | echo -e "FAILED COMMAND File: \c" |
| 675 | echo $FAILCMDFILE | cut -b4- |
| 676 | |
| 677 | if [ "$HTMLFILE" ]; then |
| 678 | echo "HTML File: $HTMLFILE" |
| 679 | fi |
| 680 | |
| 681 | echo "Running tests......." |
subrata_modak | e47fb35 | 2007-11-25 17:03:49 +0000 | [diff] [blame] | 682 | test_start_time=$(date) |
subrata_modak | d48c4d0 | 2008-01-23 12:59:40 +0000 | [diff] [blame] | 683 | ${LTPROOT}/pan/pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE $FAILCMDFILE |
| 684 | |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 685 | if [ $? -eq 0 ]; then |
| 686 | echo "INFO: pan reported all tests PASS" |
| 687 | VALUE=0 |
subrata_modak | e47fb35 | 2007-11-25 17:03:49 +0000 | [diff] [blame] | 688 | export LTP_EXIT_VALUE=0; |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 689 | else |
| 690 | echo "INFO: pan reported some tests FAIL" |
| 691 | VALUE=1 |
subrata_modak | e47fb35 | 2007-11-25 17:03:49 +0000 | [diff] [blame] | 692 | export LTP_EXIT_VALUE=1; |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 693 | fi |
mreed10 | 9169642 | 2006-05-03 19:07:22 +0000 | [diff] [blame] | 694 | echo "LTP Version: $version_date" |
| 695 | |
subrata_modak | e47fb35 | 2007-11-25 17:03:49 +0000 | [diff] [blame] | 696 | if [ "$ALT_HTML_OUT" -eq 1 ] ; then #User wants the HTML output to be created, it then needs to be generated |
| 697 | export LTP_VERSION=$version_date |
| 698 | export TEST_START_TIME=$test_start_time |
| 699 | export TEST_END_TIME=$(date) |
| 700 | OUTPUT_DIRECTORY=`echo $OUTPUTFILE | cut -c4-` |
| 701 | LOGS_DIRECTORY="$LTPROOT/results" |
| 702 | export TEST_OUTPUT_DIRECTORY="$LTPROOT/output" |
| 703 | export TEST_LOGS_DIRECTORY=$LOGS_DIRECTORY |
| 704 | echo "Generating HTML Output.....!!" |
| 705 | ( perl $LTPROOT/tools/genhtml.pl $LTPROOT/tools/html_report_header.txt test_start test_end test_output execution_status $OUTPUT_DIRECTORY > $HTMLFILE; ) |
| 706 | echo "Generated HTML Output.....!!" |
| 707 | echo "Location: $HTMLFILE"; |
| 708 | |
| 709 | fi |
| 710 | |
subrata_modak | 08dde6f | 2007-11-28 11:02:51 +0000 | [diff] [blame] | 711 | if [ "$ALT_EMAIL_OUT" -eq 1 ] ; then ## User wants reports to be e-mailed |
| 712 | if [ [ ! "$HTMLFILE_NAME" ] -o [ ! "$OUTPUTFILE_NAME" ] -o [ ! "$LOGFILE_NAME" ] ] ; then |
| 713 | ##User does not have output/logs/html-output, nothing to be mailed in this situation |
| 714 | echo "Nothing to be mailed here...." |
| 715 | else |
subrata_modak | 4393821 | 2008-05-19 08:48:46 +0000 | [diff] [blame] | 716 | TAR_FILE_NAME=LTP_RUN_$version_date$DEFAULT_FILE_NAME_GENERATION_TIME.tar |
subrata_modak | 08dde6f | 2007-11-28 11:02:51 +0000 | [diff] [blame] | 717 | if [ "$HTMLFILE_NAME" ] ; then ## HTML file Exists |
| 718 | if [ "$ALT_HTML_OUT" -ne 1 ] ; then ## The HTML file path is absolute and not $LTPROOT/output |
| 719 | mkdir -p $LTPROOT/output ## We need to create this Directory |
| 720 | cp $HTMLFILE_NAME $LTPROOT/output/ |
| 721 | fi |
| 722 | fi |
| 723 | if [ "$OUTPUTFILE_NAME" ] ; then ## Output file exists |
| 724 | if [ "$ALT_DIR_OUT" -ne 1 ] ; then ## The Output file path is absolute and not $LTPROOT/output |
| 725 | mkdir -p $LTPROOT/output ## We need to create this Directory |
| 726 | cp $OUTPUTFILE_NAME $LTPROOT/output/ |
| 727 | fi |
| 728 | fi |
| 729 | if [ "$LOGFILE_NAME" ] ; then ## Log file exists |
| 730 | if [ "$ALT_DIR_RES" -ne 1 ] ; then ## The Log file path is absolute and not $LTPROOT/results |
| 731 | mkdir -p $LTPROOT/results ## We need to create this Directory |
| 732 | cp $LOGFILE_NAME $LTPROOT/results/ |
| 733 | fi |
| 734 | fi |
| 735 | if [ -d $LTPROOT/output ] ; then |
| 736 | tar -cf ./$TAR_FILE_NAME $LTPROOT/output |
| 737 | if [ $? -eq 0 ]; then |
| 738 | echo "Created TAR File: ./$TAR_FILE_NAME successfully, added $LTPROOT/output" |
| 739 | else |
| 740 | echo "Cannot Create TAR File: ./$TAR_FILE_NAME for adding $LTPROOT/output" |
| 741 | fi |
| 742 | fi |
| 743 | if [ -d $LTPROOT/results ] ; then |
| 744 | tar -uf ./$TAR_FILE_NAME $LTPROOT/results |
| 745 | if [ $? -eq 0 ]; then |
| 746 | echo "Updated TAR File: ./$TAR_FILE_NAME successfully, added $LTPROOT/results" |
| 747 | else |
| 748 | echo "Cannot Update TAR File: ./$TAR_FILE_NAME for adding $LTPROOT/results" |
| 749 | fi |
| 750 | fi |
| 751 | if [ -e $LTPROOT/nohup.out ] ; then ## If User would have Chosen nohup to do ltprun |
| 752 | tar -uf ./$TAR_FILE_NAME $LTPROOT/nohup.out |
| 753 | if [ $? -eq 0 ]; then |
| 754 | echo "Updated TAR File: ./$TAR_FILE_NAME successfully, added $LTPROOT/nohup.out" |
| 755 | else |
| 756 | echo "Cannot Update TAR File: ./$TAR_FILE_NAME for adding $LTPROOT/nohup.out" |
| 757 | fi |
| 758 | fi |
| 759 | gzip ./$TAR_FILE_NAME ## gzip this guy |
| 760 | if [ $? -eq 0 ]; then |
| 761 | echo "Gunzipped TAR File: ./$TAR_FILE_NAME" |
| 762 | else |
| 763 | echo "Cannot Gunzip TAR File: ./$TAR_FILE_NAME" |
| 764 | fi |
| 765 | if [ -e /usr/bin/mutt ] ; then ## This is a better mail client than others |
| 766 | echo "Starting mailing reports to: $EMAIL_TO, file: ./$TAR_FILE_NAME.gz" |
| 767 | mutt -a ./$TAR_FILE_NAME.gz -s "LTP Reports on $test_start_time" $EMAIL_TO < /dev/null |
| 768 | if [ $? -eq 0 ]; then |
| 769 | echo "Reports Successfully mailed to: $EMAIL_TO" |
| 770 | else |
| 771 | echo "Reports cannot be mailed to: $EMAIL_TO" |
| 772 | fi |
| 773 | else ## Use our Ageold mail program |
| 774 | echo "Starting mailing reports to: $EMAIL_TO, file: ./$TAR_FILE_NAME.gz" |
| 775 | uuencode ./$TAR_FILE_NAME.gz $TAR_FILE_NAME.gz | mail $EMAIL_TO -s "LTP Reports on $test_start_time" |
| 776 | if [ $? -eq 0 ]; then |
| 777 | echo "Reports Successfully mailed to: $EMAIL_TO" |
| 778 | else |
| 779 | echo "Reports cannot be mailed to: $EMAIL_TO" |
| 780 | fi |
| 781 | fi |
| 782 | fi |
| 783 | fi |
| 784 | |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 785 | [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test end time: $(date)" ; } |
| 786 | |
subrata_modak | e099b2a | 2007-10-29 12:22:01 +0000 | [diff] [blame] | 787 | [ "$GENLOAD" -eq 1 ] && { killall -9 genload >/dev/null 2>&1; } |
| 788 | [ "$NETPIPE" -eq 1 ] && { killall -9 NPtcp >/dev/null 2>&1; } |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 789 | |
subrata_modak | 5d7deea | 2007-09-15 13:51:36 +0000 | [diff] [blame] | 790 | [ "$ALT_DIR_OUT" -eq 1 ] || [ "$ALT_DIR_RES" -eq 1 ] && \ |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 791 | { |
| 792 | cat <<-EOF >&1 |
| 793 | |
| 794 | ###############################################################" |
| 795 | |
| 796 | Done executing testcases." |
mreed10 | 9169642 | 2006-05-03 19:07:22 +0000 | [diff] [blame] | 797 | LTP Version: $version_date |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 798 | ###############################################################" |
| 799 | |
| 800 | EOF |
| 801 | } |
| 802 | exit $VALUE |
| 803 | } |
| 804 | |
| 805 | cleanup() |
| 806 | { |
| 807 | rm -rf ${TMP} |
| 808 | } |
| 809 | |
| 810 | trap "cleanup" 0 |
| 811 | setup |
| 812 | main "$@" |