blob: 28e6bed7bed4359d83fb59d894f57803a3099ea8 [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
yaberauneya6d41cc32010-01-28 16:24:16 +000083 [ -d "$LTPROOT/testcases/bin" ] ||
84 {
Garrett Coopercf86b8b2010-11-16 21:46:41 -080085 echo "FATAL: LTP not installed correctly"
86 echo "INFO: Follow directions in INSTALL!"
yaberauneya6d41cc32010-01-28 16:24:16 +000087 exit 1
88 }
89
90 [ -e "$LTPROOT/bin/ltp-pan" ] ||
91 {
92 echo "FATAL: Test suite driver 'ltp-pan' not found"
Garrett Coopercf86b8b2010-11-16 21:46:41 -080093 echo "INFO: Follow directions in INSTALL!"
yaberauneya6d41cc32010-01-28 16:24:16 +000094 exit 1
95 }
plars4a120e82004-09-02 18:56:06 +000096}
97
mreed1091696422006-05-03 19:07:22 +000098version_of_ltp()
99{
yaberauneyaef772532009-10-09 17:55:43 +0000100 cat "$LTPROOT/Version"
yaberauneya6d41cc32010-01-28 16:24:16 +0000101 exit 0
mreed1091696422006-05-03 19:07:22 +0000102}
plars4a120e82004-09-02 18:56:06 +0000103
Chris Dearman37550cf2012-10-17 19:54:01 -0700104usage()
plars4a120e82004-09-02 18:56:06 +0000105{
yaberauneya6d41cc32010-01-28 16:24:16 +0000106 cat <<-EOF >&2
plars4a120e82004-09-02 18:56:06 +0000107
Garrett Cooperf95875a2010-03-05 02:44:39 -0800108 usage: ${0##*/} [ -a EMAIL_TO ] [ -c NUM_PROCS ] [ -C FAILCMDFILE ] [ -d TMPDIR ]
subrata_modake47fb352007-11-25 17:03:49 +0000109 [ -D NUM_PROCS,NUM_FILES,NUM_BYTES,CLEAN_FLAG ] -e [ -f CMDFILES(,...) ] [ -g HTMLFILE]
Chris Dearman37550cf2012-10-17 19:54:01 -0700110 [ -i NUM_PROCS ] [ -l LOGFILE ] [ -m NUM_PROCS,CHUNKS,BYTES,HANGUP_FLAG ]
subrata_modake099b2a2007-10-29 12:22:01 +0000111 -N -n [ -o OUTPUTFILE ] -p -q [ -r LTPROOT ] [ -s PATTERN ] [ -t DURATION ]
subrata_modakd9fb3862008-12-29 11:25:36 +0000112 -v [ -w CMDFILEADDR ] [ -x INSTANCES ] [ -b DEVICE ] [-B DEVICE_FS_TYPE]
yaberauneya6d41cc32010-01-28 16:24:16 +0000113 [ -F LOOPS,PERCENTAGE ]
Chris Dearman37550cf2012-10-17 19:54:01 -0700114
subrata_modak08dde6f2007-11-28 11:02:51 +0000115 -a EMAIL_TO EMAIL all your Reports to this E-mail Address
subrata_modake099b2a2007-10-29 12:22:01 +0000116 -c NUM_PROCS Run LTP under additional background CPU load
117 [NUM_PROCS = no. of processes creating the CPU Load by spinning over sqrt()
118 (Defaults to 1 when value)]
subrata_modakbc833d32007-07-25 10:12:02 +0000119 -C FAILCMDFILE Command file with all failed test cases.
plars4a120e82004-09-02 18:56:06 +0000120 -d TMPDIR Directory where temporary files will be created.
subrata_modake099b2a2007-10-29 12:22:01 +0000121 -D NUM_PROCS,NUM_FILES,NUM_BYTES,CLEAN_FLAG
122 Run LTP under additional background Load on Secondary Storage (Seperate by comma)
123 [NUM_PROCS = no. of processes creating Storage Load by spinning over write()]
124 [NUM_FILES = Write() to these many files (Defaults to 1 when value 0 or undefined)]
125 [NUM_BYTES = write these many bytes (defaults to 1GB, when value 0 or undefined)]
126 [CLEAN_FLAG = unlink file to which random data written, when value 1]
mreed1091696422006-05-03 19:07:22 +0000127 -e Prints the date of the current LTP release
subrata_modakbc833d32007-07-25 10:12:02 +0000128 -f CMDFILES Execute user defined list of testcases (separate with ',')
yaberauneya6d41cc32010-01-28 16:24:16 +0000129 -F LOOPS,PERCENTAGE Induce PERCENTAGE Fault in the Kernel Subsystems, and, run each test for LOOPS loop
subrata_modake47fb352007-11-25 17:03:49 +0000130 -g HTMLFILE Create an additional HTML output format
plars4a120e82004-09-02 18:56:06 +0000131 -h Help. Prints all available options.
subrata_modake099b2a2007-10-29 12:22:01 +0000132 -i NUM_PROCS Run LTP under additional background Load on IO Bus
133 [NUM_PROCS = no. of processes creating IO Bus Load by spinning over sync()]
Subrata Modakbd9d4402010-05-12 22:03:21 +0530134 -K DMESG_LOG_DIR
Chris Dearman37550cf2012-10-17 19:54:01 -0700135 Log Kernel messages generated for each test cases inside this directory
plars4a120e82004-09-02 18:56:06 +0000136 -l LOGFILE Log results of test in a logfile.
subrata_modake099b2a2007-10-29 12:22:01 +0000137 -m NUM_PROCS,CHUNKS,BYTES,HANGUP_FLAG
138 Run LTP under additional background Load on Main memory (Seperate by comma)
139 [NUM_PROCS = no. of processes creating main Memory Load by spinning over malloc()]
140 [CHUNKS = malloc these many chunks (default is 1 when value 0 or undefined)]
141 [BYTES = malloc CHUNKS of BYTES bytes (default is 256MB when value 0 or undefined) ]
142 [HANGUP_FLAG = hang in a sleep loop after memory allocated, when value 1]
yaberauneya6d41cc32010-01-28 16:24:16 +0000143 -M CHECK_TYPE
144 [CHECK_TYPE=1 => Full Memory Leak Check tracing children as well]
145 [CHECK_TYPE=2 => Thread Concurrency Check tracing children as well]
146 [CHECK_TYPE=3 => Full Memory Leak & Thread Concurrency Check tracing children as well]
Chris Dearman37550cf2012-10-17 19:54:01 -0700147 -N Run all the networking tests.
plars4a120e82004-09-02 18:56:06 +0000148 -n Run LTP with network traffic in background.
149 -o OUTPUTFILE Redirect test output to a file.
Chris Dearman37550cf2012-10-17 19:54:01 -0700150 -p Human readable format logfiles.
plars4a120e82004-09-02 18:56:06 +0000151 -q Print less verbose output to screen.
152 -r LTPROOT Fully qualified path where testsuite is installed.
subrata_modaka1fd64b2007-04-11 11:24:49 +0000153 -s PATTERN Only run test cases which match PATTERN.
subrata_modak2f6c9812009-08-14 17:07:48 +0000154 -S SKIPFILE Skip tests specified in SKIPFILE
plars4a120e82004-09-02 18:56:06 +0000155 -t DURATION Execute the testsuite for given duration. Examples:
156 -t 60s = 60 seconds
157 -t 45m = 45 minutes
158 -t 24h = 24 hours
159 -t 2d = 2 days
subrata_modak8c138332008-01-28 11:19:32 +0000160 -T REPETITION Execute the testsuite for REPETITION no. of times
subrata_modakbc833d32007-07-25 10:12:02 +0000161 -w CMDFILEADDR Uses wget to get the user's list of testcases.
plars4a120e82004-09-02 18:56:06 +0000162 -x INSTANCES Run multiple instances of this testsuite.
subrata_modakd9fb3862008-12-29 11:25:36 +0000163 -b DEVICE Some tests require an unmounted block device
164 to run correctly.
165 -B DEVICE_FS_TYPE The file system of test block devices.
166
plars4a120e82004-09-02 18:56:06 +0000167
Garrett Cooperf95875a2010-03-05 02:44:39 -0800168 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 +0000169
plars4a120e82004-09-02 18:56:06 +0000170
yaberauneya6d41cc32010-01-28 16:24:16 +0000171 EOF
172exit 0
plars4a120e82004-09-02 18:56:06 +0000173}
174
plars4a120e82004-09-02 18:56:06 +0000175main()
176{
subrata_modakbc833d32007-07-25 10:12:02 +0000177 local CMDFILES=""
plars4a120e82004-09-02 18:56:06 +0000178 local PRETTY_PRT=""
subrata_modak5d7deea2007-09-15 13:51:36 +0000179 local ALT_DIR_OUT=0
180 local ALT_DIR_RES=0
subrata_modake47fb352007-11-25 17:03:49 +0000181 local ALT_HTML_OUT=0
subrata_modak08dde6f2007-11-28 11:02:51 +0000182 local ALT_EMAIL_OUT=0
Subrata Modakbd9d4402010-05-12 22:03:21 +0530183 local ALT_DMESG_OUT=0
plars4a120e82004-09-02 18:56:06 +0000184 local RUN_NETEST=0
subrata_modak8c138332008-01-28 11:19:32 +0000185 local RUN_REPEATED=0
yaberauneya6d41cc32010-01-28 16:24:16 +0000186 local QUIET_MODE=""
plars4a120e82004-09-02 18:56:06 +0000187 local NETPIPE=0
188 local GENLOAD=0
189 local MEMSIZE=0
190 local DURATION=""
subrata_modakbc833d32007-07-25 10:12:02 +0000191 local CMDFILEADDR=""
subrata_modak43938212008-05-19 08:48:46 +0000192 local FAILCMDFILE=""
yaberauneyaef772532009-10-09 17:55:43 +0000193 local INJECT_KERNEL_FAULT=""
194 local INJECT_KERNEL_FAULT_PERCENTAGE=""
195 local INJECT_FAULT_LOOPS_PER_TEST=""
196 local VALGRIND_CHECK=""
197 local VALGRIND_CHECK_TYPE=""
subrata_modake47fb352007-11-25 17:03:49 +0000198 local LOGFILE_NAME=""
plars4a120e82004-09-02 18:56:06 +0000199 local LOGFILE=""
subrata_modake47fb352007-11-25 17:03:49 +0000200 local OUTPUTFILE_NAME=""
201 local OUTPUTFILE=""
202 local HTMLFILE_NAME=""
203 local HTMLFILE=""
Subrata Modakbd9d4402010-05-12 22:03:21 +0530204 local DMESG_DIR=""
subrata_modak08dde6f2007-11-28 11:02:51 +0000205 local EMAIL_TO=""
robbiew7d43d772005-02-07 20:07:30 +0000206 local TAG_RESTRICT_STRING=""
207 local PAN_COMMAND=""
subrata_modak43938212008-05-19 08:48:46 +0000208 local DEFAULT_FILE_NAME_GENERATION_TIME=`date +"%Y_%b_%d-%Hh_%Mm_%Ss"`
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800209
210 local scenfile=
211
yaberauneyaef772532009-10-09 17:55:43 +0000212 version_date=$(cat "$LTPROOT/Version")
plars4a120e82004-09-02 18:56:06 +0000213
Subrata Modakbd9d4402010-05-12 22:03:21 +0530214 while getopts a:c:C:d:D:f:F:ehi:K:g:l:m:M:Nno:pqr:s:S:t:T:w:x:b:B: arg
yaberauneya6d41cc32010-01-28 16:24:16 +0000215 do case $arg in
subrata_modak08dde6f2007-11-28 11:02:51 +0000216 a) EMAIL_TO=$OPTARG
217 ALT_EMAIL_OUT=1;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700218 c)
subrata_modake099b2a2007-10-29 12:22:01 +0000219 NUM_PROCS=$(($OPTARG))
220 if [ "$NUM_PROCS" -eq 0 ]; then
221 # User Did not Define the Value ,or, User Defined Zero,
222 # hence, prevent from creating infinite processes
223 NUM_PROCS=1
224 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000225 $LTPROOT/testcases/bin/genload --cpu $NUM_PROCS >/dev/null 2>&1 &
plars4a120e82004-09-02 18:56:06 +0000226 GENLOAD=1 ;;
subrata_modakbc833d32007-07-25 10:12:02 +0000227
Chris Dearman37550cf2012-10-17 19:54:01 -0700228 C)
subrata_modak6838ec32007-09-14 10:10:12 +0000229 case $OPTARG in
230 /*)
231 FAILCMDFILE="-C $OPTARG" ;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700232 *)
subrata_modak6838ec32007-09-14 10:10:12 +0000233 FAILCMDFILE="-C $LTPROOT/output/$OPTARG"
subrata_modak5d7deea2007-09-15 13:51:36 +0000234 ALT_DIR_OUT=1 ;;
subrata_modak6838ec32007-09-14 10:10:12 +0000235 esac ;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700236
subrata_modak5ee3e892008-10-21 13:17:56 +0000237 d) # convert the user path to absolute path.
Garrett Cooper5d520f42012-08-07 08:57:31 -0700238 export TMPBASE=$(readlink -f ${OPTARG}) ;;
subrata_modake099b2a2007-10-29 12:22:01 +0000239
240 D) NUM_PROCS=1; NUM_FILES=1; NUM_BYTES=$((1024 * 1024 * 1024)); CLEAN_FLAG=0
subrata_modak548379d2008-08-20 09:15:49 +0000241 ARGUMENT_LIST=$OPTARG
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800242 TOTAL_ARGUMENTS=1
243 for ARGUMENT in `echo "$ARGUMENT_LIST" | tr ',' ' '`
subrata_modake099b2a2007-10-29 12:22:01 +0000244 do
245 case $TOTAL_ARGUMENTS in
yaberauneya6d41cc32010-01-28 16:24:16 +0000246 1) NUM_PROCS="$ARGUMENT" ;;
247 2) NUM_FILES="$ARGUMENT" ;;
248 3) NUM_BYTES="$ARGUMENT" ;;
249 4) CLEAN_FLAG="$ARGUMENT" ;;
subrata_modake099b2a2007-10-29 12:22:01 +0000250 esac
yaberauneya6d41cc32010-01-28 16:24:16 +0000251 TOTAL_ARGUMENTS=`expr $TOTAL_ARGUMENTS + 1`
subrata_modake099b2a2007-10-29 12:22:01 +0000252 done
253 # just to get the default values if the user passed 0
254 if [ "$NUM_PROCS" -eq 0 ]; then
255 NUM_PROCS=1
256 fi
257 if [ "$NUM_FILES" -eq 0 ]; then
258 NUM_FILES=1
259 fi
260 if [ "$NUM_BYTES" -eq 0 ]; then
261 NUM_BYTES=$((1024 * 1024 * 1024))
262 fi
263 if [ "$CLEAN_FLAG" -ne 1 ]; then
264 CLEAN_FLAG=0
265 fi
266 if [ "$CLEAN_FLAG" -eq 1 ]; then
267 # Do not unlink file in this case
yaberauneya6d41cc32010-01-28 16:24:16 +0000268 $LTPROOT/testcases/bin/genload --hdd $NUM_PROCS --hdd-files \
subrata_modake099b2a2007-10-29 12:22:01 +0000269 $NUM_FILES --hdd-bytes $NUM_BYTES >/dev/null 2>&1 &
270 else
271 # Cleanup otherwise
yaberauneya6d41cc32010-01-28 16:24:16 +0000272 $LTPROOT/testcases/bin/genload --hdd $NUM_PROCS --hdd-files \
subrata_modake099b2a2007-10-29 12:22:01 +0000273 $NUM_FILES --hdd-bytes $NUM_BYTES --hdd-noclean >/dev/null 2>&1 &
274 fi
275 GENLOAD=1;;
276
mreed1091696422006-05-03 19:07:22 +0000277 e) # Print out the version of LTP
278 version_of_ltp
yaberauneya6d41cc32010-01-28 16:24:16 +0000279 ;;
plars4a120e82004-09-02 18:56:06 +0000280 f) # Execute user defined set of testcases.
subrata_modakbc833d32007-07-25 10:12:02 +0000281 # Can be more then one file, just separate it with ',', like:
282 # -f nfs,commands,/tmp/testfile
283 CMDFILES=$OPTARG;;
yaberauneya6d41cc32010-01-28 16:24:16 +0000284 F) INJECT_KERNEL_FAULT=1
285 #Seperate out the NO_OF_LOOPS & FAULT_PERCENTAGE
286 INJECT_FAULT_LOOPS_PER_TEST=`echo $OPTARG |cut -d',' -f1 | tr -d '\n' | tr -d ' '`
287 INJECT_KERNEL_FAULT_PERCENTAGE=`echo $OPTARG |cut -d',' -f2 | tr -d '\n' | tr -d ' '`
288 if [ ! $INJECT_FAULT_LOOPS_PER_TEST ]; then
289 echo "Loops not properly defined. Resorting to default 5..."
290 export INJECT_FAULT_LOOPS_PER_TEST=5
291 fi
292 if [ ! $INJECT_KERNEL_FAULT_PERCENTAGE ]; then
293 echo "Fault Persentage not properly defined. Resorting to default 10..."
294 export INJECT_KERNEL_FAULT_PERCENTAGE=10
295 fi;;
subrata_modake47fb352007-11-25 17:03:49 +0000296 g) HTMLFILE_NAME="$OPTARG"
297 case $OPTARG in
298 /*)
299 HTMLFILE="$OPTARG";;
300 *)
subrata_modakd48c4d02008-01-23 12:59:40 +0000301 HTMLFILE="$LTPROOT/output/$OPTARG";;
302 esac
Chris Dearman37550cf2012-10-17 19:54:01 -0700303 ALT_DIR_OUT=1
subrata_modakd48c4d02008-01-23 12:59:40 +0000304 ALT_HTML_OUT=1;;
plars4a120e82004-09-02 18:56:06 +0000305 h) usage;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700306
subrata_modake099b2a2007-10-29 12:22:01 +0000307 i)
308 NUM_PROCS=$(($OPTARG))
309 if [ "$NUM_PROCS" -eq 0 ]; then
310 # User Did not Define the Value ,or, User Defined Zero,
311 # hence, prevent from creating infinite processes
312 NUM_PROCS=1
313 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000314 $LTPROOT/testcases/bin/genload --io $NUM_PROCS >/dev/null 2>&1 &
plars4a120e82004-09-02 18:56:06 +0000315 GENLOAD=1 ;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700316
317 K)
Subrata Modakbd9d4402010-05-12 22:03:21 +0530318 case $OPTARG in
319 /*)
320 DMESG_DIR="$OPTARG-dmesg-output-`echo $$-``date +%X | tr -d ' '`";;
321 *)
322 DMESG_DIR="$LTPROOT/output/$OPTARG-dmesg-output-`echo $$-``date +%X | tr -d ' '`";;
323 esac
324 mkdir -p $DMESG_DIR
325 ALT_DMESG_OUT=1;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700326 l)
subrata_modak6838ec32007-09-14 10:10:12 +0000327 LOGFILE_NAME="$OPTARG"
plars4a120e82004-09-02 18:56:06 +0000328 case $OPTARG in
subrata_modak5d7deea2007-09-15 13:51:36 +0000329 /*)
plars4a120e82004-09-02 18:56:06 +0000330 LOGFILE="-l $OPTARG" ;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700331 *)
plars4a120e82004-09-02 18:56:06 +0000332 LOGFILE="-l $LTPROOT/results/$OPTARG"
subrata_modak5d7deea2007-09-15 13:51:36 +0000333 ALT_DIR_RES=1 ;;
plars4a120e82004-09-02 18:56:06 +0000334 esac ;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700335
subrata_modake099b2a2007-10-29 12:22:01 +0000336 m) NUM_PROCS=1; CHUNKS=1; BYTES=$((256 * 1024 * 1024)); HANGUP_FLAG=0
subrata_modak29a96d82008-08-27 13:34:46 +0000337 ARGUMENT_LIST=$OPTARG
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800338 TOTAL_ARGUMENTS=1
339 for ARGUMENT in `echo "$ARGUMENT_LIST" | tr ',' ' '`
subrata_modake099b2a2007-10-29 12:22:01 +0000340 do
341 case $TOTAL_ARGUMENTS in
yaberauneya6d41cc32010-01-28 16:24:16 +0000342 1) NUM_PROCS="$ARGUMENT" ;;
343 2) CHUNKS="$ARGUMENT" ;;
344 3) BYTES="$ARGUMENT" ;;
345 4) HANGUP_FLAG="$ARGUMENT" ;;
subrata_modake099b2a2007-10-29 12:22:01 +0000346 esac
yaberauneya6d41cc32010-01-28 16:24:16 +0000347 TOTAL_ARGUMENTS=`expr $TOTAL_ARGUMENTS + 1`
subrata_modake099b2a2007-10-29 12:22:01 +0000348 done
349 # just to get the default values if the user passed 0
yaberauneya6d41cc32010-01-28 16:24:16 +0000350 if [ "$NUM_PROCS" -eq 0 ]; then
351 NUM_PROCS=1
352 fi
353 if [ "$CHUNKS" -eq 0 ]; then
354 CHUNKS=1
355 fi
356 if [ "$BYTES" -eq 0 ]; then
357 BYTES=$((256 * 1024 * 1024))
358 fi
359 if [ "$HANGUP_FLAG" -ne 1 ]; then
360 HANGUP_FLAG=0
361 fi
subrata_modake099b2a2007-10-29 12:22:01 +0000362 if [ "$HANGUP_FLAG" -eq 1 ]; then
363 # Hang in a Sleep loop after memory allocated
yaberauneya6d41cc32010-01-28 16:24:16 +0000364 $LTPROOT/testcases/bin/genload --vm $NUM_PROCS --vm-chunks \
subrata_modake099b2a2007-10-29 12:22:01 +0000365 $CHUNKS --vm-bytes $BYTES --vm-hang >/dev/null 2>&1 &
366 else
367 # Otherwise Do not Hangup
yaberauneya6d41cc32010-01-28 16:24:16 +0000368 $LTPROOT/testcases/bin/genload --vm $NUM_PROCS --vm-chunks \
subrata_modake099b2a2007-10-29 12:22:01 +0000369 $CHUNKS --vm-bytes $BYTES >/dev/null 2>&1 &
370 fi
plars4a120e82004-09-02 18:56:06 +0000371 GENLOAD=1;;
yaberauneya6d41cc32010-01-28 16:24:16 +0000372 M)
373 VALGRIND_CHECK=1
374 VALGRIND_CHECK_TYPE="$OPTARG";;
subrata_modak9c7072a2009-08-26 07:00:25 +0000375
plars4a120e82004-09-02 18:56:06 +0000376 N) RUN_NETEST=1;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700377
378 n)
yaberauneya6d41cc32010-01-28 16:24:16 +0000379 $LTPROOT/testcases/bin/netpipe.sh
plars4a120e82004-09-02 18:56:06 +0000380 NETPIPE=1;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700381
subrata_modak6838ec32007-09-14 10:10:12 +0000382 o) OUTPUTFILE_NAME="$OPTARG"
subrata_modak6838ec32007-09-14 10:10:12 +0000383 case $OPTARG in
384 /*)
385 OUTPUTFILE="-o $OPTARG";;
386 *)
387 OUTPUTFILE="-o $LTPROOT/output/$OPTARG"
subrata_modak5d7deea2007-09-15 13:51:36 +0000388 ALT_DIR_OUT=1 ;;
yaberauneya6d41cc32010-01-28 16:24:16 +0000389 esac ;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700390
plars4a120e82004-09-02 18:56:06 +0000391 p) PRETTY_PRT=" -p ";;
Chris Dearman37550cf2012-10-17 19:54:01 -0700392
yaberauneya6d41cc32010-01-28 16:24:16 +0000393 q) QUIET_MODE=" -q ";;
Chris Dearman37550cf2012-10-17 19:54:01 -0700394
plars4a120e82004-09-02 18:56:06 +0000395 r) LTPROOT=$OPTARG;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700396
robbiew7d43d772005-02-07 20:07:30 +0000397 s) TAG_RESTRICT_STRING=$OPTARG;;
subrata_modak2f6c9812009-08-14 17:07:48 +0000398
yaberauneya6d41cc32010-01-28 16:24:16 +0000399 S) case $OPTARG in
subrata_modak2f6c9812009-08-14 17:07:48 +0000400 /*)
401 SKIPFILE=$OPTARG;;
402 *)
403 SKIPFILE="$LTPROOT/$OPTARG";;
yaberauneya6d41cc32010-01-28 16:24:16 +0000404 esac ;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700405
406 t) # In case you want to specify the time
407 # to run from the command line
plars4a120e82004-09-02 18:56:06 +0000408 # (2m = two minutes, 2h = two hours, etc)
409 DURATION="-t $OPTARG" ;;
subrata_modak8c138332008-01-28 11:19:32 +0000410
411 T) # In case you want the testcases to runsequentially RUN_REPEATED times
412 RUN_REPEATED=$OPTARG;;
413
subrata_modakbc833d32007-07-25 10:12:02 +0000414 w) CMDFILEADDR=$OPTARG;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700415
plars4a120e82004-09-02 18:56:06 +0000416 x) # number of ltp's to run
yaberauneya6d41cc32010-01-28 16:24:16 +0000417 cat <<-EOF >&1
418 WARNING: The use of -x can cause unpredictable failures, as a
419 result of concurrently running multiple tests designed
420 to be ran exclusively.
421 Pausing for 10 seconds..."
422 EOF
Chris Dearman37550cf2012-10-17 19:54:01 -0700423 sleep 10
yaberauneya6d41cc32010-01-28 16:24:16 +0000424 INSTANCES="-x $OPTARG";;
subrata_modakd9fb3862008-12-29 11:25:36 +0000425 b) DEVICE=$OPTARG;;
426 B) DEVICE_FS_TYPE=$OPTARG;;
plars4a120e82004-09-02 18:56:06 +0000427 \?) usage;;
428 esac
429 done
subrata_modak43938212008-05-19 08:48:46 +0000430
431 ## It would be nice to create a default log file even if the user has not mentioned
432 if [ ! "$LOGFILE" ]; then ## User has not mentioned about Log File name
433 LOGFILE_NAME=$DEFAULT_FILE_NAME_GENERATION_TIME
434 LOGFILE="-l $LTPROOT/results/LTP_RUN_ON-$LOGFILE_NAME.log"
435 ALT_DIR_RES=1
436 PRETTY_PRT=" -p "
437 fi
Chris Dearman37550cf2012-10-17 19:54:01 -0700438
439 ## 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 +0000440
yaberauneya6d41cc32010-01-28 16:24:16 +0000441 if [ ! "$FAILCMDFILE" ]; then ## User has not mentioned about Failed File name
subrata_modak5d7deea2007-09-15 13:51:36 +0000442 ALT_DIR_OUT=1
yaberauneya6d41cc32010-01-28 16:24:16 +0000443 if [ ! "$OUTPUTFILE" ]; then ## User has not mentioned about Output File name either
444 if [ ! "$LOGFILE" ]; then ## User has not mentioned about Log File name either
445 FAILED_FILE_NAME=$DEFAULT_FILE_NAME_GENERATION_TIME
446 FAILCMDFILE="-C $LTPROOT/output/LTP_RUN_ON-$FAILED_FILE_NAME.failed"
447 else ## User Fortunately wanted a log file,
448 FAILED_FILE_NAME=`basename $LOGFILE_NAME` ## Extract log file name and use it to construct Failed file name
449 FAILCMDFILE="-C $LTPROOT/output/LTP_RUN_ON-$FAILED_FILE_NAME.failed"
subrata_modak6838ec32007-09-14 10:10:12 +0000450 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000451 else ## User Fortunately wanted a Output file
452 FAILED_FILE_NAME=`basename $OUTPUTFILE_NAME` ## Extract output file name and use it to construct Failed file name
453 FAILCMDFILE="-C $LTPROOT/output/LTP_RUN_ON-$FAILED_FILE_NAME.failed"
subrata_modak6838ec32007-09-14 10:10:12 +0000454 fi
455 fi
subrata_modaka1fd64b2007-04-11 11:24:49 +0000456
subrata_modakd48c4d02008-01-23 12:59:40 +0000457 if [ "$ALT_HTML_OUT" -eq 1 ] ; then ## User wants the HTML version of the output
yaberauneya6d41cc32010-01-28 16:24:16 +0000458 QUIET_MODE="" ## Suppressing this guy as it will prevent generation of proper output
subrata_modakd48c4d02008-01-23 12:59:40 +0000459 ## which the HTML parser will require
yaberauneya6d41cc32010-01-28 16:24:16 +0000460 if [ ! "$OUTPUTFILE" ]; then ## User has not mentioned about the Outputfile name, then we need to definitely generate one
subrata_modak43938212008-05-19 08:48:46 +0000461 OUTPUTFILE_NAME=$DEFAULT_FILE_NAME_GENERATION_TIME
subrata_modake47fb352007-11-25 17:03:49 +0000462 OUTPUTFILE="-o $LTPROOT/output/LTP_RUN_ON-$OUTPUTFILE_NAME.output"
subrata_modak08dde6f2007-11-28 11:02:51 +0000463 ALT_DIR_OUT=1
yaberauneya6d41cc32010-01-28 16:24:16 +0000464 if [ ! "$HTMLFILE" ] ; then ## User has not mentioned HTML File name, We need to create one
465 HTMLFILE_NAME=`basename $OUTPUTFILE_NAME`
subrata_modake47fb352007-11-25 17:03:49 +0000466 HTMLFILE="$LTPROOT/output/$HTMLFILE_NAME.html"
467 fi
468 fi
469 fi
470
subrata_modak5d7deea2007-09-15 13:51:36 +0000471 # If we need, create the output directory
yaberauneya6d41cc32010-01-28 16:24:16 +0000472 [ "$ALT_DIR_OUT" -eq 1 ] && \
473 {
474 [ ! -d $LTPROOT/output ] && \
475 {
476 echo "INFO: creating $LTPROOT/output directory"
477 mkdir -p $LTPROOT/output || \
478 {
479 echo "ERROR: failed to create $LTPROOT/output"
480 exit 1
481 }
482 }
483 }
subrata_modak5d7deea2007-09-15 13:51:36 +0000484 # If we need, create the results directory
yaberauneya6d41cc32010-01-28 16:24:16 +0000485 [ "$ALT_DIR_RES" -eq 1 ] && \
486 {
487 echo "INFO: creating $LTPROOT/results directory"
488 [ ! -d $LTPROOT/results ] && \
489 {
490 mkdir -p $LTPROOT/results || \
491 {
492 echo "ERROR: failed to create $LTPROOT/results"
493 exit 1
494 }
495 }
496 }
subrata_modak5d7deea2007-09-15 13:51:36 +0000497
Chris Dearman37550cf2012-10-17 19:54:01 -0700498 # Added -m 777 for tests that call tst_tmpdir() and try to
subrata_modaka1fd64b2007-04-11 11:24:49 +0000499 # write to it as user nobody
yaberauneya6d41cc32010-01-28 16:24:16 +0000500 mkdir -m 777 -p $TMPBASE || \
501 {
502 echo "FATAL: Unable to make temporary directory $TMPBASE"
503 exit 1
504 }
subrata_modak5ee3e892008-10-21 13:17:56 +0000505 # use mktemp to create "safe" temporary directories
506 export TMPTEMPLATE="${TMPBASE}/ltp-XXXXXXXXXX"
yaberauneya6d41cc32010-01-28 16:24:16 +0000507 TMP=`mktemp -d $TMPTEMPLATE` || \
508 {
509 echo "FATAL: Unable to make temporary directory: $TMP"
510 exit 1
511 }
512 export TMP
subrata_modak225cfbe2009-06-23 14:01:26 +0000513 # To be invoked by tst_tmpdir()
514 # write to it as user nobody
515 export TMPDIR=$TMP
subrata_modak6edfbda2008-10-17 12:25:48 +0000516
yaberauneya6d41cc32010-01-28 16:24:16 +0000517 chmod 777 $TMP || \
518 {
519 echo "unable to chmod 777 $TMP ... aborting"
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800520 exit 1
yaberauneya6d41cc32010-01-28 16:24:16 +0000521 }
Chris Dearman37550cf2012-10-17 19:54:01 -0700522
yaberauneya6d41cc32010-01-28 16:24:16 +0000523 cd $TMP || \
524 {
525 echo "could not cd ${TMP} ... exiting"
526 exit 1
527 }
Chris Dearman37550cf2012-10-17 19:54:01 -0700528
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800529 [ -n "$INSTANCES" ] && \
yaberauneya6d41cc32010-01-28 16:24:16 +0000530 {
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800531 INSTANCES="$INSTANCES -O ${TMP}"
yaberauneya6d41cc32010-01-28 16:24:16 +0000532 }
Chris Dearman37550cf2012-10-17 19:54:01 -0700533
yaberauneya6d41cc32010-01-28 16:24:16 +0000534 [ "$RUN_NETEST" -eq 1 ] && \
535 {
536 [ -z "$RHOST" ] || [ -z "$PASSWD" ] && \
537 {
538 [ -z "$RHOST" ] && \
539 {
plars4a120e82004-09-02 18:56:06 +0000540 echo \
541 "INFO: Enter RHOST = 'name of the remote host machine'"
542 echo -n "-> "
543 read RHOST
yaberauneya6d41cc32010-01-28 16:24:16 +0000544 }
plars4a120e82004-09-02 18:56:06 +0000545
yaberauneya6d41cc32010-01-28 16:24:16 +0000546 [ -z "$PASSWD" ] && \
547 {
548 echo " "
plars4a120e82004-09-02 18:56:06 +0000549 echo \
550 "INFO: Enter PASSWD = 'root passwd of the remote host machine'"
551 echo -n "-> "
552 read PASSWD
yaberauneya6d41cc32010-01-28 16:24:16 +0000553 }
plars4a120e82004-09-02 18:56:06 +0000554 export RHOST=$RHOST
555 export PASSWD=$PASSWD
yaberauneya6d41cc32010-01-28 16:24:16 +0000556 echo "WARNING: security of $RHOST may be compromised"
557 }
558 }
Chris Dearman37550cf2012-10-17 19:54:01 -0700559
plars4a120e82004-09-02 18:56:06 +0000560 # If user does not provide a command file select a default set of testcases
561 # to execute.
yaberauneya6d41cc32010-01-28 16:24:16 +0000562 if [ -z "$CMDFILES" ] && [ -z "$CMDFILEADDR" ]
563 then
564 cat <<-EOF >&1
plars4a120e82004-09-02 18:56:06 +0000565
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800566 INFO: no command files were provided. Will execute the following
567 runtest scenario files:
Garrett Cooper66d67b52010-11-16 22:42:48 -0800568
569`cat $LTPROOT/scenario_groups/default | tr '\012' ' '`
Chris Dearman37550cf2012-10-17 19:54:01 -0700570
yaberauneya6d41cc32010-01-28 16:24:16 +0000571 EOF
plars4a120e82004-09-02 18:56:06 +0000572
Garrett Cooper89fde872010-11-16 22:38:08 -0800573 SCENARIO_LISTS="$LTPROOT/scenario_groups/default"
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800574 if [ "$RUN_NETEST" -eq 1 ]; then
Garrett Cooper89fde872010-11-16 22:38:08 -0800575 SCENARIO_LISTS="$SCENARIO_LISTS $LTPROOT/scenario_groups/network"
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800576 fi
plars4a120e82004-09-02 18:56:06 +0000577
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800578 # DO NOT INDENT/DEDENT!
579 if [ -n "$SCENARIO_LISTS" ]; then
580 # Insurance to make sure that the first element in the pipe
581 # completed successfully.
582 cat_ok_sentinel=$TMP/cat_ok.$$
Garrett Cooper66d67b52010-11-16 22:42:48 -0800583 (cat $SCENARIO_LISTS && touch "$cat_ok_sentinel") | \
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800584 while read scenfile; do
585
586 scenfile=${LTPROOT}/runtest/$scenfile
587
588 # Skip over non-existent scenario files; things are
589 # robust enough now that the build will fail if these
590 # files don't exist.
591 [ -f "$scenfile" ] || continue
592
593 cat $scenfile >> "$TMP/alltests" || {
594 echo "FATAL: unable to append to command file"
595 rm -Rf "$TMP"
596 rm -f "$cat_ok_sentinel"
597 exit 1
598 }
599
600 done
601
602 rm -f "$cat_ok_sentinel"
603
604 fi
605 # ^^DO NOT INDENT/DEDENT!^^
606
subrata_modakbc833d32007-07-25 10:12:02 +0000607 fi
608
yaberauneya6d41cc32010-01-28 16:24:16 +0000609 [ -n "$CMDFILES" ] && \
610 {
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800611 for scenfile in `echo "$CMDFILES" | tr ',' ' '`
yaberauneya6d41cc32010-01-28 16:24:16 +0000612 do
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800613 [ -f "$scenfile" ] || scenfile="$LTPROOT/runtest/$scenfile"
614 cat "$scenfile" >> ${TMP}/alltests || \
yaberauneya6d41cc32010-01-28 16:24:16 +0000615 {
616 echo "FATAL: unable to create command file"
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800617 rm -Rf "$TMP"
yaberauneya6d41cc32010-01-28 16:24:16 +0000618 exit 1
619 }
plars4a120e82004-09-02 18:56:06 +0000620 done
yaberauneya6d41cc32010-01-28 16:24:16 +0000621 }
Chris Dearman37550cf2012-10-17 19:54:01 -0700622
yaberauneya6d41cc32010-01-28 16:24:16 +0000623 [ -n "$CMDFILEADDR" ] && \
624 {
625 wget -q "${CMDFILEADDR}" -O ${TMP}/wgetcmdfile
626 if [ $? -ne 0 ]; then
627 echo "FATAL: error while getting the command file with wget (address $CMDFILEADDR)"
628 exit 1
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000629 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000630 cat "${TMP}/wgetcmdfile" >> ${TMP}/alltests || \
631 {
632 echo "FATAL: unable to create command file"
633 exit 1
634 }
635 }
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000636
plars4a120e82004-09-02 18:56:06 +0000637 # The fsx-linux tests use the SCRATCHDEV environment variable as a location
Chris Dearman37550cf2012-10-17 19:54:01 -0700638 # that can be reformatted and run on. Set SCRATCHDEV if you want to run
plars4a120e82004-09-02 18:56:06 +0000639 # these tests. As a safeguard, this is disabled.
640 unset SCRATCHDEV
yaberauneya6d41cc32010-01-28 16:24:16 +0000641 [ -n "$SCRATCHDEV" ] && \
642 {
643 cat ${LTPROOT}/runtest/fsx >> ${TMP}/alltests ||
644 {
645 echo "FATAL: unable to create fsx-linux tests command file"
646 exit 1
647 }
648 }
subrata_modakbc833d32007-07-25 10:12:02 +0000649
650 # If enabled, execute only test cases that match the PATTERN
yaberauneya6d41cc32010-01-28 16:24:16 +0000651 if [ -n "$TAG_RESTRICT_STRING" ]
652 then
653 mv -f ${TMP}/alltests ${TMP}/alltests.orig
654 grep $TAG_RESTRICT_STRING ${TMP}/alltests.orig > ${TMP}/alltests #Not worth checking return codes for this case
subrata_modakbc833d32007-07-25 10:12:02 +0000655 fi
subrata_modak2f6c9812009-08-14 17:07:48 +0000656
657 # Blacklist or skip tests if a SKIPFILE was specified with -S
yaberauneya6d41cc32010-01-28 16:24:16 +0000658 if [ -n "$SKIPFILE" ]
659 then
subrata_modak2f6c9812009-08-14 17:07:48 +0000660 for file in $( cat $SKIPFILE ); do
Andrew Chen410c6952011-06-30 14:19:45 +0800661 sed -i "/^$file[ \t]/d" ${TMP}/alltests
subrata_modak2f6c9812009-08-14 17:07:48 +0000662 done
663 fi
Chris Dearman37550cf2012-10-17 19:54:01 -0700664
plars4a120e82004-09-02 18:56:06 +0000665 # check for required users and groups
Cyril Hrubisb88fa5b2013-06-25 15:50:08 +0200666 ${LTPROOT}/IDcheck.sh || \
yaberauneya6d41cc32010-01-28 16:24:16 +0000667 {
668 echo "WARNING: required users and groups not present"
669 echo "WARNING: some test cases may fail"
670 }
Chris Dearman37550cf2012-10-17 19:54:01 -0700671
plars4a120e82004-09-02 18:56:06 +0000672 # display versions of installed software
yaberauneya6d41cc32010-01-28 16:24:16 +0000673 [ -z "$QUIET_MODE" ] && \
Chris Dearman37550cf2012-10-17 19:54:01 -0700674 {
yaberauneya6d41cc32010-01-28 16:24:16 +0000675 ${LTPROOT}/ver_linux || \
676 {
677 echo "WARNING: unable to display versions of software installed"
678 exit 1
679 }
680 }
681
682 if [ -n "$DEVICE" ]; then
683 sed -i "s|DEVICE|$DEVICE|" ${TMP}/alltests
Ramesh YR0a78f232013-04-16 09:31:28 +0800684 RC=$?
yaberauneya6d41cc32010-01-28 16:24:16 +0000685 else
Ramesh YR0a78f232013-04-16 09:31:28 +0800686 create_block
687 if [ $? -eq 0 ]; then
688 sed -i "s|DEVICE|$DEVICE|" ${TMP}/alltests
689 RC=$?
690 else
691 echo "no block device was specified on commandline."
692 echo "Block device could not be created using loopback device"
693 echo "Tests which require block device are disabled."
694 echo "You can specify it with option -b"
695 sed -i "/DEVICE/d" ${TMP}/alltests
696 RC=$?
697 fi
subrata_modakd9fb3862008-12-29 11:25:36 +0000698 fi
699
Ramesh YR0a78f232013-04-16 09:31:28 +0800700 if [ $RC -ne 0 ]; then
701 echo "FATAL: error during processing alltests file by sed"
yaberauneya6d41cc32010-01-28 16:24:16 +0000702 exit 1
703 fi
704
705 if [ -n "$DEVICE" ]; then
Simon Xu47d716b2012-08-02 23:42:11 +0800706 mnt_pnt=`mktemp -d "${TMP}/mnt_pnt.XXXXXX"`
subrata_modakd9fb3862008-12-29 11:25:36 +0000707 if [ -n "$DEVICE_FS_TYPE" ]; then
708 mount -t $DEVICE_FS_TYPE $DEVICE $mnt_pnt
709 else
710 mount $DEVICE $mnt_pnt
711 fi
712
713 if [ $? -ne 0 ]; then
yaberauneya6d41cc32010-01-28 16:24:16 +0000714 echo "FATAL: can't mount block device $DEVICE."
715 exit 1
subrata_modakd9fb3862008-12-29 11:25:36 +0000716 fi
717
718 if [ -z "$DEVICE_FS_TYPE" ]; then
yaberauneya6d41cc32010-01-28 16:24:16 +0000719 DEVICE_FS_TYPE=`cat /proc/mounts | awk "{if (\\\$1 == \"$DEVICE\") print \\\$3; }"`
720 echo "determine file system $DEVICE_FS_TYPE on block device $DEVICE"
subrata_modakd9fb3862008-12-29 11:25:36 +0000721 fi
722
yaberauneya6d41cc32010-01-28 16:24:16 +0000723 umount $DEVICE
724 if [ $? -ne 0 ]; then
725 echo "FATAL: can't umount $DEVICE"
726 exit 1
subrata_modakd9fb3862008-12-29 11:25:36 +0000727 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000728 rm -rf $mnt_pnt
subrata_modakd9fb3862008-12-29 11:25:36 +0000729 fi
730
yaberauneya6d41cc32010-01-28 16:24:16 +0000731 if [ -n "$DEVICE" ]; then
Wanlong Gao0b6c3562012-06-22 10:35:35 +0800732 sed -i "s|DEVICE_FS_TYPE|$DEVICE_FS_TYPE|" ${TMP}/alltests
yaberauneya6d41cc32010-01-28 16:24:16 +0000733 fi
734
735 if [ $? -ne 0 ]; then
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800736 echo "FATAL: error during processing alltests file by sed"
yaberauneya6d41cc32010-01-28 16:24:16 +0000737 exit 1
subrata_modakd9fb3862008-12-29 11:25:36 +0000738 fi
739
subrata_modak8c138332008-01-28 11:19:32 +0000740 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 +0000741 echo "PAN will run these test cases $RUN_REPEATED times....."
742 echo "Test Tags will be Prepended with ITERATION NO.s....."
743 inc=1
744 sed -e '/^$/ d' -e 's/^[ ,\t]*//' -e '/^#/ d' < ${TMP}/alltests > ${TMP}/alltests.temp ##This removes all newlines, leading spaces, tabs, #
745 sed 's/^[0-9,a-z,A-Z]*/'"$inc"'_ITERATION_&/' < ${TMP}/alltests.temp > ${TMP}/alltests ## .temp is kept as Base file
746 while [ $inc -lt $RUN_REPEATED ] ; do
747 inc=`expr $inc + 1`
748 sed 's/^[0-9,a-z,A-Z]*/'"$inc"'_ITERATION_&/' < ${TMP}/alltests.temp >> ${TMP}/alltests #Keep appending with Iteration No.s
749 done
subrata_modak8c138332008-01-28 11:19:32 +0000750 fi
751
yaberauneya6d41cc32010-01-28 16:24:16 +0000752 [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test start time: $(date)" ; }
753 PAN_COMMAND="${LTPROOT}/bin/ltp-pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ \
754 -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE $FAILCMDFILE"
755 echo "COMMAND: $PAN_COMMAND"
756 if [ ! -z "$TAG_RESTRICT_STRING" ] ; then
757 echo "INFO: Restricted to $TAG_RESTRICT_STRING"
robbiew7d43d772005-02-07 20:07:30 +0000758 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000759 #$PAN_COMMAND #Duplicated code here, because otherwise if we fail, only "PAN_COMMAND" gets output
Chris Dearman37550cf2012-10-17 19:54:01 -0700760
subrata_modak43938212008-05-19 08:48:46 +0000761 ## Display the Output/Log/Failed/HTML file names here
yaberauneya6d41cc32010-01-28 16:24:16 +0000762 echo -e "LOG File: \c"
763 echo $LOGFILE | cut -b4-
subrata_modak43938212008-05-19 08:48:46 +0000764
yaberauneya6d41cc32010-01-28 16:24:16 +0000765 if [ "$OUTPUTFILE" ]; then
766 echo -e "OUTPUT File: \c"
767 echo $OUTPUTFILE | cut -b4-
subrata_modak43938212008-05-19 08:48:46 +0000768 fi
769
yaberauneya6d41cc32010-01-28 16:24:16 +0000770 echo -e "FAILED COMMAND File: \c"
771 echo $FAILCMDFILE | cut -b4-
772
773 if [ "$HTMLFILE" ]; then
774 echo "HTML File: $HTMLFILE"
775 fi
776
777 echo "Running tests......."
subrata_modake47fb352007-11-25 17:03:49 +0000778 test_start_time=$(date)
subrata_modak724098e2009-03-19 08:49:18 +0000779
yaberauneya6d41cc32010-01-28 16:24:16 +0000780 # User wants testing with Kernel Fault Injection
781 if [ $INJECT_KERNEL_FAULT ] ; then
782 #See if Debugfs is mounted, and
783 #Fault Injection Framework available through Debugfs
Garrett Coopercb66da52012-04-03 22:09:42 -0700784 use_faultinjection=true
785 for debug_subdir in \
786 fail_io_timeout \
787 fail_make_request \
788 fail_page_alloc \
789 failslab \
790 ; do
791 if [ -d "/sys/kernel/debug/$debug_subdir" ]
792 then
793 use_faultinjection=true
794 break
795 fi
796 done
797 if $use_faultinjection; then
yaberauneya6d41cc32010-01-28 16:24:16 +0000798 #If atleast one of the Framework is available
799 #Go ahead to Inject Fault & Create required
800 #Command Files for LTP run
801 echo Running tests with Fault Injection Enabled in the Kernel...
Garrett Coopercb66da52012-04-03 22:09:42 -0700802 awk -v LOOPS=$INJECT_FAULT_LOOPS_PER_TEST \
803 -v PERCENTAGE=$INJECT_KERNEL_FAULT_PERCENTAGE \
804 -f ${LTPROOT}/bin/create_kernel_faults_in_loops_and_probability.awk \
805 ${TMP}/alltests > ${TMP}/alltests.tmp
yaberauneya6d41cc32010-01-28 16:24:16 +0000806 cp ${TMP}/alltests.tmp ${TMP}/alltests
807 rm -rf ${TMP}/alltests.tmp
808 else
809 echo Fault Injection not enabled in the Kernel..
810 echo Running tests normally...
811 fi
812 fi
813
814 ## Valgrind Check will work only when Kernel Fault Injection is not expected,
815 ## We do not want to test Faults when valgrind is running
816 if [ $VALGRIND_CHECK ]; then
817 if [ ! $INJECT_KERNEL_FAULT ]; then
818 which valgrind || VALGRIND_CHECK_TYPE=XYZ
819 case $VALGRIND_CHECK_TYPE in
Garrett Cooper3920fd12012-04-03 19:47:16 -0700820 [1-3])
821 awk -v CHECK_LEVEL=$VALGRIND_CHECK_TYPE \
822 -f ${LTPROOT}/bin/create_valgrind_check.awk \
823 ${TMP}/alltests $VALGRIND_CHECK_TYPE > \
824 ${TMP}/alltests.tmp
yaberauneya6d41cc32010-01-28 16:24:16 +0000825 cp ${TMP}/alltests.tmp ${TMP}/alltests
Garrett Cooper3920fd12012-04-03 19:47:16 -0700826 rm -rf ${TMP}/alltests.tmp
827 ;;
828 *)
829 echo "Invalid Memory Check Type, or, Valgrind is not available"
830 ;;
yaberauneya6d41cc32010-01-28 16:24:16 +0000831 esac
832 fi
833 fi
834
Subrata Modakbd9d4402010-05-12 22:03:21 +0530835 if [ $ALT_DMESG_OUT -eq 1 ] ; then
836 #We want to print dmesg output for each test,lets do the trick inside the script
837 echo Enabling dmesg output logging for each test...
Garrett Cooper66030122012-04-03 20:22:14 -0700838 awk -v DMESG_DIR=$DMESG_DIR \
839 -f ${LTPROOT}/bin/create_dmesg_entries_for_each_test.awk \
840 ${TMP}/alltests > ${TMP}/alltests.tmp
Subrata Modakbd9d4402010-05-12 22:03:21 +0530841 cp ${TMP}/alltests.tmp ${TMP}/alltests
842 rm -rf ${TMP}/alltests.tmp
843 fi
subrata_modak724098e2009-03-19 08:49:18 +0000844 # Some tests need to run inside the "bin" directory.
845 cd "${LTPROOT}/testcases/bin"
yaberauneya6d41cc32010-01-28 16:24:16 +0000846 "${LTPROOT}/bin/ltp-pan" $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE $FAILCMDFILE
Chris Dearman37550cf2012-10-17 19:54:01 -0700847
plars4a120e82004-09-02 18:56:06 +0000848 if [ $? -eq 0 ]; then
yaberauneya6d41cc32010-01-28 16:24:16 +0000849 echo "INFO: ltp-pan reported all tests PASS"
850 VALUE=0
851 export LTP_EXIT_VALUE=0;
plars4a120e82004-09-02 18:56:06 +0000852 else
yaberauneya6d41cc32010-01-28 16:24:16 +0000853 echo "INFO: ltp-pan reported some tests FAIL"
854 VALUE=1
855 export LTP_EXIT_VALUE=1;
plars4a120e82004-09-02 18:56:06 +0000856 fi
subrata_modak724098e2009-03-19 08:49:18 +0000857 cd ..
yaberauneya6d41cc32010-01-28 16:24:16 +0000858 echo "LTP Version: $version_date"
mreed1091696422006-05-03 19:07:22 +0000859
Subrata Modake3bc3752010-07-03 23:32:27 +0530860 # $DMESG_DIR is used to cache messages obtained from dmesg after a test run.
861 # Proactively reap all of the 0-byte files in $DMESG_DIR as they have zero value
862 # and only clutter up the filesystem.
863
864 if [ $ALT_DMESG_OUT -eq 1 ] ; then
865 if ! find "$DMESG_DIR" -size 0 -exec rm {} + ; then
866 echo "cd to $DMESG_DIR failed: $?"
867 fi
868 if [ -n "$(ls "$DMESG_DIR")" ] ; then
869 echo "Kernel messages were generated for LTP tests $version_date"
870 else
871 echo "No Kernel messages were generated for LTP tests $version_date"
872 fi
873 fi
874
subrata_modake47fb352007-11-25 17:03:49 +0000875 if [ "$ALT_HTML_OUT" -eq 1 ] ; then #User wants the HTML output to be created, it then needs to be generated
876 export LTP_VERSION=$version_date
877 export TEST_START_TIME=$test_start_time
878 export TEST_END_TIME=$(date)
yaberauneya6d41cc32010-01-28 16:24:16 +0000879 OUTPUT_DIRECTORY=`echo $OUTPUTFILE | cut -c4-`
subrata_modake47fb352007-11-25 17:03:49 +0000880 LOGS_DIRECTORY="$LTPROOT/results"
881 export TEST_OUTPUT_DIRECTORY="$LTPROOT/output"
882 export TEST_LOGS_DIRECTORY=$LOGS_DIRECTORY
yaberauneya6d41cc32010-01-28 16:24:16 +0000883 echo "Generating HTML Output.....!!"
Chris Dearman37550cf2012-10-17 19:54:01 -0700884 ( 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 +0000885 echo "Generated HTML Output.....!!"
886 echo "Location: $HTMLFILE";
887
subrata_modake47fb352007-11-25 17:03:49 +0000888 fi
Chris Dearman37550cf2012-10-17 19:54:01 -0700889
yaberauneya6d41cc32010-01-28 16:24:16 +0000890 if [ "$ALT_EMAIL_OUT" -eq 1 ] ; then ## User wants reports to be e-mailed
Chris Dearman37550cf2012-10-17 19:54:01 -0700891 if [ [ ! "$HTMLFILE_NAME" ] -o [ ! "$OUTPUTFILE_NAME" ] -o [ ! "$LOGFILE_NAME" ] ] ; then
yaberauneya6d41cc32010-01-28 16:24:16 +0000892 ##User does not have output/logs/html-output, nothing to be mailed in this situation
893 echo "Nothing to be mailed here...."
subrata_modak08dde6f2007-11-28 11:02:51 +0000894 else
subrata_modak43938212008-05-19 08:48:46 +0000895 TAR_FILE_NAME=LTP_RUN_$version_date$DEFAULT_FILE_NAME_GENERATION_TIME.tar
yaberauneya6d41cc32010-01-28 16:24:16 +0000896 if [ "$HTMLFILE_NAME" ] ; then ## HTML file Exists
897 if [ "$ALT_HTML_OUT" -ne 1 ] ; then ## The HTML file path is absolute and not $LTPROOT/output
898 mkdir -p $LTPROOT/output ## We need to create this Directory
899 cp $HTMLFILE_NAME $LTPROOT/output/
900 fi
subrata_modak08dde6f2007-11-28 11:02:51 +0000901 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000902 if [ "$OUTPUTFILE_NAME" ] ; then ## Output file exists
903 if [ "$ALT_DIR_OUT" -ne 1 ] ; then ## The Output file path is absolute and not $LTPROOT/output
904 mkdir -p $LTPROOT/output ## We need to create this Directory
905 cp $OUTPUTFILE_NAME $LTPROOT/output/
906 fi
subrata_modak08dde6f2007-11-28 11:02:51 +0000907 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000908 if [ "$LOGFILE_NAME" ] ; then ## Log file exists
909 if [ "$ALT_DIR_RES" -ne 1 ] ; then ## The Log file path is absolute and not $LTPROOT/results
910 mkdir -p $LTPROOT/results ## We need to create this Directory
911 cp $LOGFILE_NAME $LTPROOT/results/
912 fi
913 fi
914 if [ -d $LTPROOT/output ] ; then
915 tar -cf ./$TAR_FILE_NAME $LTPROOT/output
916 if [ $? -eq 0 ]; then
917 echo "Created TAR File: ./$TAR_FILE_NAME successfully, added $LTPROOT/output"
918 else
919 echo "Cannot Create TAR File: ./$TAR_FILE_NAME for adding $LTPROOT/output"
920 fi
921 fi
922 if [ -d $LTPROOT/results ] ; then
923 tar -uf ./$TAR_FILE_NAME $LTPROOT/results
924 if [ $? -eq 0 ]; then
925 echo "Updated TAR File: ./$TAR_FILE_NAME successfully, added $LTPROOT/results"
926 else
927 echo "Cannot Update TAR File: ./$TAR_FILE_NAME for adding $LTPROOT/results"
928 fi
929 fi
930 if [ -e $LTPROOT/nohup.out ] ; then ## If User would have Chosen nohup to do ltprun
931 tar -uf ./$TAR_FILE_NAME $LTPROOT/nohup.out
932 if [ $? -eq 0 ]; then
933 echo "Updated TAR File: ./$TAR_FILE_NAME successfully, added $LTPROOT/nohup.out"
934 else
935 echo "Cannot Update TAR File: ./$TAR_FILE_NAME for adding $LTPROOT/nohup.out"
936 fi
937 fi
938 gzip ./$TAR_FILE_NAME ## gzip this guy
939 if [ $? -eq 0 ]; then
940 echo "Gunzipped TAR File: ./$TAR_FILE_NAME"
subrata_modak08dde6f2007-11-28 11:02:51 +0000941 else
yaberauneya6d41cc32010-01-28 16:24:16 +0000942 echo "Cannot Gunzip TAR File: ./$TAR_FILE_NAME"
subrata_modak08dde6f2007-11-28 11:02:51 +0000943 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000944 if [ -e /usr/bin/mutt ] ; then ## This is a better mail client than others
945 echo "Starting mailing reports to: $EMAIL_TO, file: ./$TAR_FILE_NAME.gz"
946 mutt -a ./$TAR_FILE_NAME.gz -s "LTP Reports on $test_start_time" $EMAIL_TO < /dev/null
947 if [ $? -eq 0 ]; then
948 echo "Reports Successfully mailed to: $EMAIL_TO"
949 else
950 echo "Reports cannot be mailed to: $EMAIL_TO"
951 fi
952 else ## Use our Ageold mail program
953 echo "Starting mailing reports to: $EMAIL_TO, file: ./$TAR_FILE_NAME.gz"
954 uuencode ./$TAR_FILE_NAME.gz $TAR_FILE_NAME.gz | mail $EMAIL_TO -s "LTP Reports on $test_start_time"
955 if [ $? -eq 0 ]; then
956 echo "Reports Successfully mailed to: $EMAIL_TO"
957 else
958 echo "Reports cannot be mailed to: $EMAIL_TO"
959 fi
Chris Dearman37550cf2012-10-17 19:54:01 -0700960 fi
subrata_modak08dde6f2007-11-28 11:02:51 +0000961 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000962 fi
Chris Dearman37550cf2012-10-17 19:54:01 -0700963
yaberauneya6d41cc32010-01-28 16:24:16 +0000964 [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test end time: $(date)" ; }
Chris Dearman37550cf2012-10-17 19:54:01 -0700965
yaberauneya6d41cc32010-01-28 16:24:16 +0000966 [ "$GENLOAD" -eq 1 ] && { killall -9 genload >/dev/null 2>&1; }
967 [ "$NETPIPE" -eq 1 ] && { killall -9 NPtcp >/dev/null 2>&1; }
Chris Dearman37550cf2012-10-17 19:54:01 -0700968
yaberauneya6d41cc32010-01-28 16:24:16 +0000969 [ "$ALT_DIR_OUT" -eq 1 ] || [ "$ALT_DIR_RES" -eq 1 ] && \
970 {
971 cat <<-EOF >&1
Chris Dearman37550cf2012-10-17 19:54:01 -0700972
Markos Chandras11328662012-03-06 10:28:59 +0000973 ###############################################################
Chris Dearman37550cf2012-10-17 19:54:01 -0700974
Markos Chandras11328662012-03-06 10:28:59 +0000975 Done executing testcases.
mreed1091696422006-05-03 19:07:22 +0000976 LTP Version: $version_date
Markos Chandras11328662012-03-06 10:28:59 +0000977 ###############################################################
Chris Dearman37550cf2012-10-17 19:54:01 -0700978
yaberauneya6d41cc32010-01-28 16:24:16 +0000979 EOF
980 }
981 exit $VALUE
plars4a120e82004-09-02 18:56:06 +0000982}
983
Ramesh YR0a78f232013-04-16 09:31:28 +0800984create_block()
985{
986 #create a block device with ext4 filesystem.
Cyril Hrubisb88fa5b2013-06-25 15:50:08 +0200987 dd if=/dev/zero of=${TMP}/test.img bs=1kB count=10240
Ramesh YR0a78f232013-04-16 09:31:28 +0800988 if [ $? -ne 0 ]; then
989 echo "Failed to create loopback device image, please check disk space and re-run"
990 return 1
991 else
992 ##search for an unused loop dev
993 LOOP_DEV=$(losetup -f)
994 if [ $? -ne 0 ]; then
995 echo "no unused loop device is found"
996 return 1
997 else
998 ##attach the created file to loop dev.
Cyril Hrubisb88fa5b2013-06-25 15:50:08 +0200999 losetup $LOOP_DEV ${TMP}/test.img
Ramesh YR0a78f232013-04-16 09:31:28 +08001000 if [ $? -ne 0 ]; then
1001 echo "losetup failed to create block device"
1002 return 1
1003 else
Wanlong Gao44be66d2013-07-05 16:49:21 +08001004 DEVICE_FS_TYPE="ext4"
Cyril Hrubisb88fa5b2013-06-25 15:50:08 +02001005 mkfs.ext4 $LOOP_DEV
Wanlong Gao44be66d2013-07-05 16:49:21 +08001006 if [ $? -ne 0 ]; then
1007 DEVICE_FS_TYPE="ext3"
1008 mkfs.ext3 $LOOP_DEV
1009 if [ $? -ne 0 ]; then
1010 echo "creating an ext4/3 block device failed."
1011 return 1
1012 fi
1013 fi
Ramesh YR0a78f232013-04-16 09:31:28 +08001014 #set the values in alltests which require block device.
1015 DEVICE=$LOOP_DEV
Ramesh YR0a78f232013-04-16 09:31:28 +08001016 return 0
1017 fi
1018 fi
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
1028trap "cleanup" 0
1029setup
1030main "$@"
Garrett Coopercf86b8b2010-11-16 21:46:41 -08001031
1032#vim: syntax=sh