blob: 3c8b94e605979ecbe85a821df7a220bac1f87f17 [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
Xiaoguang Wang5b42a1e2013-12-12 19:10:58 +080083 export LTP_DEV=""
84 export LTP_BIG_DEV=""
85 export LTP_DEV_FS_TYPE="ext2"
86 export LTP_BIG_DEV_FS_TYPE="ext2"
87
yaberauneya6d41cc32010-01-28 16:24:16 +000088 [ -d "$LTPROOT/testcases/bin" ] ||
89 {
Garrett Coopercf86b8b2010-11-16 21:46:41 -080090 echo "FATAL: LTP not installed correctly"
91 echo "INFO: Follow directions in INSTALL!"
yaberauneya6d41cc32010-01-28 16:24:16 +000092 exit 1
93 }
94
95 [ -e "$LTPROOT/bin/ltp-pan" ] ||
96 {
97 echo "FATAL: Test suite driver 'ltp-pan' not found"
Garrett Coopercf86b8b2010-11-16 21:46:41 -080098 echo "INFO: Follow directions in INSTALL!"
yaberauneya6d41cc32010-01-28 16:24:16 +000099 exit 1
100 }
plars4a120e82004-09-02 18:56:06 +0000101}
102
mreed1091696422006-05-03 19:07:22 +0000103version_of_ltp()
104{
yaberauneyaef772532009-10-09 17:55:43 +0000105 cat "$LTPROOT/Version"
yaberauneya6d41cc32010-01-28 16:24:16 +0000106 exit 0
mreed1091696422006-05-03 19:07:22 +0000107}
plars4a120e82004-09-02 18:56:06 +0000108
Chris Dearman37550cf2012-10-17 19:54:01 -0700109usage()
plars4a120e82004-09-02 18:56:06 +0000110{
yaberauneya6d41cc32010-01-28 16:24:16 +0000111 cat <<-EOF >&2
plars4a120e82004-09-02 18:56:06 +0000112
Garrett Cooperf95875a2010-03-05 02:44:39 -0800113 usage: ${0##*/} [ -a EMAIL_TO ] [ -c NUM_PROCS ] [ -C FAILCMDFILE ] [ -d TMPDIR ]
subrata_modake47fb352007-11-25 17:03:49 +0000114 [ -D NUM_PROCS,NUM_FILES,NUM_BYTES,CLEAN_FLAG ] -e [ -f CMDFILES(,...) ] [ -g HTMLFILE]
Chris Dearman37550cf2012-10-17 19:54:01 -0700115 [ -i NUM_PROCS ] [ -l LOGFILE ] [ -m NUM_PROCS,CHUNKS,BYTES,HANGUP_FLAG ]
subrata_modake099b2a2007-10-29 12:22:01 +0000116 -N -n [ -o OUTPUTFILE ] -p -q [ -r LTPROOT ] [ -s PATTERN ] [ -t DURATION ]
Xiaoguang Wang5b42a1e2013-12-12 19:10:58 +0800117 -v [ -w CMDFILEADDR ] [ -x INSTANCES ] [ -b DEVICE ] [-B LTP_DEV_FS_TYPE]
118 [ -F LOOPS,PERCENTAGE ] [ -z BIG_DEVICE ] [-Z LTP_BIG_DEV_FS_TYPE]
Chris Dearman37550cf2012-10-17 19:54:01 -0700119
subrata_modak08dde6f2007-11-28 11:02:51 +0000120 -a EMAIL_TO EMAIL all your Reports to this E-mail Address
subrata_modake099b2a2007-10-29 12:22:01 +0000121 -c NUM_PROCS Run LTP under additional background CPU load
122 [NUM_PROCS = no. of processes creating the CPU Load by spinning over sqrt()
123 (Defaults to 1 when value)]
subrata_modakbc833d32007-07-25 10:12:02 +0000124 -C FAILCMDFILE Command file with all failed test cases.
plars4a120e82004-09-02 18:56:06 +0000125 -d TMPDIR Directory where temporary files will be created.
subrata_modake099b2a2007-10-29 12:22:01 +0000126 -D NUM_PROCS,NUM_FILES,NUM_BYTES,CLEAN_FLAG
127 Run LTP under additional background Load on Secondary Storage (Seperate by comma)
128 [NUM_PROCS = no. of processes creating Storage Load by spinning over write()]
129 [NUM_FILES = Write() to these many files (Defaults to 1 when value 0 or undefined)]
130 [NUM_BYTES = write these many bytes (defaults to 1GB, when value 0 or undefined)]
131 [CLEAN_FLAG = unlink file to which random data written, when value 1]
mreed1091696422006-05-03 19:07:22 +0000132 -e Prints the date of the current LTP release
subrata_modakbc833d32007-07-25 10:12:02 +0000133 -f CMDFILES Execute user defined list of testcases (separate with ',')
yaberauneya6d41cc32010-01-28 16:24:16 +0000134 -F LOOPS,PERCENTAGE Induce PERCENTAGE Fault in the Kernel Subsystems, and, run each test for LOOPS loop
subrata_modake47fb352007-11-25 17:03:49 +0000135 -g HTMLFILE Create an additional HTML output format
plars4a120e82004-09-02 18:56:06 +0000136 -h Help. Prints all available options.
subrata_modake099b2a2007-10-29 12:22:01 +0000137 -i NUM_PROCS Run LTP under additional background Load on IO Bus
138 [NUM_PROCS = no. of processes creating IO Bus Load by spinning over sync()]
Subrata Modakbd9d4402010-05-12 22:03:21 +0530139 -K DMESG_LOG_DIR
Chris Dearman37550cf2012-10-17 19:54:01 -0700140 Log Kernel messages generated for each test cases inside this directory
plars4a120e82004-09-02 18:56:06 +0000141 -l LOGFILE Log results of test in a logfile.
subrata_modake099b2a2007-10-29 12:22:01 +0000142 -m NUM_PROCS,CHUNKS,BYTES,HANGUP_FLAG
143 Run LTP under additional background Load on Main memory (Seperate by comma)
144 [NUM_PROCS = no. of processes creating main Memory Load by spinning over malloc()]
145 [CHUNKS = malloc these many chunks (default is 1 when value 0 or undefined)]
146 [BYTES = malloc CHUNKS of BYTES bytes (default is 256MB when value 0 or undefined) ]
147 [HANGUP_FLAG = hang in a sleep loop after memory allocated, when value 1]
yaberauneya6d41cc32010-01-28 16:24:16 +0000148 -M CHECK_TYPE
149 [CHECK_TYPE=1 => Full Memory Leak Check tracing children as well]
150 [CHECK_TYPE=2 => Thread Concurrency Check tracing children as well]
151 [CHECK_TYPE=3 => Full Memory Leak & Thread Concurrency Check tracing children as well]
Chris Dearman37550cf2012-10-17 19:54:01 -0700152 -N Run all the networking tests.
plars4a120e82004-09-02 18:56:06 +0000153 -n Run LTP with network traffic in background.
154 -o OUTPUTFILE Redirect test output to a file.
Chris Dearman37550cf2012-10-17 19:54:01 -0700155 -p Human readable format logfiles.
plars4a120e82004-09-02 18:56:06 +0000156 -q Print less verbose output to screen.
157 -r LTPROOT Fully qualified path where testsuite is installed.
subrata_modaka1fd64b2007-04-11 11:24:49 +0000158 -s PATTERN Only run test cases which match PATTERN.
subrata_modak2f6c9812009-08-14 17:07:48 +0000159 -S SKIPFILE Skip tests specified in SKIPFILE
plars4a120e82004-09-02 18:56:06 +0000160 -t DURATION Execute the testsuite for given duration. Examples:
161 -t 60s = 60 seconds
162 -t 45m = 45 minutes
163 -t 24h = 24 hours
164 -t 2d = 2 days
subrata_modak8c138332008-01-28 11:19:32 +0000165 -T REPETITION Execute the testsuite for REPETITION no. of times
subrata_modakbc833d32007-07-25 10:12:02 +0000166 -w CMDFILEADDR Uses wget to get the user's list of testcases.
plars4a120e82004-09-02 18:56:06 +0000167 -x INSTANCES Run multiple instances of this testsuite.
subrata_modakd9fb3862008-12-29 11:25:36 +0000168 -b DEVICE Some tests require an unmounted block device
169 to run correctly.
Xiaoguang Wang5b42a1e2013-12-12 19:10:58 +0800170 -B LTP_DEV_FS_TYPE The file system of test block devices.
171 -z BIG_DEVICE Some tests require a big unmounted block device
172 to run correctly.
173 -Z LTP_BIG_DEV_FS_TYPE The file system of the big device
174
subrata_modakd9fb3862008-12-29 11:25:36 +0000175
plars4a120e82004-09-02 18:56:06 +0000176
Garrett Cooperf95875a2010-03-05 02:44:39 -0800177 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 +0000178
plars4a120e82004-09-02 18:56:06 +0000179
yaberauneya6d41cc32010-01-28 16:24:16 +0000180 EOF
181exit 0
plars4a120e82004-09-02 18:56:06 +0000182}
183
plars4a120e82004-09-02 18:56:06 +0000184main()
185{
subrata_modakbc833d32007-07-25 10:12:02 +0000186 local CMDFILES=""
plars4a120e82004-09-02 18:56:06 +0000187 local PRETTY_PRT=""
subrata_modak5d7deea2007-09-15 13:51:36 +0000188 local ALT_DIR_OUT=0
189 local ALT_DIR_RES=0
subrata_modake47fb352007-11-25 17:03:49 +0000190 local ALT_HTML_OUT=0
subrata_modak08dde6f2007-11-28 11:02:51 +0000191 local ALT_EMAIL_OUT=0
Subrata Modakbd9d4402010-05-12 22:03:21 +0530192 local ALT_DMESG_OUT=0
plars4a120e82004-09-02 18:56:06 +0000193 local RUN_NETEST=0
subrata_modak8c138332008-01-28 11:19:32 +0000194 local RUN_REPEATED=0
yaberauneya6d41cc32010-01-28 16:24:16 +0000195 local QUIET_MODE=""
plars4a120e82004-09-02 18:56:06 +0000196 local NETPIPE=0
197 local GENLOAD=0
198 local MEMSIZE=0
199 local DURATION=""
subrata_modakbc833d32007-07-25 10:12:02 +0000200 local CMDFILEADDR=""
subrata_modak43938212008-05-19 08:48:46 +0000201 local FAILCMDFILE=""
yaberauneyaef772532009-10-09 17:55:43 +0000202 local INJECT_KERNEL_FAULT=""
203 local INJECT_KERNEL_FAULT_PERCENTAGE=""
204 local INJECT_FAULT_LOOPS_PER_TEST=""
205 local VALGRIND_CHECK=""
206 local VALGRIND_CHECK_TYPE=""
subrata_modake47fb352007-11-25 17:03:49 +0000207 local LOGFILE_NAME=""
plars4a120e82004-09-02 18:56:06 +0000208 local LOGFILE=""
subrata_modake47fb352007-11-25 17:03:49 +0000209 local OUTPUTFILE_NAME=""
210 local OUTPUTFILE=""
211 local HTMLFILE_NAME=""
212 local HTMLFILE=""
Subrata Modakbd9d4402010-05-12 22:03:21 +0530213 local DMESG_DIR=""
subrata_modak08dde6f2007-11-28 11:02:51 +0000214 local EMAIL_TO=""
robbiew7d43d772005-02-07 20:07:30 +0000215 local TAG_RESTRICT_STRING=""
216 local PAN_COMMAND=""
subrata_modak43938212008-05-19 08:48:46 +0000217 local DEFAULT_FILE_NAME_GENERATION_TIME=`date +"%Y_%b_%d-%Hh_%Mm_%Ss"`
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800218 local scenfile=
219
yaberauneyaef772532009-10-09 17:55:43 +0000220 version_date=$(cat "$LTPROOT/Version")
plars4a120e82004-09-02 18:56:06 +0000221
Xiaoguang Wang5b42a1e2013-12-12 19:10:58 +0800222 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:z:Z: arg
yaberauneya6d41cc32010-01-28 16:24:16 +0000223 do case $arg in
subrata_modak08dde6f2007-11-28 11:02:51 +0000224 a) EMAIL_TO=$OPTARG
225 ALT_EMAIL_OUT=1;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700226 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
yaberauneya6d41cc32010-01-28 16:24:16 +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
Chris Dearman37550cf2012-10-17 19:54:01 -0700236 C)
subrata_modak6838ec32007-09-14 10:10:12 +0000237 case $OPTARG in
238 /*)
239 FAILCMDFILE="-C $OPTARG" ;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700240 *)
subrata_modak6838ec32007-09-14 10:10:12 +0000241 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 ;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700244
subrata_modak5ee3e892008-10-21 13:17:56 +0000245 d) # convert the user path to absolute path.
Garrett Cooper5d520f42012-08-07 08:57:31 -0700246 export TMPBASE=$(readlink -f ${OPTARG}) ;;
subrata_modake099b2a2007-10-29 12:22:01 +0000247
248 D) NUM_PROCS=1; NUM_FILES=1; NUM_BYTES=$((1024 * 1024 * 1024)); CLEAN_FLAG=0
subrata_modak548379d2008-08-20 09:15:49 +0000249 ARGUMENT_LIST=$OPTARG
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800250 TOTAL_ARGUMENTS=1
251 for ARGUMENT in `echo "$ARGUMENT_LIST" | tr ',' ' '`
subrata_modake099b2a2007-10-29 12:22:01 +0000252 do
253 case $TOTAL_ARGUMENTS in
yaberauneya6d41cc32010-01-28 16:24:16 +0000254 1) NUM_PROCS="$ARGUMENT" ;;
255 2) NUM_FILES="$ARGUMENT" ;;
256 3) NUM_BYTES="$ARGUMENT" ;;
257 4) CLEAN_FLAG="$ARGUMENT" ;;
subrata_modake099b2a2007-10-29 12:22:01 +0000258 esac
yaberauneya6d41cc32010-01-28 16:24:16 +0000259 TOTAL_ARGUMENTS=`expr $TOTAL_ARGUMENTS + 1`
subrata_modake099b2a2007-10-29 12:22:01 +0000260 done
261 # just to get the default values if the user passed 0
262 if [ "$NUM_PROCS" -eq 0 ]; then
263 NUM_PROCS=1
264 fi
265 if [ "$NUM_FILES" -eq 0 ]; then
266 NUM_FILES=1
267 fi
268 if [ "$NUM_BYTES" -eq 0 ]; then
269 NUM_BYTES=$((1024 * 1024 * 1024))
270 fi
271 if [ "$CLEAN_FLAG" -ne 1 ]; then
272 CLEAN_FLAG=0
273 fi
274 if [ "$CLEAN_FLAG" -eq 1 ]; then
275 # Do not unlink file in this case
yaberauneya6d41cc32010-01-28 16:24:16 +0000276 $LTPROOT/testcases/bin/genload --hdd $NUM_PROCS --hdd-files \
subrata_modake099b2a2007-10-29 12:22:01 +0000277 $NUM_FILES --hdd-bytes $NUM_BYTES >/dev/null 2>&1 &
278 else
279 # Cleanup otherwise
yaberauneya6d41cc32010-01-28 16:24:16 +0000280 $LTPROOT/testcases/bin/genload --hdd $NUM_PROCS --hdd-files \
subrata_modake099b2a2007-10-29 12:22:01 +0000281 $NUM_FILES --hdd-bytes $NUM_BYTES --hdd-noclean >/dev/null 2>&1 &
282 fi
283 GENLOAD=1;;
284
mreed1091696422006-05-03 19:07:22 +0000285 e) # Print out the version of LTP
286 version_of_ltp
yaberauneya6d41cc32010-01-28 16:24:16 +0000287 ;;
plars4a120e82004-09-02 18:56:06 +0000288 f) # Execute user defined set of testcases.
subrata_modakbc833d32007-07-25 10:12:02 +0000289 # Can be more then one file, just separate it with ',', like:
290 # -f nfs,commands,/tmp/testfile
291 CMDFILES=$OPTARG;;
yaberauneya6d41cc32010-01-28 16:24:16 +0000292 F) INJECT_KERNEL_FAULT=1
293 #Seperate out the NO_OF_LOOPS & FAULT_PERCENTAGE
294 INJECT_FAULT_LOOPS_PER_TEST=`echo $OPTARG |cut -d',' -f1 | tr -d '\n' | tr -d ' '`
295 INJECT_KERNEL_FAULT_PERCENTAGE=`echo $OPTARG |cut -d',' -f2 | tr -d '\n' | tr -d ' '`
296 if [ ! $INJECT_FAULT_LOOPS_PER_TEST ]; then
297 echo "Loops not properly defined. Resorting to default 5..."
298 export INJECT_FAULT_LOOPS_PER_TEST=5
299 fi
300 if [ ! $INJECT_KERNEL_FAULT_PERCENTAGE ]; then
301 echo "Fault Persentage not properly defined. Resorting to default 10..."
302 export INJECT_KERNEL_FAULT_PERCENTAGE=10
303 fi;;
subrata_modake47fb352007-11-25 17:03:49 +0000304 g) HTMLFILE_NAME="$OPTARG"
305 case $OPTARG in
306 /*)
307 HTMLFILE="$OPTARG";;
308 *)
subrata_modakd48c4d02008-01-23 12:59:40 +0000309 HTMLFILE="$LTPROOT/output/$OPTARG";;
310 esac
Chris Dearman37550cf2012-10-17 19:54:01 -0700311 ALT_DIR_OUT=1
subrata_modakd48c4d02008-01-23 12:59:40 +0000312 ALT_HTML_OUT=1;;
plars4a120e82004-09-02 18:56:06 +0000313 h) usage;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700314
subrata_modake099b2a2007-10-29 12:22:01 +0000315 i)
316 NUM_PROCS=$(($OPTARG))
317 if [ "$NUM_PROCS" -eq 0 ]; then
318 # User Did not Define the Value ,or, User Defined Zero,
319 # hence, prevent from creating infinite processes
320 NUM_PROCS=1
321 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000322 $LTPROOT/testcases/bin/genload --io $NUM_PROCS >/dev/null 2>&1 &
plars4a120e82004-09-02 18:56:06 +0000323 GENLOAD=1 ;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700324
325 K)
Subrata Modakbd9d4402010-05-12 22:03:21 +0530326 case $OPTARG in
327 /*)
Cyril Hrubisc381f582013-08-08 18:19:35 +0200328 DMESG_DIR="$OPTARG-dmesg-output-`echo $$-``date +%X | tr -d ' '`";;
Subrata Modakbd9d4402010-05-12 22:03:21 +0530329 *)
Cyril Hrubisc381f582013-08-08 18:19:35 +0200330 DMESG_DIR="$LTPROOT/output/$OPTARG-dmesg-output-`echo $$-``date +%X | tr -d ' '`";;
Subrata Modakbd9d4402010-05-12 22:03:21 +0530331 esac
332 mkdir -p $DMESG_DIR
333 ALT_DMESG_OUT=1;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700334 l)
subrata_modak6838ec32007-09-14 10:10:12 +0000335 LOGFILE_NAME="$OPTARG"
plars4a120e82004-09-02 18:56:06 +0000336 case $OPTARG in
subrata_modak5d7deea2007-09-15 13:51:36 +0000337 /*)
plars4a120e82004-09-02 18:56:06 +0000338 LOGFILE="-l $OPTARG" ;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700339 *)
plars4a120e82004-09-02 18:56:06 +0000340 LOGFILE="-l $LTPROOT/results/$OPTARG"
subrata_modak5d7deea2007-09-15 13:51:36 +0000341 ALT_DIR_RES=1 ;;
plars4a120e82004-09-02 18:56:06 +0000342 esac ;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700343
subrata_modake099b2a2007-10-29 12:22:01 +0000344 m) NUM_PROCS=1; CHUNKS=1; BYTES=$((256 * 1024 * 1024)); HANGUP_FLAG=0
subrata_modak29a96d82008-08-27 13:34:46 +0000345 ARGUMENT_LIST=$OPTARG
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800346 TOTAL_ARGUMENTS=1
347 for ARGUMENT in `echo "$ARGUMENT_LIST" | tr ',' ' '`
subrata_modake099b2a2007-10-29 12:22:01 +0000348 do
349 case $TOTAL_ARGUMENTS in
yaberauneya6d41cc32010-01-28 16:24:16 +0000350 1) NUM_PROCS="$ARGUMENT" ;;
351 2) CHUNKS="$ARGUMENT" ;;
352 3) BYTES="$ARGUMENT" ;;
353 4) HANGUP_FLAG="$ARGUMENT" ;;
subrata_modake099b2a2007-10-29 12:22:01 +0000354 esac
yaberauneya6d41cc32010-01-28 16:24:16 +0000355 TOTAL_ARGUMENTS=`expr $TOTAL_ARGUMENTS + 1`
subrata_modake099b2a2007-10-29 12:22:01 +0000356 done
357 # just to get the default values if the user passed 0
yaberauneya6d41cc32010-01-28 16:24:16 +0000358 if [ "$NUM_PROCS" -eq 0 ]; then
359 NUM_PROCS=1
360 fi
361 if [ "$CHUNKS" -eq 0 ]; then
362 CHUNKS=1
363 fi
364 if [ "$BYTES" -eq 0 ]; then
365 BYTES=$((256 * 1024 * 1024))
366 fi
367 if [ "$HANGUP_FLAG" -ne 1 ]; then
368 HANGUP_FLAG=0
369 fi
subrata_modake099b2a2007-10-29 12:22:01 +0000370 if [ "$HANGUP_FLAG" -eq 1 ]; then
371 # Hang in a Sleep loop after memory allocated
yaberauneya6d41cc32010-01-28 16:24:16 +0000372 $LTPROOT/testcases/bin/genload --vm $NUM_PROCS --vm-chunks \
subrata_modake099b2a2007-10-29 12:22:01 +0000373 $CHUNKS --vm-bytes $BYTES --vm-hang >/dev/null 2>&1 &
374 else
375 # Otherwise Do not Hangup
yaberauneya6d41cc32010-01-28 16:24:16 +0000376 $LTPROOT/testcases/bin/genload --vm $NUM_PROCS --vm-chunks \
subrata_modake099b2a2007-10-29 12:22:01 +0000377 $CHUNKS --vm-bytes $BYTES >/dev/null 2>&1 &
378 fi
plars4a120e82004-09-02 18:56:06 +0000379 GENLOAD=1;;
yaberauneya6d41cc32010-01-28 16:24:16 +0000380 M)
381 VALGRIND_CHECK=1
382 VALGRIND_CHECK_TYPE="$OPTARG";;
subrata_modak9c7072a2009-08-26 07:00:25 +0000383
plars4a120e82004-09-02 18:56:06 +0000384 N) RUN_NETEST=1;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700385
386 n)
yaberauneya6d41cc32010-01-28 16:24:16 +0000387 $LTPROOT/testcases/bin/netpipe.sh
plars4a120e82004-09-02 18:56:06 +0000388 NETPIPE=1;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700389
subrata_modak6838ec32007-09-14 10:10:12 +0000390 o) OUTPUTFILE_NAME="$OPTARG"
subrata_modak6838ec32007-09-14 10:10:12 +0000391 case $OPTARG in
392 /*)
393 OUTPUTFILE="-o $OPTARG";;
394 *)
395 OUTPUTFILE="-o $LTPROOT/output/$OPTARG"
subrata_modak5d7deea2007-09-15 13:51:36 +0000396 ALT_DIR_OUT=1 ;;
yaberauneya6d41cc32010-01-28 16:24:16 +0000397 esac ;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700398
plars4a120e82004-09-02 18:56:06 +0000399 p) PRETTY_PRT=" -p ";;
Chris Dearman37550cf2012-10-17 19:54:01 -0700400
yaberauneya6d41cc32010-01-28 16:24:16 +0000401 q) QUIET_MODE=" -q ";;
Chris Dearman37550cf2012-10-17 19:54:01 -0700402
plars4a120e82004-09-02 18:56:06 +0000403 r) LTPROOT=$OPTARG;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700404
robbiew7d43d772005-02-07 20:07:30 +0000405 s) TAG_RESTRICT_STRING=$OPTARG;;
subrata_modak2f6c9812009-08-14 17:07:48 +0000406
yaberauneya6d41cc32010-01-28 16:24:16 +0000407 S) case $OPTARG in
subrata_modak2f6c9812009-08-14 17:07:48 +0000408 /*)
409 SKIPFILE=$OPTARG;;
410 *)
411 SKIPFILE="$LTPROOT/$OPTARG";;
yaberauneya6d41cc32010-01-28 16:24:16 +0000412 esac ;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700413
414 t) # In case you want to specify the time
415 # to run from the command line
plars4a120e82004-09-02 18:56:06 +0000416 # (2m = two minutes, 2h = two hours, etc)
417 DURATION="-t $OPTARG" ;;
subrata_modak8c138332008-01-28 11:19:32 +0000418
419 T) # In case you want the testcases to runsequentially RUN_REPEATED times
420 RUN_REPEATED=$OPTARG;;
421
subrata_modakbc833d32007-07-25 10:12:02 +0000422 w) CMDFILEADDR=$OPTARG;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700423
plars4a120e82004-09-02 18:56:06 +0000424 x) # number of ltp's to run
yaberauneya6d41cc32010-01-28 16:24:16 +0000425 cat <<-EOF >&1
426 WARNING: The use of -x can cause unpredictable failures, as a
427 result of concurrently running multiple tests designed
428 to be ran exclusively.
429 Pausing for 10 seconds..."
430 EOF
Chris Dearman37550cf2012-10-17 19:54:01 -0700431 sleep 10
yaberauneya6d41cc32010-01-28 16:24:16 +0000432 INSTANCES="-x $OPTARG";;
subrata_modakd9fb3862008-12-29 11:25:36 +0000433 b) DEVICE=$OPTARG;;
Xiaoguang Wang5b42a1e2013-12-12 19:10:58 +0800434 B) LTP_DEV_FS_TYPE=$OPTARG;;
435 z) BIG_DEVICE=$OPTARG;;
436 Z) LTP_BIG_DEV_FS_TYPE=$OPTARG;;
plars4a120e82004-09-02 18:56:06 +0000437 \?) usage;;
438 esac
439 done
subrata_modak43938212008-05-19 08:48:46 +0000440
441 ## It would be nice to create a default log file even if the user has not mentioned
442 if [ ! "$LOGFILE" ]; then ## User has not mentioned about Log File name
443 LOGFILE_NAME=$DEFAULT_FILE_NAME_GENERATION_TIME
444 LOGFILE="-l $LTPROOT/results/LTP_RUN_ON-$LOGFILE_NAME.log"
445 ALT_DIR_RES=1
446 PRETTY_PRT=" -p "
447 fi
Chris Dearman37550cf2012-10-17 19:54:01 -0700448
449 ## 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 +0000450
yaberauneya6d41cc32010-01-28 16:24:16 +0000451 if [ ! "$FAILCMDFILE" ]; then ## User has not mentioned about Failed File name
subrata_modak5d7deea2007-09-15 13:51:36 +0000452 ALT_DIR_OUT=1
yaberauneya6d41cc32010-01-28 16:24:16 +0000453 if [ ! "$OUTPUTFILE" ]; then ## User has not mentioned about Output File name either
454 if [ ! "$LOGFILE" ]; then ## User has not mentioned about Log File name either
455 FAILED_FILE_NAME=$DEFAULT_FILE_NAME_GENERATION_TIME
456 FAILCMDFILE="-C $LTPROOT/output/LTP_RUN_ON-$FAILED_FILE_NAME.failed"
457 else ## User Fortunately wanted a log file,
458 FAILED_FILE_NAME=`basename $LOGFILE_NAME` ## Extract log file name and use it to construct Failed file name
459 FAILCMDFILE="-C $LTPROOT/output/LTP_RUN_ON-$FAILED_FILE_NAME.failed"
subrata_modak6838ec32007-09-14 10:10:12 +0000460 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000461 else ## User Fortunately wanted a Output file
462 FAILED_FILE_NAME=`basename $OUTPUTFILE_NAME` ## Extract output file name and use it to construct Failed file name
463 FAILCMDFILE="-C $LTPROOT/output/LTP_RUN_ON-$FAILED_FILE_NAME.failed"
subrata_modak6838ec32007-09-14 10:10:12 +0000464 fi
465 fi
subrata_modaka1fd64b2007-04-11 11:24:49 +0000466
subrata_modakd48c4d02008-01-23 12:59:40 +0000467 if [ "$ALT_HTML_OUT" -eq 1 ] ; then ## User wants the HTML version of the output
yaberauneya6d41cc32010-01-28 16:24:16 +0000468 QUIET_MODE="" ## Suppressing this guy as it will prevent generation of proper output
subrata_modakd48c4d02008-01-23 12:59:40 +0000469 ## which the HTML parser will require
yaberauneya6d41cc32010-01-28 16:24:16 +0000470 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 +0000471 OUTPUTFILE_NAME=$DEFAULT_FILE_NAME_GENERATION_TIME
subrata_modake47fb352007-11-25 17:03:49 +0000472 OUTPUTFILE="-o $LTPROOT/output/LTP_RUN_ON-$OUTPUTFILE_NAME.output"
subrata_modak08dde6f2007-11-28 11:02:51 +0000473 ALT_DIR_OUT=1
yaberauneya6d41cc32010-01-28 16:24:16 +0000474 if [ ! "$HTMLFILE" ] ; then ## User has not mentioned HTML File name, We need to create one
475 HTMLFILE_NAME=`basename $OUTPUTFILE_NAME`
subrata_modake47fb352007-11-25 17:03:49 +0000476 HTMLFILE="$LTPROOT/output/$HTMLFILE_NAME.html"
477 fi
478 fi
479 fi
480
subrata_modak5d7deea2007-09-15 13:51:36 +0000481 # If we need, create the output directory
yaberauneya6d41cc32010-01-28 16:24:16 +0000482 [ "$ALT_DIR_OUT" -eq 1 ] && \
483 {
484 [ ! -d $LTPROOT/output ] && \
485 {
486 echo "INFO: creating $LTPROOT/output directory"
487 mkdir -p $LTPROOT/output || \
488 {
489 echo "ERROR: failed to create $LTPROOT/output"
490 exit 1
491 }
492 }
493 }
subrata_modak5d7deea2007-09-15 13:51:36 +0000494 # If we need, create the results directory
yaberauneya6d41cc32010-01-28 16:24:16 +0000495 [ "$ALT_DIR_RES" -eq 1 ] && \
496 {
497 echo "INFO: creating $LTPROOT/results directory"
498 [ ! -d $LTPROOT/results ] && \
499 {
500 mkdir -p $LTPROOT/results || \
501 {
502 echo "ERROR: failed to create $LTPROOT/results"
503 exit 1
504 }
505 }
506 }
subrata_modak5d7deea2007-09-15 13:51:36 +0000507
Chris Dearman37550cf2012-10-17 19:54:01 -0700508 # Added -m 777 for tests that call tst_tmpdir() and try to
subrata_modaka1fd64b2007-04-11 11:24:49 +0000509 # write to it as user nobody
yaberauneya6d41cc32010-01-28 16:24:16 +0000510 mkdir -m 777 -p $TMPBASE || \
511 {
512 echo "FATAL: Unable to make temporary directory $TMPBASE"
513 exit 1
514 }
subrata_modak5ee3e892008-10-21 13:17:56 +0000515 # use mktemp to create "safe" temporary directories
516 export TMPTEMPLATE="${TMPBASE}/ltp-XXXXXXXXXX"
yaberauneya6d41cc32010-01-28 16:24:16 +0000517 TMP=`mktemp -d $TMPTEMPLATE` || \
518 {
519 echo "FATAL: Unable to make temporary directory: $TMP"
520 exit 1
521 }
522 export TMP
subrata_modak225cfbe2009-06-23 14:01:26 +0000523 # To be invoked by tst_tmpdir()
524 # write to it as user nobody
525 export TMPDIR=$TMP
subrata_modak6edfbda2008-10-17 12:25:48 +0000526
yaberauneya6d41cc32010-01-28 16:24:16 +0000527 chmod 777 $TMP || \
528 {
529 echo "unable to chmod 777 $TMP ... aborting"
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800530 exit 1
yaberauneya6d41cc32010-01-28 16:24:16 +0000531 }
Chris Dearman37550cf2012-10-17 19:54:01 -0700532
yaberauneya6d41cc32010-01-28 16:24:16 +0000533 cd $TMP || \
534 {
535 echo "could not cd ${TMP} ... exiting"
536 exit 1
537 }
Chris Dearman37550cf2012-10-17 19:54:01 -0700538
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800539 [ -n "$INSTANCES" ] && \
yaberauneya6d41cc32010-01-28 16:24:16 +0000540 {
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800541 INSTANCES="$INSTANCES -O ${TMP}"
yaberauneya6d41cc32010-01-28 16:24:16 +0000542 }
Chris Dearman37550cf2012-10-17 19:54:01 -0700543
yaberauneya6d41cc32010-01-28 16:24:16 +0000544 [ "$RUN_NETEST" -eq 1 ] && \
545 {
546 [ -z "$RHOST" ] || [ -z "$PASSWD" ] && \
547 {
548 [ -z "$RHOST" ] && \
549 {
Anders Roxell4691f012013-09-03 09:42:35 +0200550 printf "INFO: Enter RHOST = 'name of the remote host machine'"
551 printf "\n-> "
plars4a120e82004-09-02 18:56:06 +0000552 read RHOST
yaberauneya6d41cc32010-01-28 16:24:16 +0000553 }
plars4a120e82004-09-02 18:56:06 +0000554
yaberauneya6d41cc32010-01-28 16:24:16 +0000555 [ -z "$PASSWD" ] && \
556 {
Anders Roxell4691f012013-09-03 09:42:35 +0200557 printf "\nINFO: "
558 printf "Enter PASSWD = 'root passwd of the remote host machine'"
559 printf "\n-> "
plars4a120e82004-09-02 18:56:06 +0000560 read PASSWD
yaberauneya6d41cc32010-01-28 16:24:16 +0000561 }
plars4a120e82004-09-02 18:56:06 +0000562 export RHOST=$RHOST
563 export PASSWD=$PASSWD
yaberauneya6d41cc32010-01-28 16:24:16 +0000564 echo "WARNING: security of $RHOST may be compromised"
565 }
566 }
Chris Dearman37550cf2012-10-17 19:54:01 -0700567
plars4a120e82004-09-02 18:56:06 +0000568 # If user does not provide a command file select a default set of testcases
569 # to execute.
yaberauneya6d41cc32010-01-28 16:24:16 +0000570 if [ -z "$CMDFILES" ] && [ -z "$CMDFILEADDR" ]
571 then
572 cat <<-EOF >&1
plars4a120e82004-09-02 18:56:06 +0000573
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800574 INFO: no command files were provided. Will execute the following
575 runtest scenario files:
Garrett Cooper66d67b52010-11-16 22:42:48 -0800576
577`cat $LTPROOT/scenario_groups/default | tr '\012' ' '`
Chris Dearman37550cf2012-10-17 19:54:01 -0700578
yaberauneya6d41cc32010-01-28 16:24:16 +0000579 EOF
plars4a120e82004-09-02 18:56:06 +0000580
Garrett Cooper89fde872010-11-16 22:38:08 -0800581 SCENARIO_LISTS="$LTPROOT/scenario_groups/default"
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800582 if [ "$RUN_NETEST" -eq 1 ]; then
Garrett Cooper89fde872010-11-16 22:38:08 -0800583 SCENARIO_LISTS="$SCENARIO_LISTS $LTPROOT/scenario_groups/network"
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800584 fi
plars4a120e82004-09-02 18:56:06 +0000585
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800586 # DO NOT INDENT/DEDENT!
587 if [ -n "$SCENARIO_LISTS" ]; then
588 # Insurance to make sure that the first element in the pipe
589 # completed successfully.
590 cat_ok_sentinel=$TMP/cat_ok.$$
Garrett Cooper66d67b52010-11-16 22:42:48 -0800591 (cat $SCENARIO_LISTS && touch "$cat_ok_sentinel") | \
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800592 while read scenfile; do
593
594 scenfile=${LTPROOT}/runtest/$scenfile
595
596 # Skip over non-existent scenario files; things are
597 # robust enough now that the build will fail if these
598 # files don't exist.
599 [ -f "$scenfile" ] || continue
600
601 cat $scenfile >> "$TMP/alltests" || {
602 echo "FATAL: unable to append to command file"
603 rm -Rf "$TMP"
604 rm -f "$cat_ok_sentinel"
605 exit 1
606 }
607
608 done
609
610 rm -f "$cat_ok_sentinel"
611
612 fi
613 # ^^DO NOT INDENT/DEDENT!^^
614
subrata_modakbc833d32007-07-25 10:12:02 +0000615 fi
616
yaberauneya6d41cc32010-01-28 16:24:16 +0000617 [ -n "$CMDFILES" ] && \
618 {
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800619 for scenfile in `echo "$CMDFILES" | tr ',' ' '`
yaberauneya6d41cc32010-01-28 16:24:16 +0000620 do
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800621 [ -f "$scenfile" ] || scenfile="$LTPROOT/runtest/$scenfile"
622 cat "$scenfile" >> ${TMP}/alltests || \
yaberauneya6d41cc32010-01-28 16:24:16 +0000623 {
624 echo "FATAL: unable to create command file"
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800625 rm -Rf "$TMP"
yaberauneya6d41cc32010-01-28 16:24:16 +0000626 exit 1
627 }
plars4a120e82004-09-02 18:56:06 +0000628 done
yaberauneya6d41cc32010-01-28 16:24:16 +0000629 }
Chris Dearman37550cf2012-10-17 19:54:01 -0700630
yaberauneya6d41cc32010-01-28 16:24:16 +0000631 [ -n "$CMDFILEADDR" ] && \
632 {
633 wget -q "${CMDFILEADDR}" -O ${TMP}/wgetcmdfile
634 if [ $? -ne 0 ]; then
635 echo "FATAL: error while getting the command file with wget (address $CMDFILEADDR)"
636 exit 1
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000637 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000638 cat "${TMP}/wgetcmdfile" >> ${TMP}/alltests || \
639 {
640 echo "FATAL: unable to create command file"
641 exit 1
642 }
643 }
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000644
plars4a120e82004-09-02 18:56:06 +0000645 # The fsx-linux tests use the SCRATCHDEV environment variable as a location
Chris Dearman37550cf2012-10-17 19:54:01 -0700646 # that can be reformatted and run on. Set SCRATCHDEV if you want to run
plars4a120e82004-09-02 18:56:06 +0000647 # these tests. As a safeguard, this is disabled.
648 unset SCRATCHDEV
yaberauneya6d41cc32010-01-28 16:24:16 +0000649 [ -n "$SCRATCHDEV" ] && \
650 {
651 cat ${LTPROOT}/runtest/fsx >> ${TMP}/alltests ||
652 {
653 echo "FATAL: unable to create fsx-linux tests command file"
654 exit 1
655 }
656 }
subrata_modakbc833d32007-07-25 10:12:02 +0000657
658 # If enabled, execute only test cases that match the PATTERN
yaberauneya6d41cc32010-01-28 16:24:16 +0000659 if [ -n "$TAG_RESTRICT_STRING" ]
660 then
661 mv -f ${TMP}/alltests ${TMP}/alltests.orig
662 grep $TAG_RESTRICT_STRING ${TMP}/alltests.orig > ${TMP}/alltests #Not worth checking return codes for this case
subrata_modakbc833d32007-07-25 10:12:02 +0000663 fi
subrata_modak2f6c9812009-08-14 17:07:48 +0000664
665 # Blacklist or skip tests if a SKIPFILE was specified with -S
yaberauneya6d41cc32010-01-28 16:24:16 +0000666 if [ -n "$SKIPFILE" ]
667 then
subrata_modak2f6c9812009-08-14 17:07:48 +0000668 for file in $( cat $SKIPFILE ); do
Andrew Chen410c6952011-06-30 14:19:45 +0800669 sed -i "/^$file[ \t]/d" ${TMP}/alltests
subrata_modak2f6c9812009-08-14 17:07:48 +0000670 done
671 fi
Chris Dearman37550cf2012-10-17 19:54:01 -0700672
plars4a120e82004-09-02 18:56:06 +0000673 # check for required users and groups
Cyril Hrubisb88fa5b2013-06-25 15:50:08 +0200674 ${LTPROOT}/IDcheck.sh || \
yaberauneya6d41cc32010-01-28 16:24:16 +0000675 {
676 echo "WARNING: required users and groups not present"
677 echo "WARNING: some test cases may fail"
678 }
Chris Dearman37550cf2012-10-17 19:54:01 -0700679
plars4a120e82004-09-02 18:56:06 +0000680 # display versions of installed software
yaberauneya6d41cc32010-01-28 16:24:16 +0000681 [ -z "$QUIET_MODE" ] && \
Chris Dearman37550cf2012-10-17 19:54:01 -0700682 {
yaberauneya6d41cc32010-01-28 16:24:16 +0000683 ${LTPROOT}/ver_linux || \
684 {
685 echo "WARNING: unable to display versions of software installed"
686 exit 1
687 }
688 }
689
Harald Weppner8bdf0a02014-03-03 14:10:07 -0800690 set_block_device
subrata_modakd9fb3862008-12-29 11:25:36 +0000691
Xiaoguang Wang5b42a1e2013-12-12 19:10:58 +0800692 # here even if the user don't specify a big block device, we
693 # also don't create the big block device.
694 if [ -z "$BIG_DEVICE" ]; then
695 echo "no big block device was specified on commandline."
696 echo "Tests which require a big block device are disabled."
697 echo "You can specify it with option -z"
698 else
699 LTP_BIG_DEV=$BIG_DEVICE
subrata_modakd9fb3862008-12-29 11:25:36 +0000700 fi
701
subrata_modak8c138332008-01-28 11:19:32 +0000702 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 +0000703 echo "PAN will run these test cases $RUN_REPEATED times....."
704 echo "Test Tags will be Prepended with ITERATION NO.s....."
705 inc=1
706 sed -e '/^$/ d' -e 's/^[ ,\t]*//' -e '/^#/ d' < ${TMP}/alltests > ${TMP}/alltests.temp ##This removes all newlines, leading spaces, tabs, #
707 sed 's/^[0-9,a-z,A-Z]*/'"$inc"'_ITERATION_&/' < ${TMP}/alltests.temp > ${TMP}/alltests ## .temp is kept as Base file
708 while [ $inc -lt $RUN_REPEATED ] ; do
709 inc=`expr $inc + 1`
710 sed 's/^[0-9,a-z,A-Z]*/'"$inc"'_ITERATION_&/' < ${TMP}/alltests.temp >> ${TMP}/alltests #Keep appending with Iteration No.s
711 done
subrata_modak8c138332008-01-28 11:19:32 +0000712 fi
713
yaberauneya6d41cc32010-01-28 16:24:16 +0000714 [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test start time: $(date)" ; }
715 PAN_COMMAND="${LTPROOT}/bin/ltp-pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ \
716 -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE $FAILCMDFILE"
717 echo "COMMAND: $PAN_COMMAND"
718 if [ ! -z "$TAG_RESTRICT_STRING" ] ; then
719 echo "INFO: Restricted to $TAG_RESTRICT_STRING"
robbiew7d43d772005-02-07 20:07:30 +0000720 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000721 #$PAN_COMMAND #Duplicated code here, because otherwise if we fail, only "PAN_COMMAND" gets output
Chris Dearman37550cf2012-10-17 19:54:01 -0700722
subrata_modak43938212008-05-19 08:48:46 +0000723 ## Display the Output/Log/Failed/HTML file names here
Anders Roxell4691f012013-09-03 09:42:35 +0200724 printf "LOG File: "
yaberauneya6d41cc32010-01-28 16:24:16 +0000725 echo $LOGFILE | cut -b4-
subrata_modak43938212008-05-19 08:48:46 +0000726
yaberauneya6d41cc32010-01-28 16:24:16 +0000727 if [ "$OUTPUTFILE" ]; then
Anders Roxell4691f012013-09-03 09:42:35 +0200728 printf "OUTPUT File: "
yaberauneya6d41cc32010-01-28 16:24:16 +0000729 echo $OUTPUTFILE | cut -b4-
subrata_modak43938212008-05-19 08:48:46 +0000730 fi
731
Anders Roxell4691f012013-09-03 09:42:35 +0200732 printf "FAILED COMMAND File: "
yaberauneya6d41cc32010-01-28 16:24:16 +0000733 echo $FAILCMDFILE | cut -b4-
734
735 if [ "$HTMLFILE" ]; then
736 echo "HTML File: $HTMLFILE"
737 fi
738
739 echo "Running tests......."
subrata_modake47fb352007-11-25 17:03:49 +0000740 test_start_time=$(date)
subrata_modak724098e2009-03-19 08:49:18 +0000741
yaberauneya6d41cc32010-01-28 16:24:16 +0000742 # User wants testing with Kernel Fault Injection
743 if [ $INJECT_KERNEL_FAULT ] ; then
744 #See if Debugfs is mounted, and
745 #Fault Injection Framework available through Debugfs
Garrett Coopercb66da52012-04-03 22:09:42 -0700746 use_faultinjection=true
747 for debug_subdir in \
748 fail_io_timeout \
749 fail_make_request \
750 fail_page_alloc \
751 failslab \
752 ; do
753 if [ -d "/sys/kernel/debug/$debug_subdir" ]
754 then
755 use_faultinjection=true
756 break
757 fi
758 done
759 if $use_faultinjection; then
yaberauneya6d41cc32010-01-28 16:24:16 +0000760 #If atleast one of the Framework is available
761 #Go ahead to Inject Fault & Create required
762 #Command Files for LTP run
763 echo Running tests with Fault Injection Enabled in the Kernel...
Garrett Coopercb66da52012-04-03 22:09:42 -0700764 awk -v LOOPS=$INJECT_FAULT_LOOPS_PER_TEST \
765 -v PERCENTAGE=$INJECT_KERNEL_FAULT_PERCENTAGE \
766 -f ${LTPROOT}/bin/create_kernel_faults_in_loops_and_probability.awk \
767 ${TMP}/alltests > ${TMP}/alltests.tmp
yaberauneya6d41cc32010-01-28 16:24:16 +0000768 cp ${TMP}/alltests.tmp ${TMP}/alltests
769 rm -rf ${TMP}/alltests.tmp
770 else
771 echo Fault Injection not enabled in the Kernel..
772 echo Running tests normally...
773 fi
774 fi
775
776 ## Valgrind Check will work only when Kernel Fault Injection is not expected,
777 ## We do not want to test Faults when valgrind is running
778 if [ $VALGRIND_CHECK ]; then
779 if [ ! $INJECT_KERNEL_FAULT ]; then
780 which valgrind || VALGRIND_CHECK_TYPE=XYZ
781 case $VALGRIND_CHECK_TYPE in
Garrett Cooper3920fd12012-04-03 19:47:16 -0700782 [1-3])
783 awk -v CHECK_LEVEL=$VALGRIND_CHECK_TYPE \
784 -f ${LTPROOT}/bin/create_valgrind_check.awk \
785 ${TMP}/alltests $VALGRIND_CHECK_TYPE > \
786 ${TMP}/alltests.tmp
yaberauneya6d41cc32010-01-28 16:24:16 +0000787 cp ${TMP}/alltests.tmp ${TMP}/alltests
Garrett Cooper3920fd12012-04-03 19:47:16 -0700788 rm -rf ${TMP}/alltests.tmp
789 ;;
790 *)
791 echo "Invalid Memory Check Type, or, Valgrind is not available"
792 ;;
yaberauneya6d41cc32010-01-28 16:24:16 +0000793 esac
794 fi
795 fi
796
Subrata Modakbd9d4402010-05-12 22:03:21 +0530797 if [ $ALT_DMESG_OUT -eq 1 ] ; then
798 #We want to print dmesg output for each test,lets do the trick inside the script
799 echo Enabling dmesg output logging for each test...
Garrett Cooper66030122012-04-03 20:22:14 -0700800 awk -v DMESG_DIR=$DMESG_DIR \
801 -f ${LTPROOT}/bin/create_dmesg_entries_for_each_test.awk \
802 ${TMP}/alltests > ${TMP}/alltests.tmp
Subrata Modakbd9d4402010-05-12 22:03:21 +0530803 cp ${TMP}/alltests.tmp ${TMP}/alltests
804 rm -rf ${TMP}/alltests.tmp
805 fi
subrata_modak724098e2009-03-19 08:49:18 +0000806 # Some tests need to run inside the "bin" directory.
807 cd "${LTPROOT}/testcases/bin"
yaberauneya6d41cc32010-01-28 16:24:16 +0000808 "${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 -0700809
plars4a120e82004-09-02 18:56:06 +0000810 if [ $? -eq 0 ]; then
yaberauneya6d41cc32010-01-28 16:24:16 +0000811 echo "INFO: ltp-pan reported all tests PASS"
812 VALUE=0
813 export LTP_EXIT_VALUE=0;
plars4a120e82004-09-02 18:56:06 +0000814 else
yaberauneya6d41cc32010-01-28 16:24:16 +0000815 echo "INFO: ltp-pan reported some tests FAIL"
816 VALUE=1
817 export LTP_EXIT_VALUE=1;
plars4a120e82004-09-02 18:56:06 +0000818 fi
subrata_modak724098e2009-03-19 08:49:18 +0000819 cd ..
yaberauneya6d41cc32010-01-28 16:24:16 +0000820 echo "LTP Version: $version_date"
mreed1091696422006-05-03 19:07:22 +0000821
Subrata Modake3bc3752010-07-03 23:32:27 +0530822 # $DMESG_DIR is used to cache messages obtained from dmesg after a test run.
823 # Proactively reap all of the 0-byte files in $DMESG_DIR as they have zero value
824 # and only clutter up the filesystem.
825
826 if [ $ALT_DMESG_OUT -eq 1 ] ; then
827 if ! find "$DMESG_DIR" -size 0 -exec rm {} + ; then
828 echo "cd to $DMESG_DIR failed: $?"
829 fi
830 if [ -n "$(ls "$DMESG_DIR")" ] ; then
831 echo "Kernel messages were generated for LTP tests $version_date"
832 else
833 echo "No Kernel messages were generated for LTP tests $version_date"
834 fi
835 fi
836
subrata_modake47fb352007-11-25 17:03:49 +0000837 if [ "$ALT_HTML_OUT" -eq 1 ] ; then #User wants the HTML output to be created, it then needs to be generated
838 export LTP_VERSION=$version_date
839 export TEST_START_TIME=$test_start_time
840 export TEST_END_TIME=$(date)
yaberauneya6d41cc32010-01-28 16:24:16 +0000841 OUTPUT_DIRECTORY=`echo $OUTPUTFILE | cut -c4-`
subrata_modake47fb352007-11-25 17:03:49 +0000842 LOGS_DIRECTORY="$LTPROOT/results"
843 export TEST_OUTPUT_DIRECTORY="$LTPROOT/output"
844 export TEST_LOGS_DIRECTORY=$LOGS_DIRECTORY
yaberauneya6d41cc32010-01-28 16:24:16 +0000845 echo "Generating HTML Output.....!!"
Chris Dearman37550cf2012-10-17 19:54:01 -0700846 ( 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 +0000847 echo "Generated HTML Output.....!!"
848 echo "Location: $HTMLFILE";
849
subrata_modake47fb352007-11-25 17:03:49 +0000850 fi
Chris Dearman37550cf2012-10-17 19:54:01 -0700851
yaberauneya6d41cc32010-01-28 16:24:16 +0000852 if [ "$ALT_EMAIL_OUT" -eq 1 ] ; then ## User wants reports to be e-mailed
Chris Dearman37550cf2012-10-17 19:54:01 -0700853 if [ [ ! "$HTMLFILE_NAME" ] -o [ ! "$OUTPUTFILE_NAME" ] -o [ ! "$LOGFILE_NAME" ] ] ; then
yaberauneya6d41cc32010-01-28 16:24:16 +0000854 ##User does not have output/logs/html-output, nothing to be mailed in this situation
855 echo "Nothing to be mailed here...."
subrata_modak08dde6f2007-11-28 11:02:51 +0000856 else
subrata_modak43938212008-05-19 08:48:46 +0000857 TAR_FILE_NAME=LTP_RUN_$version_date$DEFAULT_FILE_NAME_GENERATION_TIME.tar
yaberauneya6d41cc32010-01-28 16:24:16 +0000858 if [ "$HTMLFILE_NAME" ] ; then ## HTML file Exists
859 if [ "$ALT_HTML_OUT" -ne 1 ] ; then ## The HTML file path is absolute and not $LTPROOT/output
860 mkdir -p $LTPROOT/output ## We need to create this Directory
861 cp $HTMLFILE_NAME $LTPROOT/output/
862 fi
subrata_modak08dde6f2007-11-28 11:02:51 +0000863 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000864 if [ "$OUTPUTFILE_NAME" ] ; then ## Output file exists
865 if [ "$ALT_DIR_OUT" -ne 1 ] ; then ## The Output file path is absolute and not $LTPROOT/output
866 mkdir -p $LTPROOT/output ## We need to create this Directory
867 cp $OUTPUTFILE_NAME $LTPROOT/output/
868 fi
subrata_modak08dde6f2007-11-28 11:02:51 +0000869 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000870 if [ "$LOGFILE_NAME" ] ; then ## Log file exists
871 if [ "$ALT_DIR_RES" -ne 1 ] ; then ## The Log file path is absolute and not $LTPROOT/results
872 mkdir -p $LTPROOT/results ## We need to create this Directory
873 cp $LOGFILE_NAME $LTPROOT/results/
874 fi
875 fi
876 if [ -d $LTPROOT/output ] ; then
877 tar -cf ./$TAR_FILE_NAME $LTPROOT/output
878 if [ $? -eq 0 ]; then
879 echo "Created TAR File: ./$TAR_FILE_NAME successfully, added $LTPROOT/output"
880 else
881 echo "Cannot Create TAR File: ./$TAR_FILE_NAME for adding $LTPROOT/output"
882 fi
883 fi
884 if [ -d $LTPROOT/results ] ; then
885 tar -uf ./$TAR_FILE_NAME $LTPROOT/results
886 if [ $? -eq 0 ]; then
887 echo "Updated TAR File: ./$TAR_FILE_NAME successfully, added $LTPROOT/results"
888 else
889 echo "Cannot Update TAR File: ./$TAR_FILE_NAME for adding $LTPROOT/results"
890 fi
891 fi
892 if [ -e $LTPROOT/nohup.out ] ; then ## If User would have Chosen nohup to do ltprun
893 tar -uf ./$TAR_FILE_NAME $LTPROOT/nohup.out
894 if [ $? -eq 0 ]; then
895 echo "Updated TAR File: ./$TAR_FILE_NAME successfully, added $LTPROOT/nohup.out"
896 else
897 echo "Cannot Update TAR File: ./$TAR_FILE_NAME for adding $LTPROOT/nohup.out"
898 fi
899 fi
900 gzip ./$TAR_FILE_NAME ## gzip this guy
901 if [ $? -eq 0 ]; then
902 echo "Gunzipped TAR File: ./$TAR_FILE_NAME"
subrata_modak08dde6f2007-11-28 11:02:51 +0000903 else
yaberauneya6d41cc32010-01-28 16:24:16 +0000904 echo "Cannot Gunzip TAR File: ./$TAR_FILE_NAME"
subrata_modak08dde6f2007-11-28 11:02:51 +0000905 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000906 if [ -e /usr/bin/mutt ] ; then ## This is a better mail client than others
907 echo "Starting mailing reports to: $EMAIL_TO, file: ./$TAR_FILE_NAME.gz"
908 mutt -a ./$TAR_FILE_NAME.gz -s "LTP Reports on $test_start_time" $EMAIL_TO < /dev/null
909 if [ $? -eq 0 ]; then
910 echo "Reports Successfully mailed to: $EMAIL_TO"
911 else
912 echo "Reports cannot be mailed to: $EMAIL_TO"
913 fi
914 else ## Use our Ageold mail program
915 echo "Starting mailing reports to: $EMAIL_TO, file: ./$TAR_FILE_NAME.gz"
916 uuencode ./$TAR_FILE_NAME.gz $TAR_FILE_NAME.gz | mail $EMAIL_TO -s "LTP Reports on $test_start_time"
917 if [ $? -eq 0 ]; then
918 echo "Reports Successfully mailed to: $EMAIL_TO"
919 else
920 echo "Reports cannot be mailed to: $EMAIL_TO"
921 fi
Chris Dearman37550cf2012-10-17 19:54:01 -0700922 fi
subrata_modak08dde6f2007-11-28 11:02:51 +0000923 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000924 fi
Chris Dearman37550cf2012-10-17 19:54:01 -0700925
yaberauneya6d41cc32010-01-28 16:24:16 +0000926 [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test end time: $(date)" ; }
Chris Dearman37550cf2012-10-17 19:54:01 -0700927
yaberauneya6d41cc32010-01-28 16:24:16 +0000928 [ "$GENLOAD" -eq 1 ] && { killall -9 genload >/dev/null 2>&1; }
929 [ "$NETPIPE" -eq 1 ] && { killall -9 NPtcp >/dev/null 2>&1; }
Chris Dearman37550cf2012-10-17 19:54:01 -0700930
yaberauneya6d41cc32010-01-28 16:24:16 +0000931 [ "$ALT_DIR_OUT" -eq 1 ] || [ "$ALT_DIR_RES" -eq 1 ] && \
932 {
933 cat <<-EOF >&1
Chris Dearman37550cf2012-10-17 19:54:01 -0700934
Markos Chandras11328662012-03-06 10:28:59 +0000935 ###############################################################
Chris Dearman37550cf2012-10-17 19:54:01 -0700936
Markos Chandras11328662012-03-06 10:28:59 +0000937 Done executing testcases.
mreed1091696422006-05-03 19:07:22 +0000938 LTP Version: $version_date
Markos Chandras11328662012-03-06 10:28:59 +0000939 ###############################################################
Chris Dearman37550cf2012-10-17 19:54:01 -0700940
yaberauneya6d41cc32010-01-28 16:24:16 +0000941 EOF
942 }
943 exit $VALUE
plars4a120e82004-09-02 18:56:06 +0000944}
945
Ramesh YR0a78f232013-04-16 09:31:28 +0800946create_block()
947{
DAN LI189c4412013-09-10 10:53:34 +0800948 #create a block device
Wanlong Gao36894aa2013-11-25 08:33:30 +0800949 dd if=/dev/zero of=${TMP}/test.img bs=1kB count=20480 >/dev/null 2>&1
Ramesh YR0a78f232013-04-16 09:31:28 +0800950 if [ $? -ne 0 ]; then
951 echo "Failed to create loopback device image, please check disk space and re-run"
952 return 1
953 else
954 ##search for an unused loop dev
955 LOOP_DEV=$(losetup -f)
956 if [ $? -ne 0 ]; then
957 echo "no unused loop device is found"
958 return 1
959 else
960 ##attach the created file to loop dev.
Cyril Hrubisb88fa5b2013-06-25 15:50:08 +0200961 losetup $LOOP_DEV ${TMP}/test.img
Ramesh YR0a78f232013-04-16 09:31:28 +0800962 if [ $? -ne 0 ]; then
963 echo "losetup failed to create block device"
964 return 1
Ramesh YR0a78f232013-04-16 09:31:28 +0800965 fi
Cyril Hrubisc381f582013-08-08 18:19:35 +0200966 DEVICE=$LOOP_DEV
967 return 0
Ramesh YR0a78f232013-04-16 09:31:28 +0800968 fi
969 fi
970}
971
Harald Weppner8bdf0a02014-03-03 14:10:07 -0800972set_block_device()
973{
974 if [ -z "$DEVICE" ]; then
975 create_block
976 if [ $? -ne 0 ]; then
977 echo "no block device was specified on commandline."
978 echo "Block device could not be created using loopback device"
979 echo "Tests which require block device are disabled."
980 echo "You can specify it with option -b"
981 else
982 LTP_DEV=$DEVICE
983 fi
984 else
985 LTP_DEV=$DEVICE
986 fi
987}
988
plars4a120e82004-09-02 18:56:06 +0000989cleanup()
990{
Ramesh YR0a78f232013-04-16 09:31:28 +0800991 [ "$LOOP_DEV" ] && losetup -d $LOOP_DEV
yaberauneya6d41cc32010-01-28 16:24:16 +0000992 rm -rf ${TMP}
plars4a120e82004-09-02 18:56:06 +0000993}
994
Harald Weppner8bdf0a02014-03-03 14:10:07 -0800995
996LTP_SCRIPT="$(basename $0)"
997
998if [[ "$LTP_SCRIPT" == "runltp" ]]; then
999 trap "cleanup" 0
1000 setup
1001 main "$@"
1002fi
Garrett Coopercf86b8b2010-11-16 21:46:41 -08001003
1004#vim: syntax=sh