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