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 ## |
Wanlong Gao | 4548c6c | 2012-10-19 18:03:36 +0800 | [diff] [blame] | 18 | ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ## |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 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 |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 27 | # |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 28 | # History: Oct 07 2003 - Modified - Manoj Iyer |
| 29 | # - use functions |
| 30 | # - clean up on script exit |
| 31 | # - error checking etc. |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 32 | # |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 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 |
subrata_modak | 14390fd | 2009-05-19 09:39:11 +0000 | [diff] [blame] | 36 | # - exit with error if ltp-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 |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 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 |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 65 | # Aug 17 2009 - Modified - Subrata Modak |
| 66 | # - Added Fault Injection generation Capability through -F Option |
subrata_modak | e099b2a | 2007-10-29 12:22:01 +0000 | [diff] [blame] | 67 | # |
subrata_modak | 6838ec3 | 2007-09-14 10:10:12 +0000 | [diff] [blame] | 68 | ################################################################################# |
subrata_modak | bc833d3 | 2007-07-25 10:12:02 +0000 | [diff] [blame] | 69 | |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 70 | |
| 71 | |
| 72 | setup() |
| 73 | { |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 74 | cd `dirname $0` || \ |
| 75 | { |
| 76 | echo "FATAL: unable to change directory to $(dirname $0)" |
| 77 | exit 1 |
| 78 | } |
| 79 | export LTPROOT=${PWD} |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 80 | export TMPBASE="/tmp" |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 81 | export PATH="${PATH}:${LTPROOT}/testcases/bin" |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 82 | |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 83 | [ -d "$LTPROOT/testcases/bin" ] || |
| 84 | { |
Garrett Cooper | cf86b8b | 2010-11-16 21:46:41 -0800 | [diff] [blame] | 85 | echo "FATAL: LTP not installed correctly" |
| 86 | echo "INFO: Follow directions in INSTALL!" |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 87 | exit 1 |
| 88 | } |
| 89 | |
| 90 | [ -e "$LTPROOT/bin/ltp-pan" ] || |
| 91 | { |
| 92 | echo "FATAL: Test suite driver 'ltp-pan' not found" |
Garrett Cooper | cf86b8b | 2010-11-16 21:46:41 -0800 | [diff] [blame] | 93 | echo "INFO: Follow directions in INSTALL!" |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 94 | exit 1 |
| 95 | } |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 96 | } |
| 97 | |
mreed10 | 9169642 | 2006-05-03 19:07:22 +0000 | [diff] [blame] | 98 | version_of_ltp() |
| 99 | { |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 100 | cat "$LTPROOT/Version" |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 101 | exit 0 |
mreed10 | 9169642 | 2006-05-03 19:07:22 +0000 | [diff] [blame] | 102 | } |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 103 | |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 104 | usage() |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 105 | { |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 106 | cat <<-EOF >&2 |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 107 | |
Garrett Cooper | f95875a | 2010-03-05 02:44:39 -0800 | [diff] [blame] | 108 | usage: ${0##*/} [ -a EMAIL_TO ] [ -c NUM_PROCS ] [ -C FAILCMDFILE ] [ -d TMPDIR ] |
subrata_modak | e47fb35 | 2007-11-25 17:03:49 +0000 | [diff] [blame] | 109 | [ -D NUM_PROCS,NUM_FILES,NUM_BYTES,CLEAN_FLAG ] -e [ -f CMDFILES(,...) ] [ -g HTMLFILE] |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 110 | [ -i NUM_PROCS ] [ -l LOGFILE ] [ -m NUM_PROCS,CHUNKS,BYTES,HANGUP_FLAG ] |
subrata_modak | e099b2a | 2007-10-29 12:22:01 +0000 | [diff] [blame] | 111 | -N -n [ -o OUTPUTFILE ] -p -q [ -r LTPROOT ] [ -s PATTERN ] [ -t DURATION ] |
subrata_modak | d9fb386 | 2008-12-29 11:25:36 +0000 | [diff] [blame] | 112 | -v [ -w CMDFILEADDR ] [ -x INSTANCES ] [ -b DEVICE ] [-B DEVICE_FS_TYPE] |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 113 | [ -F LOOPS,PERCENTAGE ] |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 114 | |
subrata_modak | 08dde6f | 2007-11-28 11:02:51 +0000 | [diff] [blame] | 115 | -a EMAIL_TO EMAIL all your Reports to this E-mail Address |
subrata_modak | e099b2a | 2007-10-29 12:22:01 +0000 | [diff] [blame] | 116 | -c NUM_PROCS Run LTP under additional background CPU load |
| 117 | [NUM_PROCS = no. of processes creating the CPU Load by spinning over sqrt() |
| 118 | (Defaults to 1 when value)] |
subrata_modak | bc833d3 | 2007-07-25 10:12:02 +0000 | [diff] [blame] | 119 | -C FAILCMDFILE Command file with all failed test cases. |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 120 | -d TMPDIR Directory where temporary files will be created. |
subrata_modak | e099b2a | 2007-10-29 12:22:01 +0000 | [diff] [blame] | 121 | -D NUM_PROCS,NUM_FILES,NUM_BYTES,CLEAN_FLAG |
| 122 | Run LTP under additional background Load on Secondary Storage (Seperate by comma) |
| 123 | [NUM_PROCS = no. of processes creating Storage Load by spinning over write()] |
| 124 | [NUM_FILES = Write() to these many files (Defaults to 1 when value 0 or undefined)] |
| 125 | [NUM_BYTES = write these many bytes (defaults to 1GB, when value 0 or undefined)] |
| 126 | [CLEAN_FLAG = unlink file to which random data written, when value 1] |
mreed10 | 9169642 | 2006-05-03 19:07:22 +0000 | [diff] [blame] | 127 | -e Prints the date of the current LTP release |
subrata_modak | bc833d3 | 2007-07-25 10:12:02 +0000 | [diff] [blame] | 128 | -f CMDFILES Execute user defined list of testcases (separate with ',') |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 129 | -F LOOPS,PERCENTAGE Induce PERCENTAGE Fault in the Kernel Subsystems, and, run each test for LOOPS loop |
subrata_modak | e47fb35 | 2007-11-25 17:03:49 +0000 | [diff] [blame] | 130 | -g HTMLFILE Create an additional HTML output format |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 131 | -h Help. Prints all available options. |
subrata_modak | e099b2a | 2007-10-29 12:22:01 +0000 | [diff] [blame] | 132 | -i NUM_PROCS Run LTP under additional background Load on IO Bus |
| 133 | [NUM_PROCS = no. of processes creating IO Bus Load by spinning over sync()] |
Subrata Modak | bd9d440 | 2010-05-12 22:03:21 +0530 | [diff] [blame] | 134 | -K DMESG_LOG_DIR |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 135 | Log Kernel messages generated for each test cases inside this directory |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 136 | -l LOGFILE Log results of test in a logfile. |
subrata_modak | e099b2a | 2007-10-29 12:22:01 +0000 | [diff] [blame] | 137 | -m NUM_PROCS,CHUNKS,BYTES,HANGUP_FLAG |
| 138 | Run LTP under additional background Load on Main memory (Seperate by comma) |
| 139 | [NUM_PROCS = no. of processes creating main Memory Load by spinning over malloc()] |
| 140 | [CHUNKS = malloc these many chunks (default is 1 when value 0 or undefined)] |
| 141 | [BYTES = malloc CHUNKS of BYTES bytes (default is 256MB when value 0 or undefined) ] |
| 142 | [HANGUP_FLAG = hang in a sleep loop after memory allocated, when value 1] |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 143 | -M CHECK_TYPE |
| 144 | [CHECK_TYPE=1 => Full Memory Leak Check tracing children as well] |
| 145 | [CHECK_TYPE=2 => Thread Concurrency Check tracing children as well] |
| 146 | [CHECK_TYPE=3 => Full Memory Leak & Thread Concurrency Check tracing children as well] |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 147 | -N Run all the networking tests. |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 148 | -n Run LTP with network traffic in background. |
| 149 | -o OUTPUTFILE Redirect test output to a file. |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 150 | -p Human readable format logfiles. |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 151 | -q Print less verbose output to screen. |
| 152 | -r LTPROOT Fully qualified path where testsuite is installed. |
subrata_modak | a1fd64b | 2007-04-11 11:24:49 +0000 | [diff] [blame] | 153 | -s PATTERN Only run test cases which match PATTERN. |
subrata_modak | 2f6c981 | 2009-08-14 17:07:48 +0000 | [diff] [blame] | 154 | -S SKIPFILE Skip tests specified in SKIPFILE |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 155 | -t DURATION Execute the testsuite for given duration. Examples: |
| 156 | -t 60s = 60 seconds |
| 157 | -t 45m = 45 minutes |
| 158 | -t 24h = 24 hours |
| 159 | -t 2d = 2 days |
subrata_modak | 8c13833 | 2008-01-28 11:19:32 +0000 | [diff] [blame] | 160 | -T REPETITION Execute the testsuite for REPETITION no. of times |
subrata_modak | bc833d3 | 2007-07-25 10:12:02 +0000 | [diff] [blame] | 161 | -w CMDFILEADDR Uses wget to get the user's list of testcases. |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 162 | -x INSTANCES Run multiple instances of this testsuite. |
subrata_modak | d9fb386 | 2008-12-29 11:25:36 +0000 | [diff] [blame] | 163 | -b DEVICE Some tests require an unmounted block device |
| 164 | to run correctly. |
| 165 | -B DEVICE_FS_TYPE The file system of test block devices. |
| 166 | |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 167 | |
Garrett Cooper | f95875a | 2010-03-05 02:44:39 -0800 | [diff] [blame] | 168 | 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] | 169 | |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 170 | |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 171 | EOF |
| 172 | exit 0 |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 173 | } |
| 174 | |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 175 | main() |
| 176 | { |
subrata_modak | bc833d3 | 2007-07-25 10:12:02 +0000 | [diff] [blame] | 177 | local CMDFILES="" |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 178 | local PRETTY_PRT="" |
subrata_modak | 5d7deea | 2007-09-15 13:51:36 +0000 | [diff] [blame] | 179 | local ALT_DIR_OUT=0 |
| 180 | local ALT_DIR_RES=0 |
subrata_modak | e47fb35 | 2007-11-25 17:03:49 +0000 | [diff] [blame] | 181 | local ALT_HTML_OUT=0 |
subrata_modak | 08dde6f | 2007-11-28 11:02:51 +0000 | [diff] [blame] | 182 | local ALT_EMAIL_OUT=0 |
Subrata Modak | bd9d440 | 2010-05-12 22:03:21 +0530 | [diff] [blame] | 183 | local ALT_DMESG_OUT=0 |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 184 | local RUN_NETEST=0 |
subrata_modak | 8c13833 | 2008-01-28 11:19:32 +0000 | [diff] [blame] | 185 | local RUN_REPEATED=0 |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 186 | local QUIET_MODE="" |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 187 | local NETPIPE=0 |
| 188 | local GENLOAD=0 |
| 189 | local MEMSIZE=0 |
| 190 | local DURATION="" |
subrata_modak | bc833d3 | 2007-07-25 10:12:02 +0000 | [diff] [blame] | 191 | local CMDFILEADDR="" |
subrata_modak | 4393821 | 2008-05-19 08:48:46 +0000 | [diff] [blame] | 192 | local FAILCMDFILE="" |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 193 | local INJECT_KERNEL_FAULT="" |
| 194 | local INJECT_KERNEL_FAULT_PERCENTAGE="" |
| 195 | local INJECT_FAULT_LOOPS_PER_TEST="" |
| 196 | local VALGRIND_CHECK="" |
| 197 | local VALGRIND_CHECK_TYPE="" |
subrata_modak | e47fb35 | 2007-11-25 17:03:49 +0000 | [diff] [blame] | 198 | local LOGFILE_NAME="" |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 199 | local LOGFILE="" |
subrata_modak | e47fb35 | 2007-11-25 17:03:49 +0000 | [diff] [blame] | 200 | local OUTPUTFILE_NAME="" |
| 201 | local OUTPUTFILE="" |
| 202 | local HTMLFILE_NAME="" |
| 203 | local HTMLFILE="" |
Subrata Modak | bd9d440 | 2010-05-12 22:03:21 +0530 | [diff] [blame] | 204 | local DMESG_DIR="" |
subrata_modak | 08dde6f | 2007-11-28 11:02:51 +0000 | [diff] [blame] | 205 | local EMAIL_TO="" |
robbiew | 7d43d77 | 2005-02-07 20:07:30 +0000 | [diff] [blame] | 206 | local TAG_RESTRICT_STRING="" |
| 207 | local PAN_COMMAND="" |
subrata_modak | 4393821 | 2008-05-19 08:48:46 +0000 | [diff] [blame] | 208 | local DEFAULT_FILE_NAME_GENERATION_TIME=`date +"%Y_%b_%d-%Hh_%Mm_%Ss"` |
Garrett Cooper | cf86b8b | 2010-11-16 21:46:41 -0800 | [diff] [blame] | 209 | |
| 210 | local scenfile= |
| 211 | |
yaberauneya | ef77253 | 2009-10-09 17:55:43 +0000 | [diff] [blame] | 212 | version_date=$(cat "$LTPROOT/Version") |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 213 | |
Subrata Modak | bd9d440 | 2010-05-12 22:03:21 +0530 | [diff] [blame] | 214 | while getopts a:c:C:d:D:f:F:ehi:K:g:l:m:M:Nno:pqr:s:S:t:T:w:x:b:B: arg |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 215 | do case $arg in |
subrata_modak | 08dde6f | 2007-11-28 11:02:51 +0000 | [diff] [blame] | 216 | a) EMAIL_TO=$OPTARG |
| 217 | ALT_EMAIL_OUT=1;; |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 218 | c) |
subrata_modak | e099b2a | 2007-10-29 12:22:01 +0000 | [diff] [blame] | 219 | NUM_PROCS=$(($OPTARG)) |
| 220 | if [ "$NUM_PROCS" -eq 0 ]; then |
| 221 | # User Did not Define the Value ,or, User Defined Zero, |
| 222 | # hence, prevent from creating infinite processes |
| 223 | NUM_PROCS=1 |
| 224 | fi |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 225 | $LTPROOT/testcases/bin/genload --cpu $NUM_PROCS >/dev/null 2>&1 & |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 226 | GENLOAD=1 ;; |
subrata_modak | bc833d3 | 2007-07-25 10:12:02 +0000 | [diff] [blame] | 227 | |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 228 | C) |
subrata_modak | 6838ec3 | 2007-09-14 10:10:12 +0000 | [diff] [blame] | 229 | case $OPTARG in |
| 230 | /*) |
| 231 | FAILCMDFILE="-C $OPTARG" ;; |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 232 | *) |
subrata_modak | 6838ec3 | 2007-09-14 10:10:12 +0000 | [diff] [blame] | 233 | FAILCMDFILE="-C $LTPROOT/output/$OPTARG" |
subrata_modak | 5d7deea | 2007-09-15 13:51:36 +0000 | [diff] [blame] | 234 | ALT_DIR_OUT=1 ;; |
subrata_modak | 6838ec3 | 2007-09-14 10:10:12 +0000 | [diff] [blame] | 235 | esac ;; |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 236 | |
subrata_modak | 5ee3e89 | 2008-10-21 13:17:56 +0000 | [diff] [blame] | 237 | d) # convert the user path to absolute path. |
Garrett Cooper | 5d520f4 | 2012-08-07 08:57:31 -0700 | [diff] [blame] | 238 | export TMPBASE=$(readlink -f ${OPTARG}) ;; |
subrata_modak | e099b2a | 2007-10-29 12:22:01 +0000 | [diff] [blame] | 239 | |
| 240 | 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] | 241 | ARGUMENT_LIST=$OPTARG |
Garrett Cooper | cf86b8b | 2010-11-16 21:46:41 -0800 | [diff] [blame] | 242 | TOTAL_ARGUMENTS=1 |
| 243 | for ARGUMENT in `echo "$ARGUMENT_LIST" | tr ',' ' '` |
subrata_modak | e099b2a | 2007-10-29 12:22:01 +0000 | [diff] [blame] | 244 | do |
| 245 | case $TOTAL_ARGUMENTS in |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 246 | 1) NUM_PROCS="$ARGUMENT" ;; |
| 247 | 2) NUM_FILES="$ARGUMENT" ;; |
| 248 | 3) NUM_BYTES="$ARGUMENT" ;; |
| 249 | 4) CLEAN_FLAG="$ARGUMENT" ;; |
subrata_modak | e099b2a | 2007-10-29 12:22:01 +0000 | [diff] [blame] | 250 | esac |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 251 | TOTAL_ARGUMENTS=`expr $TOTAL_ARGUMENTS + 1` |
subrata_modak | e099b2a | 2007-10-29 12:22:01 +0000 | [diff] [blame] | 252 | done |
| 253 | # just to get the default values if the user passed 0 |
| 254 | if [ "$NUM_PROCS" -eq 0 ]; then |
| 255 | NUM_PROCS=1 |
| 256 | fi |
| 257 | if [ "$NUM_FILES" -eq 0 ]; then |
| 258 | NUM_FILES=1 |
| 259 | fi |
| 260 | if [ "$NUM_BYTES" -eq 0 ]; then |
| 261 | NUM_BYTES=$((1024 * 1024 * 1024)) |
| 262 | fi |
| 263 | if [ "$CLEAN_FLAG" -ne 1 ]; then |
| 264 | CLEAN_FLAG=0 |
| 265 | fi |
| 266 | if [ "$CLEAN_FLAG" -eq 1 ]; then |
| 267 | # Do not unlink file in this case |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 268 | $LTPROOT/testcases/bin/genload --hdd $NUM_PROCS --hdd-files \ |
subrata_modak | e099b2a | 2007-10-29 12:22:01 +0000 | [diff] [blame] | 269 | $NUM_FILES --hdd-bytes $NUM_BYTES >/dev/null 2>&1 & |
| 270 | else |
| 271 | # Cleanup otherwise |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 272 | $LTPROOT/testcases/bin/genload --hdd $NUM_PROCS --hdd-files \ |
subrata_modak | e099b2a | 2007-10-29 12:22:01 +0000 | [diff] [blame] | 273 | $NUM_FILES --hdd-bytes $NUM_BYTES --hdd-noclean >/dev/null 2>&1 & |
| 274 | fi |
| 275 | GENLOAD=1;; |
| 276 | |
mreed10 | 9169642 | 2006-05-03 19:07:22 +0000 | [diff] [blame] | 277 | e) # Print out the version of LTP |
| 278 | version_of_ltp |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 279 | ;; |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 280 | f) # Execute user defined set of testcases. |
subrata_modak | bc833d3 | 2007-07-25 10:12:02 +0000 | [diff] [blame] | 281 | # Can be more then one file, just separate it with ',', like: |
| 282 | # -f nfs,commands,/tmp/testfile |
| 283 | CMDFILES=$OPTARG;; |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 284 | F) INJECT_KERNEL_FAULT=1 |
| 285 | #Seperate out the NO_OF_LOOPS & FAULT_PERCENTAGE |
| 286 | INJECT_FAULT_LOOPS_PER_TEST=`echo $OPTARG |cut -d',' -f1 | tr -d '\n' | tr -d ' '` |
| 287 | INJECT_KERNEL_FAULT_PERCENTAGE=`echo $OPTARG |cut -d',' -f2 | tr -d '\n' | tr -d ' '` |
| 288 | if [ ! $INJECT_FAULT_LOOPS_PER_TEST ]; then |
| 289 | echo "Loops not properly defined. Resorting to default 5..." |
| 290 | export INJECT_FAULT_LOOPS_PER_TEST=5 |
| 291 | fi |
| 292 | if [ ! $INJECT_KERNEL_FAULT_PERCENTAGE ]; then |
| 293 | echo "Fault Persentage not properly defined. Resorting to default 10..." |
| 294 | export INJECT_KERNEL_FAULT_PERCENTAGE=10 |
| 295 | fi;; |
subrata_modak | e47fb35 | 2007-11-25 17:03:49 +0000 | [diff] [blame] | 296 | g) HTMLFILE_NAME="$OPTARG" |
| 297 | case $OPTARG in |
| 298 | /*) |
| 299 | HTMLFILE="$OPTARG";; |
| 300 | *) |
subrata_modak | d48c4d0 | 2008-01-23 12:59:40 +0000 | [diff] [blame] | 301 | HTMLFILE="$LTPROOT/output/$OPTARG";; |
| 302 | esac |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 303 | ALT_DIR_OUT=1 |
subrata_modak | d48c4d0 | 2008-01-23 12:59:40 +0000 | [diff] [blame] | 304 | ALT_HTML_OUT=1;; |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 305 | h) usage;; |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 306 | |
subrata_modak | e099b2a | 2007-10-29 12:22:01 +0000 | [diff] [blame] | 307 | i) |
| 308 | NUM_PROCS=$(($OPTARG)) |
| 309 | if [ "$NUM_PROCS" -eq 0 ]; then |
| 310 | # User Did not Define the Value ,or, User Defined Zero, |
| 311 | # hence, prevent from creating infinite processes |
| 312 | NUM_PROCS=1 |
| 313 | fi |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 314 | $LTPROOT/testcases/bin/genload --io $NUM_PROCS >/dev/null 2>&1 & |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 315 | GENLOAD=1 ;; |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 316 | |
| 317 | K) |
Subrata Modak | bd9d440 | 2010-05-12 22:03:21 +0530 | [diff] [blame] | 318 | case $OPTARG in |
| 319 | /*) |
| 320 | DMESG_DIR="$OPTARG-dmesg-output-`echo $$-``date +%X | tr -d ' '`";; |
| 321 | *) |
| 322 | DMESG_DIR="$LTPROOT/output/$OPTARG-dmesg-output-`echo $$-``date +%X | tr -d ' '`";; |
| 323 | esac |
| 324 | mkdir -p $DMESG_DIR |
| 325 | ALT_DMESG_OUT=1;; |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 326 | l) |
subrata_modak | 6838ec3 | 2007-09-14 10:10:12 +0000 | [diff] [blame] | 327 | LOGFILE_NAME="$OPTARG" |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 328 | case $OPTARG in |
subrata_modak | 5d7deea | 2007-09-15 13:51:36 +0000 | [diff] [blame] | 329 | /*) |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 330 | LOGFILE="-l $OPTARG" ;; |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 331 | *) |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 332 | LOGFILE="-l $LTPROOT/results/$OPTARG" |
subrata_modak | 5d7deea | 2007-09-15 13:51:36 +0000 | [diff] [blame] | 333 | ALT_DIR_RES=1 ;; |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 334 | esac ;; |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 335 | |
subrata_modak | e099b2a | 2007-10-29 12:22:01 +0000 | [diff] [blame] | 336 | 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] | 337 | ARGUMENT_LIST=$OPTARG |
Garrett Cooper | cf86b8b | 2010-11-16 21:46:41 -0800 | [diff] [blame] | 338 | TOTAL_ARGUMENTS=1 |
| 339 | for ARGUMENT in `echo "$ARGUMENT_LIST" | tr ',' ' '` |
subrata_modak | e099b2a | 2007-10-29 12:22:01 +0000 | [diff] [blame] | 340 | do |
| 341 | case $TOTAL_ARGUMENTS in |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 342 | 1) NUM_PROCS="$ARGUMENT" ;; |
| 343 | 2) CHUNKS="$ARGUMENT" ;; |
| 344 | 3) BYTES="$ARGUMENT" ;; |
| 345 | 4) HANGUP_FLAG="$ARGUMENT" ;; |
subrata_modak | e099b2a | 2007-10-29 12:22:01 +0000 | [diff] [blame] | 346 | esac |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 347 | TOTAL_ARGUMENTS=`expr $TOTAL_ARGUMENTS + 1` |
subrata_modak | e099b2a | 2007-10-29 12:22:01 +0000 | [diff] [blame] | 348 | done |
| 349 | # just to get the default values if the user passed 0 |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 350 | if [ "$NUM_PROCS" -eq 0 ]; then |
| 351 | NUM_PROCS=1 |
| 352 | fi |
| 353 | if [ "$CHUNKS" -eq 0 ]; then |
| 354 | CHUNKS=1 |
| 355 | fi |
| 356 | if [ "$BYTES" -eq 0 ]; then |
| 357 | BYTES=$((256 * 1024 * 1024)) |
| 358 | fi |
| 359 | if [ "$HANGUP_FLAG" -ne 1 ]; then |
| 360 | HANGUP_FLAG=0 |
| 361 | fi |
subrata_modak | e099b2a | 2007-10-29 12:22:01 +0000 | [diff] [blame] | 362 | if [ "$HANGUP_FLAG" -eq 1 ]; then |
| 363 | # Hang in a Sleep loop after memory allocated |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 364 | $LTPROOT/testcases/bin/genload --vm $NUM_PROCS --vm-chunks \ |
subrata_modak | e099b2a | 2007-10-29 12:22:01 +0000 | [diff] [blame] | 365 | $CHUNKS --vm-bytes $BYTES --vm-hang >/dev/null 2>&1 & |
| 366 | else |
| 367 | # Otherwise Do not Hangup |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 368 | $LTPROOT/testcases/bin/genload --vm $NUM_PROCS --vm-chunks \ |
subrata_modak | e099b2a | 2007-10-29 12:22:01 +0000 | [diff] [blame] | 369 | $CHUNKS --vm-bytes $BYTES >/dev/null 2>&1 & |
| 370 | fi |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 371 | GENLOAD=1;; |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 372 | M) |
| 373 | VALGRIND_CHECK=1 |
| 374 | VALGRIND_CHECK_TYPE="$OPTARG";; |
subrata_modak | 9c7072a | 2009-08-26 07:00:25 +0000 | [diff] [blame] | 375 | |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 376 | N) RUN_NETEST=1;; |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 377 | |
| 378 | n) |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 379 | $LTPROOT/testcases/bin/netpipe.sh |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 380 | NETPIPE=1;; |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 381 | |
subrata_modak | 6838ec3 | 2007-09-14 10:10:12 +0000 | [diff] [blame] | 382 | o) OUTPUTFILE_NAME="$OPTARG" |
subrata_modak | 6838ec3 | 2007-09-14 10:10:12 +0000 | [diff] [blame] | 383 | case $OPTARG in |
| 384 | /*) |
| 385 | OUTPUTFILE="-o $OPTARG";; |
| 386 | *) |
| 387 | OUTPUTFILE="-o $LTPROOT/output/$OPTARG" |
subrata_modak | 5d7deea | 2007-09-15 13:51:36 +0000 | [diff] [blame] | 388 | ALT_DIR_OUT=1 ;; |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 389 | esac ;; |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 390 | |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 391 | p) PRETTY_PRT=" -p ";; |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 392 | |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 393 | q) QUIET_MODE=" -q ";; |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 394 | |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 395 | r) LTPROOT=$OPTARG;; |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 396 | |
robbiew | 7d43d77 | 2005-02-07 20:07:30 +0000 | [diff] [blame] | 397 | s) TAG_RESTRICT_STRING=$OPTARG;; |
subrata_modak | 2f6c981 | 2009-08-14 17:07:48 +0000 | [diff] [blame] | 398 | |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 399 | S) case $OPTARG in |
subrata_modak | 2f6c981 | 2009-08-14 17:07:48 +0000 | [diff] [blame] | 400 | /*) |
| 401 | SKIPFILE=$OPTARG;; |
| 402 | *) |
| 403 | SKIPFILE="$LTPROOT/$OPTARG";; |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 404 | esac ;; |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 405 | |
| 406 | t) # In case you want to specify the time |
| 407 | # to run from the command line |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 408 | # (2m = two minutes, 2h = two hours, etc) |
| 409 | DURATION="-t $OPTARG" ;; |
subrata_modak | 8c13833 | 2008-01-28 11:19:32 +0000 | [diff] [blame] | 410 | |
| 411 | T) # In case you want the testcases to runsequentially RUN_REPEATED times |
| 412 | RUN_REPEATED=$OPTARG;; |
| 413 | |
subrata_modak | bc833d3 | 2007-07-25 10:12:02 +0000 | [diff] [blame] | 414 | w) CMDFILEADDR=$OPTARG;; |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 415 | |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 416 | x) # number of ltp's to run |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 417 | cat <<-EOF >&1 |
| 418 | WARNING: The use of -x can cause unpredictable failures, as a |
| 419 | result of concurrently running multiple tests designed |
| 420 | to be ran exclusively. |
| 421 | Pausing for 10 seconds..." |
| 422 | EOF |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 423 | sleep 10 |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 424 | INSTANCES="-x $OPTARG";; |
subrata_modak | d9fb386 | 2008-12-29 11:25:36 +0000 | [diff] [blame] | 425 | b) DEVICE=$OPTARG;; |
| 426 | B) DEVICE_FS_TYPE=$OPTARG;; |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 427 | \?) usage;; |
| 428 | esac |
| 429 | done |
subrata_modak | 4393821 | 2008-05-19 08:48:46 +0000 | [diff] [blame] | 430 | |
| 431 | ## It would be nice to create a default log file even if the user has not mentioned |
| 432 | if [ ! "$LOGFILE" ]; then ## User has not mentioned about Log File name |
| 433 | LOGFILE_NAME=$DEFAULT_FILE_NAME_GENERATION_TIME |
| 434 | LOGFILE="-l $LTPROOT/results/LTP_RUN_ON-$LOGFILE_NAME.log" |
| 435 | ALT_DIR_RES=1 |
| 436 | PRETTY_PRT=" -p " |
| 437 | fi |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 438 | |
| 439 | ## It would be nice if a Failed File is compulsorily created (gives User better Idea of Tests that failed) |
subrata_modak | 6838ec3 | 2007-09-14 10:10:12 +0000 | [diff] [blame] | 440 | |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 441 | if [ ! "$FAILCMDFILE" ]; then ## User has not mentioned about Failed File name |
subrata_modak | 5d7deea | 2007-09-15 13:51:36 +0000 | [diff] [blame] | 442 | ALT_DIR_OUT=1 |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 443 | if [ ! "$OUTPUTFILE" ]; then ## User has not mentioned about Output File name either |
| 444 | if [ ! "$LOGFILE" ]; then ## User has not mentioned about Log File name either |
| 445 | FAILED_FILE_NAME=$DEFAULT_FILE_NAME_GENERATION_TIME |
| 446 | FAILCMDFILE="-C $LTPROOT/output/LTP_RUN_ON-$FAILED_FILE_NAME.failed" |
| 447 | else ## User Fortunately wanted a log file, |
| 448 | FAILED_FILE_NAME=`basename $LOGFILE_NAME` ## Extract log file name and use it to construct Failed file name |
| 449 | FAILCMDFILE="-C $LTPROOT/output/LTP_RUN_ON-$FAILED_FILE_NAME.failed" |
subrata_modak | 6838ec3 | 2007-09-14 10:10:12 +0000 | [diff] [blame] | 450 | fi |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 451 | else ## User Fortunately wanted a Output file |
| 452 | FAILED_FILE_NAME=`basename $OUTPUTFILE_NAME` ## Extract output file name and use it to construct Failed file name |
| 453 | FAILCMDFILE="-C $LTPROOT/output/LTP_RUN_ON-$FAILED_FILE_NAME.failed" |
subrata_modak | 6838ec3 | 2007-09-14 10:10:12 +0000 | [diff] [blame] | 454 | fi |
| 455 | fi |
subrata_modak | a1fd64b | 2007-04-11 11:24:49 +0000 | [diff] [blame] | 456 | |
subrata_modak | d48c4d0 | 2008-01-23 12:59:40 +0000 | [diff] [blame] | 457 | if [ "$ALT_HTML_OUT" -eq 1 ] ; then ## User wants the HTML version of the output |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 458 | QUIET_MODE="" ## Suppressing this guy as it will prevent generation of proper output |
subrata_modak | d48c4d0 | 2008-01-23 12:59:40 +0000 | [diff] [blame] | 459 | ## which the HTML parser will require |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 460 | 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] | 461 | OUTPUTFILE_NAME=$DEFAULT_FILE_NAME_GENERATION_TIME |
subrata_modak | e47fb35 | 2007-11-25 17:03:49 +0000 | [diff] [blame] | 462 | OUTPUTFILE="-o $LTPROOT/output/LTP_RUN_ON-$OUTPUTFILE_NAME.output" |
subrata_modak | 08dde6f | 2007-11-28 11:02:51 +0000 | [diff] [blame] | 463 | ALT_DIR_OUT=1 |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 464 | if [ ! "$HTMLFILE" ] ; then ## User has not mentioned HTML File name, We need to create one |
| 465 | HTMLFILE_NAME=`basename $OUTPUTFILE_NAME` |
subrata_modak | e47fb35 | 2007-11-25 17:03:49 +0000 | [diff] [blame] | 466 | HTMLFILE="$LTPROOT/output/$HTMLFILE_NAME.html" |
| 467 | fi |
| 468 | fi |
| 469 | fi |
| 470 | |
subrata_modak | 5d7deea | 2007-09-15 13:51:36 +0000 | [diff] [blame] | 471 | # If we need, create the output directory |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 472 | [ "$ALT_DIR_OUT" -eq 1 ] && \ |
| 473 | { |
| 474 | [ ! -d $LTPROOT/output ] && \ |
| 475 | { |
| 476 | echo "INFO: creating $LTPROOT/output directory" |
| 477 | mkdir -p $LTPROOT/output || \ |
| 478 | { |
| 479 | echo "ERROR: failed to create $LTPROOT/output" |
| 480 | exit 1 |
| 481 | } |
| 482 | } |
| 483 | } |
subrata_modak | 5d7deea | 2007-09-15 13:51:36 +0000 | [diff] [blame] | 484 | # If we need, create the results directory |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 485 | [ "$ALT_DIR_RES" -eq 1 ] && \ |
| 486 | { |
| 487 | echo "INFO: creating $LTPROOT/results directory" |
| 488 | [ ! -d $LTPROOT/results ] && \ |
| 489 | { |
| 490 | mkdir -p $LTPROOT/results || \ |
| 491 | { |
| 492 | echo "ERROR: failed to create $LTPROOT/results" |
| 493 | exit 1 |
| 494 | } |
| 495 | } |
| 496 | } |
subrata_modak | 5d7deea | 2007-09-15 13:51:36 +0000 | [diff] [blame] | 497 | |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 498 | # Added -m 777 for tests that call tst_tmpdir() and try to |
subrata_modak | a1fd64b | 2007-04-11 11:24:49 +0000 | [diff] [blame] | 499 | # write to it as user nobody |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 500 | mkdir -m 777 -p $TMPBASE || \ |
| 501 | { |
| 502 | echo "FATAL: Unable to make temporary directory $TMPBASE" |
| 503 | exit 1 |
| 504 | } |
subrata_modak | 5ee3e89 | 2008-10-21 13:17:56 +0000 | [diff] [blame] | 505 | # use mktemp to create "safe" temporary directories |
| 506 | export TMPTEMPLATE="${TMPBASE}/ltp-XXXXXXXXXX" |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 507 | TMP=`mktemp -d $TMPTEMPLATE` || \ |
| 508 | { |
| 509 | echo "FATAL: Unable to make temporary directory: $TMP" |
| 510 | exit 1 |
| 511 | } |
| 512 | export TMP |
subrata_modak | 225cfbe | 2009-06-23 14:01:26 +0000 | [diff] [blame] | 513 | # To be invoked by tst_tmpdir() |
| 514 | # write to it as user nobody |
| 515 | export TMPDIR=$TMP |
subrata_modak | 6edfbda | 2008-10-17 12:25:48 +0000 | [diff] [blame] | 516 | |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 517 | chmod 777 $TMP || \ |
| 518 | { |
| 519 | echo "unable to chmod 777 $TMP ... aborting" |
Garrett Cooper | cf86b8b | 2010-11-16 21:46:41 -0800 | [diff] [blame] | 520 | exit 1 |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 521 | } |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 522 | |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 523 | cd $TMP || \ |
| 524 | { |
| 525 | echo "could not cd ${TMP} ... exiting" |
| 526 | exit 1 |
| 527 | } |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 528 | |
Garrett Cooper | cf86b8b | 2010-11-16 21:46:41 -0800 | [diff] [blame] | 529 | [ -n "$INSTANCES" ] && \ |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 530 | { |
Garrett Cooper | cf86b8b | 2010-11-16 21:46:41 -0800 | [diff] [blame] | 531 | INSTANCES="$INSTANCES -O ${TMP}" |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 532 | } |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 533 | |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 534 | [ "$RUN_NETEST" -eq 1 ] && \ |
| 535 | { |
| 536 | [ -z "$RHOST" ] || [ -z "$PASSWD" ] && \ |
| 537 | { |
| 538 | [ -z "$RHOST" ] && \ |
| 539 | { |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 540 | echo \ |
| 541 | "INFO: Enter RHOST = 'name of the remote host machine'" |
| 542 | echo -n "-> " |
| 543 | read RHOST |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 544 | } |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 545 | |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 546 | [ -z "$PASSWD" ] && \ |
| 547 | { |
| 548 | echo " " |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 549 | echo \ |
| 550 | "INFO: Enter PASSWD = 'root passwd of the remote host machine'" |
| 551 | echo -n "-> " |
| 552 | read PASSWD |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 553 | } |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 554 | export RHOST=$RHOST |
| 555 | export PASSWD=$PASSWD |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 556 | echo "WARNING: security of $RHOST may be compromised" |
| 557 | } |
| 558 | } |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 559 | |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 560 | # If user does not provide a command file select a default set of testcases |
| 561 | # to execute. |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 562 | if [ -z "$CMDFILES" ] && [ -z "$CMDFILEADDR" ] |
| 563 | then |
| 564 | cat <<-EOF >&1 |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 565 | |
Garrett Cooper | cf86b8b | 2010-11-16 21:46:41 -0800 | [diff] [blame] | 566 | INFO: no command files were provided. Will execute the following |
| 567 | runtest scenario files: |
Garrett Cooper | 66d67b5 | 2010-11-16 22:42:48 -0800 | [diff] [blame] | 568 | |
| 569 | `cat $LTPROOT/scenario_groups/default | tr '\012' ' '` |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 570 | |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 571 | EOF |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 572 | |
Garrett Cooper | 89fde87 | 2010-11-16 22:38:08 -0800 | [diff] [blame] | 573 | SCENARIO_LISTS="$LTPROOT/scenario_groups/default" |
Garrett Cooper | cf86b8b | 2010-11-16 21:46:41 -0800 | [diff] [blame] | 574 | if [ "$RUN_NETEST" -eq 1 ]; then |
Garrett Cooper | 89fde87 | 2010-11-16 22:38:08 -0800 | [diff] [blame] | 575 | SCENARIO_LISTS="$SCENARIO_LISTS $LTPROOT/scenario_groups/network" |
Garrett Cooper | cf86b8b | 2010-11-16 21:46:41 -0800 | [diff] [blame] | 576 | fi |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 577 | |
Garrett Cooper | cf86b8b | 2010-11-16 21:46:41 -0800 | [diff] [blame] | 578 | # DO NOT INDENT/DEDENT! |
| 579 | if [ -n "$SCENARIO_LISTS" ]; then |
| 580 | # Insurance to make sure that the first element in the pipe |
| 581 | # completed successfully. |
| 582 | cat_ok_sentinel=$TMP/cat_ok.$$ |
Garrett Cooper | 66d67b5 | 2010-11-16 22:42:48 -0800 | [diff] [blame] | 583 | (cat $SCENARIO_LISTS && touch "$cat_ok_sentinel") | \ |
Garrett Cooper | cf86b8b | 2010-11-16 21:46:41 -0800 | [diff] [blame] | 584 | while read scenfile; do |
| 585 | |
| 586 | scenfile=${LTPROOT}/runtest/$scenfile |
| 587 | |
| 588 | # Skip over non-existent scenario files; things are |
| 589 | # robust enough now that the build will fail if these |
| 590 | # files don't exist. |
| 591 | [ -f "$scenfile" ] || continue |
| 592 | |
| 593 | cat $scenfile >> "$TMP/alltests" || { |
| 594 | echo "FATAL: unable to append to command file" |
| 595 | rm -Rf "$TMP" |
| 596 | rm -f "$cat_ok_sentinel" |
| 597 | exit 1 |
| 598 | } |
| 599 | |
| 600 | done |
| 601 | |
| 602 | rm -f "$cat_ok_sentinel" |
| 603 | |
| 604 | fi |
| 605 | # ^^DO NOT INDENT/DEDENT!^^ |
| 606 | |
subrata_modak | bc833d3 | 2007-07-25 10:12:02 +0000 | [diff] [blame] | 607 | fi |
| 608 | |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 609 | [ -n "$CMDFILES" ] && \ |
| 610 | { |
Garrett Cooper | cf86b8b | 2010-11-16 21:46:41 -0800 | [diff] [blame] | 611 | for scenfile in `echo "$CMDFILES" | tr ',' ' '` |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 612 | do |
Garrett Cooper | cf86b8b | 2010-11-16 21:46:41 -0800 | [diff] [blame] | 613 | [ -f "$scenfile" ] || scenfile="$LTPROOT/runtest/$scenfile" |
| 614 | cat "$scenfile" >> ${TMP}/alltests || \ |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 615 | { |
| 616 | echo "FATAL: unable to create command file" |
Garrett Cooper | cf86b8b | 2010-11-16 21:46:41 -0800 | [diff] [blame] | 617 | rm -Rf "$TMP" |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 618 | exit 1 |
| 619 | } |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 620 | done |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 621 | } |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 622 | |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 623 | [ -n "$CMDFILEADDR" ] && \ |
| 624 | { |
| 625 | wget -q "${CMDFILEADDR}" -O ${TMP}/wgetcmdfile |
| 626 | if [ $? -ne 0 ]; then |
| 627 | echo "FATAL: error while getting the command file with wget (address $CMDFILEADDR)" |
| 628 | exit 1 |
yaberauneya | d8f1f5d | 2010-01-28 15:46:58 +0000 | [diff] [blame] | 629 | fi |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 630 | cat "${TMP}/wgetcmdfile" >> ${TMP}/alltests || \ |
| 631 | { |
| 632 | echo "FATAL: unable to create command file" |
| 633 | exit 1 |
| 634 | } |
| 635 | } |
yaberauneya | d8f1f5d | 2010-01-28 15:46:58 +0000 | [diff] [blame] | 636 | |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 637 | # The fsx-linux tests use the SCRATCHDEV environment variable as a location |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 638 | # that can be reformatted and run on. Set SCRATCHDEV if you want to run |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 639 | # these tests. As a safeguard, this is disabled. |
| 640 | unset SCRATCHDEV |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 641 | [ -n "$SCRATCHDEV" ] && \ |
| 642 | { |
| 643 | cat ${LTPROOT}/runtest/fsx >> ${TMP}/alltests || |
| 644 | { |
| 645 | echo "FATAL: unable to create fsx-linux tests command file" |
| 646 | exit 1 |
| 647 | } |
| 648 | } |
subrata_modak | bc833d3 | 2007-07-25 10:12:02 +0000 | [diff] [blame] | 649 | |
| 650 | # If enabled, execute only test cases that match the PATTERN |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 651 | if [ -n "$TAG_RESTRICT_STRING" ] |
| 652 | then |
| 653 | mv -f ${TMP}/alltests ${TMP}/alltests.orig |
| 654 | grep $TAG_RESTRICT_STRING ${TMP}/alltests.orig > ${TMP}/alltests #Not worth checking return codes for this case |
subrata_modak | bc833d3 | 2007-07-25 10:12:02 +0000 | [diff] [blame] | 655 | fi |
subrata_modak | 2f6c981 | 2009-08-14 17:07:48 +0000 | [diff] [blame] | 656 | |
| 657 | # Blacklist or skip tests if a SKIPFILE was specified with -S |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 658 | if [ -n "$SKIPFILE" ] |
| 659 | then |
subrata_modak | 2f6c981 | 2009-08-14 17:07:48 +0000 | [diff] [blame] | 660 | for file in $( cat $SKIPFILE ); do |
Andrew Chen | 410c695 | 2011-06-30 14:19:45 +0800 | [diff] [blame] | 661 | sed -i "/^$file[ \t]/d" ${TMP}/alltests |
subrata_modak | 2f6c981 | 2009-08-14 17:07:48 +0000 | [diff] [blame] | 662 | done |
| 663 | fi |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 664 | |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 665 | # check for required users and groups |
Cyril Hrubis | b88fa5b | 2013-06-25 15:50:08 +0200 | [diff] [blame] | 666 | ${LTPROOT}/IDcheck.sh || \ |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 667 | { |
| 668 | echo "WARNING: required users and groups not present" |
| 669 | echo "WARNING: some test cases may fail" |
| 670 | } |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 671 | |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 672 | # display versions of installed software |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 673 | [ -z "$QUIET_MODE" ] && \ |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 674 | { |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 675 | ${LTPROOT}/ver_linux || \ |
| 676 | { |
| 677 | echo "WARNING: unable to display versions of software installed" |
| 678 | exit 1 |
| 679 | } |
| 680 | } |
| 681 | |
| 682 | if [ -n "$DEVICE" ]; then |
| 683 | sed -i "s|DEVICE|$DEVICE|" ${TMP}/alltests |
Ramesh YR | 0a78f23 | 2013-04-16 09:31:28 +0800 | [diff] [blame] | 684 | RC=$? |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 685 | else |
Ramesh YR | 0a78f23 | 2013-04-16 09:31:28 +0800 | [diff] [blame] | 686 | create_block |
| 687 | if [ $? -eq 0 ]; then |
| 688 | sed -i "s|DEVICE|$DEVICE|" ${TMP}/alltests |
| 689 | RC=$? |
| 690 | else |
| 691 | echo "no block device was specified on commandline." |
| 692 | echo "Block device could not be created using loopback device" |
| 693 | echo "Tests which require block device are disabled." |
| 694 | echo "You can specify it with option -b" |
| 695 | sed -i "/DEVICE/d" ${TMP}/alltests |
| 696 | RC=$? |
| 697 | fi |
subrata_modak | d9fb386 | 2008-12-29 11:25:36 +0000 | [diff] [blame] | 698 | fi |
| 699 | |
Ramesh YR | 0a78f23 | 2013-04-16 09:31:28 +0800 | [diff] [blame] | 700 | if [ $RC -ne 0 ]; then |
| 701 | echo "FATAL: error during processing alltests file by sed" |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 702 | exit 1 |
| 703 | fi |
| 704 | |
| 705 | if [ -n "$DEVICE" ]; then |
Simon Xu | 47d716b | 2012-08-02 23:42:11 +0800 | [diff] [blame] | 706 | mnt_pnt=`mktemp -d "${TMP}/mnt_pnt.XXXXXX"` |
subrata_modak | d9fb386 | 2008-12-29 11:25:36 +0000 | [diff] [blame] | 707 | if [ -n "$DEVICE_FS_TYPE" ]; then |
| 708 | mount -t $DEVICE_FS_TYPE $DEVICE $mnt_pnt |
| 709 | else |
| 710 | mount $DEVICE $mnt_pnt |
| 711 | fi |
| 712 | |
| 713 | if [ $? -ne 0 ]; then |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 714 | echo "FATAL: can't mount block device $DEVICE." |
| 715 | exit 1 |
subrata_modak | d9fb386 | 2008-12-29 11:25:36 +0000 | [diff] [blame] | 716 | fi |
| 717 | |
| 718 | if [ -z "$DEVICE_FS_TYPE" ]; then |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 719 | DEVICE_FS_TYPE=`cat /proc/mounts | awk "{if (\\\$1 == \"$DEVICE\") print \\\$3; }"` |
| 720 | echo "determine file system $DEVICE_FS_TYPE on block device $DEVICE" |
subrata_modak | d9fb386 | 2008-12-29 11:25:36 +0000 | [diff] [blame] | 721 | fi |
| 722 | |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 723 | umount $DEVICE |
| 724 | if [ $? -ne 0 ]; then |
| 725 | echo "FATAL: can't umount $DEVICE" |
| 726 | exit 1 |
subrata_modak | d9fb386 | 2008-12-29 11:25:36 +0000 | [diff] [blame] | 727 | fi |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 728 | rm -rf $mnt_pnt |
subrata_modak | d9fb386 | 2008-12-29 11:25:36 +0000 | [diff] [blame] | 729 | fi |
| 730 | |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 731 | if [ -n "$DEVICE" ]; then |
Wanlong Gao | 0b6c356 | 2012-06-22 10:35:35 +0800 | [diff] [blame] | 732 | sed -i "s|DEVICE_FS_TYPE|$DEVICE_FS_TYPE|" ${TMP}/alltests |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 733 | fi |
| 734 | |
| 735 | if [ $? -ne 0 ]; then |
Garrett Cooper | cf86b8b | 2010-11-16 21:46:41 -0800 | [diff] [blame] | 736 | echo "FATAL: error during processing alltests file by sed" |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 737 | exit 1 |
subrata_modak | d9fb386 | 2008-12-29 11:25:36 +0000 | [diff] [blame] | 738 | fi |
| 739 | |
subrata_modak | 8c13833 | 2008-01-28 11:19:32 +0000 | [diff] [blame] | 740 | if [ $RUN_REPEATED -gt 1 ]; then # You need to specify at least more than 1 sequential run, else it runs default |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 741 | echo "PAN will run these test cases $RUN_REPEATED times....." |
| 742 | echo "Test Tags will be Prepended with ITERATION NO.s....." |
| 743 | inc=1 |
| 744 | sed -e '/^$/ d' -e 's/^[ ,\t]*//' -e '/^#/ d' < ${TMP}/alltests > ${TMP}/alltests.temp ##This removes all newlines, leading spaces, tabs, # |
| 745 | sed 's/^[0-9,a-z,A-Z]*/'"$inc"'_ITERATION_&/' < ${TMP}/alltests.temp > ${TMP}/alltests ## .temp is kept as Base file |
| 746 | while [ $inc -lt $RUN_REPEATED ] ; do |
| 747 | inc=`expr $inc + 1` |
| 748 | sed 's/^[0-9,a-z,A-Z]*/'"$inc"'_ITERATION_&/' < ${TMP}/alltests.temp >> ${TMP}/alltests #Keep appending with Iteration No.s |
| 749 | done |
subrata_modak | 8c13833 | 2008-01-28 11:19:32 +0000 | [diff] [blame] | 750 | fi |
| 751 | |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 752 | [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test start time: $(date)" ; } |
| 753 | PAN_COMMAND="${LTPROOT}/bin/ltp-pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ \ |
| 754 | -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE $FAILCMDFILE" |
| 755 | echo "COMMAND: $PAN_COMMAND" |
| 756 | if [ ! -z "$TAG_RESTRICT_STRING" ] ; then |
| 757 | echo "INFO: Restricted to $TAG_RESTRICT_STRING" |
robbiew | 7d43d77 | 2005-02-07 20:07:30 +0000 | [diff] [blame] | 758 | fi |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 759 | #$PAN_COMMAND #Duplicated code here, because otherwise if we fail, only "PAN_COMMAND" gets output |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 760 | |
subrata_modak | 4393821 | 2008-05-19 08:48:46 +0000 | [diff] [blame] | 761 | ## Display the Output/Log/Failed/HTML file names here |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 762 | echo -e "LOG File: \c" |
| 763 | echo $LOGFILE | cut -b4- |
subrata_modak | 4393821 | 2008-05-19 08:48:46 +0000 | [diff] [blame] | 764 | |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 765 | if [ "$OUTPUTFILE" ]; then |
| 766 | echo -e "OUTPUT File: \c" |
| 767 | echo $OUTPUTFILE | cut -b4- |
subrata_modak | 4393821 | 2008-05-19 08:48:46 +0000 | [diff] [blame] | 768 | fi |
| 769 | |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 770 | echo -e "FAILED COMMAND File: \c" |
| 771 | echo $FAILCMDFILE | cut -b4- |
| 772 | |
| 773 | if [ "$HTMLFILE" ]; then |
| 774 | echo "HTML File: $HTMLFILE" |
| 775 | fi |
| 776 | |
| 777 | echo "Running tests......." |
subrata_modak | e47fb35 | 2007-11-25 17:03:49 +0000 | [diff] [blame] | 778 | test_start_time=$(date) |
subrata_modak | 724098e | 2009-03-19 08:49:18 +0000 | [diff] [blame] | 779 | |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 780 | # User wants testing with Kernel Fault Injection |
| 781 | if [ $INJECT_KERNEL_FAULT ] ; then |
| 782 | #See if Debugfs is mounted, and |
| 783 | #Fault Injection Framework available through Debugfs |
Garrett Cooper | cb66da5 | 2012-04-03 22:09:42 -0700 | [diff] [blame] | 784 | use_faultinjection=true |
| 785 | for debug_subdir in \ |
| 786 | fail_io_timeout \ |
| 787 | fail_make_request \ |
| 788 | fail_page_alloc \ |
| 789 | failslab \ |
| 790 | ; do |
| 791 | if [ -d "/sys/kernel/debug/$debug_subdir" ] |
| 792 | then |
| 793 | use_faultinjection=true |
| 794 | break |
| 795 | fi |
| 796 | done |
| 797 | if $use_faultinjection; then |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 798 | #If atleast one of the Framework is available |
| 799 | #Go ahead to Inject Fault & Create required |
| 800 | #Command Files for LTP run |
| 801 | echo Running tests with Fault Injection Enabled in the Kernel... |
Garrett Cooper | cb66da5 | 2012-04-03 22:09:42 -0700 | [diff] [blame] | 802 | awk -v LOOPS=$INJECT_FAULT_LOOPS_PER_TEST \ |
| 803 | -v PERCENTAGE=$INJECT_KERNEL_FAULT_PERCENTAGE \ |
| 804 | -f ${LTPROOT}/bin/create_kernel_faults_in_loops_and_probability.awk \ |
| 805 | ${TMP}/alltests > ${TMP}/alltests.tmp |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 806 | cp ${TMP}/alltests.tmp ${TMP}/alltests |
| 807 | rm -rf ${TMP}/alltests.tmp |
| 808 | else |
| 809 | echo Fault Injection not enabled in the Kernel.. |
| 810 | echo Running tests normally... |
| 811 | fi |
| 812 | fi |
| 813 | |
| 814 | ## Valgrind Check will work only when Kernel Fault Injection is not expected, |
| 815 | ## We do not want to test Faults when valgrind is running |
| 816 | if [ $VALGRIND_CHECK ]; then |
| 817 | if [ ! $INJECT_KERNEL_FAULT ]; then |
| 818 | which valgrind || VALGRIND_CHECK_TYPE=XYZ |
| 819 | case $VALGRIND_CHECK_TYPE in |
Garrett Cooper | 3920fd1 | 2012-04-03 19:47:16 -0700 | [diff] [blame] | 820 | [1-3]) |
| 821 | awk -v CHECK_LEVEL=$VALGRIND_CHECK_TYPE \ |
| 822 | -f ${LTPROOT}/bin/create_valgrind_check.awk \ |
| 823 | ${TMP}/alltests $VALGRIND_CHECK_TYPE > \ |
| 824 | ${TMP}/alltests.tmp |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 825 | cp ${TMP}/alltests.tmp ${TMP}/alltests |
Garrett Cooper | 3920fd1 | 2012-04-03 19:47:16 -0700 | [diff] [blame] | 826 | rm -rf ${TMP}/alltests.tmp |
| 827 | ;; |
| 828 | *) |
| 829 | echo "Invalid Memory Check Type, or, Valgrind is not available" |
| 830 | ;; |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 831 | esac |
| 832 | fi |
| 833 | fi |
| 834 | |
Subrata Modak | bd9d440 | 2010-05-12 22:03:21 +0530 | [diff] [blame] | 835 | if [ $ALT_DMESG_OUT -eq 1 ] ; then |
| 836 | #We want to print dmesg output for each test,lets do the trick inside the script |
| 837 | echo Enabling dmesg output logging for each test... |
Garrett Cooper | 6603012 | 2012-04-03 20:22:14 -0700 | [diff] [blame] | 838 | awk -v DMESG_DIR=$DMESG_DIR \ |
| 839 | -f ${LTPROOT}/bin/create_dmesg_entries_for_each_test.awk \ |
| 840 | ${TMP}/alltests > ${TMP}/alltests.tmp |
Subrata Modak | bd9d440 | 2010-05-12 22:03:21 +0530 | [diff] [blame] | 841 | cp ${TMP}/alltests.tmp ${TMP}/alltests |
| 842 | rm -rf ${TMP}/alltests.tmp |
| 843 | fi |
subrata_modak | 724098e | 2009-03-19 08:49:18 +0000 | [diff] [blame] | 844 | # Some tests need to run inside the "bin" directory. |
| 845 | cd "${LTPROOT}/testcases/bin" |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 846 | "${LTPROOT}/bin/ltp-pan" $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE $FAILCMDFILE |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 847 | |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 848 | if [ $? -eq 0 ]; then |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 849 | echo "INFO: ltp-pan reported all tests PASS" |
| 850 | VALUE=0 |
| 851 | export LTP_EXIT_VALUE=0; |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 852 | else |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 853 | echo "INFO: ltp-pan reported some tests FAIL" |
| 854 | VALUE=1 |
| 855 | export LTP_EXIT_VALUE=1; |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 856 | fi |
subrata_modak | 724098e | 2009-03-19 08:49:18 +0000 | [diff] [blame] | 857 | cd .. |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 858 | echo "LTP Version: $version_date" |
mreed10 | 9169642 | 2006-05-03 19:07:22 +0000 | [diff] [blame] | 859 | |
Subrata Modak | e3bc375 | 2010-07-03 23:32:27 +0530 | [diff] [blame] | 860 | # $DMESG_DIR is used to cache messages obtained from dmesg after a test run. |
| 861 | # Proactively reap all of the 0-byte files in $DMESG_DIR as they have zero value |
| 862 | # and only clutter up the filesystem. |
| 863 | |
| 864 | if [ $ALT_DMESG_OUT -eq 1 ] ; then |
| 865 | if ! find "$DMESG_DIR" -size 0 -exec rm {} + ; then |
| 866 | echo "cd to $DMESG_DIR failed: $?" |
| 867 | fi |
| 868 | if [ -n "$(ls "$DMESG_DIR")" ] ; then |
| 869 | echo "Kernel messages were generated for LTP tests $version_date" |
| 870 | else |
| 871 | echo "No Kernel messages were generated for LTP tests $version_date" |
| 872 | fi |
| 873 | fi |
| 874 | |
subrata_modak | e47fb35 | 2007-11-25 17:03:49 +0000 | [diff] [blame] | 875 | if [ "$ALT_HTML_OUT" -eq 1 ] ; then #User wants the HTML output to be created, it then needs to be generated |
| 876 | export LTP_VERSION=$version_date |
| 877 | export TEST_START_TIME=$test_start_time |
| 878 | export TEST_END_TIME=$(date) |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 879 | OUTPUT_DIRECTORY=`echo $OUTPUTFILE | cut -c4-` |
subrata_modak | e47fb35 | 2007-11-25 17:03:49 +0000 | [diff] [blame] | 880 | LOGS_DIRECTORY="$LTPROOT/results" |
| 881 | export TEST_OUTPUT_DIRECTORY="$LTPROOT/output" |
| 882 | export TEST_LOGS_DIRECTORY=$LOGS_DIRECTORY |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 883 | echo "Generating HTML Output.....!!" |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 884 | ( perl $LTPROOT/bin/genhtml.pl $LTPROOT/bin/html_report_header.txt test_start test_end test_output execution_status $OUTPUT_DIRECTORY > $HTMLFILE; ) |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 885 | echo "Generated HTML Output.....!!" |
| 886 | echo "Location: $HTMLFILE"; |
| 887 | |
subrata_modak | e47fb35 | 2007-11-25 17:03:49 +0000 | [diff] [blame] | 888 | fi |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 889 | |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 890 | if [ "$ALT_EMAIL_OUT" -eq 1 ] ; then ## User wants reports to be e-mailed |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 891 | if [ [ ! "$HTMLFILE_NAME" ] -o [ ! "$OUTPUTFILE_NAME" ] -o [ ! "$LOGFILE_NAME" ] ] ; then |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 892 | ##User does not have output/logs/html-output, nothing to be mailed in this situation |
| 893 | echo "Nothing to be mailed here...." |
subrata_modak | 08dde6f | 2007-11-28 11:02:51 +0000 | [diff] [blame] | 894 | else |
subrata_modak | 4393821 | 2008-05-19 08:48:46 +0000 | [diff] [blame] | 895 | TAR_FILE_NAME=LTP_RUN_$version_date$DEFAULT_FILE_NAME_GENERATION_TIME.tar |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 896 | if [ "$HTMLFILE_NAME" ] ; then ## HTML file Exists |
| 897 | if [ "$ALT_HTML_OUT" -ne 1 ] ; then ## The HTML file path is absolute and not $LTPROOT/output |
| 898 | mkdir -p $LTPROOT/output ## We need to create this Directory |
| 899 | cp $HTMLFILE_NAME $LTPROOT/output/ |
| 900 | fi |
subrata_modak | 08dde6f | 2007-11-28 11:02:51 +0000 | [diff] [blame] | 901 | fi |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 902 | if [ "$OUTPUTFILE_NAME" ] ; then ## Output file exists |
| 903 | if [ "$ALT_DIR_OUT" -ne 1 ] ; then ## The Output file path is absolute and not $LTPROOT/output |
| 904 | mkdir -p $LTPROOT/output ## We need to create this Directory |
| 905 | cp $OUTPUTFILE_NAME $LTPROOT/output/ |
| 906 | fi |
subrata_modak | 08dde6f | 2007-11-28 11:02:51 +0000 | [diff] [blame] | 907 | fi |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 908 | if [ "$LOGFILE_NAME" ] ; then ## Log file exists |
| 909 | if [ "$ALT_DIR_RES" -ne 1 ] ; then ## The Log file path is absolute and not $LTPROOT/results |
| 910 | mkdir -p $LTPROOT/results ## We need to create this Directory |
| 911 | cp $LOGFILE_NAME $LTPROOT/results/ |
| 912 | fi |
| 913 | fi |
| 914 | if [ -d $LTPROOT/output ] ; then |
| 915 | tar -cf ./$TAR_FILE_NAME $LTPROOT/output |
| 916 | if [ $? -eq 0 ]; then |
| 917 | echo "Created TAR File: ./$TAR_FILE_NAME successfully, added $LTPROOT/output" |
| 918 | else |
| 919 | echo "Cannot Create TAR File: ./$TAR_FILE_NAME for adding $LTPROOT/output" |
| 920 | fi |
| 921 | fi |
| 922 | if [ -d $LTPROOT/results ] ; then |
| 923 | tar -uf ./$TAR_FILE_NAME $LTPROOT/results |
| 924 | if [ $? -eq 0 ]; then |
| 925 | echo "Updated TAR File: ./$TAR_FILE_NAME successfully, added $LTPROOT/results" |
| 926 | else |
| 927 | echo "Cannot Update TAR File: ./$TAR_FILE_NAME for adding $LTPROOT/results" |
| 928 | fi |
| 929 | fi |
| 930 | if [ -e $LTPROOT/nohup.out ] ; then ## If User would have Chosen nohup to do ltprun |
| 931 | tar -uf ./$TAR_FILE_NAME $LTPROOT/nohup.out |
| 932 | if [ $? -eq 0 ]; then |
| 933 | echo "Updated TAR File: ./$TAR_FILE_NAME successfully, added $LTPROOT/nohup.out" |
| 934 | else |
| 935 | echo "Cannot Update TAR File: ./$TAR_FILE_NAME for adding $LTPROOT/nohup.out" |
| 936 | fi |
| 937 | fi |
| 938 | gzip ./$TAR_FILE_NAME ## gzip this guy |
| 939 | if [ $? -eq 0 ]; then |
| 940 | echo "Gunzipped TAR File: ./$TAR_FILE_NAME" |
subrata_modak | 08dde6f | 2007-11-28 11:02:51 +0000 | [diff] [blame] | 941 | else |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 942 | echo "Cannot Gunzip TAR File: ./$TAR_FILE_NAME" |
subrata_modak | 08dde6f | 2007-11-28 11:02:51 +0000 | [diff] [blame] | 943 | fi |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 944 | if [ -e /usr/bin/mutt ] ; then ## This is a better mail client than others |
| 945 | echo "Starting mailing reports to: $EMAIL_TO, file: ./$TAR_FILE_NAME.gz" |
| 946 | mutt -a ./$TAR_FILE_NAME.gz -s "LTP Reports on $test_start_time" $EMAIL_TO < /dev/null |
| 947 | if [ $? -eq 0 ]; then |
| 948 | echo "Reports Successfully mailed to: $EMAIL_TO" |
| 949 | else |
| 950 | echo "Reports cannot be mailed to: $EMAIL_TO" |
| 951 | fi |
| 952 | else ## Use our Ageold mail program |
| 953 | echo "Starting mailing reports to: $EMAIL_TO, file: ./$TAR_FILE_NAME.gz" |
| 954 | uuencode ./$TAR_FILE_NAME.gz $TAR_FILE_NAME.gz | mail $EMAIL_TO -s "LTP Reports on $test_start_time" |
| 955 | if [ $? -eq 0 ]; then |
| 956 | echo "Reports Successfully mailed to: $EMAIL_TO" |
| 957 | else |
| 958 | echo "Reports cannot be mailed to: $EMAIL_TO" |
| 959 | fi |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 960 | fi |
subrata_modak | 08dde6f | 2007-11-28 11:02:51 +0000 | [diff] [blame] | 961 | fi |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 962 | fi |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 963 | |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 964 | [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test end time: $(date)" ; } |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 965 | |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 966 | [ "$GENLOAD" -eq 1 ] && { killall -9 genload >/dev/null 2>&1; } |
| 967 | [ "$NETPIPE" -eq 1 ] && { killall -9 NPtcp >/dev/null 2>&1; } |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 968 | |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 969 | [ "$ALT_DIR_OUT" -eq 1 ] || [ "$ALT_DIR_RES" -eq 1 ] && \ |
| 970 | { |
| 971 | cat <<-EOF >&1 |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 972 | |
Markos Chandras | 1132866 | 2012-03-06 10:28:59 +0000 | [diff] [blame] | 973 | ############################################################### |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 974 | |
Markos Chandras | 1132866 | 2012-03-06 10:28:59 +0000 | [diff] [blame] | 975 | Done executing testcases. |
mreed10 | 9169642 | 2006-05-03 19:07:22 +0000 | [diff] [blame] | 976 | LTP Version: $version_date |
Markos Chandras | 1132866 | 2012-03-06 10:28:59 +0000 | [diff] [blame] | 977 | ############################################################### |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 978 | |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 979 | EOF |
| 980 | } |
| 981 | exit $VALUE |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 982 | } |
| 983 | |
Ramesh YR | 0a78f23 | 2013-04-16 09:31:28 +0800 | [diff] [blame] | 984 | create_block() |
| 985 | { |
| 986 | #create a block device with ext4 filesystem. |
Cyril Hrubis | b88fa5b | 2013-06-25 15:50:08 +0200 | [diff] [blame] | 987 | dd if=/dev/zero of=${TMP}/test.img bs=1kB count=10240 |
Ramesh YR | 0a78f23 | 2013-04-16 09:31:28 +0800 | [diff] [blame] | 988 | if [ $? -ne 0 ]; then |
| 989 | echo "Failed to create loopback device image, please check disk space and re-run" |
| 990 | return 1 |
| 991 | else |
| 992 | ##search for an unused loop dev |
| 993 | LOOP_DEV=$(losetup -f) |
| 994 | if [ $? -ne 0 ]; then |
| 995 | echo "no unused loop device is found" |
| 996 | return 1 |
| 997 | else |
| 998 | ##attach the created file to loop dev. |
Cyril Hrubis | b88fa5b | 2013-06-25 15:50:08 +0200 | [diff] [blame] | 999 | losetup $LOOP_DEV ${TMP}/test.img |
Ramesh YR | 0a78f23 | 2013-04-16 09:31:28 +0800 | [diff] [blame] | 1000 | if [ $? -ne 0 ]; then |
| 1001 | echo "losetup failed to create block device" |
| 1002 | return 1 |
| 1003 | else |
Cyril Hrubis | b88fa5b | 2013-06-25 15:50:08 +0200 | [diff] [blame] | 1004 | mkfs.ext4 $LOOP_DEV |
Ramesh YR | 0a78f23 | 2013-04-16 09:31:28 +0800 | [diff] [blame] | 1005 | [ $? -ne 0 ] && (echo "creating a ext4 block device failed" && return 1) |
| 1006 | #set the values in alltests which require block device. |
| 1007 | DEVICE=$LOOP_DEV |
| 1008 | DEVICE_FS_TYPE="ext4" |
| 1009 | return 0 |
| 1010 | fi |
| 1011 | fi |
| 1012 | fi |
| 1013 | } |
| 1014 | |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 1015 | cleanup() |
| 1016 | { |
Ramesh YR | 0a78f23 | 2013-04-16 09:31:28 +0800 | [diff] [blame] | 1017 | [ "$LOOP_DEV" ] && losetup -d $LOOP_DEV |
| 1018 | [ -e "${TEMP}/test.img" ] && rm -f ${TEMP}/test.img |
yaberauneya | 6d41cc3 | 2010-01-28 16:24:16 +0000 | [diff] [blame] | 1019 | rm -rf ${TMP} |
plars | 4a120e8 | 2004-09-02 18:56:06 +0000 | [diff] [blame] | 1020 | } |
| 1021 | |
| 1022 | trap "cleanup" 0 |
| 1023 | setup |
| 1024 | main "$@" |
Garrett Cooper | cf86b8b | 2010-11-16 21:46:41 -0800 | [diff] [blame] | 1025 | |
| 1026 | #vim: syntax=sh |