blob: 11ab32a203674ef41b0df9545a0503e862d51532 [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 ##
18## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ##
19## ##
20################################################################################
21# File: runltp
22#
23# Description: This script can be used to the tests in the LTP test suite
24#
25# Authors: Manoj Iyer - manjo@mail.utexas.edu
26# Robbe Williamson - robbiew@us.ibm.com
27#
28# History: Oct 07 2003 - Modified - Manoj Iyer
29# - use functions
30# - clean up on script exit
31# - error checking etc.
32#
33# Oct 08 2003 - Modified - Manoj Iyer
34# - fixed bug in creating results directory
subrata_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
104usage()
105{
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]
subrata_modake099b2a2007-10-29 12:22:01 +0000110 [ -i NUM_PROCS ] [ -l LOGFILE ] [ -m NUM_PROCS,CHUNKS,BYTES,HANGUP_FLAG ]
111 -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 ]
plars4a120e82004-09-02 18:56:06 +0000114
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
135 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]
plars4a120e82004-09-02 18:56:06 +0000147 -N Run all the networking tests.
148 -n Run LTP with network traffic in background.
149 -o OUTPUTFILE Redirect test output to a file.
150 -p Human readable format logfiles.
151 -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;;
plars4a120e82004-09-02 18:56:06 +0000218 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
subrata_modak5d7deea2007-09-15 13:51:36 +0000228 C)
subrata_modak6838ec32007-09-14 10:10:12 +0000229 case $OPTARG in
230 /*)
231 FAILCMDFILE="-C $OPTARG" ;;
232 *)
233 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 ;;
plars4a120e82004-09-02 18:56:06 +0000236
subrata_modak5ee3e892008-10-21 13:17:56 +0000237 d) # convert the user path to absolute path.
yaberauneya6d41cc32010-01-28 16:24:16 +0000238 export TMPBASE=`cd \`dirname ${OPTARG}\`; pwd`/`basename ${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
303 ALT_DIR_OUT=1
304 ALT_HTML_OUT=1;;
plars4a120e82004-09-02 18:56:06 +0000305 h) usage;;
306
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 ;;
316
Subrata Modakbd9d4402010-05-12 22:03:21 +0530317 K)
318 case $OPTARG in
319 /*)
320 DMESG_DIR="$OPTARG-dmesg-output-`echo $$-``date +%X | tr -d ' '`";;
321 *)
322 DMESG_DIR="$LTPROOT/output/$OPTARG-dmesg-output-`echo $$-``date +%X | tr -d ' '`";;
323 esac
324 mkdir -p $DMESG_DIR
325 ALT_DMESG_OUT=1;;
plars4a120e82004-09-02 18:56:06 +0000326 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" ;;
331 *)
332 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 ;;
335
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;;
377
378 n)
yaberauneya6d41cc32010-01-28 16:24:16 +0000379 $LTPROOT/testcases/bin/netpipe.sh
plars4a120e82004-09-02 18:56:06 +0000380 NETPIPE=1;;
381
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 ;;
plars4a120e82004-09-02 18:56:06 +0000390
391 p) PRETTY_PRT=" -p ";;
392
yaberauneya6d41cc32010-01-28 16:24:16 +0000393 q) QUIET_MODE=" -q ";;
plars4a120e82004-09-02 18:56:06 +0000394
395 r) LTPROOT=$OPTARG;;
396
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 ;;
robbiew7d43d772005-02-07 20:07:30 +0000405
plars4a120e82004-09-02 18:56:06 +0000406 t) # In case you want to specify the time
407 # to run from the command line
408 # (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;;
robbiew7d43d772005-02-07 20:07:30 +0000415
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
plars4a120e82004-09-02 18:56:06 +0000423 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
subrata_modak6838ec32007-09-14 10:10:12 +0000438
439 ## It would be nice if a Failed File is compulsorily created (gives User better Idea of Tests that failed)
440
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
subrata_modaka1fd64b2007-04-11 11:24:49 +0000498 # Added -m 777 for tests that call tst_tmpdir() and try to
499 # 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 }
plars4a120e82004-09-02 18:56:06 +0000522
yaberauneya6d41cc32010-01-28 16:24:16 +0000523 cd $TMP || \
524 {
525 echo "could not cd ${TMP} ... exiting"
526 exit 1
527 }
plars4a120e82004-09-02 18:56:06 +0000528
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 }
subrata_modak6edfbda2008-10-17 12:25:48 +0000533
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 }
plars4a120e82004-09-02 18:56:06 +0000559
560 # 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 Cooper89fde872010-11-16 22:38:08 -0800568 `cat $LTPROOT/scenario_groups/default`
yaberauneya6d41cc32010-01-28 16:24:16 +0000569
570 EOF
plars4a120e82004-09-02 18:56:06 +0000571
Garrett Cooper89fde872010-11-16 22:38:08 -0800572 SCENARIO_LISTS="$LTPROOT/scenario_groups/default"
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800573 if [ "$RUN_NETEST" -eq 1 ]; then
Garrett Cooper89fde872010-11-16 22:38:08 -0800574 SCENARIO_LISTS="$SCENARIO_LISTS $LTPROOT/scenario_groups/network"
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800575 fi
plars4a120e82004-09-02 18:56:06 +0000576
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800577 # DO NOT INDENT/DEDENT!
578 if [ -n "$SCENARIO_LISTS" ]; then
579 # Insurance to make sure that the first element in the pipe
580 # completed successfully.
581 cat_ok_sentinel=$TMP/cat_ok.$$
582 (cat $SCENARIO_FILES && touch "$cat_ok_sentinel") | \
583 while read scenfile; do
584
585 scenfile=${LTPROOT}/runtest/$scenfile
586
587 # Skip over non-existent scenario files; things are
588 # robust enough now that the build will fail if these
589 # files don't exist.
590 [ -f "$scenfile" ] || continue
591
592 cat $scenfile >> "$TMP/alltests" || {
593 echo "FATAL: unable to append to command file"
594 rm -Rf "$TMP"
595 rm -f "$cat_ok_sentinel"
596 exit 1
597 }
598
599 done
600
601 rm -f "$cat_ok_sentinel"
602
603 fi
604 # ^^DO NOT INDENT/DEDENT!^^
605
subrata_modakbc833d32007-07-25 10:12:02 +0000606 fi
607
yaberauneya6d41cc32010-01-28 16:24:16 +0000608 [ -n "$CMDFILES" ] && \
609 {
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800610 for scenfile in `echo "$CMDFILES" | tr ',' ' '`
yaberauneya6d41cc32010-01-28 16:24:16 +0000611 do
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800612 [ -f "$scenfile" ] || scenfile="$LTPROOT/runtest/$scenfile"
613 cat "$scenfile" >> ${TMP}/alltests || \
yaberauneya6d41cc32010-01-28 16:24:16 +0000614 {
615 echo "FATAL: unable to create command file"
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800616 rm -Rf "$TMP"
yaberauneya6d41cc32010-01-28 16:24:16 +0000617 exit 1
618 }
plars4a120e82004-09-02 18:56:06 +0000619 done
yaberauneya6d41cc32010-01-28 16:24:16 +0000620 }
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800621
yaberauneya6d41cc32010-01-28 16:24:16 +0000622 [ -n "$CMDFILEADDR" ] && \
623 {
624 wget -q "${CMDFILEADDR}" -O ${TMP}/wgetcmdfile
625 if [ $? -ne 0 ]; then
626 echo "FATAL: error while getting the command file with wget (address $CMDFILEADDR)"
627 exit 1
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000628 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000629 cat "${TMP}/wgetcmdfile" >> ${TMP}/alltests || \
630 {
631 echo "FATAL: unable to create command file"
632 exit 1
633 }
634 }
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000635
plars4a120e82004-09-02 18:56:06 +0000636 # The fsx-linux tests use the SCRATCHDEV environment variable as a location
637 # that can be reformatted and run on. Set SCRATCHDEV if you want to run
638 # these tests. As a safeguard, this is disabled.
639 unset SCRATCHDEV
yaberauneya6d41cc32010-01-28 16:24:16 +0000640 [ -n "$SCRATCHDEV" ] && \
641 {
642 cat ${LTPROOT}/runtest/fsx >> ${TMP}/alltests ||
643 {
644 echo "FATAL: unable to create fsx-linux tests command file"
645 exit 1
646 }
647 }
subrata_modakbc833d32007-07-25 10:12:02 +0000648
649 # If enabled, execute only test cases that match the PATTERN
yaberauneya6d41cc32010-01-28 16:24:16 +0000650 if [ -n "$TAG_RESTRICT_STRING" ]
651 then
652 mv -f ${TMP}/alltests ${TMP}/alltests.orig
653 grep $TAG_RESTRICT_STRING ${TMP}/alltests.orig > ${TMP}/alltests #Not worth checking return codes for this case
subrata_modakbc833d32007-07-25 10:12:02 +0000654 fi
subrata_modak2f6c9812009-08-14 17:07:48 +0000655
656 # Blacklist or skip tests if a SKIPFILE was specified with -S
yaberauneya6d41cc32010-01-28 16:24:16 +0000657 if [ -n "$SKIPFILE" ]
658 then
subrata_modak2f6c9812009-08-14 17:07:48 +0000659 for file in $( cat $SKIPFILE ); do
yaberauneya6d41cc32010-01-28 16:24:16 +0000660 sed -i "/$file/d" ${TMP}/alltests
subrata_modak2f6c9812009-08-14 17:07:48 +0000661 done
662 fi
plars4a120e82004-09-02 18:56:06 +0000663
664 # check for required users and groups
yaberauneya6d41cc32010-01-28 16:24:16 +0000665 ${LTPROOT}/IDcheck.sh &>/dev/null || \
666 {
667 echo "WARNING: required users and groups not present"
668 echo "WARNING: some test cases may fail"
669 }
670
plars4a120e82004-09-02 18:56:06 +0000671 # display versions of installed software
yaberauneya6d41cc32010-01-28 16:24:16 +0000672 [ -z "$QUIET_MODE" ] && \
673 {
674 ${LTPROOT}/ver_linux || \
675 {
676 echo "WARNING: unable to display versions of software installed"
677 exit 1
678 }
679 }
680
681 if [ -n "$DEVICE" ]; then
682 sed -i "s|DEVICE|$DEVICE|" ${TMP}/alltests
683 else
684 echo "remove test cases which require the block device."
685 echo "You can specify it with option -b"
686 sed -i "/DEVICE/d" ${TMP}/alltests
subrata_modakd9fb3862008-12-29 11:25:36 +0000687 fi
688
yaberauneya6d41cc32010-01-28 16:24:16 +0000689 if [ $? -ne 0 ]; then
690 echo "FATAL: error during prcessing alltests file by sed"
691 exit 1
692 fi
693
694 if [ -n "$DEVICE" ]; then
695 mnt_pnt=`mktemp -d --tmpdir=${TMP} mnt_pnt.XXXXXX`
subrata_modakd9fb3862008-12-29 11:25:36 +0000696 if [ -n "$DEVICE_FS_TYPE" ]; then
697 mount -t $DEVICE_FS_TYPE $DEVICE $mnt_pnt
698 else
699 mount $DEVICE $mnt_pnt
700 fi
701
702 if [ $? -ne 0 ]; then
yaberauneya6d41cc32010-01-28 16:24:16 +0000703 echo "FATAL: can't mount block device $DEVICE."
704 exit 1
subrata_modakd9fb3862008-12-29 11:25:36 +0000705 fi
706
707 if [ -z "$DEVICE_FS_TYPE" ]; then
yaberauneya6d41cc32010-01-28 16:24:16 +0000708 DEVICE_FS_TYPE=`cat /proc/mounts | awk "{if (\\\$1 == \"$DEVICE\") print \\\$3; }"`
709 echo "determine file system $DEVICE_FS_TYPE on block device $DEVICE"
subrata_modakd9fb3862008-12-29 11:25:36 +0000710 fi
711
yaberauneya6d41cc32010-01-28 16:24:16 +0000712 umount $DEVICE
713 if [ $? -ne 0 ]; then
714 echo "FATAL: can't umount $DEVICE"
715 exit 1
subrata_modakd9fb3862008-12-29 11:25:36 +0000716 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000717 rm -rf $mnt_pnt
subrata_modakd9fb3862008-12-29 11:25:36 +0000718 fi
719
yaberauneya6d41cc32010-01-28 16:24:16 +0000720 if [ -n "$DEVICE" ]; then
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800721 sed -i "" -e "s|DEVICE_FS_TYPE|$DEVICE_FS_TYPE|" ${TMP}/alltests
yaberauneya6d41cc32010-01-28 16:24:16 +0000722 fi
723
724 if [ $? -ne 0 ]; then
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800725 echo "FATAL: error during processing alltests file by sed"
yaberauneya6d41cc32010-01-28 16:24:16 +0000726 exit 1
subrata_modakd9fb3862008-12-29 11:25:36 +0000727 fi
728
subrata_modak8c138332008-01-28 11:19:32 +0000729 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 +0000730 echo "PAN will run these test cases $RUN_REPEATED times....."
731 echo "Test Tags will be Prepended with ITERATION NO.s....."
732 inc=1
733 sed -e '/^$/ d' -e 's/^[ ,\t]*//' -e '/^#/ d' < ${TMP}/alltests > ${TMP}/alltests.temp ##This removes all newlines, leading spaces, tabs, #
734 sed 's/^[0-9,a-z,A-Z]*/'"$inc"'_ITERATION_&/' < ${TMP}/alltests.temp > ${TMP}/alltests ## .temp is kept as Base file
735 while [ $inc -lt $RUN_REPEATED ] ; do
736 inc=`expr $inc + 1`
737 sed 's/^[0-9,a-z,A-Z]*/'"$inc"'_ITERATION_&/' < ${TMP}/alltests.temp >> ${TMP}/alltests #Keep appending with Iteration No.s
738 done
subrata_modak8c138332008-01-28 11:19:32 +0000739 fi
740
yaberauneya6d41cc32010-01-28 16:24:16 +0000741 [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test start time: $(date)" ; }
742 PAN_COMMAND="${LTPROOT}/bin/ltp-pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ \
743 -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE $FAILCMDFILE"
744 echo "COMMAND: $PAN_COMMAND"
745 if [ ! -z "$TAG_RESTRICT_STRING" ] ; then
746 echo "INFO: Restricted to $TAG_RESTRICT_STRING"
robbiew7d43d772005-02-07 20:07:30 +0000747 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000748 #$PAN_COMMAND #Duplicated code here, because otherwise if we fail, only "PAN_COMMAND" gets output
749
subrata_modak43938212008-05-19 08:48:46 +0000750 ## Display the Output/Log/Failed/HTML file names here
yaberauneya6d41cc32010-01-28 16:24:16 +0000751 echo -e "LOG File: \c"
752 echo $LOGFILE | cut -b4-
subrata_modak43938212008-05-19 08:48:46 +0000753
yaberauneya6d41cc32010-01-28 16:24:16 +0000754 if [ "$OUTPUTFILE" ]; then
755 echo -e "OUTPUT File: \c"
756 echo $OUTPUTFILE | cut -b4-
subrata_modak43938212008-05-19 08:48:46 +0000757 fi
758
yaberauneya6d41cc32010-01-28 16:24:16 +0000759 echo -e "FAILED COMMAND File: \c"
760 echo $FAILCMDFILE | cut -b4-
761
762 if [ "$HTMLFILE" ]; then
763 echo "HTML File: $HTMLFILE"
764 fi
765
766 echo "Running tests......."
subrata_modake47fb352007-11-25 17:03:49 +0000767 test_start_time=$(date)
subrata_modak724098e2009-03-19 08:49:18 +0000768
yaberauneya6d41cc32010-01-28 16:24:16 +0000769 # User wants testing with Kernel Fault Injection
770 if [ $INJECT_KERNEL_FAULT ] ; then
771 #See if Debugfs is mounted, and
772 #Fault Injection Framework available through Debugfs
773 if [ -d "/sys/kernel/debug/fail_io_timeout" -o \
774 -d "/sys/kernel/debug/fail_make_request" -o \
775 -d "/sys/kernel/debug/fail_page_alloc" -o \
776 -d "/sys/kernel/debug/failslab" ]; then
777 #If atleast one of the Framework is available
778 #Go ahead to Inject Fault & Create required
779 #Command Files for LTP run
780 echo Running tests with Fault Injection Enabled in the Kernel...
781 ${LTPROOT}/tools/create_kernel_faults_in_loops_and_probability.pl\
782 ${TMP}/alltests $INJECT_FAULT_LOOPS_PER_TEST $INJECT_KERNEL_FAULT_PERCENTAGE > ${TMP}/alltests.tmp
783 cp ${TMP}/alltests.tmp ${TMP}/alltests
784 rm -rf ${TMP}/alltests.tmp
785 else
786 echo Fault Injection not enabled in the Kernel..
787 echo Running tests normally...
788 fi
789 fi
790
791 ## Valgrind Check will work only when Kernel Fault Injection is not expected,
792 ## We do not want to test Faults when valgrind is running
793 if [ $VALGRIND_CHECK ]; then
794 if [ ! $INJECT_KERNEL_FAULT ]; then
795 which valgrind || VALGRIND_CHECK_TYPE=XYZ
796 case $VALGRIND_CHECK_TYPE in
797 1)
798 ${LTPROOT}/tools/create_valgrind_check.pl ${TMP}/alltests 1 > ${TMP}/alltests.tmp
799 cp ${TMP}/alltests.tmp ${TMP}/alltests
800 rm -rf ${TMP}/alltests.tmp;;
801 2)
802 ${LTPROOT}/tools/create_valgrind_check.pl ${TMP}/alltests 2 > ${TMP}/alltests.tmp
803 cp ${TMP}/alltests.tmp ${TMP}/alltests
804 rm -rf ${TMP}/alltests.tmp;;
805 3)
806 ${LTPROOT}/tools/create_valgrind_check.pl ${TMP}/alltests 3 > ${TMP}/alltests.tmp
807 cp ${TMP}/alltests.tmp ${TMP}/alltests
808 rm -rf ${TMP}/alltests.tmp;;
809 *) echo "Invalid Memory Check Type, or, Valgrind is not available";;
810 esac
811 fi
812 fi
813
Subrata Modakbd9d4402010-05-12 22:03:21 +0530814 if [ $ALT_DMESG_OUT -eq 1 ] ; then
815 #We want to print dmesg output for each test,lets do the trick inside the script
816 echo Enabling dmesg output logging for each test...
817 ${LTPROOT}/bin/create_dmesg_entries_for_each_test.pl ${TMP}/alltests $DMESG_DIR > ${TMP}/alltests.tmp
818 cp ${TMP}/alltests.tmp ${TMP}/alltests
819 rm -rf ${TMP}/alltests.tmp
820 fi
subrata_modak724098e2009-03-19 08:49:18 +0000821 # Some tests need to run inside the "bin" directory.
822 cd "${LTPROOT}/testcases/bin"
yaberauneya6d41cc32010-01-28 16:24:16 +0000823 "${LTPROOT}/bin/ltp-pan" $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE $FAILCMDFILE
subrata_modakd48c4d02008-01-23 12:59:40 +0000824
plars4a120e82004-09-02 18:56:06 +0000825 if [ $? -eq 0 ]; then
yaberauneya6d41cc32010-01-28 16:24:16 +0000826 echo "INFO: ltp-pan reported all tests PASS"
827 VALUE=0
828 export LTP_EXIT_VALUE=0;
plars4a120e82004-09-02 18:56:06 +0000829 else
yaberauneya6d41cc32010-01-28 16:24:16 +0000830 echo "INFO: ltp-pan reported some tests FAIL"
831 VALUE=1
832 export LTP_EXIT_VALUE=1;
plars4a120e82004-09-02 18:56:06 +0000833 fi
subrata_modak724098e2009-03-19 08:49:18 +0000834 cd ..
yaberauneya6d41cc32010-01-28 16:24:16 +0000835 echo "LTP Version: $version_date"
mreed1091696422006-05-03 19:07:22 +0000836
Subrata Modake3bc3752010-07-03 23:32:27 +0530837 # $DMESG_DIR is used to cache messages obtained from dmesg after a test run.
838 # Proactively reap all of the 0-byte files in $DMESG_DIR as they have zero value
839 # and only clutter up the filesystem.
840
841 if [ $ALT_DMESG_OUT -eq 1 ] ; then
842 if ! find "$DMESG_DIR" -size 0 -exec rm {} + ; then
843 echo "cd to $DMESG_DIR failed: $?"
844 fi
845 if [ -n "$(ls "$DMESG_DIR")" ] ; then
846 echo "Kernel messages were generated for LTP tests $version_date"
847 else
848 echo "No Kernel messages were generated for LTP tests $version_date"
849 fi
850 fi
851
subrata_modake47fb352007-11-25 17:03:49 +0000852 if [ "$ALT_HTML_OUT" -eq 1 ] ; then #User wants the HTML output to be created, it then needs to be generated
853 export LTP_VERSION=$version_date
854 export TEST_START_TIME=$test_start_time
855 export TEST_END_TIME=$(date)
yaberauneya6d41cc32010-01-28 16:24:16 +0000856 OUTPUT_DIRECTORY=`echo $OUTPUTFILE | cut -c4-`
subrata_modake47fb352007-11-25 17:03:49 +0000857 LOGS_DIRECTORY="$LTPROOT/results"
858 export TEST_OUTPUT_DIRECTORY="$LTPROOT/output"
859 export TEST_LOGS_DIRECTORY=$LOGS_DIRECTORY
yaberauneya6d41cc32010-01-28 16:24:16 +0000860 echo "Generating HTML Output.....!!"
Rishikesh K Rajakc2ce5362010-04-28 11:39:03 +0530861 ( perl $LTPROOT/bin/genhtml.pl $LTPROOT/tools/html_report_header.txt test_start test_end test_output execution_status $OUTPUT_DIRECTORY > $HTMLFILE; )
yaberauneya6d41cc32010-01-28 16:24:16 +0000862 echo "Generated HTML Output.....!!"
863 echo "Location: $HTMLFILE";
864
subrata_modake47fb352007-11-25 17:03:49 +0000865 fi
866
yaberauneya6d41cc32010-01-28 16:24:16 +0000867 if [ "$ALT_EMAIL_OUT" -eq 1 ] ; then ## User wants reports to be e-mailed
868 if [ [ ! "$HTMLFILE_NAME" ] -o [ ! "$OUTPUTFILE_NAME" ] -o [ ! "$LOGFILE_NAME" ] ] ; then
869 ##User does not have output/logs/html-output, nothing to be mailed in this situation
870 echo "Nothing to be mailed here...."
subrata_modak08dde6f2007-11-28 11:02:51 +0000871 else
subrata_modak43938212008-05-19 08:48:46 +0000872 TAR_FILE_NAME=LTP_RUN_$version_date$DEFAULT_FILE_NAME_GENERATION_TIME.tar
yaberauneya6d41cc32010-01-28 16:24:16 +0000873 if [ "$HTMLFILE_NAME" ] ; then ## HTML file Exists
874 if [ "$ALT_HTML_OUT" -ne 1 ] ; then ## The HTML file path is absolute and not $LTPROOT/output
875 mkdir -p $LTPROOT/output ## We need to create this Directory
876 cp $HTMLFILE_NAME $LTPROOT/output/
877 fi
subrata_modak08dde6f2007-11-28 11:02:51 +0000878 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000879 if [ "$OUTPUTFILE_NAME" ] ; then ## Output file exists
880 if [ "$ALT_DIR_OUT" -ne 1 ] ; then ## The Output file path is absolute and not $LTPROOT/output
881 mkdir -p $LTPROOT/output ## We need to create this Directory
882 cp $OUTPUTFILE_NAME $LTPROOT/output/
883 fi
subrata_modak08dde6f2007-11-28 11:02:51 +0000884 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000885 if [ "$LOGFILE_NAME" ] ; then ## Log file exists
886 if [ "$ALT_DIR_RES" -ne 1 ] ; then ## The Log file path is absolute and not $LTPROOT/results
887 mkdir -p $LTPROOT/results ## We need to create this Directory
888 cp $LOGFILE_NAME $LTPROOT/results/
889 fi
890 fi
891 if [ -d $LTPROOT/output ] ; then
892 tar -cf ./$TAR_FILE_NAME $LTPROOT/output
893 if [ $? -eq 0 ]; then
894 echo "Created TAR File: ./$TAR_FILE_NAME successfully, added $LTPROOT/output"
895 else
896 echo "Cannot Create TAR File: ./$TAR_FILE_NAME for adding $LTPROOT/output"
897 fi
898 fi
899 if [ -d $LTPROOT/results ] ; then
900 tar -uf ./$TAR_FILE_NAME $LTPROOT/results
901 if [ $? -eq 0 ]; then
902 echo "Updated TAR File: ./$TAR_FILE_NAME successfully, added $LTPROOT/results"
903 else
904 echo "Cannot Update TAR File: ./$TAR_FILE_NAME for adding $LTPROOT/results"
905 fi
906 fi
907 if [ -e $LTPROOT/nohup.out ] ; then ## If User would have Chosen nohup to do ltprun
908 tar -uf ./$TAR_FILE_NAME $LTPROOT/nohup.out
909 if [ $? -eq 0 ]; then
910 echo "Updated TAR File: ./$TAR_FILE_NAME successfully, added $LTPROOT/nohup.out"
911 else
912 echo "Cannot Update TAR File: ./$TAR_FILE_NAME for adding $LTPROOT/nohup.out"
913 fi
914 fi
915 gzip ./$TAR_FILE_NAME ## gzip this guy
916 if [ $? -eq 0 ]; then
917 echo "Gunzipped TAR File: ./$TAR_FILE_NAME"
subrata_modak08dde6f2007-11-28 11:02:51 +0000918 else
yaberauneya6d41cc32010-01-28 16:24:16 +0000919 echo "Cannot Gunzip TAR File: ./$TAR_FILE_NAME"
subrata_modak08dde6f2007-11-28 11:02:51 +0000920 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000921 if [ -e /usr/bin/mutt ] ; then ## This is a better mail client than others
922 echo "Starting mailing reports to: $EMAIL_TO, file: ./$TAR_FILE_NAME.gz"
923 mutt -a ./$TAR_FILE_NAME.gz -s "LTP Reports on $test_start_time" $EMAIL_TO < /dev/null
924 if [ $? -eq 0 ]; then
925 echo "Reports Successfully mailed to: $EMAIL_TO"
926 else
927 echo "Reports cannot be mailed to: $EMAIL_TO"
928 fi
929 else ## Use our Ageold mail program
930 echo "Starting mailing reports to: $EMAIL_TO, file: ./$TAR_FILE_NAME.gz"
931 uuencode ./$TAR_FILE_NAME.gz $TAR_FILE_NAME.gz | mail $EMAIL_TO -s "LTP Reports on $test_start_time"
932 if [ $? -eq 0 ]; then
933 echo "Reports Successfully mailed to: $EMAIL_TO"
934 else
935 echo "Reports cannot be mailed to: $EMAIL_TO"
936 fi
937 fi
subrata_modak08dde6f2007-11-28 11:02:51 +0000938 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000939 fi
subrata_modak08dde6f2007-11-28 11:02:51 +0000940
yaberauneya6d41cc32010-01-28 16:24:16 +0000941 [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test end time: $(date)" ; }
plars4a120e82004-09-02 18:56:06 +0000942
yaberauneya6d41cc32010-01-28 16:24:16 +0000943 [ "$GENLOAD" -eq 1 ] && { killall -9 genload >/dev/null 2>&1; }
944 [ "$NETPIPE" -eq 1 ] && { killall -9 NPtcp >/dev/null 2>&1; }
plars4a120e82004-09-02 18:56:06 +0000945
yaberauneya6d41cc32010-01-28 16:24:16 +0000946 [ "$ALT_DIR_OUT" -eq 1 ] || [ "$ALT_DIR_RES" -eq 1 ] && \
947 {
948 cat <<-EOF >&1
plars4a120e82004-09-02 18:56:06 +0000949
950 ###############################################################"
951
952 Done executing testcases."
mreed1091696422006-05-03 19:07:22 +0000953 LTP Version: $version_date
plars4a120e82004-09-02 18:56:06 +0000954 ###############################################################"
955
yaberauneya6d41cc32010-01-28 16:24:16 +0000956 EOF
957 }
958 exit $VALUE
plars4a120e82004-09-02 18:56:06 +0000959}
960
961cleanup()
962{
yaberauneya6d41cc32010-01-28 16:24:16 +0000963 rm -rf ${TMP}
plars4a120e82004-09-02 18:56:06 +0000964}
965
966trap "cleanup" 0
967setup
968main "$@"
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800969
970#vim: syntax=sh