blob: e86f5c7c2ebc5a11a1fb12b03732a8dd9d1a13f5 [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"`
Cyril Hrubisc381f582013-08-08 18:19:35 +0200209 local DEVICE_FS_TYPE="ext2"
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800210 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 /*)
Cyril Hrubisc381f582013-08-08 18:19:35 +0200320 DMESG_DIR="$OPTARG-dmesg-output-`echo $$-``date +%X | tr -d ' '`";;
Subrata Modakbd9d4402010-05-12 22:03:21 +0530321 *)
Cyril Hrubisc381f582013-08-08 18:19:35 +0200322 DMESG_DIR="$LTPROOT/output/$OPTARG-dmesg-output-`echo $$-``date +%X | tr -d ' '`";;
Subrata Modakbd9d4402010-05-12 22:03:21 +0530323 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 {
Anders Roxell4691f012013-09-03 09:42:35 +0200540 printf "INFO: Enter RHOST = 'name of the remote host machine'"
541 printf "\n-> "
plars4a120e82004-09-02 18:56:06 +0000542 read RHOST
yaberauneya6d41cc32010-01-28 16:24:16 +0000543 }
plars4a120e82004-09-02 18:56:06 +0000544
yaberauneya6d41cc32010-01-28 16:24:16 +0000545 [ -z "$PASSWD" ] && \
546 {
Anders Roxell4691f012013-09-03 09:42:35 +0200547 printf "\nINFO: "
548 printf "Enter PASSWD = 'root passwd of the remote host machine'"
549 printf "\n-> "
plars4a120e82004-09-02 18:56:06 +0000550 read PASSWD
yaberauneya6d41cc32010-01-28 16:24:16 +0000551 }
plars4a120e82004-09-02 18:56:06 +0000552 export RHOST=$RHOST
553 export PASSWD=$PASSWD
yaberauneya6d41cc32010-01-28 16:24:16 +0000554 echo "WARNING: security of $RHOST may be compromised"
555 }
556 }
Chris Dearman37550cf2012-10-17 19:54:01 -0700557
plars4a120e82004-09-02 18:56:06 +0000558 # If user does not provide a command file select a default set of testcases
559 # to execute.
yaberauneya6d41cc32010-01-28 16:24:16 +0000560 if [ -z "$CMDFILES" ] && [ -z "$CMDFILEADDR" ]
561 then
562 cat <<-EOF >&1
plars4a120e82004-09-02 18:56:06 +0000563
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800564 INFO: no command files were provided. Will execute the following
565 runtest scenario files:
Garrett Cooper66d67b52010-11-16 22:42:48 -0800566
567`cat $LTPROOT/scenario_groups/default | tr '\012' ' '`
Chris Dearman37550cf2012-10-17 19:54:01 -0700568
yaberauneya6d41cc32010-01-28 16:24:16 +0000569 EOF
plars4a120e82004-09-02 18:56:06 +0000570
Garrett Cooper89fde872010-11-16 22:38:08 -0800571 SCENARIO_LISTS="$LTPROOT/scenario_groups/default"
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800572 if [ "$RUN_NETEST" -eq 1 ]; then
Garrett Cooper89fde872010-11-16 22:38:08 -0800573 SCENARIO_LISTS="$SCENARIO_LISTS $LTPROOT/scenario_groups/network"
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800574 fi
plars4a120e82004-09-02 18:56:06 +0000575
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800576 # DO NOT INDENT/DEDENT!
577 if [ -n "$SCENARIO_LISTS" ]; then
578 # Insurance to make sure that the first element in the pipe
579 # completed successfully.
580 cat_ok_sentinel=$TMP/cat_ok.$$
Garrett Cooper66d67b52010-11-16 22:42:48 -0800581 (cat $SCENARIO_LISTS && touch "$cat_ok_sentinel") | \
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800582 while read scenfile; do
583
584 scenfile=${LTPROOT}/runtest/$scenfile
585
586 # Skip over non-existent scenario files; things are
587 # robust enough now that the build will fail if these
588 # files don't exist.
589 [ -f "$scenfile" ] || continue
590
591 cat $scenfile >> "$TMP/alltests" || {
592 echo "FATAL: unable to append to command file"
593 rm -Rf "$TMP"
594 rm -f "$cat_ok_sentinel"
595 exit 1
596 }
597
598 done
599
600 rm -f "$cat_ok_sentinel"
601
602 fi
603 # ^^DO NOT INDENT/DEDENT!^^
604
subrata_modakbc833d32007-07-25 10:12:02 +0000605 fi
606
yaberauneya6d41cc32010-01-28 16:24:16 +0000607 [ -n "$CMDFILES" ] && \
608 {
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800609 for scenfile in `echo "$CMDFILES" | tr ',' ' '`
yaberauneya6d41cc32010-01-28 16:24:16 +0000610 do
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800611 [ -f "$scenfile" ] || scenfile="$LTPROOT/runtest/$scenfile"
612 cat "$scenfile" >> ${TMP}/alltests || \
yaberauneya6d41cc32010-01-28 16:24:16 +0000613 {
614 echo "FATAL: unable to create command file"
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800615 rm -Rf "$TMP"
yaberauneya6d41cc32010-01-28 16:24:16 +0000616 exit 1
617 }
plars4a120e82004-09-02 18:56:06 +0000618 done
yaberauneya6d41cc32010-01-28 16:24:16 +0000619 }
Chris Dearman37550cf2012-10-17 19:54:01 -0700620
yaberauneya6d41cc32010-01-28 16:24:16 +0000621 [ -n "$CMDFILEADDR" ] && \
622 {
623 wget -q "${CMDFILEADDR}" -O ${TMP}/wgetcmdfile
624 if [ $? -ne 0 ]; then
625 echo "FATAL: error while getting the command file with wget (address $CMDFILEADDR)"
626 exit 1
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000627 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000628 cat "${TMP}/wgetcmdfile" >> ${TMP}/alltests || \
629 {
630 echo "FATAL: unable to create command file"
631 exit 1
632 }
633 }
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000634
plars4a120e82004-09-02 18:56:06 +0000635 # The fsx-linux tests use the SCRATCHDEV environment variable as a location
Chris Dearman37550cf2012-10-17 19:54:01 -0700636 # that can be reformatted and run on. Set SCRATCHDEV if you want to run
plars4a120e82004-09-02 18:56:06 +0000637 # these tests. As a safeguard, this is disabled.
638 unset SCRATCHDEV
yaberauneya6d41cc32010-01-28 16:24:16 +0000639 [ -n "$SCRATCHDEV" ] && \
640 {
641 cat ${LTPROOT}/runtest/fsx >> ${TMP}/alltests ||
642 {
643 echo "FATAL: unable to create fsx-linux tests command file"
644 exit 1
645 }
646 }
subrata_modakbc833d32007-07-25 10:12:02 +0000647
648 # If enabled, execute only test cases that match the PATTERN
yaberauneya6d41cc32010-01-28 16:24:16 +0000649 if [ -n "$TAG_RESTRICT_STRING" ]
650 then
651 mv -f ${TMP}/alltests ${TMP}/alltests.orig
652 grep $TAG_RESTRICT_STRING ${TMP}/alltests.orig > ${TMP}/alltests #Not worth checking return codes for this case
subrata_modakbc833d32007-07-25 10:12:02 +0000653 fi
subrata_modak2f6c9812009-08-14 17:07:48 +0000654
655 # Blacklist or skip tests if a SKIPFILE was specified with -S
yaberauneya6d41cc32010-01-28 16:24:16 +0000656 if [ -n "$SKIPFILE" ]
657 then
subrata_modak2f6c9812009-08-14 17:07:48 +0000658 for file in $( cat $SKIPFILE ); do
Andrew Chen410c6952011-06-30 14:19:45 +0800659 sed -i "/^$file[ \t]/d" ${TMP}/alltests
subrata_modak2f6c9812009-08-14 17:07:48 +0000660 done
661 fi
Chris Dearman37550cf2012-10-17 19:54:01 -0700662
plars4a120e82004-09-02 18:56:06 +0000663 # check for required users and groups
Cyril Hrubisb88fa5b2013-06-25 15:50:08 +0200664 ${LTPROOT}/IDcheck.sh || \
yaberauneya6d41cc32010-01-28 16:24:16 +0000665 {
666 echo "WARNING: required users and groups not present"
667 echo "WARNING: some test cases may fail"
668 }
Chris Dearman37550cf2012-10-17 19:54:01 -0700669
plars4a120e82004-09-02 18:56:06 +0000670 # display versions of installed software
yaberauneya6d41cc32010-01-28 16:24:16 +0000671 [ -z "$QUIET_MODE" ] && \
Chris Dearman37550cf2012-10-17 19:54:01 -0700672 {
yaberauneya6d41cc32010-01-28 16:24:16 +0000673 ${LTPROOT}/ver_linux || \
674 {
675 echo "WARNING: unable to display versions of software installed"
676 exit 1
677 }
678 }
679
680 if [ -n "$DEVICE" ]; then
681 sed -i "s|DEVICE|$DEVICE|" ${TMP}/alltests
Ramesh YR0a78f232013-04-16 09:31:28 +0800682 RC=$?
yaberauneya6d41cc32010-01-28 16:24:16 +0000683 else
Ramesh YR0a78f232013-04-16 09:31:28 +0800684 create_block
685 if [ $? -eq 0 ]; then
686 sed -i "s|DEVICE|$DEVICE|" ${TMP}/alltests
687 RC=$?
688 else
689 echo "no block device was specified on commandline."
690 echo "Block device could not be created using loopback device"
691 echo "Tests which require block device are disabled."
692 echo "You can specify it with option -b"
693 sed -i "/DEVICE/d" ${TMP}/alltests
694 RC=$?
695 fi
subrata_modakd9fb3862008-12-29 11:25:36 +0000696 fi
697
Ramesh YR0a78f232013-04-16 09:31:28 +0800698 if [ $RC -ne 0 ]; then
699 echo "FATAL: error during processing alltests file by sed"
yaberauneya6d41cc32010-01-28 16:24:16 +0000700 exit 1
701 fi
702
703 if [ -n "$DEVICE" ]; then
Wanlong Gao0b6c3562012-06-22 10:35:35 +0800704 sed -i "s|DEVICE_FS_TYPE|$DEVICE_FS_TYPE|" ${TMP}/alltests
yaberauneya6d41cc32010-01-28 16:24:16 +0000705 fi
706
707 if [ $? -ne 0 ]; then
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800708 echo "FATAL: error during processing alltests file by sed"
yaberauneya6d41cc32010-01-28 16:24:16 +0000709 exit 1
subrata_modakd9fb3862008-12-29 11:25:36 +0000710 fi
711
subrata_modak8c138332008-01-28 11:19:32 +0000712 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 +0000713 echo "PAN will run these test cases $RUN_REPEATED times....."
714 echo "Test Tags will be Prepended with ITERATION NO.s....."
715 inc=1
716 sed -e '/^$/ d' -e 's/^[ ,\t]*//' -e '/^#/ d' < ${TMP}/alltests > ${TMP}/alltests.temp ##This removes all newlines, leading spaces, tabs, #
717 sed 's/^[0-9,a-z,A-Z]*/'"$inc"'_ITERATION_&/' < ${TMP}/alltests.temp > ${TMP}/alltests ## .temp is kept as Base file
718 while [ $inc -lt $RUN_REPEATED ] ; do
719 inc=`expr $inc + 1`
720 sed 's/^[0-9,a-z,A-Z]*/'"$inc"'_ITERATION_&/' < ${TMP}/alltests.temp >> ${TMP}/alltests #Keep appending with Iteration No.s
721 done
subrata_modak8c138332008-01-28 11:19:32 +0000722 fi
723
yaberauneya6d41cc32010-01-28 16:24:16 +0000724 [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test start time: $(date)" ; }
725 PAN_COMMAND="${LTPROOT}/bin/ltp-pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ \
726 -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE $FAILCMDFILE"
727 echo "COMMAND: $PAN_COMMAND"
728 if [ ! -z "$TAG_RESTRICT_STRING" ] ; then
729 echo "INFO: Restricted to $TAG_RESTRICT_STRING"
robbiew7d43d772005-02-07 20:07:30 +0000730 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000731 #$PAN_COMMAND #Duplicated code here, because otherwise if we fail, only "PAN_COMMAND" gets output
Chris Dearman37550cf2012-10-17 19:54:01 -0700732
subrata_modak43938212008-05-19 08:48:46 +0000733 ## Display the Output/Log/Failed/HTML file names here
Anders Roxell4691f012013-09-03 09:42:35 +0200734 printf "LOG File: "
yaberauneya6d41cc32010-01-28 16:24:16 +0000735 echo $LOGFILE | cut -b4-
subrata_modak43938212008-05-19 08:48:46 +0000736
yaberauneya6d41cc32010-01-28 16:24:16 +0000737 if [ "$OUTPUTFILE" ]; then
Anders Roxell4691f012013-09-03 09:42:35 +0200738 printf "OUTPUT File: "
yaberauneya6d41cc32010-01-28 16:24:16 +0000739 echo $OUTPUTFILE | cut -b4-
subrata_modak43938212008-05-19 08:48:46 +0000740 fi
741
Anders Roxell4691f012013-09-03 09:42:35 +0200742 printf "FAILED COMMAND File: "
yaberauneya6d41cc32010-01-28 16:24:16 +0000743 echo $FAILCMDFILE | cut -b4-
744
745 if [ "$HTMLFILE" ]; then
746 echo "HTML File: $HTMLFILE"
747 fi
748
749 echo "Running tests......."
subrata_modake47fb352007-11-25 17:03:49 +0000750 test_start_time=$(date)
subrata_modak724098e2009-03-19 08:49:18 +0000751
yaberauneya6d41cc32010-01-28 16:24:16 +0000752 # User wants testing with Kernel Fault Injection
753 if [ $INJECT_KERNEL_FAULT ] ; then
754 #See if Debugfs is mounted, and
755 #Fault Injection Framework available through Debugfs
Garrett Coopercb66da52012-04-03 22:09:42 -0700756 use_faultinjection=true
757 for debug_subdir in \
758 fail_io_timeout \
759 fail_make_request \
760 fail_page_alloc \
761 failslab \
762 ; do
763 if [ -d "/sys/kernel/debug/$debug_subdir" ]
764 then
765 use_faultinjection=true
766 break
767 fi
768 done
769 if $use_faultinjection; then
yaberauneya6d41cc32010-01-28 16:24:16 +0000770 #If atleast one of the Framework is available
771 #Go ahead to Inject Fault & Create required
772 #Command Files for LTP run
773 echo Running tests with Fault Injection Enabled in the Kernel...
Garrett Coopercb66da52012-04-03 22:09:42 -0700774 awk -v LOOPS=$INJECT_FAULT_LOOPS_PER_TEST \
775 -v PERCENTAGE=$INJECT_KERNEL_FAULT_PERCENTAGE \
776 -f ${LTPROOT}/bin/create_kernel_faults_in_loops_and_probability.awk \
777 ${TMP}/alltests > ${TMP}/alltests.tmp
yaberauneya6d41cc32010-01-28 16:24:16 +0000778 cp ${TMP}/alltests.tmp ${TMP}/alltests
779 rm -rf ${TMP}/alltests.tmp
780 else
781 echo Fault Injection not enabled in the Kernel..
782 echo Running tests normally...
783 fi
784 fi
785
786 ## Valgrind Check will work only when Kernel Fault Injection is not expected,
787 ## We do not want to test Faults when valgrind is running
788 if [ $VALGRIND_CHECK ]; then
789 if [ ! $INJECT_KERNEL_FAULT ]; then
790 which valgrind || VALGRIND_CHECK_TYPE=XYZ
791 case $VALGRIND_CHECK_TYPE in
Garrett Cooper3920fd12012-04-03 19:47:16 -0700792 [1-3])
793 awk -v CHECK_LEVEL=$VALGRIND_CHECK_TYPE \
794 -f ${LTPROOT}/bin/create_valgrind_check.awk \
795 ${TMP}/alltests $VALGRIND_CHECK_TYPE > \
796 ${TMP}/alltests.tmp
yaberauneya6d41cc32010-01-28 16:24:16 +0000797 cp ${TMP}/alltests.tmp ${TMP}/alltests
Garrett Cooper3920fd12012-04-03 19:47:16 -0700798 rm -rf ${TMP}/alltests.tmp
799 ;;
800 *)
801 echo "Invalid Memory Check Type, or, Valgrind is not available"
802 ;;
yaberauneya6d41cc32010-01-28 16:24:16 +0000803 esac
804 fi
805 fi
806
Subrata Modakbd9d4402010-05-12 22:03:21 +0530807 if [ $ALT_DMESG_OUT -eq 1 ] ; then
808 #We want to print dmesg output for each test,lets do the trick inside the script
809 echo Enabling dmesg output logging for each test...
Garrett Cooper66030122012-04-03 20:22:14 -0700810 awk -v DMESG_DIR=$DMESG_DIR \
811 -f ${LTPROOT}/bin/create_dmesg_entries_for_each_test.awk \
812 ${TMP}/alltests > ${TMP}/alltests.tmp
Subrata Modakbd9d4402010-05-12 22:03:21 +0530813 cp ${TMP}/alltests.tmp ${TMP}/alltests
814 rm -rf ${TMP}/alltests.tmp
815 fi
subrata_modak724098e2009-03-19 08:49:18 +0000816 # Some tests need to run inside the "bin" directory.
817 cd "${LTPROOT}/testcases/bin"
yaberauneya6d41cc32010-01-28 16:24:16 +0000818 "${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 -0700819
plars4a120e82004-09-02 18:56:06 +0000820 if [ $? -eq 0 ]; then
yaberauneya6d41cc32010-01-28 16:24:16 +0000821 echo "INFO: ltp-pan reported all tests PASS"
822 VALUE=0
823 export LTP_EXIT_VALUE=0;
plars4a120e82004-09-02 18:56:06 +0000824 else
yaberauneya6d41cc32010-01-28 16:24:16 +0000825 echo "INFO: ltp-pan reported some tests FAIL"
826 VALUE=1
827 export LTP_EXIT_VALUE=1;
plars4a120e82004-09-02 18:56:06 +0000828 fi
subrata_modak724098e2009-03-19 08:49:18 +0000829 cd ..
yaberauneya6d41cc32010-01-28 16:24:16 +0000830 echo "LTP Version: $version_date"
mreed1091696422006-05-03 19:07:22 +0000831
Subrata Modake3bc3752010-07-03 23:32:27 +0530832 # $DMESG_DIR is used to cache messages obtained from dmesg after a test run.
833 # Proactively reap all of the 0-byte files in $DMESG_DIR as they have zero value
834 # and only clutter up the filesystem.
835
836 if [ $ALT_DMESG_OUT -eq 1 ] ; then
837 if ! find "$DMESG_DIR" -size 0 -exec rm {} + ; then
838 echo "cd to $DMESG_DIR failed: $?"
839 fi
840 if [ -n "$(ls "$DMESG_DIR")" ] ; then
841 echo "Kernel messages were generated for LTP tests $version_date"
842 else
843 echo "No Kernel messages were generated for LTP tests $version_date"
844 fi
845 fi
846
subrata_modake47fb352007-11-25 17:03:49 +0000847 if [ "$ALT_HTML_OUT" -eq 1 ] ; then #User wants the HTML output to be created, it then needs to be generated
848 export LTP_VERSION=$version_date
849 export TEST_START_TIME=$test_start_time
850 export TEST_END_TIME=$(date)
yaberauneya6d41cc32010-01-28 16:24:16 +0000851 OUTPUT_DIRECTORY=`echo $OUTPUTFILE | cut -c4-`
subrata_modake47fb352007-11-25 17:03:49 +0000852 LOGS_DIRECTORY="$LTPROOT/results"
853 export TEST_OUTPUT_DIRECTORY="$LTPROOT/output"
854 export TEST_LOGS_DIRECTORY=$LOGS_DIRECTORY
yaberauneya6d41cc32010-01-28 16:24:16 +0000855 echo "Generating HTML Output.....!!"
Chris Dearman37550cf2012-10-17 19:54:01 -0700856 ( 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 +0000857 echo "Generated HTML Output.....!!"
858 echo "Location: $HTMLFILE";
859
subrata_modake47fb352007-11-25 17:03:49 +0000860 fi
Chris Dearman37550cf2012-10-17 19:54:01 -0700861
yaberauneya6d41cc32010-01-28 16:24:16 +0000862 if [ "$ALT_EMAIL_OUT" -eq 1 ] ; then ## User wants reports to be e-mailed
Chris Dearman37550cf2012-10-17 19:54:01 -0700863 if [ [ ! "$HTMLFILE_NAME" ] -o [ ! "$OUTPUTFILE_NAME" ] -o [ ! "$LOGFILE_NAME" ] ] ; then
yaberauneya6d41cc32010-01-28 16:24:16 +0000864 ##User does not have output/logs/html-output, nothing to be mailed in this situation
865 echo "Nothing to be mailed here...."
subrata_modak08dde6f2007-11-28 11:02:51 +0000866 else
subrata_modak43938212008-05-19 08:48:46 +0000867 TAR_FILE_NAME=LTP_RUN_$version_date$DEFAULT_FILE_NAME_GENERATION_TIME.tar
yaberauneya6d41cc32010-01-28 16:24:16 +0000868 if [ "$HTMLFILE_NAME" ] ; then ## HTML file Exists
869 if [ "$ALT_HTML_OUT" -ne 1 ] ; then ## The HTML file path is absolute and not $LTPROOT/output
870 mkdir -p $LTPROOT/output ## We need to create this Directory
871 cp $HTMLFILE_NAME $LTPROOT/output/
872 fi
subrata_modak08dde6f2007-11-28 11:02:51 +0000873 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000874 if [ "$OUTPUTFILE_NAME" ] ; then ## Output file exists
875 if [ "$ALT_DIR_OUT" -ne 1 ] ; then ## The Output file path is absolute and not $LTPROOT/output
876 mkdir -p $LTPROOT/output ## We need to create this Directory
877 cp $OUTPUTFILE_NAME $LTPROOT/output/
878 fi
subrata_modak08dde6f2007-11-28 11:02:51 +0000879 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000880 if [ "$LOGFILE_NAME" ] ; then ## Log file exists
881 if [ "$ALT_DIR_RES" -ne 1 ] ; then ## The Log file path is absolute and not $LTPROOT/results
882 mkdir -p $LTPROOT/results ## We need to create this Directory
883 cp $LOGFILE_NAME $LTPROOT/results/
884 fi
885 fi
886 if [ -d $LTPROOT/output ] ; then
887 tar -cf ./$TAR_FILE_NAME $LTPROOT/output
888 if [ $? -eq 0 ]; then
889 echo "Created TAR File: ./$TAR_FILE_NAME successfully, added $LTPROOT/output"
890 else
891 echo "Cannot Create TAR File: ./$TAR_FILE_NAME for adding $LTPROOT/output"
892 fi
893 fi
894 if [ -d $LTPROOT/results ] ; then
895 tar -uf ./$TAR_FILE_NAME $LTPROOT/results
896 if [ $? -eq 0 ]; then
897 echo "Updated TAR File: ./$TAR_FILE_NAME successfully, added $LTPROOT/results"
898 else
899 echo "Cannot Update TAR File: ./$TAR_FILE_NAME for adding $LTPROOT/results"
900 fi
901 fi
902 if [ -e $LTPROOT/nohup.out ] ; then ## If User would have Chosen nohup to do ltprun
903 tar -uf ./$TAR_FILE_NAME $LTPROOT/nohup.out
904 if [ $? -eq 0 ]; then
905 echo "Updated TAR File: ./$TAR_FILE_NAME successfully, added $LTPROOT/nohup.out"
906 else
907 echo "Cannot Update TAR File: ./$TAR_FILE_NAME for adding $LTPROOT/nohup.out"
908 fi
909 fi
910 gzip ./$TAR_FILE_NAME ## gzip this guy
911 if [ $? -eq 0 ]; then
912 echo "Gunzipped TAR File: ./$TAR_FILE_NAME"
subrata_modak08dde6f2007-11-28 11:02:51 +0000913 else
yaberauneya6d41cc32010-01-28 16:24:16 +0000914 echo "Cannot Gunzip TAR File: ./$TAR_FILE_NAME"
subrata_modak08dde6f2007-11-28 11:02:51 +0000915 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000916 if [ -e /usr/bin/mutt ] ; then ## This is a better mail client than others
917 echo "Starting mailing reports to: $EMAIL_TO, file: ./$TAR_FILE_NAME.gz"
918 mutt -a ./$TAR_FILE_NAME.gz -s "LTP Reports on $test_start_time" $EMAIL_TO < /dev/null
919 if [ $? -eq 0 ]; then
920 echo "Reports Successfully mailed to: $EMAIL_TO"
921 else
922 echo "Reports cannot be mailed to: $EMAIL_TO"
923 fi
924 else ## Use our Ageold mail program
925 echo "Starting mailing reports to: $EMAIL_TO, file: ./$TAR_FILE_NAME.gz"
926 uuencode ./$TAR_FILE_NAME.gz $TAR_FILE_NAME.gz | mail $EMAIL_TO -s "LTP Reports on $test_start_time"
927 if [ $? -eq 0 ]; then
928 echo "Reports Successfully mailed to: $EMAIL_TO"
929 else
930 echo "Reports cannot be mailed to: $EMAIL_TO"
931 fi
Chris Dearman37550cf2012-10-17 19:54:01 -0700932 fi
subrata_modak08dde6f2007-11-28 11:02:51 +0000933 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000934 fi
Chris Dearman37550cf2012-10-17 19:54:01 -0700935
yaberauneya6d41cc32010-01-28 16:24:16 +0000936 [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test end time: $(date)" ; }
Chris Dearman37550cf2012-10-17 19:54:01 -0700937
yaberauneya6d41cc32010-01-28 16:24:16 +0000938 [ "$GENLOAD" -eq 1 ] && { killall -9 genload >/dev/null 2>&1; }
939 [ "$NETPIPE" -eq 1 ] && { killall -9 NPtcp >/dev/null 2>&1; }
Chris Dearman37550cf2012-10-17 19:54:01 -0700940
yaberauneya6d41cc32010-01-28 16:24:16 +0000941 [ "$ALT_DIR_OUT" -eq 1 ] || [ "$ALT_DIR_RES" -eq 1 ] && \
942 {
943 cat <<-EOF >&1
Chris Dearman37550cf2012-10-17 19:54:01 -0700944
Markos Chandras11328662012-03-06 10:28:59 +0000945 ###############################################################
Chris Dearman37550cf2012-10-17 19:54:01 -0700946
Markos Chandras11328662012-03-06 10:28:59 +0000947 Done executing testcases.
mreed1091696422006-05-03 19:07:22 +0000948 LTP Version: $version_date
Markos Chandras11328662012-03-06 10:28:59 +0000949 ###############################################################
Chris Dearman37550cf2012-10-17 19:54:01 -0700950
yaberauneya6d41cc32010-01-28 16:24:16 +0000951 EOF
952 }
953 exit $VALUE
plars4a120e82004-09-02 18:56:06 +0000954}
955
Ramesh YR0a78f232013-04-16 09:31:28 +0800956create_block()
957{
958 #create a block device with ext4 filesystem.
Cyril Hrubisb88fa5b2013-06-25 15:50:08 +0200959 dd if=/dev/zero of=${TMP}/test.img bs=1kB count=10240
Ramesh YR0a78f232013-04-16 09:31:28 +0800960 if [ $? -ne 0 ]; then
961 echo "Failed to create loopback device image, please check disk space and re-run"
962 return 1
963 else
964 ##search for an unused loop dev
965 LOOP_DEV=$(losetup -f)
966 if [ $? -ne 0 ]; then
967 echo "no unused loop device is found"
968 return 1
969 else
970 ##attach the created file to loop dev.
Cyril Hrubisb88fa5b2013-06-25 15:50:08 +0200971 losetup $LOOP_DEV ${TMP}/test.img
Ramesh YR0a78f232013-04-16 09:31:28 +0800972 if [ $? -ne 0 ]; then
973 echo "losetup failed to create block device"
974 return 1
Ramesh YR0a78f232013-04-16 09:31:28 +0800975 fi
Cyril Hrubisc381f582013-08-08 18:19:35 +0200976 DEVICE=$LOOP_DEV
977 return 0
Ramesh YR0a78f232013-04-16 09:31:28 +0800978 fi
979 fi
980}
981
plars4a120e82004-09-02 18:56:06 +0000982cleanup()
983{
Ramesh YR0a78f232013-04-16 09:31:28 +0800984 [ "$LOOP_DEV" ] && losetup -d $LOOP_DEV
yaberauneya6d41cc32010-01-28 16:24:16 +0000985 rm -rf ${TMP}
plars4a120e82004-09-02 18:56:06 +0000986}
987
988trap "cleanup" 0
989setup
990main "$@"
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800991
992#vim: syntax=sh