blob: 04cc690dbca45f8d0d2d88379ad5015e98b1f282 [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
yaberauneya6d41cc32010-01-28 16:24:16 +0000666 ${LTPROOT}/IDcheck.sh &>/dev/null || \
667 {
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
684 else
685 echo "remove test cases which require the block device."
Wanlong Gao0b6c3562012-06-22 10:35:35 +0800686 echo "You can specify it with option -b"
yaberauneya6d41cc32010-01-28 16:24:16 +0000687 sed -i "/DEVICE/d" ${TMP}/alltests
subrata_modakd9fb3862008-12-29 11:25:36 +0000688 fi
689
yaberauneya6d41cc32010-01-28 16:24:16 +0000690 if [ $? -ne 0 ]; then
691 echo "FATAL: error during prcessing alltests file by sed"
692 exit 1
693 fi
694
695 if [ -n "$DEVICE" ]; then
Simon Xu47d716b2012-08-02 23:42:11 +0800696 mnt_pnt=`mktemp -d "${TMP}/mnt_pnt.XXXXXX"`
subrata_modakd9fb3862008-12-29 11:25:36 +0000697 if [ -n "$DEVICE_FS_TYPE" ]; then
698 mount -t $DEVICE_FS_TYPE $DEVICE $mnt_pnt
699 else
700 mount $DEVICE $mnt_pnt
701 fi
702
703 if [ $? -ne 0 ]; then
yaberauneya6d41cc32010-01-28 16:24:16 +0000704 echo "FATAL: can't mount block device $DEVICE."
705 exit 1
subrata_modakd9fb3862008-12-29 11:25:36 +0000706 fi
707
708 if [ -z "$DEVICE_FS_TYPE" ]; then
yaberauneya6d41cc32010-01-28 16:24:16 +0000709 DEVICE_FS_TYPE=`cat /proc/mounts | awk "{if (\\\$1 == \"$DEVICE\") print \\\$3; }"`
710 echo "determine file system $DEVICE_FS_TYPE on block device $DEVICE"
subrata_modakd9fb3862008-12-29 11:25:36 +0000711 fi
712
yaberauneya6d41cc32010-01-28 16:24:16 +0000713 umount $DEVICE
714 if [ $? -ne 0 ]; then
715 echo "FATAL: can't umount $DEVICE"
716 exit 1
subrata_modakd9fb3862008-12-29 11:25:36 +0000717 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000718 rm -rf $mnt_pnt
subrata_modakd9fb3862008-12-29 11:25:36 +0000719 fi
720
yaberauneya6d41cc32010-01-28 16:24:16 +0000721 if [ -n "$DEVICE" ]; then
Wanlong Gao0b6c3562012-06-22 10:35:35 +0800722 sed -i "s|DEVICE_FS_TYPE|$DEVICE_FS_TYPE|" ${TMP}/alltests
yaberauneya6d41cc32010-01-28 16:24:16 +0000723 fi
724
725 if [ $? -ne 0 ]; then
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800726 echo "FATAL: error during processing alltests file by sed"
yaberauneya6d41cc32010-01-28 16:24:16 +0000727 exit 1
subrata_modakd9fb3862008-12-29 11:25:36 +0000728 fi
729
subrata_modak8c138332008-01-28 11:19:32 +0000730 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 +0000731 echo "PAN will run these test cases $RUN_REPEATED times....."
732 echo "Test Tags will be Prepended with ITERATION NO.s....."
733 inc=1
734 sed -e '/^$/ d' -e 's/^[ ,\t]*//' -e '/^#/ d' < ${TMP}/alltests > ${TMP}/alltests.temp ##This removes all newlines, leading spaces, tabs, #
735 sed 's/^[0-9,a-z,A-Z]*/'"$inc"'_ITERATION_&/' < ${TMP}/alltests.temp > ${TMP}/alltests ## .temp is kept as Base file
736 while [ $inc -lt $RUN_REPEATED ] ; do
737 inc=`expr $inc + 1`
738 sed 's/^[0-9,a-z,A-Z]*/'"$inc"'_ITERATION_&/' < ${TMP}/alltests.temp >> ${TMP}/alltests #Keep appending with Iteration No.s
739 done
subrata_modak8c138332008-01-28 11:19:32 +0000740 fi
741
yaberauneya6d41cc32010-01-28 16:24:16 +0000742 [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test start time: $(date)" ; }
743 PAN_COMMAND="${LTPROOT}/bin/ltp-pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ \
744 -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE $FAILCMDFILE"
745 echo "COMMAND: $PAN_COMMAND"
746 if [ ! -z "$TAG_RESTRICT_STRING" ] ; then
747 echo "INFO: Restricted to $TAG_RESTRICT_STRING"
robbiew7d43d772005-02-07 20:07:30 +0000748 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000749 #$PAN_COMMAND #Duplicated code here, because otherwise if we fail, only "PAN_COMMAND" gets output
Chris Dearman37550cf2012-10-17 19:54:01 -0700750
subrata_modak43938212008-05-19 08:48:46 +0000751 ## Display the Output/Log/Failed/HTML file names here
yaberauneya6d41cc32010-01-28 16:24:16 +0000752 echo -e "LOG File: \c"
753 echo $LOGFILE | cut -b4-
subrata_modak43938212008-05-19 08:48:46 +0000754
yaberauneya6d41cc32010-01-28 16:24:16 +0000755 if [ "$OUTPUTFILE" ]; then
756 echo -e "OUTPUT File: \c"
757 echo $OUTPUTFILE | cut -b4-
subrata_modak43938212008-05-19 08:48:46 +0000758 fi
759
yaberauneya6d41cc32010-01-28 16:24:16 +0000760 echo -e "FAILED COMMAND File: \c"
761 echo $FAILCMDFILE | cut -b4-
762
763 if [ "$HTMLFILE" ]; then
764 echo "HTML File: $HTMLFILE"
765 fi
766
767 echo "Running tests......."
subrata_modake47fb352007-11-25 17:03:49 +0000768 test_start_time=$(date)
subrata_modak724098e2009-03-19 08:49:18 +0000769
yaberauneya6d41cc32010-01-28 16:24:16 +0000770 # User wants testing with Kernel Fault Injection
771 if [ $INJECT_KERNEL_FAULT ] ; then
772 #See if Debugfs is mounted, and
773 #Fault Injection Framework available through Debugfs
Garrett Coopercb66da52012-04-03 22:09:42 -0700774 use_faultinjection=true
775 for debug_subdir in \
776 fail_io_timeout \
777 fail_make_request \
778 fail_page_alloc \
779 failslab \
780 ; do
781 if [ -d "/sys/kernel/debug/$debug_subdir" ]
782 then
783 use_faultinjection=true
784 break
785 fi
786 done
787 if $use_faultinjection; then
yaberauneya6d41cc32010-01-28 16:24:16 +0000788 #If atleast one of the Framework is available
789 #Go ahead to Inject Fault & Create required
790 #Command Files for LTP run
791 echo Running tests with Fault Injection Enabled in the Kernel...
Garrett Coopercb66da52012-04-03 22:09:42 -0700792 awk -v LOOPS=$INJECT_FAULT_LOOPS_PER_TEST \
793 -v PERCENTAGE=$INJECT_KERNEL_FAULT_PERCENTAGE \
794 -f ${LTPROOT}/bin/create_kernel_faults_in_loops_and_probability.awk \
795 ${TMP}/alltests > ${TMP}/alltests.tmp
yaberauneya6d41cc32010-01-28 16:24:16 +0000796 cp ${TMP}/alltests.tmp ${TMP}/alltests
797 rm -rf ${TMP}/alltests.tmp
798 else
799 echo Fault Injection not enabled in the Kernel..
800 echo Running tests normally...
801 fi
802 fi
803
804 ## Valgrind Check will work only when Kernel Fault Injection is not expected,
805 ## We do not want to test Faults when valgrind is running
806 if [ $VALGRIND_CHECK ]; then
807 if [ ! $INJECT_KERNEL_FAULT ]; then
808 which valgrind || VALGRIND_CHECK_TYPE=XYZ
809 case $VALGRIND_CHECK_TYPE in
Garrett Cooper3920fd12012-04-03 19:47:16 -0700810 [1-3])
811 awk -v CHECK_LEVEL=$VALGRIND_CHECK_TYPE \
812 -f ${LTPROOT}/bin/create_valgrind_check.awk \
813 ${TMP}/alltests $VALGRIND_CHECK_TYPE > \
814 ${TMP}/alltests.tmp
yaberauneya6d41cc32010-01-28 16:24:16 +0000815 cp ${TMP}/alltests.tmp ${TMP}/alltests
Garrett Cooper3920fd12012-04-03 19:47:16 -0700816 rm -rf ${TMP}/alltests.tmp
817 ;;
818 *)
819 echo "Invalid Memory Check Type, or, Valgrind is not available"
820 ;;
yaberauneya6d41cc32010-01-28 16:24:16 +0000821 esac
822 fi
823 fi
824
Subrata Modakbd9d4402010-05-12 22:03:21 +0530825 if [ $ALT_DMESG_OUT -eq 1 ] ; then
826 #We want to print dmesg output for each test,lets do the trick inside the script
827 echo Enabling dmesg output logging for each test...
Garrett Cooper66030122012-04-03 20:22:14 -0700828 awk -v DMESG_DIR=$DMESG_DIR \
829 -f ${LTPROOT}/bin/create_dmesg_entries_for_each_test.awk \
830 ${TMP}/alltests > ${TMP}/alltests.tmp
Subrata Modakbd9d4402010-05-12 22:03:21 +0530831 cp ${TMP}/alltests.tmp ${TMP}/alltests
832 rm -rf ${TMP}/alltests.tmp
833 fi
subrata_modak724098e2009-03-19 08:49:18 +0000834 # Some tests need to run inside the "bin" directory.
835 cd "${LTPROOT}/testcases/bin"
yaberauneya6d41cc32010-01-28 16:24:16 +0000836 "${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 -0700837
plars4a120e82004-09-02 18:56:06 +0000838 if [ $? -eq 0 ]; then
yaberauneya6d41cc32010-01-28 16:24:16 +0000839 echo "INFO: ltp-pan reported all tests PASS"
840 VALUE=0
841 export LTP_EXIT_VALUE=0;
plars4a120e82004-09-02 18:56:06 +0000842 else
yaberauneya6d41cc32010-01-28 16:24:16 +0000843 echo "INFO: ltp-pan reported some tests FAIL"
844 VALUE=1
845 export LTP_EXIT_VALUE=1;
plars4a120e82004-09-02 18:56:06 +0000846 fi
subrata_modak724098e2009-03-19 08:49:18 +0000847 cd ..
yaberauneya6d41cc32010-01-28 16:24:16 +0000848 echo "LTP Version: $version_date"
mreed1091696422006-05-03 19:07:22 +0000849
Subrata Modake3bc3752010-07-03 23:32:27 +0530850 # $DMESG_DIR is used to cache messages obtained from dmesg after a test run.
851 # Proactively reap all of the 0-byte files in $DMESG_DIR as they have zero value
852 # and only clutter up the filesystem.
853
854 if [ $ALT_DMESG_OUT -eq 1 ] ; then
855 if ! find "$DMESG_DIR" -size 0 -exec rm {} + ; then
856 echo "cd to $DMESG_DIR failed: $?"
857 fi
858 if [ -n "$(ls "$DMESG_DIR")" ] ; then
859 echo "Kernel messages were generated for LTP tests $version_date"
860 else
861 echo "No Kernel messages were generated for LTP tests $version_date"
862 fi
863 fi
864
subrata_modake47fb352007-11-25 17:03:49 +0000865 if [ "$ALT_HTML_OUT" -eq 1 ] ; then #User wants the HTML output to be created, it then needs to be generated
866 export LTP_VERSION=$version_date
867 export TEST_START_TIME=$test_start_time
868 export TEST_END_TIME=$(date)
yaberauneya6d41cc32010-01-28 16:24:16 +0000869 OUTPUT_DIRECTORY=`echo $OUTPUTFILE | cut -c4-`
subrata_modake47fb352007-11-25 17:03:49 +0000870 LOGS_DIRECTORY="$LTPROOT/results"
871 export TEST_OUTPUT_DIRECTORY="$LTPROOT/output"
872 export TEST_LOGS_DIRECTORY=$LOGS_DIRECTORY
yaberauneya6d41cc32010-01-28 16:24:16 +0000873 echo "Generating HTML Output.....!!"
Chris Dearman37550cf2012-10-17 19:54:01 -0700874 ( 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 +0000875 echo "Generated HTML Output.....!!"
876 echo "Location: $HTMLFILE";
877
subrata_modake47fb352007-11-25 17:03:49 +0000878 fi
Chris Dearman37550cf2012-10-17 19:54:01 -0700879
yaberauneya6d41cc32010-01-28 16:24:16 +0000880 if [ "$ALT_EMAIL_OUT" -eq 1 ] ; then ## User wants reports to be e-mailed
Chris Dearman37550cf2012-10-17 19:54:01 -0700881 if [ [ ! "$HTMLFILE_NAME" ] -o [ ! "$OUTPUTFILE_NAME" ] -o [ ! "$LOGFILE_NAME" ] ] ; then
yaberauneya6d41cc32010-01-28 16:24:16 +0000882 ##User does not have output/logs/html-output, nothing to be mailed in this situation
883 echo "Nothing to be mailed here...."
subrata_modak08dde6f2007-11-28 11:02:51 +0000884 else
subrata_modak43938212008-05-19 08:48:46 +0000885 TAR_FILE_NAME=LTP_RUN_$version_date$DEFAULT_FILE_NAME_GENERATION_TIME.tar
yaberauneya6d41cc32010-01-28 16:24:16 +0000886 if [ "$HTMLFILE_NAME" ] ; then ## HTML file Exists
887 if [ "$ALT_HTML_OUT" -ne 1 ] ; then ## The HTML file path is absolute and not $LTPROOT/output
888 mkdir -p $LTPROOT/output ## We need to create this Directory
889 cp $HTMLFILE_NAME $LTPROOT/output/
890 fi
subrata_modak08dde6f2007-11-28 11:02:51 +0000891 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000892 if [ "$OUTPUTFILE_NAME" ] ; then ## Output file exists
893 if [ "$ALT_DIR_OUT" -ne 1 ] ; then ## The Output file path is absolute and not $LTPROOT/output
894 mkdir -p $LTPROOT/output ## We need to create this Directory
895 cp $OUTPUTFILE_NAME $LTPROOT/output/
896 fi
subrata_modak08dde6f2007-11-28 11:02:51 +0000897 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000898 if [ "$LOGFILE_NAME" ] ; then ## Log file exists
899 if [ "$ALT_DIR_RES" -ne 1 ] ; then ## The Log file path is absolute and not $LTPROOT/results
900 mkdir -p $LTPROOT/results ## We need to create this Directory
901 cp $LOGFILE_NAME $LTPROOT/results/
902 fi
903 fi
904 if [ -d $LTPROOT/output ] ; then
905 tar -cf ./$TAR_FILE_NAME $LTPROOT/output
906 if [ $? -eq 0 ]; then
907 echo "Created TAR File: ./$TAR_FILE_NAME successfully, added $LTPROOT/output"
908 else
909 echo "Cannot Create TAR File: ./$TAR_FILE_NAME for adding $LTPROOT/output"
910 fi
911 fi
912 if [ -d $LTPROOT/results ] ; then
913 tar -uf ./$TAR_FILE_NAME $LTPROOT/results
914 if [ $? -eq 0 ]; then
915 echo "Updated TAR File: ./$TAR_FILE_NAME successfully, added $LTPROOT/results"
916 else
917 echo "Cannot Update TAR File: ./$TAR_FILE_NAME for adding $LTPROOT/results"
918 fi
919 fi
920 if [ -e $LTPROOT/nohup.out ] ; then ## If User would have Chosen nohup to do ltprun
921 tar -uf ./$TAR_FILE_NAME $LTPROOT/nohup.out
922 if [ $? -eq 0 ]; then
923 echo "Updated TAR File: ./$TAR_FILE_NAME successfully, added $LTPROOT/nohup.out"
924 else
925 echo "Cannot Update TAR File: ./$TAR_FILE_NAME for adding $LTPROOT/nohup.out"
926 fi
927 fi
928 gzip ./$TAR_FILE_NAME ## gzip this guy
929 if [ $? -eq 0 ]; then
930 echo "Gunzipped TAR File: ./$TAR_FILE_NAME"
subrata_modak08dde6f2007-11-28 11:02:51 +0000931 else
yaberauneya6d41cc32010-01-28 16:24:16 +0000932 echo "Cannot Gunzip TAR File: ./$TAR_FILE_NAME"
subrata_modak08dde6f2007-11-28 11:02:51 +0000933 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000934 if [ -e /usr/bin/mutt ] ; then ## This is a better mail client than others
935 echo "Starting mailing reports to: $EMAIL_TO, file: ./$TAR_FILE_NAME.gz"
936 mutt -a ./$TAR_FILE_NAME.gz -s "LTP Reports on $test_start_time" $EMAIL_TO < /dev/null
937 if [ $? -eq 0 ]; then
938 echo "Reports Successfully mailed to: $EMAIL_TO"
939 else
940 echo "Reports cannot be mailed to: $EMAIL_TO"
941 fi
942 else ## Use our Ageold mail program
943 echo "Starting mailing reports to: $EMAIL_TO, file: ./$TAR_FILE_NAME.gz"
944 uuencode ./$TAR_FILE_NAME.gz $TAR_FILE_NAME.gz | mail $EMAIL_TO -s "LTP Reports on $test_start_time"
945 if [ $? -eq 0 ]; then
946 echo "Reports Successfully mailed to: $EMAIL_TO"
947 else
948 echo "Reports cannot be mailed to: $EMAIL_TO"
949 fi
Chris Dearman37550cf2012-10-17 19:54:01 -0700950 fi
subrata_modak08dde6f2007-11-28 11:02:51 +0000951 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000952 fi
Chris Dearman37550cf2012-10-17 19:54:01 -0700953
yaberauneya6d41cc32010-01-28 16:24:16 +0000954 [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test end time: $(date)" ; }
Chris Dearman37550cf2012-10-17 19:54:01 -0700955
yaberauneya6d41cc32010-01-28 16:24:16 +0000956 [ "$GENLOAD" -eq 1 ] && { killall -9 genload >/dev/null 2>&1; }
957 [ "$NETPIPE" -eq 1 ] && { killall -9 NPtcp >/dev/null 2>&1; }
Chris Dearman37550cf2012-10-17 19:54:01 -0700958
yaberauneya6d41cc32010-01-28 16:24:16 +0000959 [ "$ALT_DIR_OUT" -eq 1 ] || [ "$ALT_DIR_RES" -eq 1 ] && \
960 {
961 cat <<-EOF >&1
Chris Dearman37550cf2012-10-17 19:54:01 -0700962
Markos Chandras11328662012-03-06 10:28:59 +0000963 ###############################################################
Chris Dearman37550cf2012-10-17 19:54:01 -0700964
Markos Chandras11328662012-03-06 10:28:59 +0000965 Done executing testcases.
mreed1091696422006-05-03 19:07:22 +0000966 LTP Version: $version_date
Markos Chandras11328662012-03-06 10:28:59 +0000967 ###############################################################
Chris Dearman37550cf2012-10-17 19:54:01 -0700968
yaberauneya6d41cc32010-01-28 16:24:16 +0000969 EOF
970 }
971 exit $VALUE
plars4a120e82004-09-02 18:56:06 +0000972}
973
974cleanup()
975{
yaberauneya6d41cc32010-01-28 16:24:16 +0000976 rm -rf ${TMP}
plars4a120e82004-09-02 18:56:06 +0000977}
978
979trap "cleanup" 0
980setup
981main "$@"
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800982
983#vim: syntax=sh