blob: a047cea076b90f415edba1671aa3eaef56ae2ada [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
yaberauneyad8f1f5d2010-01-28 15:46:58 +000057# - better ways to integrate "ltp/bin/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
yaberauneyad8f1f5d2010-01-28 15:46:58 +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
yaberauneyad8f1f5d2010-01-28 15:46:58 +000070die()
71{
72 error "$*"
73 exit 1
74}
plars4a120e82004-09-02 18:56:06 +000075
yaberauneyad8f1f5d2010-01-28 15:46:58 +000076error()
77{
78 echo "$RUNLTP: ERROR : $*" >&2
79}
80
81info()
82{
83 [ "x$QUIET_MODE" != x1 ] && echo "$RUNLTP: INFO : $*"
84}
85
86warning()
87{
88 echo "$RUNLTP: WARNING : $*" >&2
89}
plars4a120e82004-09-02 18:56:06 +000090
91setup()
92{
yaberauneyad8f1f5d2010-01-28 15:46:58 +000093 OLDCWD=$(pwd)
94 RUNLTP=${0##*/}
95 export LTPROOT=$(dirname "$0")
96 if ! cd "$LTPROOT"; then
97 die "unable to change directory to $LTPROOT"
98 fi
plars4a120e82004-09-02 18:56:06 +000099 export TMPBASE="/tmp"
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000100 export PATH="$LTPROOT/testcases/bin:$PATH"
plars4a120e82004-09-02 18:56:06 +0000101
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000102 if [ ! -d "$LTPROOT/testcases/bin" -o ! -x "$LTPROOT/bin/ltp-pan" ] ; then
103 die "test suite not installed correctly; please read INSTALL"
104 fi
plars4a120e82004-09-02 18:56:06 +0000105}
106
mreed1091696422006-05-03 19:07:22 +0000107version_of_ltp()
108{
yaberauneyaef772532009-10-09 17:55:43 +0000109 cat "$LTPROOT/Version"
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000110 return 0
mreed1091696422006-05-03 19:07:22 +0000111}
plars4a120e82004-09-02 18:56:06 +0000112
113usage()
114{
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000115 cat <<EOF >&2
plars4a120e82004-09-02 18:56:06 +0000116
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000117 usage: $RUNLTP [ -a EMAIL_TO ] [ -c NUM_PROCS ] [ -C FAILCMDFILE ] [ -d TMPDIR ]
subrata_modake47fb352007-11-25 17:03:49 +0000118 [ -D NUM_PROCS,NUM_FILES,NUM_BYTES,CLEAN_FLAG ] -e [ -f CMDFILES(,...) ] [ -g HTMLFILE]
subrata_modake099b2a2007-10-29 12:22:01 +0000119 [ -i NUM_PROCS ] [ -l LOGFILE ] [ -m NUM_PROCS,CHUNKS,BYTES,HANGUP_FLAG ]
120 -N -n [ -o OUTPUTFILE ] -p -q [ -r LTPROOT ] [ -s PATTERN ] [ -t DURATION ]
subrata_modakd9fb3862008-12-29 11:25:36 +0000121 -v [ -w CMDFILEADDR ] [ -x INSTANCES ] [ -b DEVICE ] [-B DEVICE_FS_TYPE]
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000122 [ -F LOOPS,PERCENTAGE ]
plars4a120e82004-09-02 18:56:06 +0000123
subrata_modak08dde6f2007-11-28 11:02:51 +0000124 -a EMAIL_TO EMAIL all your Reports to this E-mail Address
subrata_modake099b2a2007-10-29 12:22:01 +0000125 -c NUM_PROCS Run LTP under additional background CPU load
126 [NUM_PROCS = no. of processes creating the CPU Load by spinning over sqrt()
127 (Defaults to 1 when value)]
subrata_modakbc833d32007-07-25 10:12:02 +0000128 -C FAILCMDFILE Command file with all failed test cases.
plars4a120e82004-09-02 18:56:06 +0000129 -d TMPDIR Directory where temporary files will be created.
subrata_modake099b2a2007-10-29 12:22:01 +0000130 -D NUM_PROCS,NUM_FILES,NUM_BYTES,CLEAN_FLAG
131 Run LTP under additional background Load on Secondary Storage (Seperate by comma)
132 [NUM_PROCS = no. of processes creating Storage Load by spinning over write()]
133 [NUM_FILES = Write() to these many files (Defaults to 1 when value 0 or undefined)]
134 [NUM_BYTES = write these many bytes (defaults to 1GB, when value 0 or undefined)]
135 [CLEAN_FLAG = unlink file to which random data written, when value 1]
mreed1091696422006-05-03 19:07:22 +0000136 -e Prints the date of the current LTP release
subrata_modakbc833d32007-07-25 10:12:02 +0000137 -f CMDFILES Execute user defined list of testcases (separate with ',')
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000138 -F LOOPS,PERCENTAGE Induce PERCENTAGE Fault in the Kernel Subsystems, and, run each test for LOOPS loop
subrata_modake47fb352007-11-25 17:03:49 +0000139 -g HTMLFILE Create an additional HTML output format
plars4a120e82004-09-02 18:56:06 +0000140 -h Help. Prints all available options.
subrata_modake099b2a2007-10-29 12:22:01 +0000141 -i NUM_PROCS Run LTP under additional background Load on IO Bus
142 [NUM_PROCS = no. of processes creating IO Bus Load by spinning over sync()]
plars4a120e82004-09-02 18:56:06 +0000143 -l LOGFILE Log results of test in a logfile.
subrata_modake099b2a2007-10-29 12:22:01 +0000144 -m NUM_PROCS,CHUNKS,BYTES,HANGUP_FLAG
145 Run LTP under additional background Load on Main memory (Seperate by comma)
146 [NUM_PROCS = no. of processes creating main Memory Load by spinning over malloc()]
147 [CHUNKS = malloc these many chunks (default is 1 when value 0 or undefined)]
148 [BYTES = malloc CHUNKS of BYTES bytes (default is 256MB when value 0 or undefined) ]
149 [HANGUP_FLAG = hang in a sleep loop after memory allocated, when value 1]
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000150 -M CHECK_TYPE
151 [CHECK_TYPE=1 => Full Memory Leak Check tracing children as well]
152 [CHECK_TYPE=2 => Thread Concurrency Check tracing children as well]
153 [CHECK_TYPE=3 => Full Memory Leak & Thread Concurrency Check tracing children as well]
plars4a120e82004-09-02 18:56:06 +0000154 -N Run all the networking tests.
155 -n Run LTP with network traffic in background.
156 -o OUTPUTFILE Redirect test output to a file.
157 -p Human readable format logfiles.
158 -q Print less verbose output to screen.
159 -r LTPROOT Fully qualified path where testsuite is installed.
subrata_modaka1fd64b2007-04-11 11:24:49 +0000160 -s PATTERN Only run test cases which match PATTERN.
subrata_modak2f6c9812009-08-14 17:07:48 +0000161 -S SKIPFILE Skip tests specified in SKIPFILE
plars4a120e82004-09-02 18:56:06 +0000162 -t DURATION Execute the testsuite for given duration. Examples:
163 -t 60s = 60 seconds
164 -t 45m = 45 minutes
165 -t 24h = 24 hours
166 -t 2d = 2 days
subrata_modak8c138332008-01-28 11:19:32 +0000167 -T REPETITION Execute the testsuite for REPETITION no. of times
subrata_modakbc833d32007-07-25 10:12:02 +0000168 -w CMDFILEADDR Uses wget to get the user's list of testcases.
plars4a120e82004-09-02 18:56:06 +0000169 -x INSTANCES Run multiple instances of this testsuite.
subrata_modakd9fb3862008-12-29 11:25:36 +0000170 -b DEVICE Some tests require an unmounted block device
171 to run correctly.
172 -B DEVICE_FS_TYPE The file system of test block devices.
173
plars4a120e82004-09-02 18:56:06 +0000174
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000175 Example:
176
177 $RUNLTP -c 2 -i 2 -m 2,4,10240,1 -D 2,10,10240,1 -p -q \
178 -l /tmp/result-log.$$ -o /tmp/result-output.$$ \
179 -C /tmp/result-failed.$$ -d $PWD
plars4a120e82004-09-02 18:56:06 +0000180
plars4a120e82004-09-02 18:56:06 +0000181
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000182EOF
183 exit 0
plars4a120e82004-09-02 18:56:06 +0000184}
185
plars4a120e82004-09-02 18:56:06 +0000186main()
187{
subrata_modakbc833d32007-07-25 10:12:02 +0000188 local CMDFILES=""
plars4a120e82004-09-02 18:56:06 +0000189 local PRETTY_PRT=""
subrata_modak5d7deea2007-09-15 13:51:36 +0000190 local ALT_DIR_OUT=0
191 local ALT_DIR_RES=0
subrata_modake47fb352007-11-25 17:03:49 +0000192 local ALT_HTML_OUT=0
subrata_modak08dde6f2007-11-28 11:02:51 +0000193 local ALT_EMAIL_OUT=0
plars4a120e82004-09-02 18:56:06 +0000194 local RUN_NETEST=0
subrata_modak8c138332008-01-28 11:19:32 +0000195 local RUN_REPEATED=0
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000196 local QUIET_MODE=0
197 local PAN_QUIET_MODE=""
plars4a120e82004-09-02 18:56:06 +0000198 local NETPIPE=0
199 local GENLOAD=0
200 local MEMSIZE=0
201 local DURATION=""
subrata_modakbc833d32007-07-25 10:12:02 +0000202 local CMDFILEADDR=""
subrata_modak43938212008-05-19 08:48:46 +0000203 local FAILCMDFILE=""
yaberauneyaef772532009-10-09 17:55:43 +0000204 local INJECT_KERNEL_FAULT=""
205 local INJECT_KERNEL_FAULT_PERCENTAGE=""
206 local INJECT_FAULT_LOOPS_PER_TEST=""
207 local VALGRIND_CHECK=""
208 local VALGRIND_CHECK_TYPE=""
subrata_modake47fb352007-11-25 17:03:49 +0000209 local LOGFILE_NAME=""
plars4a120e82004-09-02 18:56:06 +0000210 local LOGFILE=""
subrata_modake47fb352007-11-25 17:03:49 +0000211 local OUTPUTFILE_NAME=""
212 local OUTPUTFILE=""
213 local HTMLFILE_NAME=""
214 local HTMLFILE=""
subrata_modak08dde6f2007-11-28 11:02:51 +0000215 local EMAIL_TO=""
plars4a120e82004-09-02 18:56:06 +0000216 local SCENFILES=""
robbiew7d43d772005-02-07 20:07:30 +0000217 local TAG_RESTRICT_STRING=""
218 local PAN_COMMAND=""
subrata_modak43938212008-05-19 08:48:46 +0000219 local DEFAULT_FILE_NAME_GENERATION_TIME=`date +"%Y_%b_%d-%Hh_%Mm_%Ss"`
yaberauneyaef772532009-10-09 17:55:43 +0000220 version_date=$(cat "$LTPROOT/Version")
plars4a120e82004-09-02 18:56:06 +0000221
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000222 while getopts a:c:C:d:D:f:F:ehi:g:l:m:M:Nno:pqr:s:S:t:T:w:x:b:B: arg; do
223 case "$arg" in
subrata_modak08dde6f2007-11-28 11:02:51 +0000224 a) EMAIL_TO=$OPTARG
225 ALT_EMAIL_OUT=1;;
plars4a120e82004-09-02 18:56:06 +0000226 c)
subrata_modake099b2a2007-10-29 12:22:01 +0000227 NUM_PROCS=$(($OPTARG))
228 if [ "$NUM_PROCS" -eq 0 ]; then
229 # User Did not Define the Value ,or, User Defined Zero,
230 # hence, prevent from creating infinite processes
231 NUM_PROCS=1
232 fi
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000233 "$LTPROOT/testcases/bin/genload" --cpu $NUM_PROCS >/dev/null 2>&1 &
plars4a120e82004-09-02 18:56:06 +0000234 GENLOAD=1 ;;
subrata_modakbc833d32007-07-25 10:12:02 +0000235
subrata_modak5d7deea2007-09-15 13:51:36 +0000236 C)
subrata_modak6838ec32007-09-14 10:10:12 +0000237 case $OPTARG in
238 /*)
239 FAILCMDFILE="-C $OPTARG" ;;
240 *)
241 FAILCMDFILE="-C $LTPROOT/output/$OPTARG"
subrata_modak5d7deea2007-09-15 13:51:36 +0000242 ALT_DIR_OUT=1 ;;
subrata_modak6838ec32007-09-14 10:10:12 +0000243 esac ;;
plars4a120e82004-09-02 18:56:06 +0000244
subrata_modak5ee3e892008-10-21 13:17:56 +0000245 d) # convert the user path to absolute path.
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000246 export TMPBASE=$(cd $(dirname "${OPTARG}"); pwd)/$(basename "${OPTARG}")
247 ;;
subrata_modake099b2a2007-10-29 12:22:01 +0000248
249 D) NUM_PROCS=1; NUM_FILES=1; NUM_BYTES=$((1024 * 1024 * 1024)); CLEAN_FLAG=0
subrata_modak548379d2008-08-20 09:15:49 +0000250 ARGUMENT_LIST=$OPTARG
subrata_modake099b2a2007-10-29 12:22:01 +0000251 TOTAL_ARGUMENTS=1 # Initial Assume
252 for ARGUMENT in `echo "$ARGUMENT_LIST" | sed 's/,/\n/g'` # Store all value in a Loop
253 do
254 case $TOTAL_ARGUMENTS in
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000255 1) NUM_PROCS="$ARGUMENT" ;;
256 2) NUM_FILES="$ARGUMENT" ;;
257 3) NUM_BYTES="$ARGUMENT" ;;
258 4) CLEAN_FLAG="$ARGUMENT" ;;
subrata_modake099b2a2007-10-29 12:22:01 +0000259 esac
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000260 : $((TOTAL_ARGUMENTS += 1))
subrata_modake099b2a2007-10-29 12:22:01 +0000261 done
262 # just to get the default values if the user passed 0
263 if [ "$NUM_PROCS" -eq 0 ]; then
264 NUM_PROCS=1
265 fi
266 if [ "$NUM_FILES" -eq 0 ]; then
267 NUM_FILES=1
268 fi
269 if [ "$NUM_BYTES" -eq 0 ]; then
270 NUM_BYTES=$((1024 * 1024 * 1024))
271 fi
272 if [ "$CLEAN_FLAG" -ne 1 ]; then
273 CLEAN_FLAG=0
274 fi
275 if [ "$CLEAN_FLAG" -eq 1 ]; then
276 # Do not unlink file in this case
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000277 "$LTPROOT/testcases/bin/genload" --hdd $NUM_PROCS --hdd-files \
subrata_modake099b2a2007-10-29 12:22:01 +0000278 $NUM_FILES --hdd-bytes $NUM_BYTES >/dev/null 2>&1 &
279 else
280 # Cleanup otherwise
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000281 "$LTPROOT/testcases/bin/genload" --hdd $NUM_PROCS --hdd-files \
subrata_modake099b2a2007-10-29 12:22:01 +0000282 $NUM_FILES --hdd-bytes $NUM_BYTES --hdd-noclean >/dev/null 2>&1 &
283 fi
284 GENLOAD=1;;
285
mreed1091696422006-05-03 19:07:22 +0000286 e) # Print out the version of LTP
287 version_of_ltp
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000288 ;;
plars4a120e82004-09-02 18:56:06 +0000289 f) # Execute user defined set of testcases.
subrata_modakbc833d32007-07-25 10:12:02 +0000290 # Can be more then one file, just separate it with ',', like:
291 # -f nfs,commands,/tmp/testfile
292 CMDFILES=$OPTARG;;
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000293 F) INJECT_KERNEL_FAULT=1
294 #Seperate out the NO_OF_LOOPS & FAULT_PERCENTAGE
295 INJECT_FAULT_LOOPS_PER_TEST=`echo $OPTARG |cut -d',' -f1 | tr -d '\n' | tr -d ' '`
296 INJECT_KERNEL_FAULT_PERCENTAGE=`echo $OPTARG |cut -d',' -f2 | tr -d '\n' | tr -d ' '`
297 if [ ! $INJECT_FAULT_LOOPS_PER_TEST ]; then
298 warning "Loops not properly defined. Defaulting to 5..."
299 export INJECT_FAULT_LOOPS_PER_TEST=5
300 fi
301 if [ ! $INJECT_KERNEL_FAULT_PERCENTAGE ]; then
302 warning "Fault percentage not properly defined. Defaulting to 10..."
303 export INJECT_KERNEL_FAULT_PERCENTAGE=10
304 fi;;
subrata_modake47fb352007-11-25 17:03:49 +0000305 g) HTMLFILE_NAME="$OPTARG"
306 case $OPTARG in
307 /*)
308 HTMLFILE="$OPTARG";;
309 *)
subrata_modakd48c4d02008-01-23 12:59:40 +0000310 HTMLFILE="$LTPROOT/output/$OPTARG";;
311 esac
312 ALT_DIR_OUT=1
313 ALT_HTML_OUT=1;;
plars4a120e82004-09-02 18:56:06 +0000314 h) usage;;
315
subrata_modake099b2a2007-10-29 12:22:01 +0000316 i)
317 NUM_PROCS=$(($OPTARG))
318 if [ "$NUM_PROCS" -eq 0 ]; then
319 # User Did not Define the Value ,or, User Defined Zero,
320 # hence, prevent from creating infinite processes
321 NUM_PROCS=1
322 fi
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000323 "$LTPROOT/testcases/bin/genload" --io $NUM_PROCS >/dev/null 2>&1 &
plars4a120e82004-09-02 18:56:06 +0000324 GENLOAD=1 ;;
325
326 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
subrata_modake099b2a2007-10-29 12:22:01 +0000338 TOTAL_ARGUMENTS=1 # Initial Assume
339 for ARGUMENT in `echo "$ARGUMENT_LIST" | sed 's/,/\n/g'` # Store all value in a Loop
340 do
341 case $TOTAL_ARGUMENTS in
yaberauneyad8f1f5d2010-01-28 15:46:58 +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
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000347 : $(( TOTAL_ARGUMENTS += 1 ))
subrata_modake099b2a2007-10-29 12:22:01 +0000348 done
349 # just to get the default values if the user passed 0
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000350 [ "x$NUM_PROCS" = x0 ] && NUM_PROCS=1
351 [ "x$CHUNKS" != x0 ] && CHUNKS=1
352 [ "x$BYTES" = x0 ] && BYTES=$((256 * 1024 * 1024))
353 [ "x$HANGUP_FLAG" != x1 ] && HANGUP_FLAG=0
subrata_modake099b2a2007-10-29 12:22:01 +0000354 if [ "$HANGUP_FLAG" -eq 1 ]; then
355 # Hang in a Sleep loop after memory allocated
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000356 "$LTPROOT/testcases/bin/genload" --vm $NUM_PROCS --vm-chunks \
subrata_modake099b2a2007-10-29 12:22:01 +0000357 $CHUNKS --vm-bytes $BYTES --vm-hang >/dev/null 2>&1 &
358 else
359 # Otherwise Do not Hangup
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000360 "$LTPROOT/testcases/bin/genload" --vm $NUM_PROCS --vm-chunks \
subrata_modake099b2a2007-10-29 12:22:01 +0000361 $CHUNKS --vm-bytes $BYTES >/dev/null 2>&1 &
362 fi
plars4a120e82004-09-02 18:56:06 +0000363 GENLOAD=1;;
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000364 M)
365 VALGRIND_CHECK_TYPE="$OPTARG";;
subrata_modak9c7072a2009-08-26 07:00:25 +0000366
plars4a120e82004-09-02 18:56:06 +0000367 N) RUN_NETEST=1;;
368
369 n)
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000370 "$LTPROOT/testcases/bin/netpipe.sh"
plars4a120e82004-09-02 18:56:06 +0000371 NETPIPE=1;;
372
subrata_modak6838ec32007-09-14 10:10:12 +0000373 o) OUTPUTFILE_NAME="$OPTARG"
subrata_modak6838ec32007-09-14 10:10:12 +0000374 case $OPTARG in
375 /*)
376 OUTPUTFILE="-o $OPTARG";;
377 *)
378 OUTPUTFILE="-o $LTPROOT/output/$OPTARG"
subrata_modak5d7deea2007-09-15 13:51:36 +0000379 ALT_DIR_OUT=1 ;;
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000380 esac
381 ;;
plars4a120e82004-09-02 18:56:06 +0000382
383 p) PRETTY_PRT=" -p ";;
384
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000385 q)
386 PAN_QUIET_MODE=" -q "
387 QUIET_MODE=1
388 ;;
plars4a120e82004-09-02 18:56:06 +0000389
390 r) LTPROOT=$OPTARG;;
391
robbiew7d43d772005-02-07 20:07:30 +0000392 s) TAG_RESTRICT_STRING=$OPTARG;;
subrata_modak2f6c9812009-08-14 17:07:48 +0000393
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000394 S) case $OPTARG in
subrata_modak2f6c9812009-08-14 17:07:48 +0000395 /*)
396 SKIPFILE=$OPTARG;;
397 *)
398 SKIPFILE="$LTPROOT/$OPTARG";;
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000399 esac
400 ;;
robbiew7d43d772005-02-07 20:07:30 +0000401
plars4a120e82004-09-02 18:56:06 +0000402 t) # In case you want to specify the time
403 # to run from the command line
404 # (2m = two minutes, 2h = two hours, etc)
405 DURATION="-t $OPTARG" ;;
subrata_modak8c138332008-01-28 11:19:32 +0000406
407 T) # In case you want the testcases to runsequentially RUN_REPEATED times
408 RUN_REPEATED=$OPTARG;;
409
subrata_modakbc833d32007-07-25 10:12:02 +0000410 w) CMDFILEADDR=$OPTARG;;
robbiew7d43d772005-02-07 20:07:30 +0000411
plars4a120e82004-09-02 18:56:06 +0000412 x) # number of ltp's to run
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000413 warning "Concurrent invocations of ltp-pan (-x option) can cause"
414 warning "unpredictable failures, because some tests cannot be run"
415 warning "in parallel."
416 warning "Pausing for 10 seconds."
plars4a120e82004-09-02 18:56:06 +0000417 sleep 10
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000418 INSTANCES="-x $OPTARG"
419 ;;
subrata_modakd9fb3862008-12-29 11:25:36 +0000420 b) DEVICE=$OPTARG;;
421 B) DEVICE_FS_TYPE=$OPTARG;;
plars4a120e82004-09-02 18:56:06 +0000422 \?) usage;;
423 esac
424 done
subrata_modak43938212008-05-19 08:48:46 +0000425
426 ## It would be nice to create a default log file even if the user has not mentioned
427 if [ ! "$LOGFILE" ]; then ## User has not mentioned about Log File name
428 LOGFILE_NAME=$DEFAULT_FILE_NAME_GENERATION_TIME
429 LOGFILE="-l $LTPROOT/results/LTP_RUN_ON-$LOGFILE_NAME.log"
430 ALT_DIR_RES=1
431 PRETTY_PRT=" -p "
432 fi
subrata_modak6838ec32007-09-14 10:10:12 +0000433
434 ## It would be nice if a Failed File is compulsorily created (gives User better Idea of Tests that failed)
435
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000436 ## User didn't request for a failed file to be created.
437 if [ -n "$FAILCMDFILE" ]; then
subrata_modak5d7deea2007-09-15 13:51:36 +0000438 ALT_DIR_OUT=1
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000439 # User didn't request that an output log be created.
440 if [ -n "$OUTPUTFILE" ]; then
441 # User didn't request that a log file be created.
442 if [ -n "$LOGFILE" ]; then
443 FAILCMDFILE_TAG="$DEFAULT_FILE_NAME_GENERATION_TIME"
444 # User explicitly requested a log filename.
445 else
446 FAILCMDFILE_TAG=${LOGFILE_NAME##*/}
subrata_modak6838ec32007-09-14 10:10:12 +0000447 fi
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000448 # User requested for a specific output log filename.
449 else
450 FAILCMDFILE_TAG="${OUTPUTFILE_NAME##*/}"
subrata_modak6838ec32007-09-14 10:10:12 +0000451 fi
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000452 FAILCMDFILE="-C '$LTPROOT/output/LTP_RUN_ON-${FAILCMDFILE_TAG}.failed'"
subrata_modak6838ec32007-09-14 10:10:12 +0000453 fi
subrata_modaka1fd64b2007-04-11 11:24:49 +0000454
subrata_modakd48c4d02008-01-23 12:59:40 +0000455 if [ "$ALT_HTML_OUT" -eq 1 ] ; then ## User wants the HTML version of the output
subrata_modakd48c4d02008-01-23 12:59:40 +0000456 ## which the HTML parser will require
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000457 if [ "x$OUTPUTFILE" != x ]; then ## User has not mentioned about the Outputfile name, then we need to definitely generate one
subrata_modak43938212008-05-19 08:48:46 +0000458 OUTPUTFILE_NAME=$DEFAULT_FILE_NAME_GENERATION_TIME
subrata_modake47fb352007-11-25 17:03:49 +0000459 OUTPUTFILE="-o $LTPROOT/output/LTP_RUN_ON-$OUTPUTFILE_NAME.output"
subrata_modak08dde6f2007-11-28 11:02:51 +0000460 ALT_DIR_OUT=1
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000461 if [ "x$HTMLFILE" != x ] ; then ## User has not mentioned HTML File name, We need to create one
462 HTMLFILE_NAME=${OUTPUTFILE_NAME##*/}
subrata_modake47fb352007-11-25 17:03:49 +0000463 HTMLFILE="$LTPROOT/output/$HTMLFILE_NAME.html"
464 fi
465 fi
466 fi
467
subrata_modak5d7deea2007-09-15 13:51:36 +0000468 # If we need, create the output directory
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000469 if [ "$ALT_DIR_OUT" -eq 1 ] ; then
470 if ! (test -d "$LTPROOT/output" || mkdir -p "$LTPROOT/output") ; then
471 die "failed to create $LTPROOT/output"
472 fi
473 fi
subrata_modak5d7deea2007-09-15 13:51:36 +0000474 # If we need, create the results directory
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000475 if [ "$ALT_DIR_RES" -eq 1 ] ; then
476 if ! (test -d "$LTPROOT/results" || mkdir -p "$LTPROOT/results"); then
477 die "failed to create $LTPROOT/results"
478 fi
479 fi
subrata_modak5d7deea2007-09-15 13:51:36 +0000480
subrata_modaka1fd64b2007-04-11 11:24:49 +0000481 # Added -m 777 for tests that call tst_tmpdir() and try to
482 # write to it as user nobody
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000483 if ! mkdir -m 777 -p $TMPBASE ; then
484 die "unable to make temporary directory $TMPBASE"
485 fi
subrata_modak5ee3e892008-10-21 13:17:56 +0000486 # use mktemp to create "safe" temporary directories
487 export TMPTEMPLATE="${TMPBASE}/ltp-XXXXXXXXXX"
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000488 if ! export TMP=$(mktemp -d "$TMPTEMPLATE" 2>&1); then
489 die "unable to make temp directory: $TMP"
490 fi
subrata_modak225cfbe2009-06-23 14:01:26 +0000491 # To be invoked by tst_tmpdir()
492 # write to it as user nobody
493 export TMPDIR=$TMP
subrata_modak6edfbda2008-10-17 12:25:48 +0000494
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000495 if chmod 777 "$TMP" ; then
496 die "unable to chmod 777 $TMP ... aborting"
497 fi
plars4a120e82004-09-02 18:56:06 +0000498
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000499 if ! cd $TMP ; then
500 die "could not cd ${TMP} ... exiting"
501 fi
plars4a120e82004-09-02 18:56:06 +0000502
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000503 if [ -n $INSTANCES ] ; then
504 INSTANCES="$INSTANCES -O ${TMP}"
505 fi
subrata_modak6edfbda2008-10-17 12:25:48 +0000506
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000507 if [ "$RUN_NETEST" -eq 1 ] ; then
508
509 if [ -z "$RHOST" -o -z "$PASSWD" ] ; then
510
511 if [ -z "$RHOST" ] ; then
plars4a120e82004-09-02 18:56:06 +0000512 echo \
513 "INFO: Enter RHOST = 'name of the remote host machine'"
514 echo -n "-> "
515 read RHOST
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000516 fi
plars4a120e82004-09-02 18:56:06 +0000517
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000518 if [ -z "$PASSWD" ] ; then
519 echo
plars4a120e82004-09-02 18:56:06 +0000520 echo \
521 "INFO: Enter PASSWD = 'root passwd of the remote host machine'"
522 echo -n "-> "
523 read PASSWD
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000524 fi
plars4a120e82004-09-02 18:56:06 +0000525 export RHOST=$RHOST
526 export PASSWD=$PASSWD
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000527 fi
528 fi
plars4a120e82004-09-02 18:56:06 +0000529
530 # If user does not provide a command file select a default set of testcases
531 # to execute.
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000532 if [ -z "$CMDFILES" -a -z "$CMDFILEADDR" ] ; then
plars4a120e82004-09-02 18:56:06 +0000533
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000534 info "No command files were provided; executing the following default "
535 info "test scenario's:"
plars4a120e82004-09-02 18:56:06 +0000536
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000537 SCENFILES="syscalls fs fsx dio io mm ipc sched math nptl pty containers"
538 SCENFILES="$SCENFILES fs_bind controllers filecaps cap_bounds"
539 SCENFILES="$SCENFILES fcntl-locktests connectors admin_tools timers"
540 SCENFILES="$SCENFILES power_management_tests numa hugetlb commands"
plars4a120e82004-09-02 18:56:06 +0000541
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000542 case "$(uname -m)" in
543 *86*)
544 # No sense in even trying to run hyperthreading tests if it
545 # isn't an Intel platform.
546 SCENFILES="$SCENFILES hyperthreading"
547 ;;
548 esac
549
550 info "No command files were provided; executing the following default "
551 info "test scenario's:"
552 if [ "x$QUIET_MODE" != x1 ] ; then
553 for SCENARIO in $SCENFILES; do
554 echo " $SCENARIO"
555 done
556 fi
557
558 elif [ "x$CMDFILEADDR" = x ] ; then
559 SCENFILES=$(echo "$CMDFILES" | awk 'BEGIN { RS=","; } { print }')
subrata_modakbc833d32007-07-25 10:12:02 +0000560 fi
561
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000562 if [ "x$SCENFILES" != x ] ; then
subrata_modakbc833d32007-07-25 10:12:02 +0000563
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000564 for SCENARIO in "$SCENFILES"; do
565
566 # Most likely not an absolute path.
567 if [ ! -f "$SCENARIO" ] ; then
568 # Relative path from $OLDCWD.
569 if [ -f "$OLDCWD/$SCENFILES" ] ; then
570 SCENFILE="$OLDCWD/$SCENARIO"
571 # Let's assume it's just a runtest filename -- we'll figure
572 # out whether or not this assumption is correct in a
573 # second ;)...
574 else
575 SCENFILE="$LTPROOT/runtest/$SCENARIO"
576 fi
577 fi
578 # Print out a user readable message that makes sense, because the
579 # `unable to create command file' one isn't helpful in this regard
580 # if the file doesn't exist...
581 if [ ! -f "$SCENFILE" ] ; then
582 die "scenario file - $SCENFILE - doesn't exist."
583 elif ! cat "$SCENFILE" >> "$TMP/alltests"; then
584 die "unable add $SCENFILE to command file \`$TMP/alltests'"
585 fi
586
plars4a120e82004-09-02 18:56:06 +0000587 done
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000588
589 elif [ "x$CMDFILEADDR" != x ] ; then
590 if ! type wget >/dev/null; then
591 die "You must have wget to get $CMDFILEADDR"
592 elif wget -q "$CMDFILEADDR" -O "$TMP/wgetcmdfile" ; then
593 die "the file transfer with wget failed (address $CMDFILEADDR)"
594 elif ! cat "$TMP/wgetcmdfile" >> "$TMP/alltests" ; then
595 die "unable to add scenario - $SCENFILE - to the command file"
596 fi
597 fi
598
599 if [ "$RUN_NETEST" -eq 1 ] ; then
600
601 for SCENARIO in tcp_cmds multicast rpc nfs ; do
602
603 SCENFILE="$LTPROOT/runtest/$SCENARIO"
604 if [ ! -e "$SCENFILE" ] ; then
605 die "missing scenario file: $SCENFILE"
606 fi
607
608 if ! cat "$SCENFILE" >> ${TMP}/alltests ; then
609 die "unable to add scenario - $SCENFILE - to $TMP/alltests"
610 fi
611
612 done
613
614 fi
subrata_modakbc833d32007-07-25 10:12:02 +0000615
plars4a120e82004-09-02 18:56:06 +0000616 # The fsx-linux tests use the SCRATCHDEV environment variable as a location
617 # that can be reformatted and run on. Set SCRATCHDEV if you want to run
618 # these tests. As a safeguard, this is disabled.
619 unset SCRATCHDEV
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000620 if [ "x$SCRATCHDEV" != x ] ; then
621 if ! cat "$LTPROOT/runtest/fsx" >> "$TMP/alltests"; then
622 die "unable to create fsx-linux tests command file: $TMP/alltests"
623 fi
624 fi
subrata_modakbc833d32007-07-25 10:12:02 +0000625
626 # If enabled, execute only test cases that match the PATTERN
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000627 if [ -n "$TAG_RESTRICT_STRING" ]; then
628 mv -f "$TMP/alltests" "$TMP/alltests.orig"
629 # Filter out all non-restricted tags.
630 grep "$TAG_RESTRICT_STRING" "$TMP/alltests.orig" > "$TMP/alltests"
subrata_modakbc833d32007-07-25 10:12:02 +0000631 fi
subrata_modak2f6c9812009-08-14 17:07:48 +0000632
633 # Blacklist or skip tests if a SKIPFILE was specified with -S
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000634 if [ -n "$SKIPFILE" ]; then
subrata_modak2f6c9812009-08-14 17:07:48 +0000635 for file in $( cat $SKIPFILE ); do
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000636 sed -i "/$file/d" "${TMP}/alltests"
subrata_modak2f6c9812009-08-14 17:07:48 +0000637 done
638 fi
plars4a120e82004-09-02 18:56:06 +0000639
640 # check for required users and groups
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000641 if "$LTPROOT/IDcheck.sh" &>/dev/null ; then
642 warning "missing some required users and/or groups; some testcases will fail"
643 fi
plars4a120e82004-09-02 18:56:06 +0000644 # display versions of installed software
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000645 if [ -z "$QUIET_MODE" ] ; then
646 if ! "$LTPROOT/ver_linux" ; then
647 die "unable to display versions of software installed"
648 fi
subrata_modakd9fb3862008-12-29 11:25:36 +0000649 fi
650
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000651 if [ "x$DEVICE" != x ]; then
652 if ! sed -i "s|DEVICE|$DEVICE|" "$TMP/alltests" ; then
653 die "the sed operation on alltests failed (DEVICE)"
654 elif ! mnt_pnt=$(mktemp -d --tmpdir=${TMP} mnt_pnt.XXXXXX); then
655 die "Failed to create a temporary mountpoint"
656 fi
subrata_modakd9fb3862008-12-29 11:25:36 +0000657 if [ -n "$DEVICE_FS_TYPE" ]; then
658 mount -t $DEVICE_FS_TYPE $DEVICE $mnt_pnt
659 else
660 mount $DEVICE $mnt_pnt
661 fi
662
663 if [ $? -ne 0 ]; then
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000664 die "can't mount block device $DEVICE."
subrata_modakd9fb3862008-12-29 11:25:36 +0000665 fi
666
667 if [ -z "$DEVICE_FS_TYPE" ]; then
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000668 DEVICE_FS_TYPE=$(awk "{if (\\\$1 == \"$DEVICE\") print \\\$3; }" /proc/mounts)
669 info "determining the file system $DEVICE_FS_TYPE on block device $DEVICE"
subrata_modakd9fb3862008-12-29 11:25:36 +0000670 fi
671
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000672 if ! umount $DEVICE; then
673 die "can't umount $DEVICE"
subrata_modakd9fb3862008-12-29 11:25:36 +0000674 fi
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000675 else
676 info "removing testcases which require block devices."
677 if ! sed -i "/DEVICE/d" "$TMP/alltests"; then
678 die "the sed operation on alltests failed (DEVICE)"
679 fi
subrata_modakd9fb3862008-12-29 11:25:36 +0000680 fi
681
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000682 if [ "x$DEVICE_FS_TYPE" != x ]; then
683 if ! sed -i "s|DEVICE_FS_TYPE|$DEVICE_FS_TYPE|" "$TMP/alltests" ; then
684 die "the sed operation on alltests failed (DEVICE_FS_TYPE)"
685 fi
subrata_modakd9fb3862008-12-29 11:25:36 +0000686 fi
687
subrata_modak8c138332008-01-28 11:19:32 +0000688 if [ $RUN_REPEATED -gt 1 ]; then # You need to specify at least more than 1 sequential run, else it runs default
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000689 info "PAN will run these test cases $RUN_REPEATED times."
690 info "Test Tags will be prefixed with iteration"
691 inc=1
692 ## Remove all whitespace.
693 sed -e '/^$/ d' -e 's/^[ ,\t]*//' -e '/^#/ d' < "$TMP/alltests" > "$TMP/alltests.temp"
694 ## .temp is the baseline file
695 sed 's/^[0-9,a-z,A-Z]*/'"$inc"'_ITERATION_&/' < "$TMP/alltests.temp" > "$TMP/alltests"
696 while [ $inc -lt $RUN_REPEATED ] ; do
697 : $(( inc += 1 ))
698 # Append the iteration number.
699 sed 's/^[0-9,a-z,A-Z]*/'"$inc"'_ITERATION_&/' < "$TMP/alltests.temp" >> "$TMP/alltests"
700 done
subrata_modak8c138332008-01-28 11:19:32 +0000701 fi
702
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000703 info "Test start time: $(date)"
704 PAN_COMMAND="\"${LTPROOT}/bin/ltp-pan\" $PAN_QUIET_MODE -e -S $INSTANCES"
705 PAN_COMMAND="$PAN_COMMAND $DURATION -a $$ -n $$ $PRETTY_PRT"
706 PAN_COMMAND="$PAN_COMMAND -f \"$TMP/alltests\" $LOGFILE $OUTPUTFILE "
707 PAN_COMMAND="$PAN_COMMAND $FAILCMDFILE"
708 info "COMMAND: $PAN_COMMAND"
709 if [ -n "$TAG_RESTRICT_STRING" ] ; then
710 info "Restricting testcase tags to: $TAG_RESTRICT_STRING"
robbiew7d43d772005-02-07 20:07:30 +0000711 fi
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000712
subrata_modak43938212008-05-19 08:48:46 +0000713 ## Display the Output/Log/Failed/HTML file names here
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000714 info "LOG File: $(cut -b4- < "$LOGFILE")"
subrata_modak43938212008-05-19 08:48:46 +0000715
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000716 [ -n "$OUTPUTFILE" ] && info "OUTPUT File: $(cut -b4- < "$OUTPUTFILE")"
717 info "FAILED COMMAND File: $(cut -b4- < "$FAILCMDFILE")"
718
719 [ -n "$HTMLFILE" ] && info "HTML File: $HTMLFILE"
720
721 # User wants testing with Kernel Fault Injection
722 if [ "x$INJECT_KERNEL_FAULT" = x1 ] ; then
723 #See if Debugfs is mounted, and
724 #Fault Injection Framework available through Debugfs
725 if [ -d "/sys/kernel/debug/fail_io_timeout" -o \
726 -d "/sys/kernel/debug/fail_make_request" -o \
727 -d "/sys/kernel/debug/fail_page_alloc" -o \
728 -d "/sys/kernel/debug/failslab" ]; then
729 # If atleast one of the Framework is available
730 # Go ahead to Inject Fault & Create required
731 # Command Files for LTP run
732 info "Running tests with Fault Injection Enabled in the Kernel..."
733 "${LTPROOT}/bin/create_kernel_faults_in_loops_and_probability.pl"\
734 "${TMP}/alltests" $INJECT_FAULT_LOOPS_PER_TEST \
735 $INJECT_KERNEL_FAULT_PERCENTAGE > "${TMP}/alltests.tmp"
736 cp "${TMP}/alltests.tmp" "${TMP}/alltests"
737 rm -f "${TMP}/alltests.tmp"
738 else
739 warning "Fault injection not enabled in the kernel; will run"
740 warning "testcases normally."
741 fi
742 ## Valgrind Check will work only when Kernel Fault Injection is not expected,
743 ## We do not want to test Faults when valgrind is running
744 elif [ "x$VALGRIND_CHECK_TYPE" = x1 ]; then
745 if ! type valgrind 2>/dev/null ; then
746 error "valgrind isn't available"
747 else
748 case "$VALGRIND_CHECK_TYPE" in
749 [1-3])
750 "${LTPROOT}/bin/create_valgrind_check.pl" "$TMP/alltests" \
751 $VALGRIND_CHECK_TYPE > "$TMP/alltests.tmp"
752 cp "$TMP/alltests.tmp" "$TMP/alltests"
753 rm -rf "$TMP/alltests.tmp"
754 ;;
755 *)
756 error "Invalid valgrind memory check type: $VALGRIND_CHECK_TYPE.";;
757 esac
758 fi
subrata_modak43938212008-05-19 08:48:46 +0000759 fi
760
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000761 info "Running tests......."
subrata_modake47fb352007-11-25 17:03:49 +0000762 test_start_time=$(date)
subrata_modak724098e2009-03-19 08:49:18 +0000763
764 # Some tests need to run inside the "bin" directory.
765 cd "${LTPROOT}/testcases/bin"
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000766 "${PAN_COMMAND}"
767 #"${LTPROOT}/bin/ltp-pan" $PAN_QUIET_MODE -e -S $INSTANCES $DURATION -a $$ \
768 # -n $$ $PRETTY_PRT -f "$TMP/alltests" "$LOGFILE" "$OUTPUTFILE" \
769 # "$FAILCMDFILE"
subrata_modakd48c4d02008-01-23 12:59:40 +0000770
plars4a120e82004-09-02 18:56:06 +0000771 if [ $? -eq 0 ]; then
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000772 info "ltp-pan reported all tests PASS'ed"
773 LTP_EXIT_VALUE=0
plars4a120e82004-09-02 18:56:06 +0000774 else
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000775 info "ltp-pan reported some tests FAIL'ed"
776 LTP_EXIT_VALUE=1
plars4a120e82004-09-02 18:56:06 +0000777 fi
subrata_modak724098e2009-03-19 08:49:18 +0000778 cd ..
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000779 info "LTP Version: $version_date"
mreed1091696422006-05-03 19:07:22 +0000780
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000781 # Punt out
subrata_modake47fb352007-11-25 17:03:49 +0000782 if [ "$ALT_HTML_OUT" -eq 1 ] ; then #User wants the HTML output to be created, it then needs to be generated
783 export LTP_VERSION=$version_date
784 export TEST_START_TIME=$test_start_time
785 export TEST_END_TIME=$(date)
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000786 OUTPUT_DIRECTORY=$(cut -c4- < "$OUTPUTFILE")
subrata_modake47fb352007-11-25 17:03:49 +0000787 LOGS_DIRECTORY="$LTPROOT/results"
788 export TEST_OUTPUT_DIRECTORY="$LTPROOT/output"
789 export TEST_LOGS_DIRECTORY=$LOGS_DIRECTORY
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000790 info "Generating HTML Output.....!!"
791 ( perl $LTPROOT/bin/genhtml.pl $LTPROOT/bin/html_report_header.txt \
792 test_start test_end test_output execution_status \
793 "$OUTPUT_DIRECTORY" > "$HTMLFILE" )
794 info "Generated HTML Output.....!!"
795 info "Location: $HTMLFILE"
subrata_modake47fb352007-11-25 17:03:49 +0000796 fi
797
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000798 # Send email report
799 if [ "$ALT_EMAIL_OUT" -eq 1 ] ; then
800
801 if [ ! -r "$HTMLFILE_NAME" -a ! -r "$OUTPUTFILE_NAME" -a ! -r "$LOGFILE_NAME" ] ; then
802 ## User does not have output/logs/html-output, nothing to be
803 ## mailed in this situation
804 info "Nothing to be mailed"
805 elif ! MUTT=$(which mutt 2>/dev/null) && ! MAIL=$(which mail 2>/dev/null) ; then
806 error "********************************************"
807 error "Cannot find a working copy of mail or mutt."
808 error "Will not email report."
809 error "********************************************"
810 elif ! type gzip 2>/dev/null; then
811 error "********************************************"
812 error "Cannot find a working copy of gzip"
813 error "Will not email report."
814 error "********************************************"
subrata_modak08dde6f2007-11-28 11:02:51 +0000815 else
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000816
subrata_modak43938212008-05-19 08:48:46 +0000817 TAR_FILE_NAME=LTP_RUN_$version_date$DEFAULT_FILE_NAME_GENERATION_TIME.tar
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000818
819 # Got HTML file.
820 for f in "$HTMLFILE_NAME" "$OUTPUTFILE_NAME" ; do
821
822 if [ -r "$f" -a "$(readlink -f "$(dirname "$f")")" != "$(readlink -f "$LTPROOT/output")" ] ; then
823
824 test -d "$LTPROOT/output" || mkdir -p "$LTPROOT/output"
825 if [ $? -eq 0 ] ; then
826 cp $HTMLFILE_NAME "$LTPROOT/output/."
827 else
828 error "Failed to create \`$LTPROOT/output/'."
829 error "Skipping tar for all files in $LTPROOT/output/."
830 fi
831
832 fi
833
834 done
835
836 if [ -r "$LOGFILE_NAME" -a "$(readlink -f "$(dirname "$LOGFILE_NAME")")" != "$(readlink -f "$LTPROOT/results")" ] ; then
837 test -d mkdir -p "$LTPROOT/results" ## We need to create this Directory
838 cp "$LOGFILE_NAME" "$LTPROOT/results/."
839 fi
840 test -d "$LTPROOT/output" || mkdir -p "$LTPROOT/output"
841 if [ $? -eq 0 ] ; then
842 cp "$LOGFILE_NAME" "$LTPROOT/results/."
843 else
844 error "Failed to create \`$LTPROOT/results/'."
845 error "Skipping tar for all files in $LTPROOT/results/."
846 fi
subrata_modak08dde6f2007-11-28 11:02:51 +0000847 fi
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000848 # Got output log(s)
849 if [ -d "$LTPROOT/output" ] ; then
850 if tar -cf "./$TAR_FILE_NAME" "$LTPROOT/output"; then
851 info "Created TAR File: ./$TAR_FILE_NAME successfully, added $LTPROOT/output"
852 else
853 error "Cannot Create TAR File: ./$TAR_FILE_NAME for adding $LTPROOT/output"
854 fi
855 fi # END: output log(s)
856 # Got results file(s)
857 if [ -d "$LTPROOT/results" ] ; then
858 if tar -uf "./$TAR_FILE_NAME" "$LTPROOT/results"; then
859 info "Updated TAR File: ./$TAR_FILE_NAME successfully, added $LTPROOT/results"
860 else
861 error "Cannot Update TAR File: ./$TAR_FILE_NAME for adding $LTPROOT/results"
862 fi
863 fi # END: results file(s)
864 if [ -e "$LTPROOT/nohup.out" ] ; then
865 if tar -uf "./$TAR_FILE_NAME" "$LTPROOT/nohup.out"; then
866 info "Updated TAR File: ./$TAR_FILE_NAME successfully, added $LTPROOT/nohup.out"
867 else
868 error "Cannot Update TAR File: ./$TAR_FILE_NAME for adding $LTPROOT/nohup.out"
869 fi
subrata_modak08dde6f2007-11-28 11:02:51 +0000870 fi
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000871 if gzip "./$TAR_FILE_NAME"; then
872
873 info "Gunzipped TAR File: ./$TAR_FILE_NAME"
874
875 # Use mutt(1)
876 if [ -n "$MUTT" ] ; then
877 info "Starting mailing reports to: $EMAIL_TO, file: ./$TAR_FILE_NAME.gz"
878 mutt -a ./$TAR_FILE_NAME.gz -s "LTP Reports on $test_start_time" $EMAIL_TO < /dev/null
879 if [ $? -eq 0 ]; then
880 info "Reports Successfully mailed to: $EMAIL_TO"
881 else
882 error "Email operation failed"
883 fi
884 # Use mail(1)
885 elif [ -n "$MAIL" ] ; then
886 echo "Starting mailing reports to: $EMAIL_TO, file: ./$TAR_FILE_NAME.gz"
887 uuencode ./$TAR_FILE_NAME.gz $TAR_FILE_NAME.gz | mail $EMAIL_TO -s "LTP Reports on $test_start_time"
888 if [ $? -eq 0 ]; then
889 info "Reports Successfully mailed to: $EMAIL_TO"
890 else
891 error "Email operation failed"
892 fi
893
894 else
895 die "Programmer error; please report bug (\$MAIL and \$MUTT were both zero-length strings)."
896 fi # END: Send email via client mail or mutt.
subrata_modak08dde6f2007-11-28 11:02:51 +0000897 else
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000898 error "Cannot Gunzip TAR File: ./$TAR_FILE_NAME"
subrata_modak08dde6f2007-11-28 11:02:51 +0000899 fi
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000900
subrata_modak08dde6f2007-11-28 11:02:51 +0000901 fi
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000902 # END: Got something to email? // got a client to email with? //
903 # got gzip? // send report.
904
905 fi # END: Send email report?
subrata_modak08dde6f2007-11-28 11:02:51 +0000906
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000907 info "Test end time: $(date)"
plars4a120e82004-09-02 18:56:06 +0000908
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000909 [ "x$GENLOAD" = x1 ] && (killall -9 genload >/dev/null 2>&1)
910 [ "x$NETPIPE" = x1 ] && (killall -9 NPtcp >/dev/null 2>&1)
plars4a120e82004-09-02 18:56:06 +0000911
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000912 if [ "x$ALT_DIR_OUT" = x1 -o "x$ALT_DIR_RES" = x1 ] ; then
913 cat <<-EOF
plars4a120e82004-09-02 18:56:06 +0000914
915 ###############################################################"
916
917 Done executing testcases."
mreed1091696422006-05-03 19:07:22 +0000918 LTP Version: $version_date
plars4a120e82004-09-02 18:56:06 +0000919 ###############################################################"
920
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000921 EOF
922 fi
923 exit $LTP_EXIT_VALUE
924
plars4a120e82004-09-02 18:56:06 +0000925}
926
927cleanup()
928{
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000929 rm -rf "${TMP}"
plars4a120e82004-09-02 18:56:06 +0000930}
931
932trap "cleanup" 0
933setup
934main "$@"