blob: 263c106d8304ac21aff71fa00f57a29c5889c35b [file] [log] [blame]
plars4a120e82004-09-02 18:56:06 +00001#!/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 Gao4548c6c2012-10-19 18:03:36 +080018## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ##
plars4a120e82004-09-02 18:56:06 +000019## ##
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 Dearman37550cf2012-10-17 19:54:01 -070027#
plars4a120e82004-09-02 18:56:06 +000028# History: Oct 07 2003 - Modified - Manoj Iyer
29# - use functions
30# - clean up on script exit
31# - error checking etc.
Chris Dearman37550cf2012-10-17 19:54:01 -070032#
plars4a120e82004-09-02 18:56:06 +000033# Oct 08 2003 - Modified - Manoj Iyer
34# - fixed bug in creating results directory
subrata_modaka1fd64b2007-04-11 11:24:49 +000035# - all checks should be enlclosed in " " to avoid bash error
subrata_modak14390fd2009-05-19 09:39:11 +000036# - exit with error if ltp-pan is not found in pan directory
subrata_modakbc833d32007-07-25 10:12:02 +000037#
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_modak6838ec32007-09-14 10:10:12 +000047#
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_modak5d7deea2007-09-15 13:51:36 +000053# Sep 14 2007 - Modified - Ricardo Salveti de Araujo
54# - cleaning and removing duplicated code
55#
subrata_modake099b2a2007-10-29 12:22:01 +000056# Oct 27 2007 - Modified - Ricardo Salveti de Araujo and Subrata Modak
yaberauneya6d41cc32010-01-28 16:24:16 +000057# - better ways to integrate "ltp/tools/genload/stress" with "ltp/runltp"
subrata_modake47fb352007-11-25 17:03:49 +000058# 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_modakf376b482007-11-28 11:30:54 +000061# Nov 28 2007 - Modified - Subrata Modak
62# - Added a new option to mail back LTP reports
subrata_modak43938212008-05-19 08:48:46 +000063# May 19 2008 - Modified - Subrata Modak
64# - Added capability for default Log file generation
yaberauneya6d41cc32010-01-28 16:24:16 +000065# Aug 17 2009 - Modified - Subrata Modak
66# - Added Fault Injection generation Capability through -F Option
subrata_modake099b2a2007-10-29 12:22:01 +000067#
subrata_modak6838ec32007-09-14 10:10:12 +000068#################################################################################
subrata_modakbc833d32007-07-25 10:12:02 +000069
plars4a120e82004-09-02 18:56:06 +000070
71
72setup()
73{
yaberauneya6d41cc32010-01-28 16:24:16 +000074 cd `dirname $0` || \
75 {
76 echo "FATAL: unable to change directory to $(dirname $0)"
77 exit 1
78 }
79 export LTPROOT=${PWD}
plars4a120e82004-09-02 18:56:06 +000080 export TMPBASE="/tmp"
yaberauneya6d41cc32010-01-28 16:24:16 +000081 export PATH="${PATH}:${LTPROOT}/testcases/bin"
plars4a120e82004-09-02 18:56:06 +000082
Xiaoguang Wang5b42a1e2013-12-12 19:10:58 +080083 export LTP_DEV=""
Xiaoguang Wang5b42a1e2013-12-12 19:10:58 +080084 export LTP_DEV_FS_TYPE="ext2"
Xiaoguang Wang5b42a1e2013-12-12 19:10:58 +080085
yaberauneya6d41cc32010-01-28 16:24:16 +000086 [ -d "$LTPROOT/testcases/bin" ] ||
87 {
Garrett Coopercf86b8b2010-11-16 21:46:41 -080088 echo "FATAL: LTP not installed correctly"
89 echo "INFO: Follow directions in INSTALL!"
yaberauneya6d41cc32010-01-28 16:24:16 +000090 exit 1
91 }
92
93 [ -e "$LTPROOT/bin/ltp-pan" ] ||
94 {
95 echo "FATAL: Test suite driver 'ltp-pan' not found"
Garrett Coopercf86b8b2010-11-16 21:46:41 -080096 echo "INFO: Follow directions in INSTALL!"
yaberauneya6d41cc32010-01-28 16:24:16 +000097 exit 1
98 }
plars4a120e82004-09-02 18:56:06 +000099}
100
mreed1091696422006-05-03 19:07:22 +0000101version_of_ltp()
102{
yaberauneyaef772532009-10-09 17:55:43 +0000103 cat "$LTPROOT/Version"
yaberauneya6d41cc32010-01-28 16:24:16 +0000104 exit 0
mreed1091696422006-05-03 19:07:22 +0000105}
plars4a120e82004-09-02 18:56:06 +0000106
Chris Dearman37550cf2012-10-17 19:54:01 -0700107usage()
plars4a120e82004-09-02 18:56:06 +0000108{
yaberauneya6d41cc32010-01-28 16:24:16 +0000109 cat <<-EOF >&2
plars4a120e82004-09-02 18:56:06 +0000110
Xiaoguang Wang5f71cf92014-09-23 15:59:43 +0800111 usage: ${0##*/} [ -a EMAIL_TO ] [ -c NUM_PROCS ] [ -C FAILCMDFILE ] [ -T TCONFCMDFILE ]
112 [ -d TMPDIR ] [ -D NUM_PROCS,NUM_FILES,NUM_BYTES,CLEAN_FLAG ] -e [ -f CMDFILES(,...) ]
113 [ -g HTMLFILE] [ -i NUM_PROCS ] [ -l LOGFILE ] [ -m NUM_PROCS,CHUNKS,BYTES,HANGUP_FLAG ]
subrata_modake099b2a2007-10-29 12:22:01 +0000114 -N -n [ -o OUTPUTFILE ] -p -q [ -r LTPROOT ] [ -s PATTERN ] [ -t DURATION ]
Xiaoguang Wang5b42a1e2013-12-12 19:10:58 +0800115 -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 Dearman37550cf2012-10-17 19:54:01 -0700117
subrata_modak08dde6f2007-11-28 11:02:51 +0000118 -a EMAIL_TO EMAIL all your Reports to this E-mail Address
subrata_modake099b2a2007-10-29 12:22:01 +0000119 -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_modakbc833d32007-07-25 10:12:02 +0000122 -C FAILCMDFILE Command file with all failed test cases.
Xiaoguang Wang5f71cf92014-09-23 15:59:43 +0800123 -T TCONFCMDFILE Command file with all test cases that are not fully tested.
plars4a120e82004-09-02 18:56:06 +0000124 -d TMPDIR Directory where temporary files will be created.
subrata_modake099b2a2007-10-29 12:22:01 +0000125 -D NUM_PROCS,NUM_FILES,NUM_BYTES,CLEAN_FLAG
126 Run LTP under additional background Load on Secondary Storage (Seperate by comma)
127 [NUM_PROCS = no. of processes creating Storage Load by spinning over write()]
128 [NUM_FILES = Write() to these many files (Defaults to 1 when value 0 or undefined)]
129 [NUM_BYTES = write these many bytes (defaults to 1GB, when value 0 or undefined)]
130 [CLEAN_FLAG = unlink file to which random data written, when value 1]
mreed1091696422006-05-03 19:07:22 +0000131 -e Prints the date of the current LTP release
subrata_modakbc833d32007-07-25 10:12:02 +0000132 -f CMDFILES Execute user defined list of testcases (separate with ',')
yaberauneya6d41cc32010-01-28 16:24:16 +0000133 -F LOOPS,PERCENTAGE Induce PERCENTAGE Fault in the Kernel Subsystems, and, run each test for LOOPS loop
subrata_modake47fb352007-11-25 17:03:49 +0000134 -g HTMLFILE Create an additional HTML output format
plars4a120e82004-09-02 18:56:06 +0000135 -h Help. Prints all available options.
subrata_modake099b2a2007-10-29 12:22:01 +0000136 -i NUM_PROCS Run LTP under additional background Load on IO Bus
137 [NUM_PROCS = no. of processes creating IO Bus Load by spinning over sync()]
Subrata Modakbd9d4402010-05-12 22:03:21 +0530138 -K DMESG_LOG_DIR
Chris Dearman37550cf2012-10-17 19:54:01 -0700139 Log Kernel messages generated for each test cases inside this directory
plars4a120e82004-09-02 18:56:06 +0000140 -l LOGFILE Log results of test in a logfile.
subrata_modake099b2a2007-10-29 12:22:01 +0000141 -m NUM_PROCS,CHUNKS,BYTES,HANGUP_FLAG
142 Run LTP under additional background Load on Main memory (Seperate by comma)
143 [NUM_PROCS = no. of processes creating main Memory Load by spinning over malloc()]
144 [CHUNKS = malloc these many chunks (default is 1 when value 0 or undefined)]
145 [BYTES = malloc CHUNKS of BYTES bytes (default is 256MB when value 0 or undefined) ]
146 [HANGUP_FLAG = hang in a sleep loop after memory allocated, when value 1]
yaberauneya6d41cc32010-01-28 16:24:16 +0000147 -M CHECK_TYPE
148 [CHECK_TYPE=1 => Full Memory Leak Check tracing children as well]
149 [CHECK_TYPE=2 => Thread Concurrency Check tracing children as well]
150 [CHECK_TYPE=3 => Full Memory Leak & Thread Concurrency Check tracing children as well]
Chris Dearman37550cf2012-10-17 19:54:01 -0700151 -N Run all the networking tests.
plars4a120e82004-09-02 18:56:06 +0000152 -n Run LTP with network traffic in background.
153 -o OUTPUTFILE Redirect test output to a file.
Chris Dearman37550cf2012-10-17 19:54:01 -0700154 -p Human readable format logfiles.
plars4a120e82004-09-02 18:56:06 +0000155 -q Print less verbose output to screen.
156 -r LTPROOT Fully qualified path where testsuite is installed.
subrata_modaka1fd64b2007-04-11 11:24:49 +0000157 -s PATTERN Only run test cases which match PATTERN.
subrata_modak2f6c9812009-08-14 17:07:48 +0000158 -S SKIPFILE Skip tests specified in SKIPFILE
plars4a120e82004-09-02 18:56:06 +0000159 -t DURATION Execute the testsuite for given duration. Examples:
160 -t 60s = 60 seconds
161 -t 45m = 45 minutes
162 -t 24h = 24 hours
163 -t 2d = 2 days
subrata_modak8c138332008-01-28 11:19:32 +0000164 -T REPETITION Execute the testsuite for REPETITION no. of times
subrata_modakbc833d32007-07-25 10:12:02 +0000165 -w CMDFILEADDR Uses wget to get the user's list of testcases.
plars4a120e82004-09-02 18:56:06 +0000166 -x INSTANCES Run multiple instances of this testsuite.
subrata_modakd9fb3862008-12-29 11:25:36 +0000167 -b DEVICE Some tests require an unmounted block device
168 to run correctly.
Xiaoguang Wang5b42a1e2013-12-12 19:10:58 +0800169 -B LTP_DEV_FS_TYPE The file system of test block devices.
170 -z BIG_DEVICE Some tests require a big unmounted block device
171 to run correctly.
172 -Z LTP_BIG_DEV_FS_TYPE The file system of the big device
173
subrata_modakd9fb3862008-12-29 11:25:36 +0000174
plars4a120e82004-09-02 18:56:06 +0000175
Garrett Cooperf95875a2010-03-05 02:44:39 -0800176 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}
plars4a120e82004-09-02 18:56:06 +0000177
plars4a120e82004-09-02 18:56:06 +0000178
yaberauneya6d41cc32010-01-28 16:24:16 +0000179 EOF
180exit 0
plars4a120e82004-09-02 18:56:06 +0000181}
182
plars4a120e82004-09-02 18:56:06 +0000183main()
184{
subrata_modakbc833d32007-07-25 10:12:02 +0000185 local CMDFILES=""
plars4a120e82004-09-02 18:56:06 +0000186 local PRETTY_PRT=""
subrata_modak5d7deea2007-09-15 13:51:36 +0000187 local ALT_DIR_OUT=0
188 local ALT_DIR_RES=0
subrata_modake47fb352007-11-25 17:03:49 +0000189 local ALT_HTML_OUT=0
subrata_modak08dde6f2007-11-28 11:02:51 +0000190 local ALT_EMAIL_OUT=0
Subrata Modakbd9d4402010-05-12 22:03:21 +0530191 local ALT_DMESG_OUT=0
plars4a120e82004-09-02 18:56:06 +0000192 local RUN_NETEST=0
subrata_modak8c138332008-01-28 11:19:32 +0000193 local RUN_REPEATED=0
yaberauneya6d41cc32010-01-28 16:24:16 +0000194 local QUIET_MODE=""
plars4a120e82004-09-02 18:56:06 +0000195 local NETPIPE=0
196 local GENLOAD=0
197 local MEMSIZE=0
198 local DURATION=""
subrata_modakbc833d32007-07-25 10:12:02 +0000199 local CMDFILEADDR=""
subrata_modak43938212008-05-19 08:48:46 +0000200 local FAILCMDFILE=""
Xiaoguang Wang5f71cf92014-09-23 15:59:43 +0800201 local TCONFCMDFILE=""
yaberauneyaef772532009-10-09 17:55:43 +0000202 local INJECT_KERNEL_FAULT=""
203 local INJECT_KERNEL_FAULT_PERCENTAGE=""
204 local INJECT_FAULT_LOOPS_PER_TEST=""
205 local VALGRIND_CHECK=""
206 local VALGRIND_CHECK_TYPE=""
subrata_modake47fb352007-11-25 17:03:49 +0000207 local LOGFILE_NAME=""
plars4a120e82004-09-02 18:56:06 +0000208 local LOGFILE=""
subrata_modake47fb352007-11-25 17:03:49 +0000209 local OUTPUTFILE_NAME=""
210 local OUTPUTFILE=""
211 local HTMLFILE_NAME=""
212 local HTMLFILE=""
Subrata Modakbd9d4402010-05-12 22:03:21 +0530213 local DMESG_DIR=""
subrata_modak08dde6f2007-11-28 11:02:51 +0000214 local EMAIL_TO=""
robbiew7d43d772005-02-07 20:07:30 +0000215 local TAG_RESTRICT_STRING=""
216 local PAN_COMMAND=""
look69f39f52014-04-30 09:55:44 +0800217 local DEFAULT_FILE_NAME_GENERATION_TIME=`date +"%Y_%m_%d-%Hh_%Mm_%Ss"`
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800218 local scenfile=
219
yaberauneyaef772532009-10-09 17:55:43 +0000220 version_date=$(cat "$LTPROOT/Version")
plars4a120e82004-09-02 18:56:06 +0000221
Xiaoguang Wang5f71cf92014-09-23 15:59:43 +0800222 while getopts a:c:C:T:d:D:f:F:ehi:K:g:l:m:M:Nno:pqr:s:S:t:T:w:x:b:B:z:Z: arg
yaberauneya6d41cc32010-01-28 16:24:16 +0000223 do case $arg in
subrata_modak08dde6f2007-11-28 11:02:51 +0000224 a) EMAIL_TO=$OPTARG
225 ALT_EMAIL_OUT=1;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700226 c)
subrata_modake099b2a2007-10-29 12:22:01 +0000227 NUM_PROCS=$(($OPTARG))
228 if [ "$NUM_PROCS" -eq 0 ]; then
229 # User Did not Define the Value ,or, User Defined Zero,
230 # hence, prevent from creating infinite processes
231 NUM_PROCS=1
232 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000233 $LTPROOT/testcases/bin/genload --cpu $NUM_PROCS >/dev/null 2>&1 &
plars4a120e82004-09-02 18:56:06 +0000234 GENLOAD=1 ;;
subrata_modakbc833d32007-07-25 10:12:02 +0000235
Chris Dearman37550cf2012-10-17 19:54:01 -0700236 C)
subrata_modak6838ec32007-09-14 10:10:12 +0000237 case $OPTARG in
238 /*)
239 FAILCMDFILE="-C $OPTARG" ;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700240 *)
subrata_modak6838ec32007-09-14 10:10:12 +0000241 FAILCMDFILE="-C $LTPROOT/output/$OPTARG"
subrata_modak5d7deea2007-09-15 13:51:36 +0000242 ALT_DIR_OUT=1 ;;
subrata_modak6838ec32007-09-14 10:10:12 +0000243 esac ;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700244
Xiaoguang Wang5f71cf92014-09-23 15:59:43 +0800245 T)
246 case $OPTARG in
247 /*)
248 TCONFCMDFILE="-T $OPTARG" ;;
249 *)
250 TCONFCMDFILE="-T $LTPROOT/output/$OPTARG"
251 ALT_DIR_OUT=1 ;;
252 esac ;;
253
subrata_modak5ee3e892008-10-21 13:17:56 +0000254 d) # convert the user path to absolute path.
Garrett Cooper5d520f42012-08-07 08:57:31 -0700255 export TMPBASE=$(readlink -f ${OPTARG}) ;;
subrata_modake099b2a2007-10-29 12:22:01 +0000256
257 D) NUM_PROCS=1; NUM_FILES=1; NUM_BYTES=$((1024 * 1024 * 1024)); CLEAN_FLAG=0
subrata_modak548379d2008-08-20 09:15:49 +0000258 ARGUMENT_LIST=$OPTARG
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800259 TOTAL_ARGUMENTS=1
260 for ARGUMENT in `echo "$ARGUMENT_LIST" | tr ',' ' '`
subrata_modake099b2a2007-10-29 12:22:01 +0000261 do
262 case $TOTAL_ARGUMENTS in
yaberauneya6d41cc32010-01-28 16:24:16 +0000263 1) NUM_PROCS="$ARGUMENT" ;;
264 2) NUM_FILES="$ARGUMENT" ;;
265 3) NUM_BYTES="$ARGUMENT" ;;
266 4) CLEAN_FLAG="$ARGUMENT" ;;
subrata_modake099b2a2007-10-29 12:22:01 +0000267 esac
yaberauneya6d41cc32010-01-28 16:24:16 +0000268 TOTAL_ARGUMENTS=`expr $TOTAL_ARGUMENTS + 1`
subrata_modake099b2a2007-10-29 12:22:01 +0000269 done
270 # just to get the default values if the user passed 0
271 if [ "$NUM_PROCS" -eq 0 ]; then
272 NUM_PROCS=1
273 fi
274 if [ "$NUM_FILES" -eq 0 ]; then
275 NUM_FILES=1
276 fi
277 if [ "$NUM_BYTES" -eq 0 ]; then
278 NUM_BYTES=$((1024 * 1024 * 1024))
279 fi
280 if [ "$CLEAN_FLAG" -ne 1 ]; then
281 CLEAN_FLAG=0
282 fi
283 if [ "$CLEAN_FLAG" -eq 1 ]; then
284 # Do not unlink file in this case
yaberauneya6d41cc32010-01-28 16:24:16 +0000285 $LTPROOT/testcases/bin/genload --hdd $NUM_PROCS --hdd-files \
subrata_modake099b2a2007-10-29 12:22:01 +0000286 $NUM_FILES --hdd-bytes $NUM_BYTES >/dev/null 2>&1 &
287 else
288 # Cleanup otherwise
yaberauneya6d41cc32010-01-28 16:24:16 +0000289 $LTPROOT/testcases/bin/genload --hdd $NUM_PROCS --hdd-files \
subrata_modake099b2a2007-10-29 12:22:01 +0000290 $NUM_FILES --hdd-bytes $NUM_BYTES --hdd-noclean >/dev/null 2>&1 &
291 fi
292 GENLOAD=1;;
293
mreed1091696422006-05-03 19:07:22 +0000294 e) # Print out the version of LTP
295 version_of_ltp
yaberauneya6d41cc32010-01-28 16:24:16 +0000296 ;;
plars4a120e82004-09-02 18:56:06 +0000297 f) # Execute user defined set of testcases.
subrata_modakbc833d32007-07-25 10:12:02 +0000298 # Can be more then one file, just separate it with ',', like:
299 # -f nfs,commands,/tmp/testfile
300 CMDFILES=$OPTARG;;
yaberauneya6d41cc32010-01-28 16:24:16 +0000301 F) INJECT_KERNEL_FAULT=1
302 #Seperate out the NO_OF_LOOPS & FAULT_PERCENTAGE
303 INJECT_FAULT_LOOPS_PER_TEST=`echo $OPTARG |cut -d',' -f1 | tr -d '\n' | tr -d ' '`
304 INJECT_KERNEL_FAULT_PERCENTAGE=`echo $OPTARG |cut -d',' -f2 | tr -d '\n' | tr -d ' '`
305 if [ ! $INJECT_FAULT_LOOPS_PER_TEST ]; then
306 echo "Loops not properly defined. Resorting to default 5..."
307 export INJECT_FAULT_LOOPS_PER_TEST=5
308 fi
309 if [ ! $INJECT_KERNEL_FAULT_PERCENTAGE ]; then
310 echo "Fault Persentage not properly defined. Resorting to default 10..."
311 export INJECT_KERNEL_FAULT_PERCENTAGE=10
312 fi;;
subrata_modake47fb352007-11-25 17:03:49 +0000313 g) HTMLFILE_NAME="$OPTARG"
314 case $OPTARG in
315 /*)
316 HTMLFILE="$OPTARG";;
317 *)
subrata_modakd48c4d02008-01-23 12:59:40 +0000318 HTMLFILE="$LTPROOT/output/$OPTARG";;
319 esac
Chris Dearman37550cf2012-10-17 19:54:01 -0700320 ALT_DIR_OUT=1
subrata_modakd48c4d02008-01-23 12:59:40 +0000321 ALT_HTML_OUT=1;;
plars4a120e82004-09-02 18:56:06 +0000322 h) usage;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700323
subrata_modake099b2a2007-10-29 12:22:01 +0000324 i)
325 NUM_PROCS=$(($OPTARG))
326 if [ "$NUM_PROCS" -eq 0 ]; then
327 # User Did not Define the Value ,or, User Defined Zero,
328 # hence, prevent from creating infinite processes
329 NUM_PROCS=1
330 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000331 $LTPROOT/testcases/bin/genload --io $NUM_PROCS >/dev/null 2>&1 &
plars4a120e82004-09-02 18:56:06 +0000332 GENLOAD=1 ;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700333
334 K)
Subrata Modakbd9d4402010-05-12 22:03:21 +0530335 case $OPTARG in
336 /*)
Cyril Hrubisc381f582013-08-08 18:19:35 +0200337 DMESG_DIR="$OPTARG-dmesg-output-`echo $$-``date +%X | tr -d ' '`";;
Subrata Modakbd9d4402010-05-12 22:03:21 +0530338 *)
Cyril Hrubisc381f582013-08-08 18:19:35 +0200339 DMESG_DIR="$LTPROOT/output/$OPTARG-dmesg-output-`echo $$-``date +%X | tr -d ' '`";;
Subrata Modakbd9d4402010-05-12 22:03:21 +0530340 esac
341 mkdir -p $DMESG_DIR
342 ALT_DMESG_OUT=1;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700343 l)
subrata_modak6838ec32007-09-14 10:10:12 +0000344 LOGFILE_NAME="$OPTARG"
plars4a120e82004-09-02 18:56:06 +0000345 case $OPTARG in
subrata_modak5d7deea2007-09-15 13:51:36 +0000346 /*)
plars4a120e82004-09-02 18:56:06 +0000347 LOGFILE="-l $OPTARG" ;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700348 *)
plars4a120e82004-09-02 18:56:06 +0000349 LOGFILE="-l $LTPROOT/results/$OPTARG"
subrata_modak5d7deea2007-09-15 13:51:36 +0000350 ALT_DIR_RES=1 ;;
plars4a120e82004-09-02 18:56:06 +0000351 esac ;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700352
subrata_modake099b2a2007-10-29 12:22:01 +0000353 m) NUM_PROCS=1; CHUNKS=1; BYTES=$((256 * 1024 * 1024)); HANGUP_FLAG=0
subrata_modak29a96d82008-08-27 13:34:46 +0000354 ARGUMENT_LIST=$OPTARG
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800355 TOTAL_ARGUMENTS=1
356 for ARGUMENT in `echo "$ARGUMENT_LIST" | tr ',' ' '`
subrata_modake099b2a2007-10-29 12:22:01 +0000357 do
358 case $TOTAL_ARGUMENTS in
yaberauneya6d41cc32010-01-28 16:24:16 +0000359 1) NUM_PROCS="$ARGUMENT" ;;
360 2) CHUNKS="$ARGUMENT" ;;
361 3) BYTES="$ARGUMENT" ;;
362 4) HANGUP_FLAG="$ARGUMENT" ;;
subrata_modake099b2a2007-10-29 12:22:01 +0000363 esac
yaberauneya6d41cc32010-01-28 16:24:16 +0000364 TOTAL_ARGUMENTS=`expr $TOTAL_ARGUMENTS + 1`
subrata_modake099b2a2007-10-29 12:22:01 +0000365 done
366 # just to get the default values if the user passed 0
yaberauneya6d41cc32010-01-28 16:24:16 +0000367 if [ "$NUM_PROCS" -eq 0 ]; then
368 NUM_PROCS=1
369 fi
370 if [ "$CHUNKS" -eq 0 ]; then
371 CHUNKS=1
372 fi
373 if [ "$BYTES" -eq 0 ]; then
374 BYTES=$((256 * 1024 * 1024))
375 fi
376 if [ "$HANGUP_FLAG" -ne 1 ]; then
377 HANGUP_FLAG=0
378 fi
subrata_modake099b2a2007-10-29 12:22:01 +0000379 if [ "$HANGUP_FLAG" -eq 1 ]; then
380 # Hang in a Sleep loop after memory allocated
yaberauneya6d41cc32010-01-28 16:24:16 +0000381 $LTPROOT/testcases/bin/genload --vm $NUM_PROCS --vm-chunks \
subrata_modake099b2a2007-10-29 12:22:01 +0000382 $CHUNKS --vm-bytes $BYTES --vm-hang >/dev/null 2>&1 &
383 else
384 # Otherwise Do not Hangup
yaberauneya6d41cc32010-01-28 16:24:16 +0000385 $LTPROOT/testcases/bin/genload --vm $NUM_PROCS --vm-chunks \
subrata_modake099b2a2007-10-29 12:22:01 +0000386 $CHUNKS --vm-bytes $BYTES >/dev/null 2>&1 &
387 fi
plars4a120e82004-09-02 18:56:06 +0000388 GENLOAD=1;;
yaberauneya6d41cc32010-01-28 16:24:16 +0000389 M)
390 VALGRIND_CHECK=1
391 VALGRIND_CHECK_TYPE="$OPTARG";;
subrata_modak9c7072a2009-08-26 07:00:25 +0000392
plars4a120e82004-09-02 18:56:06 +0000393 N) RUN_NETEST=1;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700394
395 n)
yaberauneya6d41cc32010-01-28 16:24:16 +0000396 $LTPROOT/testcases/bin/netpipe.sh
plars4a120e82004-09-02 18:56:06 +0000397 NETPIPE=1;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700398
subrata_modak6838ec32007-09-14 10:10:12 +0000399 o) OUTPUTFILE_NAME="$OPTARG"
subrata_modak6838ec32007-09-14 10:10:12 +0000400 case $OPTARG in
401 /*)
402 OUTPUTFILE="-o $OPTARG";;
403 *)
404 OUTPUTFILE="-o $LTPROOT/output/$OPTARG"
subrata_modak5d7deea2007-09-15 13:51:36 +0000405 ALT_DIR_OUT=1 ;;
yaberauneya6d41cc32010-01-28 16:24:16 +0000406 esac ;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700407
plars4a120e82004-09-02 18:56:06 +0000408 p) PRETTY_PRT=" -p ";;
Chris Dearman37550cf2012-10-17 19:54:01 -0700409
yaberauneya6d41cc32010-01-28 16:24:16 +0000410 q) QUIET_MODE=" -q ";;
Chris Dearman37550cf2012-10-17 19:54:01 -0700411
plars4a120e82004-09-02 18:56:06 +0000412 r) LTPROOT=$OPTARG;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700413
robbiew7d43d772005-02-07 20:07:30 +0000414 s) TAG_RESTRICT_STRING=$OPTARG;;
subrata_modak2f6c9812009-08-14 17:07:48 +0000415
yaberauneya6d41cc32010-01-28 16:24:16 +0000416 S) case $OPTARG in
subrata_modak2f6c9812009-08-14 17:07:48 +0000417 /*)
418 SKIPFILE=$OPTARG;;
419 *)
420 SKIPFILE="$LTPROOT/$OPTARG";;
yaberauneya6d41cc32010-01-28 16:24:16 +0000421 esac ;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700422
423 t) # In case you want to specify the time
424 # to run from the command line
plars4a120e82004-09-02 18:56:06 +0000425 # (2m = two minutes, 2h = two hours, etc)
426 DURATION="-t $OPTARG" ;;
subrata_modak8c138332008-01-28 11:19:32 +0000427
428 T) # In case you want the testcases to runsequentially RUN_REPEATED times
429 RUN_REPEATED=$OPTARG;;
430
subrata_modakbc833d32007-07-25 10:12:02 +0000431 w) CMDFILEADDR=$OPTARG;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700432
plars4a120e82004-09-02 18:56:06 +0000433 x) # number of ltp's to run
yaberauneya6d41cc32010-01-28 16:24:16 +0000434 cat <<-EOF >&1
435 WARNING: The use of -x can cause unpredictable failures, as a
436 result of concurrently running multiple tests designed
437 to be ran exclusively.
438 Pausing for 10 seconds..."
439 EOF
Chris Dearman37550cf2012-10-17 19:54:01 -0700440 sleep 10
yaberauneya6d41cc32010-01-28 16:24:16 +0000441 INSTANCES="-x $OPTARG";;
subrata_modakd9fb3862008-12-29 11:25:36 +0000442 b) DEVICE=$OPTARG;;
Xiaoguang Wang5b42a1e2013-12-12 19:10:58 +0800443 B) LTP_DEV_FS_TYPE=$OPTARG;;
444 z) BIG_DEVICE=$OPTARG;;
Xiaoguang Wangcb1a4ae2014-04-15 19:33:21 +0800445 Z) BIG_DEVICE_FS_TYPE=$OPTARG;;
plars4a120e82004-09-02 18:56:06 +0000446 \?) usage;;
447 esac
448 done
subrata_modak43938212008-05-19 08:48:46 +0000449
450 ## It would be nice to create a default log file even if the user has not mentioned
451 if [ ! "$LOGFILE" ]; then ## User has not mentioned about Log File name
look69f39f52014-04-30 09:55:44 +0800452 LOGFILE_NAME="$DEFAULT_FILE_NAME_GENERATION_TIME"
subrata_modak43938212008-05-19 08:48:46 +0000453 LOGFILE="-l $LTPROOT/results/LTP_RUN_ON-$LOGFILE_NAME.log"
454 ALT_DIR_RES=1
455 PRETTY_PRT=" -p "
456 fi
Chris Dearman37550cf2012-10-17 19:54:01 -0700457
458 ## It would be nice if a Failed File is compulsorily created (gives User better Idea of Tests that failed)
subrata_modak6838ec32007-09-14 10:10:12 +0000459
yaberauneya6d41cc32010-01-28 16:24:16 +0000460 if [ ! "$FAILCMDFILE" ]; then ## User has not mentioned about Failed File name
subrata_modak5d7deea2007-09-15 13:51:36 +0000461 ALT_DIR_OUT=1
yaberauneya6d41cc32010-01-28 16:24:16 +0000462 if [ ! "$OUTPUTFILE" ]; then ## User has not mentioned about Output File name either
463 if [ ! "$LOGFILE" ]; then ## User has not mentioned about Log File name either
look69f39f52014-04-30 09:55:44 +0800464 FAILED_FILE_NAME="$DEFAULT_FILE_NAME_GENERATION_TIME"
yaberauneya6d41cc32010-01-28 16:24:16 +0000465 FAILCMDFILE="-C $LTPROOT/output/LTP_RUN_ON-$FAILED_FILE_NAME.failed"
466 else ## User Fortunately wanted a log file,
467 FAILED_FILE_NAME=`basename $LOGFILE_NAME` ## Extract log file name and use it to construct Failed file name
468 FAILCMDFILE="-C $LTPROOT/output/LTP_RUN_ON-$FAILED_FILE_NAME.failed"
subrata_modak6838ec32007-09-14 10:10:12 +0000469 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000470 else ## User Fortunately wanted a Output file
471 FAILED_FILE_NAME=`basename $OUTPUTFILE_NAME` ## Extract output file name and use it to construct Failed file name
472 FAILCMDFILE="-C $LTPROOT/output/LTP_RUN_ON-$FAILED_FILE_NAME.failed"
subrata_modak6838ec32007-09-14 10:10:12 +0000473 fi
474 fi
subrata_modaka1fd64b2007-04-11 11:24:49 +0000475
Xiaoguang Wang5f71cf92014-09-23 15:59:43 +0800476 if [ ! "$TCONFCMDFILE" ]; then
477 ALT_DIR_OUT=1
478 if [ ! "$OUTPUTFILE" ]; then
479 if [ ! "$LOGFILE" ]; then
480 TCONF_FILE_NAME="$DEFAULT_FILE_NAME_GENERATION_TIME"
481 TCONFCMDFILE="-T $LTPROOT/output/LTP_RUN_ON-${TCONF_FILE_NAME}.tconf"
482 else
483 TCONF_FILE_NAME=`basename $LOGFILE_NAME`
484 TCONFCMDFILE="-T $LTPROOT/output/LTP_RUN_ON-${TCONF_FILE_NAME}.tconf"
485 fi
486 else
487 TCONF_FILE_NAME=`basename $OUTPUTFILE_NAME`
488 TCONFCMDFILE="-T $LTPROOT/output/LTP_RUN_ON-${TCONF_FILE_NAME}.tconf"
489 fi
490 fi
491
subrata_modakd48c4d02008-01-23 12:59:40 +0000492 if [ "$ALT_HTML_OUT" -eq 1 ] ; then ## User wants the HTML version of the output
yaberauneya6d41cc32010-01-28 16:24:16 +0000493 QUIET_MODE="" ## Suppressing this guy as it will prevent generation of proper output
subrata_modakd48c4d02008-01-23 12:59:40 +0000494 ## which the HTML parser will require
yaberauneya6d41cc32010-01-28 16:24:16 +0000495 if [ ! "$OUTPUTFILE" ]; then ## User has not mentioned about the Outputfile name, then we need to definitely generate one
look69f39f52014-04-30 09:55:44 +0800496 OUTPUTFILE_NAME="$DEFAULT_FILE_NAME_GENERATION_TIME"
subrata_modake47fb352007-11-25 17:03:49 +0000497 OUTPUTFILE="-o $LTPROOT/output/LTP_RUN_ON-$OUTPUTFILE_NAME.output"
subrata_modak08dde6f2007-11-28 11:02:51 +0000498 ALT_DIR_OUT=1
yaberauneya6d41cc32010-01-28 16:24:16 +0000499 if [ ! "$HTMLFILE" ] ; then ## User has not mentioned HTML File name, We need to create one
500 HTMLFILE_NAME=`basename $OUTPUTFILE_NAME`
subrata_modake47fb352007-11-25 17:03:49 +0000501 HTMLFILE="$LTPROOT/output/$HTMLFILE_NAME.html"
502 fi
503 fi
504 fi
505
subrata_modak5d7deea2007-09-15 13:51:36 +0000506 # If we need, create the output directory
yaberauneya6d41cc32010-01-28 16:24:16 +0000507 [ "$ALT_DIR_OUT" -eq 1 ] && \
508 {
509 [ ! -d $LTPROOT/output ] && \
510 {
511 echo "INFO: creating $LTPROOT/output directory"
512 mkdir -p $LTPROOT/output || \
513 {
514 echo "ERROR: failed to create $LTPROOT/output"
515 exit 1
516 }
517 }
518 }
subrata_modak5d7deea2007-09-15 13:51:36 +0000519 # If we need, create the results directory
yaberauneya6d41cc32010-01-28 16:24:16 +0000520 [ "$ALT_DIR_RES" -eq 1 ] && \
521 {
522 echo "INFO: creating $LTPROOT/results directory"
523 [ ! -d $LTPROOT/results ] && \
524 {
525 mkdir -p $LTPROOT/results || \
526 {
527 echo "ERROR: failed to create $LTPROOT/results"
528 exit 1
529 }
530 }
531 }
subrata_modak5d7deea2007-09-15 13:51:36 +0000532
Chris Dearman37550cf2012-10-17 19:54:01 -0700533 # Added -m 777 for tests that call tst_tmpdir() and try to
subrata_modaka1fd64b2007-04-11 11:24:49 +0000534 # write to it as user nobody
yaberauneya6d41cc32010-01-28 16:24:16 +0000535 mkdir -m 777 -p $TMPBASE || \
536 {
537 echo "FATAL: Unable to make temporary directory $TMPBASE"
538 exit 1
539 }
subrata_modak5ee3e892008-10-21 13:17:56 +0000540 # use mktemp to create "safe" temporary directories
541 export TMPTEMPLATE="${TMPBASE}/ltp-XXXXXXXXXX"
yaberauneya6d41cc32010-01-28 16:24:16 +0000542 TMP=`mktemp -d $TMPTEMPLATE` || \
543 {
544 echo "FATAL: Unable to make temporary directory: $TMP"
545 exit 1
546 }
547 export TMP
subrata_modak225cfbe2009-06-23 14:01:26 +0000548 # To be invoked by tst_tmpdir()
549 # write to it as user nobody
550 export TMPDIR=$TMP
subrata_modak6edfbda2008-10-17 12:25:48 +0000551
yaberauneya6d41cc32010-01-28 16:24:16 +0000552 chmod 777 $TMP || \
553 {
554 echo "unable to chmod 777 $TMP ... aborting"
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800555 exit 1
yaberauneya6d41cc32010-01-28 16:24:16 +0000556 }
Chris Dearman37550cf2012-10-17 19:54:01 -0700557
yaberauneya6d41cc32010-01-28 16:24:16 +0000558 cd $TMP || \
559 {
560 echo "could not cd ${TMP} ... exiting"
561 exit 1
562 }
Chris Dearman37550cf2012-10-17 19:54:01 -0700563
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800564 [ -n "$INSTANCES" ] && \
yaberauneya6d41cc32010-01-28 16:24:16 +0000565 {
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800566 INSTANCES="$INSTANCES -O ${TMP}"
yaberauneya6d41cc32010-01-28 16:24:16 +0000567 }
Chris Dearman37550cf2012-10-17 19:54:01 -0700568
yaberauneya6d41cc32010-01-28 16:24:16 +0000569 [ "$RUN_NETEST" -eq 1 ] && \
570 {
571 [ -z "$RHOST" ] || [ -z "$PASSWD" ] && \
572 {
573 [ -z "$RHOST" ] && \
574 {
Anders Roxell4691f012013-09-03 09:42:35 +0200575 printf "INFO: Enter RHOST = 'name of the remote host machine'"
576 printf "\n-> "
plars4a120e82004-09-02 18:56:06 +0000577 read RHOST
yaberauneya6d41cc32010-01-28 16:24:16 +0000578 }
plars4a120e82004-09-02 18:56:06 +0000579
yaberauneya6d41cc32010-01-28 16:24:16 +0000580 [ -z "$PASSWD" ] && \
581 {
Anders Roxell4691f012013-09-03 09:42:35 +0200582 printf "\nINFO: "
583 printf "Enter PASSWD = 'root passwd of the remote host machine'"
584 printf "\n-> "
plars4a120e82004-09-02 18:56:06 +0000585 read PASSWD
yaberauneya6d41cc32010-01-28 16:24:16 +0000586 }
plars4a120e82004-09-02 18:56:06 +0000587 export RHOST=$RHOST
588 export PASSWD=$PASSWD
yaberauneya6d41cc32010-01-28 16:24:16 +0000589 echo "WARNING: security of $RHOST may be compromised"
590 }
591 }
Chris Dearman37550cf2012-10-17 19:54:01 -0700592
plars4a120e82004-09-02 18:56:06 +0000593 # If user does not provide a command file select a default set of testcases
594 # to execute.
yaberauneya6d41cc32010-01-28 16:24:16 +0000595 if [ -z "$CMDFILES" ] && [ -z "$CMDFILEADDR" ]
596 then
597 cat <<-EOF >&1
plars4a120e82004-09-02 18:56:06 +0000598
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800599 INFO: no command files were provided. Will execute the following
600 runtest scenario files:
Garrett Cooper66d67b52010-11-16 22:42:48 -0800601
602`cat $LTPROOT/scenario_groups/default | tr '\012' ' '`
Chris Dearman37550cf2012-10-17 19:54:01 -0700603
yaberauneya6d41cc32010-01-28 16:24:16 +0000604 EOF
plars4a120e82004-09-02 18:56:06 +0000605
Garrett Cooper89fde872010-11-16 22:38:08 -0800606 SCENARIO_LISTS="$LTPROOT/scenario_groups/default"
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800607 if [ "$RUN_NETEST" -eq 1 ]; then
Garrett Cooper89fde872010-11-16 22:38:08 -0800608 SCENARIO_LISTS="$SCENARIO_LISTS $LTPROOT/scenario_groups/network"
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800609 fi
plars4a120e82004-09-02 18:56:06 +0000610
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800611 # DO NOT INDENT/DEDENT!
612 if [ -n "$SCENARIO_LISTS" ]; then
613 # Insurance to make sure that the first element in the pipe
614 # completed successfully.
615 cat_ok_sentinel=$TMP/cat_ok.$$
Garrett Cooper66d67b52010-11-16 22:42:48 -0800616 (cat $SCENARIO_LISTS && touch "$cat_ok_sentinel") | \
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800617 while read scenfile; do
618
619 scenfile=${LTPROOT}/runtest/$scenfile
620
621 # Skip over non-existent scenario files; things are
622 # robust enough now that the build will fail if these
623 # files don't exist.
624 [ -f "$scenfile" ] || continue
625
626 cat $scenfile >> "$TMP/alltests" || {
627 echo "FATAL: unable to append to command file"
628 rm -Rf "$TMP"
629 rm -f "$cat_ok_sentinel"
630 exit 1
631 }
632
633 done
634
635 rm -f "$cat_ok_sentinel"
636
637 fi
638 # ^^DO NOT INDENT/DEDENT!^^
639
subrata_modakbc833d32007-07-25 10:12:02 +0000640 fi
641
yaberauneya6d41cc32010-01-28 16:24:16 +0000642 [ -n "$CMDFILES" ] && \
643 {
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800644 for scenfile in `echo "$CMDFILES" | tr ',' ' '`
yaberauneya6d41cc32010-01-28 16:24:16 +0000645 do
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800646 [ -f "$scenfile" ] || scenfile="$LTPROOT/runtest/$scenfile"
647 cat "$scenfile" >> ${TMP}/alltests || \
yaberauneya6d41cc32010-01-28 16:24:16 +0000648 {
649 echo "FATAL: unable to create command file"
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800650 rm -Rf "$TMP"
yaberauneya6d41cc32010-01-28 16:24:16 +0000651 exit 1
652 }
plars4a120e82004-09-02 18:56:06 +0000653 done
yaberauneya6d41cc32010-01-28 16:24:16 +0000654 }
Chris Dearman37550cf2012-10-17 19:54:01 -0700655
yaberauneya6d41cc32010-01-28 16:24:16 +0000656 [ -n "$CMDFILEADDR" ] && \
657 {
658 wget -q "${CMDFILEADDR}" -O ${TMP}/wgetcmdfile
659 if [ $? -ne 0 ]; then
660 echo "FATAL: error while getting the command file with wget (address $CMDFILEADDR)"
661 exit 1
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000662 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000663 cat "${TMP}/wgetcmdfile" >> ${TMP}/alltests || \
664 {
665 echo "FATAL: unable to create command file"
666 exit 1
667 }
668 }
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000669
plars4a120e82004-09-02 18:56:06 +0000670 # The fsx-linux tests use the SCRATCHDEV environment variable as a location
Chris Dearman37550cf2012-10-17 19:54:01 -0700671 # that can be reformatted and run on. Set SCRATCHDEV if you want to run
plars4a120e82004-09-02 18:56:06 +0000672 # these tests. As a safeguard, this is disabled.
673 unset SCRATCHDEV
yaberauneya6d41cc32010-01-28 16:24:16 +0000674 [ -n "$SCRATCHDEV" ] && \
675 {
676 cat ${LTPROOT}/runtest/fsx >> ${TMP}/alltests ||
677 {
678 echo "FATAL: unable to create fsx-linux tests command file"
679 exit 1
680 }
681 }
subrata_modakbc833d32007-07-25 10:12:02 +0000682
683 # If enabled, execute only test cases that match the PATTERN
yaberauneya6d41cc32010-01-28 16:24:16 +0000684 if [ -n "$TAG_RESTRICT_STRING" ]
685 then
686 mv -f ${TMP}/alltests ${TMP}/alltests.orig
687 grep $TAG_RESTRICT_STRING ${TMP}/alltests.orig > ${TMP}/alltests #Not worth checking return codes for this case
subrata_modakbc833d32007-07-25 10:12:02 +0000688 fi
subrata_modak2f6c9812009-08-14 17:07:48 +0000689
690 # Blacklist or skip tests if a SKIPFILE was specified with -S
yaberauneya6d41cc32010-01-28 16:24:16 +0000691 if [ -n "$SKIPFILE" ]
692 then
subrata_modak2f6c9812009-08-14 17:07:48 +0000693 for file in $( cat $SKIPFILE ); do
Andrew Chen410c6952011-06-30 14:19:45 +0800694 sed -i "/^$file[ \t]/d" ${TMP}/alltests
subrata_modak2f6c9812009-08-14 17:07:48 +0000695 done
696 fi
Chris Dearman37550cf2012-10-17 19:54:01 -0700697
plars4a120e82004-09-02 18:56:06 +0000698 # check for required users and groups
Cyril Hrubisb88fa5b2013-06-25 15:50:08 +0200699 ${LTPROOT}/IDcheck.sh || \
yaberauneya6d41cc32010-01-28 16:24:16 +0000700 {
701 echo "WARNING: required users and groups not present"
702 echo "WARNING: some test cases may fail"
703 }
Chris Dearman37550cf2012-10-17 19:54:01 -0700704
plars4a120e82004-09-02 18:56:06 +0000705 # display versions of installed software
yaberauneya6d41cc32010-01-28 16:24:16 +0000706 [ -z "$QUIET_MODE" ] && \
Chris Dearman37550cf2012-10-17 19:54:01 -0700707 {
yaberauneya6d41cc32010-01-28 16:24:16 +0000708 ${LTPROOT}/ver_linux || \
709 {
710 echo "WARNING: unable to display versions of software installed"
711 exit 1
712 }
713 }
714
Harald Weppner8bdf0a02014-03-03 14:10:07 -0800715 set_block_device
subrata_modakd9fb3862008-12-29 11:25:36 +0000716
Xiaoguang Wang5b42a1e2013-12-12 19:10:58 +0800717 # here even if the user don't specify a big block device, we
718 # also don't create the big block device.
719 if [ -z "$BIG_DEVICE" ]; then
720 echo "no big block device was specified on commandline."
721 echo "Tests which require a big block device are disabled."
722 echo "You can specify it with option -z"
723 else
Xiaoguang Wangcb1a4ae2014-04-15 19:33:21 +0800724 export LTP_BIG_DEV=$BIG_DEVICE
725 if [ -z "$BIG_DEVICE_FS_TYPE" ]; then
726 export LTP_BIG_DEV_FS_TYPE="ext2"
727 else
728 export LTP_BIG_DEV_FS_TYPE=$BIG_DEVICE_FS_TYPE
729 fi
subrata_modakd9fb3862008-12-29 11:25:36 +0000730 fi
731
subrata_modak8c138332008-01-28 11:19:32 +0000732 if [ $RUN_REPEATED -gt 1 ]; then # You need to specify at least more than 1 sequential run, else it runs default
yaberauneya6d41cc32010-01-28 16:24:16 +0000733 echo "PAN will run these test cases $RUN_REPEATED times....."
734 echo "Test Tags will be Prepended with ITERATION NO.s....."
735 inc=1
736 sed -e '/^$/ d' -e 's/^[ ,\t]*//' -e '/^#/ d' < ${TMP}/alltests > ${TMP}/alltests.temp ##This removes all newlines, leading spaces, tabs, #
737 sed 's/^[0-9,a-z,A-Z]*/'"$inc"'_ITERATION_&/' < ${TMP}/alltests.temp > ${TMP}/alltests ## .temp is kept as Base file
738 while [ $inc -lt $RUN_REPEATED ] ; do
739 inc=`expr $inc + 1`
740 sed 's/^[0-9,a-z,A-Z]*/'"$inc"'_ITERATION_&/' < ${TMP}/alltests.temp >> ${TMP}/alltests #Keep appending with Iteration No.s
741 done
subrata_modak8c138332008-01-28 11:19:32 +0000742 fi
743
yaberauneya6d41cc32010-01-28 16:24:16 +0000744 [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test start time: $(date)" ; }
745 PAN_COMMAND="${LTPROOT}/bin/ltp-pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ \
Xiaoguang Wang5f71cf92014-09-23 15:59:43 +0800746 -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE $FAILCMDFILE $TCONFCMDFILE"
yaberauneya6d41cc32010-01-28 16:24:16 +0000747 echo "COMMAND: $PAN_COMMAND"
748 if [ ! -z "$TAG_RESTRICT_STRING" ] ; then
749 echo "INFO: Restricted to $TAG_RESTRICT_STRING"
robbiew7d43d772005-02-07 20:07:30 +0000750 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000751 #$PAN_COMMAND #Duplicated code here, because otherwise if we fail, only "PAN_COMMAND" gets output
Chris Dearman37550cf2012-10-17 19:54:01 -0700752
subrata_modak43938212008-05-19 08:48:46 +0000753 ## Display the Output/Log/Failed/HTML file names here
Anders Roxell4691f012013-09-03 09:42:35 +0200754 printf "LOG File: "
yaberauneya6d41cc32010-01-28 16:24:16 +0000755 echo $LOGFILE | cut -b4-
subrata_modak43938212008-05-19 08:48:46 +0000756
yaberauneya6d41cc32010-01-28 16:24:16 +0000757 if [ "$OUTPUTFILE" ]; then
Anders Roxell4691f012013-09-03 09:42:35 +0200758 printf "OUTPUT File: "
yaberauneya6d41cc32010-01-28 16:24:16 +0000759 echo $OUTPUTFILE | cut -b4-
subrata_modak43938212008-05-19 08:48:46 +0000760 fi
761
Anders Roxell4691f012013-09-03 09:42:35 +0200762 printf "FAILED COMMAND File: "
yaberauneya6d41cc32010-01-28 16:24:16 +0000763 echo $FAILCMDFILE | cut -b4-
764
Xiaoguang Wang5f71cf92014-09-23 15:59:43 +0800765 printf "TCONF COMMAND File: "
766 echo $TCONFCMDFILE | cut -b4-
767
yaberauneya6d41cc32010-01-28 16:24:16 +0000768 if [ "$HTMLFILE" ]; then
769 echo "HTML File: $HTMLFILE"
770 fi
771
772 echo "Running tests......."
subrata_modake47fb352007-11-25 17:03:49 +0000773 test_start_time=$(date)
subrata_modak724098e2009-03-19 08:49:18 +0000774
yaberauneya6d41cc32010-01-28 16:24:16 +0000775 # User wants testing with Kernel Fault Injection
776 if [ $INJECT_KERNEL_FAULT ] ; then
777 #See if Debugfs is mounted, and
778 #Fault Injection Framework available through Debugfs
Garrett Coopercb66da52012-04-03 22:09:42 -0700779 use_faultinjection=true
780 for debug_subdir in \
781 fail_io_timeout \
782 fail_make_request \
783 fail_page_alloc \
784 failslab \
785 ; do
786 if [ -d "/sys/kernel/debug/$debug_subdir" ]
787 then
788 use_faultinjection=true
789 break
790 fi
791 done
792 if $use_faultinjection; then
yaberauneya6d41cc32010-01-28 16:24:16 +0000793 #If atleast one of the Framework is available
794 #Go ahead to Inject Fault & Create required
795 #Command Files for LTP run
796 echo Running tests with Fault Injection Enabled in the Kernel...
Garrett Coopercb66da52012-04-03 22:09:42 -0700797 awk -v LOOPS=$INJECT_FAULT_LOOPS_PER_TEST \
798 -v PERCENTAGE=$INJECT_KERNEL_FAULT_PERCENTAGE \
799 -f ${LTPROOT}/bin/create_kernel_faults_in_loops_and_probability.awk \
800 ${TMP}/alltests > ${TMP}/alltests.tmp
yaberauneya6d41cc32010-01-28 16:24:16 +0000801 cp ${TMP}/alltests.tmp ${TMP}/alltests
802 rm -rf ${TMP}/alltests.tmp
803 else
804 echo Fault Injection not enabled in the Kernel..
805 echo Running tests normally...
806 fi
807 fi
808
809 ## Valgrind Check will work only when Kernel Fault Injection is not expected,
810 ## We do not want to test Faults when valgrind is running
811 if [ $VALGRIND_CHECK ]; then
812 if [ ! $INJECT_KERNEL_FAULT ]; then
813 which valgrind || VALGRIND_CHECK_TYPE=XYZ
814 case $VALGRIND_CHECK_TYPE in
Garrett Cooper3920fd12012-04-03 19:47:16 -0700815 [1-3])
816 awk -v CHECK_LEVEL=$VALGRIND_CHECK_TYPE \
817 -f ${LTPROOT}/bin/create_valgrind_check.awk \
818 ${TMP}/alltests $VALGRIND_CHECK_TYPE > \
819 ${TMP}/alltests.tmp
yaberauneya6d41cc32010-01-28 16:24:16 +0000820 cp ${TMP}/alltests.tmp ${TMP}/alltests
Garrett Cooper3920fd12012-04-03 19:47:16 -0700821 rm -rf ${TMP}/alltests.tmp
822 ;;
823 *)
824 echo "Invalid Memory Check Type, or, Valgrind is not available"
825 ;;
yaberauneya6d41cc32010-01-28 16:24:16 +0000826 esac
827 fi
828 fi
829
Subrata Modakbd9d4402010-05-12 22:03:21 +0530830 if [ $ALT_DMESG_OUT -eq 1 ] ; then
831 #We want to print dmesg output for each test,lets do the trick inside the script
832 echo Enabling dmesg output logging for each test...
Garrett Cooper66030122012-04-03 20:22:14 -0700833 awk -v DMESG_DIR=$DMESG_DIR \
834 -f ${LTPROOT}/bin/create_dmesg_entries_for_each_test.awk \
835 ${TMP}/alltests > ${TMP}/alltests.tmp
Subrata Modakbd9d4402010-05-12 22:03:21 +0530836 cp ${TMP}/alltests.tmp ${TMP}/alltests
837 rm -rf ${TMP}/alltests.tmp
838 fi
subrata_modak724098e2009-03-19 08:49:18 +0000839 # Some tests need to run inside the "bin" directory.
840 cd "${LTPROOT}/testcases/bin"
Xiaoguang Wang5f71cf92014-09-23 15:59:43 +0800841 "${LTPROOT}/bin/ltp-pan" $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE $FAILCMDFILE $TCONFCMDFILE
Chris Dearman37550cf2012-10-17 19:54:01 -0700842
plars4a120e82004-09-02 18:56:06 +0000843 if [ $? -eq 0 ]; then
yaberauneya6d41cc32010-01-28 16:24:16 +0000844 echo "INFO: ltp-pan reported all tests PASS"
845 VALUE=0
846 export LTP_EXIT_VALUE=0;
plars4a120e82004-09-02 18:56:06 +0000847 else
yaberauneya6d41cc32010-01-28 16:24:16 +0000848 echo "INFO: ltp-pan reported some tests FAIL"
849 VALUE=1
850 export LTP_EXIT_VALUE=1;
plars4a120e82004-09-02 18:56:06 +0000851 fi
subrata_modak724098e2009-03-19 08:49:18 +0000852 cd ..
yaberauneya6d41cc32010-01-28 16:24:16 +0000853 echo "LTP Version: $version_date"
mreed1091696422006-05-03 19:07:22 +0000854
Subrata Modake3bc3752010-07-03 23:32:27 +0530855 # $DMESG_DIR is used to cache messages obtained from dmesg after a test run.
856 # Proactively reap all of the 0-byte files in $DMESG_DIR as they have zero value
857 # and only clutter up the filesystem.
858
859 if [ $ALT_DMESG_OUT -eq 1 ] ; then
860 if ! find "$DMESG_DIR" -size 0 -exec rm {} + ; then
861 echo "cd to $DMESG_DIR failed: $?"
862 fi
863 if [ -n "$(ls "$DMESG_DIR")" ] ; then
864 echo "Kernel messages were generated for LTP tests $version_date"
865 else
866 echo "No Kernel messages were generated for LTP tests $version_date"
867 fi
868 fi
869
subrata_modake47fb352007-11-25 17:03:49 +0000870 if [ "$ALT_HTML_OUT" -eq 1 ] ; then #User wants the HTML output to be created, it then needs to be generated
871 export LTP_VERSION=$version_date
872 export TEST_START_TIME=$test_start_time
873 export TEST_END_TIME=$(date)
yaberauneya6d41cc32010-01-28 16:24:16 +0000874 OUTPUT_DIRECTORY=`echo $OUTPUTFILE | cut -c4-`
subrata_modake47fb352007-11-25 17:03:49 +0000875 LOGS_DIRECTORY="$LTPROOT/results"
876 export TEST_OUTPUT_DIRECTORY="$LTPROOT/output"
877 export TEST_LOGS_DIRECTORY=$LOGS_DIRECTORY
yaberauneya6d41cc32010-01-28 16:24:16 +0000878 echo "Generating HTML Output.....!!"
Chris Dearman37550cf2012-10-17 19:54:01 -0700879 ( perl $LTPROOT/bin/genhtml.pl $LTPROOT/bin/html_report_header.txt test_start test_end test_output execution_status $OUTPUT_DIRECTORY > $HTMLFILE; )
yaberauneya6d41cc32010-01-28 16:24:16 +0000880 echo "Generated HTML Output.....!!"
881 echo "Location: $HTMLFILE";
882
subrata_modake47fb352007-11-25 17:03:49 +0000883 fi
Chris Dearman37550cf2012-10-17 19:54:01 -0700884
yaberauneya6d41cc32010-01-28 16:24:16 +0000885 if [ "$ALT_EMAIL_OUT" -eq 1 ] ; then ## User wants reports to be e-mailed
Chris Dearman37550cf2012-10-17 19:54:01 -0700886 if [ [ ! "$HTMLFILE_NAME" ] -o [ ! "$OUTPUTFILE_NAME" ] -o [ ! "$LOGFILE_NAME" ] ] ; then
yaberauneya6d41cc32010-01-28 16:24:16 +0000887 ##User does not have output/logs/html-output, nothing to be mailed in this situation
888 echo "Nothing to be mailed here...."
subrata_modak08dde6f2007-11-28 11:02:51 +0000889 else
subrata_modak43938212008-05-19 08:48:46 +0000890 TAR_FILE_NAME=LTP_RUN_$version_date$DEFAULT_FILE_NAME_GENERATION_TIME.tar
yaberauneya6d41cc32010-01-28 16:24:16 +0000891 if [ "$HTMLFILE_NAME" ] ; then ## HTML file Exists
892 if [ "$ALT_HTML_OUT" -ne 1 ] ; then ## The HTML file path is absolute and not $LTPROOT/output
893 mkdir -p $LTPROOT/output ## We need to create this Directory
894 cp $HTMLFILE_NAME $LTPROOT/output/
895 fi
subrata_modak08dde6f2007-11-28 11:02:51 +0000896 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000897 if [ "$OUTPUTFILE_NAME" ] ; then ## Output file exists
898 if [ "$ALT_DIR_OUT" -ne 1 ] ; then ## The Output file path is absolute and not $LTPROOT/output
899 mkdir -p $LTPROOT/output ## We need to create this Directory
900 cp $OUTPUTFILE_NAME $LTPROOT/output/
901 fi
subrata_modak08dde6f2007-11-28 11:02:51 +0000902 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000903 if [ "$LOGFILE_NAME" ] ; then ## Log file exists
904 if [ "$ALT_DIR_RES" -ne 1 ] ; then ## The Log file path is absolute and not $LTPROOT/results
905 mkdir -p $LTPROOT/results ## We need to create this Directory
906 cp $LOGFILE_NAME $LTPROOT/results/
907 fi
908 fi
909 if [ -d $LTPROOT/output ] ; then
910 tar -cf ./$TAR_FILE_NAME $LTPROOT/output
911 if [ $? -eq 0 ]; then
912 echo "Created TAR File: ./$TAR_FILE_NAME successfully, added $LTPROOT/output"
913 else
914 echo "Cannot Create TAR File: ./$TAR_FILE_NAME for adding $LTPROOT/output"
915 fi
916 fi
917 if [ -d $LTPROOT/results ] ; then
918 tar -uf ./$TAR_FILE_NAME $LTPROOT/results
919 if [ $? -eq 0 ]; then
920 echo "Updated TAR File: ./$TAR_FILE_NAME successfully, added $LTPROOT/results"
921 else
922 echo "Cannot Update TAR File: ./$TAR_FILE_NAME for adding $LTPROOT/results"
923 fi
924 fi
925 if [ -e $LTPROOT/nohup.out ] ; then ## If User would have Chosen nohup to do ltprun
926 tar -uf ./$TAR_FILE_NAME $LTPROOT/nohup.out
927 if [ $? -eq 0 ]; then
928 echo "Updated TAR File: ./$TAR_FILE_NAME successfully, added $LTPROOT/nohup.out"
929 else
930 echo "Cannot Update TAR File: ./$TAR_FILE_NAME for adding $LTPROOT/nohup.out"
931 fi
932 fi
933 gzip ./$TAR_FILE_NAME ## gzip this guy
934 if [ $? -eq 0 ]; then
935 echo "Gunzipped TAR File: ./$TAR_FILE_NAME"
subrata_modak08dde6f2007-11-28 11:02:51 +0000936 else
yaberauneya6d41cc32010-01-28 16:24:16 +0000937 echo "Cannot Gunzip TAR File: ./$TAR_FILE_NAME"
subrata_modak08dde6f2007-11-28 11:02:51 +0000938 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000939 if [ -e /usr/bin/mutt ] ; then ## This is a better mail client than others
940 echo "Starting mailing reports to: $EMAIL_TO, file: ./$TAR_FILE_NAME.gz"
941 mutt -a ./$TAR_FILE_NAME.gz -s "LTP Reports on $test_start_time" $EMAIL_TO < /dev/null
942 if [ $? -eq 0 ]; then
943 echo "Reports Successfully mailed to: $EMAIL_TO"
944 else
945 echo "Reports cannot be mailed to: $EMAIL_TO"
946 fi
947 else ## Use our Ageold mail program
948 echo "Starting mailing reports to: $EMAIL_TO, file: ./$TAR_FILE_NAME.gz"
949 uuencode ./$TAR_FILE_NAME.gz $TAR_FILE_NAME.gz | mail $EMAIL_TO -s "LTP Reports on $test_start_time"
950 if [ $? -eq 0 ]; then
951 echo "Reports Successfully mailed to: $EMAIL_TO"
952 else
953 echo "Reports cannot be mailed to: $EMAIL_TO"
954 fi
Chris Dearman37550cf2012-10-17 19:54:01 -0700955 fi
subrata_modak08dde6f2007-11-28 11:02:51 +0000956 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000957 fi
Chris Dearman37550cf2012-10-17 19:54:01 -0700958
yaberauneya6d41cc32010-01-28 16:24:16 +0000959 [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test end time: $(date)" ; }
Chris Dearman37550cf2012-10-17 19:54:01 -0700960
yaberauneya6d41cc32010-01-28 16:24:16 +0000961 [ "$GENLOAD" -eq 1 ] && { killall -9 genload >/dev/null 2>&1; }
962 [ "$NETPIPE" -eq 1 ] && { killall -9 NPtcp >/dev/null 2>&1; }
Chris Dearman37550cf2012-10-17 19:54:01 -0700963
yaberauneya6d41cc32010-01-28 16:24:16 +0000964 [ "$ALT_DIR_OUT" -eq 1 ] || [ "$ALT_DIR_RES" -eq 1 ] && \
965 {
966 cat <<-EOF >&1
Chris Dearman37550cf2012-10-17 19:54:01 -0700967
Markos Chandras11328662012-03-06 10:28:59 +0000968 ###############################################################
Chris Dearman37550cf2012-10-17 19:54:01 -0700969
Markos Chandras11328662012-03-06 10:28:59 +0000970 Done executing testcases.
mreed1091696422006-05-03 19:07:22 +0000971 LTP Version: $version_date
Markos Chandras11328662012-03-06 10:28:59 +0000972 ###############################################################
Chris Dearman37550cf2012-10-17 19:54:01 -0700973
yaberauneya6d41cc32010-01-28 16:24:16 +0000974 EOF
975 }
976 exit $VALUE
plars4a120e82004-09-02 18:56:06 +0000977}
978
Ramesh YR0a78f232013-04-16 09:31:28 +0800979create_block()
980{
DAN LI189c4412013-09-10 10:53:34 +0800981 #create a block device
Wanlong Gao36894aa2013-11-25 08:33:30 +0800982 dd if=/dev/zero of=${TMP}/test.img bs=1kB count=20480 >/dev/null 2>&1
Ramesh YR0a78f232013-04-16 09:31:28 +0800983 if [ $? -ne 0 ]; then
984 echo "Failed to create loopback device image, please check disk space and re-run"
985 return 1
986 else
987 ##search for an unused loop dev
988 LOOP_DEV=$(losetup -f)
989 if [ $? -ne 0 ]; then
990 echo "no unused loop device is found"
991 return 1
992 else
993 ##attach the created file to loop dev.
Cyril Hrubisb88fa5b2013-06-25 15:50:08 +0200994 losetup $LOOP_DEV ${TMP}/test.img
Ramesh YR0a78f232013-04-16 09:31:28 +0800995 if [ $? -ne 0 ]; then
996 echo "losetup failed to create block device"
997 return 1
Ramesh YR0a78f232013-04-16 09:31:28 +0800998 fi
Cyril Hrubisc381f582013-08-08 18:19:35 +0200999 DEVICE=$LOOP_DEV
1000 return 0
Ramesh YR0a78f232013-04-16 09:31:28 +08001001 fi
1002 fi
1003}
1004
Harald Weppner8bdf0a02014-03-03 14:10:07 -08001005set_block_device()
1006{
1007 if [ -z "$DEVICE" ]; then
1008 create_block
1009 if [ $? -ne 0 ]; then
1010 echo "no block device was specified on commandline."
1011 echo "Block device could not be created using loopback device"
1012 echo "Tests which require block device are disabled."
1013 echo "You can specify it with option -b"
1014 else
1015 LTP_DEV=$DEVICE
1016 fi
1017 else
1018 LTP_DEV=$DEVICE
1019 fi
1020}
1021
plars4a120e82004-09-02 18:56:06 +00001022cleanup()
1023{
Ramesh YR0a78f232013-04-16 09:31:28 +08001024 [ "$LOOP_DEV" ] && losetup -d $LOOP_DEV
yaberauneya6d41cc32010-01-28 16:24:16 +00001025 rm -rf ${TMP}
plars4a120e82004-09-02 18:56:06 +00001026}
1027
Harald Weppner8bdf0a02014-03-03 14:10:07 -08001028
1029LTP_SCRIPT="$(basename $0)"
1030
Cyril Hrubise8776ea2014-03-24 13:32:01 +01001031if [ "$LTP_SCRIPT" = "runltp" ]; then
Harald Weppner8bdf0a02014-03-03 14:10:07 -08001032 trap "cleanup" 0
1033 setup
1034 main "$@"
1035fi