blob: 928696b9e10b6349afb2b989d0ee81f7d9083722 [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"
Hoang Van Tuyen4c003972018-01-26 09:34:09 +070081 export PATH="${PATH}:${LTPROOT}/testcases/bin:${LTPROOT}/bin"
plars4a120e82004-09-02 18:56:06 +000082
Xiaoguang Wang5b42a1e2013-12-12 19:10:58 +080083 export LTP_DEV_FS_TYPE="ext2"
Xiaoguang Wang5b42a1e2013-12-12 19:10:58 +080084
yaberauneya6d41cc32010-01-28 16:24:16 +000085 [ -d "$LTPROOT/testcases/bin" ] ||
86 {
Garrett Coopercf86b8b2010-11-16 21:46:41 -080087 echo "FATAL: LTP not installed correctly"
88 echo "INFO: Follow directions in INSTALL!"
yaberauneya6d41cc32010-01-28 16:24:16 +000089 exit 1
90 }
91
92 [ -e "$LTPROOT/bin/ltp-pan" ] ||
93 {
94 echo "FATAL: Test suite driver 'ltp-pan' not found"
Garrett Coopercf86b8b2010-11-16 21:46:41 -080095 echo "INFO: Follow directions in INSTALL!"
yaberauneya6d41cc32010-01-28 16:24:16 +000096 exit 1
97 }
plars4a120e82004-09-02 18:56:06 +000098}
99
mreed1091696422006-05-03 19:07:22 +0000100version_of_ltp()
101{
yaberauneyaef772532009-10-09 17:55:43 +0000102 cat "$LTPROOT/Version"
yaberauneya6d41cc32010-01-28 16:24:16 +0000103 exit 0
mreed1091696422006-05-03 19:07:22 +0000104}
plars4a120e82004-09-02 18:56:06 +0000105
Chris Dearman37550cf2012-10-17 19:54:01 -0700106usage()
plars4a120e82004-09-02 18:56:06 +0000107{
yaberauneya6d41cc32010-01-28 16:24:16 +0000108 cat <<-EOF >&2
plars4a120e82004-09-02 18:56:06 +0000109
Xiaoguang Wang5f71cf92014-09-23 15:59:43 +0800110 usage: ${0##*/} [ -a EMAIL_TO ] [ -c NUM_PROCS ] [ -C FAILCMDFILE ] [ -T TCONFCMDFILE ]
111 [ -d TMPDIR ] [ -D NUM_PROCS,NUM_FILES,NUM_BYTES,CLEAN_FLAG ] -e [ -f CMDFILES(,...) ]
112 [ -g HTMLFILE] [ -i NUM_PROCS ] [ -l LOGFILE ] [ -m NUM_PROCS,CHUNKS,BYTES,HANGUP_FLAG ]
Petr Vorel82835202017-08-22 15:33:47 +0200113 -N -n [ -o OUTPUTFILE ] -p -q -Q [ -r LTPROOT ] [ -s PATTERN ] [ -t DURATION ]
Xiaoguang Wang5b42a1e2013-12-12 19:10:58 +0800114 -v [ -w CMDFILEADDR ] [ -x INSTANCES ] [ -b DEVICE ] [-B LTP_DEV_FS_TYPE]
115 [ -F LOOPS,PERCENTAGE ] [ -z BIG_DEVICE ] [-Z LTP_BIG_DEV_FS_TYPE]
Chris Dearman37550cf2012-10-17 19:54:01 -0700116
subrata_modak08dde6f2007-11-28 11:02:51 +0000117 -a EMAIL_TO EMAIL all your Reports to this E-mail Address
subrata_modake099b2a2007-10-29 12:22:01 +0000118 -c NUM_PROCS Run LTP under additional background CPU load
119 [NUM_PROCS = no. of processes creating the CPU Load by spinning over sqrt()
120 (Defaults to 1 when value)]
subrata_modakbc833d32007-07-25 10:12:02 +0000121 -C FAILCMDFILE Command file with all failed test cases.
Xiaoguang Wang5f71cf92014-09-23 15:59:43 +0800122 -T TCONFCMDFILE Command file with all test cases that are not fully tested.
plars4a120e82004-09-02 18:56:06 +0000123 -d TMPDIR Directory where temporary files will be created.
subrata_modake099b2a2007-10-29 12:22:01 +0000124 -D NUM_PROCS,NUM_FILES,NUM_BYTES,CLEAN_FLAG
125 Run LTP under additional background Load on Secondary Storage (Seperate by comma)
126 [NUM_PROCS = no. of processes creating Storage Load by spinning over write()]
127 [NUM_FILES = Write() to these many files (Defaults to 1 when value 0 or undefined)]
128 [NUM_BYTES = write these many bytes (defaults to 1GB, when value 0 or undefined)]
129 [CLEAN_FLAG = unlink file to which random data written, when value 1]
mreed1091696422006-05-03 19:07:22 +0000130 -e Prints the date of the current LTP release
subrata_modakbc833d32007-07-25 10:12:02 +0000131 -f CMDFILES Execute user defined list of testcases (separate with ',')
yaberauneya6d41cc32010-01-28 16:24:16 +0000132 -F LOOPS,PERCENTAGE Induce PERCENTAGE Fault in the Kernel Subsystems, and, run each test for LOOPS loop
subrata_modake47fb352007-11-25 17:03:49 +0000133 -g HTMLFILE Create an additional HTML output format
plars4a120e82004-09-02 18:56:06 +0000134 -h Help. Prints all available options.
subrata_modake099b2a2007-10-29 12:22:01 +0000135 -i NUM_PROCS Run LTP under additional background Load on IO Bus
136 [NUM_PROCS = no. of processes creating IO Bus Load by spinning over sync()]
Subrata Modakbd9d4402010-05-12 22:03:21 +0530137 -K DMESG_LOG_DIR
Chris Dearman37550cf2012-10-17 19:54:01 -0700138 Log Kernel messages generated for each test cases inside this directory
plars4a120e82004-09-02 18:56:06 +0000139 -l LOGFILE Log results of test in a logfile.
subrata_modake099b2a2007-10-29 12:22:01 +0000140 -m NUM_PROCS,CHUNKS,BYTES,HANGUP_FLAG
141 Run LTP under additional background Load on Main memory (Seperate by comma)
142 [NUM_PROCS = no. of processes creating main Memory Load by spinning over malloc()]
143 [CHUNKS = malloc these many chunks (default is 1 when value 0 or undefined)]
144 [BYTES = malloc CHUNKS of BYTES bytes (default is 256MB when value 0 or undefined) ]
145 [HANGUP_FLAG = hang in a sleep loop after memory allocated, when value 1]
yaberauneya6d41cc32010-01-28 16:24:16 +0000146 -M CHECK_TYPE
147 [CHECK_TYPE=1 => Full Memory Leak Check tracing children as well]
148 [CHECK_TYPE=2 => Thread Concurrency Check tracing children as well]
149 [CHECK_TYPE=3 => Full Memory Leak & Thread Concurrency Check tracing children as well]
Chris Dearman37550cf2012-10-17 19:54:01 -0700150 -N Run all the networking tests.
plars4a120e82004-09-02 18:56:06 +0000151 -n Run LTP with network traffic in background.
152 -o OUTPUTFILE Redirect test output to a file.
Chris Dearman37550cf2012-10-17 19:54:01 -0700153 -p Human readable format logfiles.
Petr Vorel82835202017-08-22 15:33:47 +0200154 -q Print less verbose output to screen. This implies
155 not logging start of the test in kernel log.
156 -Q Don't log start of test in kernel log.
plars4a120e82004-09-02 18:56:06 +0000157 -r LTPROOT Fully qualified path where testsuite is installed.
Zorro Lang8aa21022016-09-26 21:19:49 +0800158 -R Randomize test order.
subrata_modaka1fd64b2007-04-11 11:24:49 +0000159 -s PATTERN Only run test cases which match PATTERN.
subrata_modak2f6c9812009-08-14 17:07:48 +0000160 -S SKIPFILE Skip tests specified in SKIPFILE
plars4a120e82004-09-02 18:56:06 +0000161 -t DURATION Execute the testsuite for given duration. Examples:
162 -t 60s = 60 seconds
163 -t 45m = 45 minutes
164 -t 24h = 24 hours
165 -t 2d = 2 days
Cyril Hrubis5f795702016-04-26 14:45:57 +0200166 -I ITERATIONS Execute the testsuite ITERATIONS times.
subrata_modakbc833d32007-07-25 10:12:02 +0000167 -w CMDFILEADDR Uses wget to get the user's list of testcases.
plars4a120e82004-09-02 18:56:06 +0000168 -x INSTANCES Run multiple instances of this testsuite.
subrata_modakd9fb3862008-12-29 11:25:36 +0000169 -b DEVICE Some tests require an unmounted block device
170 to run correctly.
Xiaoguang Wang5b42a1e2013-12-12 19:10:58 +0800171 -B LTP_DEV_FS_TYPE The file system of test block devices.
172 -z BIG_DEVICE Some tests require a big unmounted block device
173 to run correctly.
174 -Z LTP_BIG_DEV_FS_TYPE The file system of the big device
175
subrata_modakd9fb3862008-12-29 11:25:36 +0000176
plars4a120e82004-09-02 18:56:06 +0000177
Garrett Cooperf95875a2010-03-05 02:44:39 -0800178 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 +0000179
plars4a120e82004-09-02 18:56:06 +0000180
yaberauneya6d41cc32010-01-28 16:24:16 +0000181 EOF
182exit 0
plars4a120e82004-09-02 18:56:06 +0000183}
184
plars4a120e82004-09-02 18:56:06 +0000185main()
186{
Petr Vorel82835202017-08-22 15:33:47 +0200187 local CMDFILES=
188 local PRETTY_PRT=
subrata_modak5d7deea2007-09-15 13:51:36 +0000189 local ALT_DIR_OUT=0
190 local ALT_DIR_RES=0
subrata_modake47fb352007-11-25 17:03:49 +0000191 local ALT_HTML_OUT=0
subrata_modak08dde6f2007-11-28 11:02:51 +0000192 local ALT_EMAIL_OUT=0
Subrata Modakbd9d4402010-05-12 22:03:21 +0530193 local ALT_DMESG_OUT=0
plars4a120e82004-09-02 18:56:06 +0000194 local RUN_NETEST=0
subrata_modak8c138332008-01-28 11:19:32 +0000195 local RUN_REPEATED=0
Petr Vorel82835202017-08-22 15:33:47 +0200196 local QUIET_MODE=
197 local NO_KMSG=
plars4a120e82004-09-02 18:56:06 +0000198 local NETPIPE=0
199 local GENLOAD=0
200 local MEMSIZE=0
Petr Vorel82835202017-08-22 15:33:47 +0200201 local DURATION=
202 local CMDFILEADDR=
203 local FAILCMDFILE=
204 local TCONFCMDFILE=
205 local INJECT_KERNEL_FAULT=
206 local INJECT_KERNEL_FAULT_PERCENTAGE=
207 local INJECT_FAULT_LOOPS_PER_TEST=
208 local VALGRIND_CHECK=
209 local VALGRIND_CHECK_TYPE=
210 local LOGFILE_NAME=
211 local LOGFILE=
212 local OUTPUTFILE_NAME=
213 local OUTPUTFILE=
214 local HTMLFILE_NAME=
215 local HTMLFILE=
216 local DMESG_DIR=
217 local EMAIL_TO=
218 local TAG_RESTRICT_STRING=
219 local PAN_COMMAND=
Zorro Lang8aa21022016-09-26 21:19:49 +0800220 local RANDOMRUN=0
look69f39f52014-04-30 09:55:44 +0800221 local DEFAULT_FILE_NAME_GENERATION_TIME=`date +"%Y_%m_%d-%Hh_%Mm_%Ss"`
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800222 local scenfile=
223
yaberauneyaef772532009-10-09 17:55:43 +0000224 version_date=$(cat "$LTPROOT/Version")
plars4a120e82004-09-02 18:56:06 +0000225
Petr Vorel82835202017-08-22 15:33:47 +0200226 while getopts a:b:B:c:C:T:d:D:ef:F:g:hi:I:K:l:m:M:No:pqQr:Rs:S:t:T:w:x:z:Z: arg
yaberauneya6d41cc32010-01-28 16:24:16 +0000227 do case $arg in
subrata_modak08dde6f2007-11-28 11:02:51 +0000228 a) EMAIL_TO=$OPTARG
229 ALT_EMAIL_OUT=1;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700230 c)
subrata_modake099b2a2007-10-29 12:22:01 +0000231 NUM_PROCS=$(($OPTARG))
232 if [ "$NUM_PROCS" -eq 0 ]; then
233 # User Did not Define the Value ,or, User Defined Zero,
234 # hence, prevent from creating infinite processes
235 NUM_PROCS=1
236 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000237 $LTPROOT/testcases/bin/genload --cpu $NUM_PROCS >/dev/null 2>&1 &
plars4a120e82004-09-02 18:56:06 +0000238 GENLOAD=1 ;;
subrata_modakbc833d32007-07-25 10:12:02 +0000239
Chris Dearman37550cf2012-10-17 19:54:01 -0700240 C)
subrata_modak6838ec32007-09-14 10:10:12 +0000241 case $OPTARG in
242 /*)
243 FAILCMDFILE="-C $OPTARG" ;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700244 *)
subrata_modak6838ec32007-09-14 10:10:12 +0000245 FAILCMDFILE="-C $LTPROOT/output/$OPTARG"
subrata_modak5d7deea2007-09-15 13:51:36 +0000246 ALT_DIR_OUT=1 ;;
subrata_modak6838ec32007-09-14 10:10:12 +0000247 esac ;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700248
Xiaoguang Wang5f71cf92014-09-23 15:59:43 +0800249 T)
250 case $OPTARG in
251 /*)
252 TCONFCMDFILE="-T $OPTARG" ;;
253 *)
254 TCONFCMDFILE="-T $LTPROOT/output/$OPTARG"
255 ALT_DIR_OUT=1 ;;
256 esac ;;
257
subrata_modak5ee3e892008-10-21 13:17:56 +0000258 d) # convert the user path to absolute path.
Garrett Cooper5d520f42012-08-07 08:57:31 -0700259 export TMPBASE=$(readlink -f ${OPTARG}) ;;
subrata_modake099b2a2007-10-29 12:22:01 +0000260
261 D) NUM_PROCS=1; NUM_FILES=1; NUM_BYTES=$((1024 * 1024 * 1024)); CLEAN_FLAG=0
subrata_modak548379d2008-08-20 09:15:49 +0000262 ARGUMENT_LIST=$OPTARG
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800263 TOTAL_ARGUMENTS=1
264 for ARGUMENT in `echo "$ARGUMENT_LIST" | tr ',' ' '`
subrata_modake099b2a2007-10-29 12:22:01 +0000265 do
266 case $TOTAL_ARGUMENTS in
yaberauneya6d41cc32010-01-28 16:24:16 +0000267 1) NUM_PROCS="$ARGUMENT" ;;
268 2) NUM_FILES="$ARGUMENT" ;;
269 3) NUM_BYTES="$ARGUMENT" ;;
270 4) CLEAN_FLAG="$ARGUMENT" ;;
subrata_modake099b2a2007-10-29 12:22:01 +0000271 esac
yaberauneya6d41cc32010-01-28 16:24:16 +0000272 TOTAL_ARGUMENTS=`expr $TOTAL_ARGUMENTS + 1`
subrata_modake099b2a2007-10-29 12:22:01 +0000273 done
274 # just to get the default values if the user passed 0
275 if [ "$NUM_PROCS" -eq 0 ]; then
276 NUM_PROCS=1
277 fi
278 if [ "$NUM_FILES" -eq 0 ]; then
279 NUM_FILES=1
280 fi
281 if [ "$NUM_BYTES" -eq 0 ]; then
282 NUM_BYTES=$((1024 * 1024 * 1024))
283 fi
284 if [ "$CLEAN_FLAG" -ne 1 ]; then
285 CLEAN_FLAG=0
286 fi
287 if [ "$CLEAN_FLAG" -eq 1 ]; then
288 # Do not unlink file in this case
yaberauneya6d41cc32010-01-28 16:24:16 +0000289 $LTPROOT/testcases/bin/genload --hdd $NUM_PROCS --hdd-files \
subrata_modake099b2a2007-10-29 12:22:01 +0000290 $NUM_FILES --hdd-bytes $NUM_BYTES >/dev/null 2>&1 &
291 else
292 # Cleanup otherwise
yaberauneya6d41cc32010-01-28 16:24:16 +0000293 $LTPROOT/testcases/bin/genload --hdd $NUM_PROCS --hdd-files \
subrata_modake099b2a2007-10-29 12:22:01 +0000294 $NUM_FILES --hdd-bytes $NUM_BYTES --hdd-noclean >/dev/null 2>&1 &
295 fi
296 GENLOAD=1;;
297
mreed1091696422006-05-03 19:07:22 +0000298 e) # Print out the version of LTP
299 version_of_ltp
yaberauneya6d41cc32010-01-28 16:24:16 +0000300 ;;
plars4a120e82004-09-02 18:56:06 +0000301 f) # Execute user defined set of testcases.
subrata_modakbc833d32007-07-25 10:12:02 +0000302 # Can be more then one file, just separate it with ',', like:
303 # -f nfs,commands,/tmp/testfile
304 CMDFILES=$OPTARG;;
yaberauneya6d41cc32010-01-28 16:24:16 +0000305 F) INJECT_KERNEL_FAULT=1
306 #Seperate out the NO_OF_LOOPS & FAULT_PERCENTAGE
307 INJECT_FAULT_LOOPS_PER_TEST=`echo $OPTARG |cut -d',' -f1 | tr -d '\n' | tr -d ' '`
308 INJECT_KERNEL_FAULT_PERCENTAGE=`echo $OPTARG |cut -d',' -f2 | tr -d '\n' | tr -d ' '`
309 if [ ! $INJECT_FAULT_LOOPS_PER_TEST ]; then
310 echo "Loops not properly defined. Resorting to default 5..."
311 export INJECT_FAULT_LOOPS_PER_TEST=5
312 fi
313 if [ ! $INJECT_KERNEL_FAULT_PERCENTAGE ]; then
314 echo "Fault Persentage not properly defined. Resorting to default 10..."
315 export INJECT_KERNEL_FAULT_PERCENTAGE=10
316 fi;;
subrata_modake47fb352007-11-25 17:03:49 +0000317 g) HTMLFILE_NAME="$OPTARG"
318 case $OPTARG in
319 /*)
320 HTMLFILE="$OPTARG";;
321 *)
subrata_modakd48c4d02008-01-23 12:59:40 +0000322 HTMLFILE="$LTPROOT/output/$OPTARG";;
323 esac
Chris Dearman37550cf2012-10-17 19:54:01 -0700324 ALT_DIR_OUT=1
subrata_modakd48c4d02008-01-23 12:59:40 +0000325 ALT_HTML_OUT=1;;
plars4a120e82004-09-02 18:56:06 +0000326 h) usage;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700327
subrata_modake099b2a2007-10-29 12:22:01 +0000328 i)
329 NUM_PROCS=$(($OPTARG))
330 if [ "$NUM_PROCS" -eq 0 ]; then
331 # User Did not Define the Value ,or, User Defined Zero,
332 # hence, prevent from creating infinite processes
333 NUM_PROCS=1
334 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000335 $LTPROOT/testcases/bin/genload --io $NUM_PROCS >/dev/null 2>&1 &
plars4a120e82004-09-02 18:56:06 +0000336 GENLOAD=1 ;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700337
338 K)
Subrata Modakbd9d4402010-05-12 22:03:21 +0530339 case $OPTARG in
340 /*)
Cyril Hrubisc381f582013-08-08 18:19:35 +0200341 DMESG_DIR="$OPTARG-dmesg-output-`echo $$-``date +%X | tr -d ' '`";;
Subrata Modakbd9d4402010-05-12 22:03:21 +0530342 *)
Cyril Hrubisc381f582013-08-08 18:19:35 +0200343 DMESG_DIR="$LTPROOT/output/$OPTARG-dmesg-output-`echo $$-``date +%X | tr -d ' '`";;
Subrata Modakbd9d4402010-05-12 22:03:21 +0530344 esac
345 mkdir -p $DMESG_DIR
346 ALT_DMESG_OUT=1;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700347 l)
subrata_modak6838ec32007-09-14 10:10:12 +0000348 LOGFILE_NAME="$OPTARG"
plars4a120e82004-09-02 18:56:06 +0000349 case $OPTARG in
subrata_modak5d7deea2007-09-15 13:51:36 +0000350 /*)
plars4a120e82004-09-02 18:56:06 +0000351 LOGFILE="-l $OPTARG" ;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700352 *)
plars4a120e82004-09-02 18:56:06 +0000353 LOGFILE="-l $LTPROOT/results/$OPTARG"
subrata_modak5d7deea2007-09-15 13:51:36 +0000354 ALT_DIR_RES=1 ;;
plars4a120e82004-09-02 18:56:06 +0000355 esac ;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700356
subrata_modake099b2a2007-10-29 12:22:01 +0000357 m) NUM_PROCS=1; CHUNKS=1; BYTES=$((256 * 1024 * 1024)); HANGUP_FLAG=0
subrata_modak29a96d82008-08-27 13:34:46 +0000358 ARGUMENT_LIST=$OPTARG
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800359 TOTAL_ARGUMENTS=1
360 for ARGUMENT in `echo "$ARGUMENT_LIST" | tr ',' ' '`
subrata_modake099b2a2007-10-29 12:22:01 +0000361 do
362 case $TOTAL_ARGUMENTS in
yaberauneya6d41cc32010-01-28 16:24:16 +0000363 1) NUM_PROCS="$ARGUMENT" ;;
364 2) CHUNKS="$ARGUMENT" ;;
365 3) BYTES="$ARGUMENT" ;;
366 4) HANGUP_FLAG="$ARGUMENT" ;;
subrata_modake099b2a2007-10-29 12:22:01 +0000367 esac
yaberauneya6d41cc32010-01-28 16:24:16 +0000368 TOTAL_ARGUMENTS=`expr $TOTAL_ARGUMENTS + 1`
subrata_modake099b2a2007-10-29 12:22:01 +0000369 done
370 # just to get the default values if the user passed 0
yaberauneya6d41cc32010-01-28 16:24:16 +0000371 if [ "$NUM_PROCS" -eq 0 ]; then
372 NUM_PROCS=1
373 fi
374 if [ "$CHUNKS" -eq 0 ]; then
375 CHUNKS=1
376 fi
377 if [ "$BYTES" -eq 0 ]; then
378 BYTES=$((256 * 1024 * 1024))
379 fi
380 if [ "$HANGUP_FLAG" -ne 1 ]; then
381 HANGUP_FLAG=0
382 fi
subrata_modake099b2a2007-10-29 12:22:01 +0000383 if [ "$HANGUP_FLAG" -eq 1 ]; then
384 # Hang in a Sleep loop after memory allocated
yaberauneya6d41cc32010-01-28 16:24:16 +0000385 $LTPROOT/testcases/bin/genload --vm $NUM_PROCS --vm-chunks \
subrata_modake099b2a2007-10-29 12:22:01 +0000386 $CHUNKS --vm-bytes $BYTES --vm-hang >/dev/null 2>&1 &
387 else
388 # Otherwise Do not Hangup
yaberauneya6d41cc32010-01-28 16:24:16 +0000389 $LTPROOT/testcases/bin/genload --vm $NUM_PROCS --vm-chunks \
subrata_modake099b2a2007-10-29 12:22:01 +0000390 $CHUNKS --vm-bytes $BYTES >/dev/null 2>&1 &
391 fi
plars4a120e82004-09-02 18:56:06 +0000392 GENLOAD=1;;
yaberauneya6d41cc32010-01-28 16:24:16 +0000393 M)
394 VALGRIND_CHECK=1
395 VALGRIND_CHECK_TYPE="$OPTARG";;
subrata_modak9c7072a2009-08-26 07:00:25 +0000396
plars4a120e82004-09-02 18:56:06 +0000397 N) RUN_NETEST=1;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700398
subrata_modak6838ec32007-09-14 10:10:12 +0000399 o) OUTPUTFILE_NAME="$OPTARG"
subrata_modak6838ec32007-09-14 10:10:12 +0000400 case $OPTARG in
401 /*)
402 OUTPUTFILE="-o $OPTARG";;
403 *)
404 OUTPUTFILE="-o $LTPROOT/output/$OPTARG"
subrata_modak5d7deea2007-09-15 13:51:36 +0000405 ALT_DIR_OUT=1 ;;
yaberauneya6d41cc32010-01-28 16:24:16 +0000406 esac ;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700407
Petr Vorel82835202017-08-22 15:33:47 +0200408 p) PRETTY_PRT="-p";;
Chris Dearman37550cf2012-10-17 19:54:01 -0700409
Petr Vorel82835202017-08-22 15:33:47 +0200410 q) QUIET_MODE="-q";;
411
412 Q) NO_KMSG="-Q";;
Chris Dearman37550cf2012-10-17 19:54:01 -0700413
plars4a120e82004-09-02 18:56:06 +0000414 r) LTPROOT=$OPTARG;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700415
Zorro Lang8aa21022016-09-26 21:19:49 +0800416 R) RANDOMRUN=1;;
417
robbiew7d43d772005-02-07 20:07:30 +0000418 s) TAG_RESTRICT_STRING=$OPTARG;;
subrata_modak2f6c9812009-08-14 17:07:48 +0000419
yaberauneya6d41cc32010-01-28 16:24:16 +0000420 S) case $OPTARG in
subrata_modak2f6c9812009-08-14 17:07:48 +0000421 /*)
422 SKIPFILE=$OPTARG;;
423 *)
424 SKIPFILE="$LTPROOT/$OPTARG";;
yaberauneya6d41cc32010-01-28 16:24:16 +0000425 esac ;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700426
427 t) # In case you want to specify the time
428 # to run from the command line
plars4a120e82004-09-02 18:56:06 +0000429 # (2m = two minutes, 2h = two hours, etc)
430 DURATION="-t $OPTARG" ;;
subrata_modak8c138332008-01-28 11:19:32 +0000431
Cyril Hrubis5f795702016-04-26 14:45:57 +0200432 I) # In case you want the testcases to runsequentially RUN_REPEATED times
subrata_modak8c138332008-01-28 11:19:32 +0000433 RUN_REPEATED=$OPTARG;;
434
subrata_modakbc833d32007-07-25 10:12:02 +0000435 w) CMDFILEADDR=$OPTARG;;
Chris Dearman37550cf2012-10-17 19:54:01 -0700436
plars4a120e82004-09-02 18:56:06 +0000437 x) # number of ltp's to run
yaberauneya6d41cc32010-01-28 16:24:16 +0000438 cat <<-EOF >&1
439 WARNING: The use of -x can cause unpredictable failures, as a
440 result of concurrently running multiple tests designed
441 to be ran exclusively.
442 Pausing for 10 seconds..."
443 EOF
Chris Dearman37550cf2012-10-17 19:54:01 -0700444 sleep 10
yaberauneya6d41cc32010-01-28 16:24:16 +0000445 INSTANCES="-x $OPTARG";;
subrata_modakd9fb3862008-12-29 11:25:36 +0000446 b) DEVICE=$OPTARG;;
Xiaoguang Wang5b42a1e2013-12-12 19:10:58 +0800447 B) LTP_DEV_FS_TYPE=$OPTARG;;
448 z) BIG_DEVICE=$OPTARG;;
Xiaoguang Wangcb1a4ae2014-04-15 19:33:21 +0800449 Z) BIG_DEVICE_FS_TYPE=$OPTARG;;
plars4a120e82004-09-02 18:56:06 +0000450 \?) usage;;
451 esac
452 done
subrata_modak43938212008-05-19 08:48:46 +0000453
454 ## It would be nice to create a default log file even if the user has not mentioned
455 if [ ! "$LOGFILE" ]; then ## User has not mentioned about Log File name
look69f39f52014-04-30 09:55:44 +0800456 LOGFILE_NAME="$DEFAULT_FILE_NAME_GENERATION_TIME"
subrata_modak43938212008-05-19 08:48:46 +0000457 LOGFILE="-l $LTPROOT/results/LTP_RUN_ON-$LOGFILE_NAME.log"
458 ALT_DIR_RES=1
Petr Vorel82835202017-08-22 15:33:47 +0200459 PRETTY_PRT="-p"
subrata_modak43938212008-05-19 08:48:46 +0000460 fi
Chris Dearman37550cf2012-10-17 19:54:01 -0700461
462 ## 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 +0000463
yaberauneya6d41cc32010-01-28 16:24:16 +0000464 if [ ! "$FAILCMDFILE" ]; then ## User has not mentioned about Failed File name
subrata_modak5d7deea2007-09-15 13:51:36 +0000465 ALT_DIR_OUT=1
yaberauneya6d41cc32010-01-28 16:24:16 +0000466 if [ ! "$OUTPUTFILE" ]; then ## User has not mentioned about Output File name either
467 if [ ! "$LOGFILE" ]; then ## User has not mentioned about Log File name either
look69f39f52014-04-30 09:55:44 +0800468 FAILED_FILE_NAME="$DEFAULT_FILE_NAME_GENERATION_TIME"
yaberauneya6d41cc32010-01-28 16:24:16 +0000469 FAILCMDFILE="-C $LTPROOT/output/LTP_RUN_ON-$FAILED_FILE_NAME.failed"
470 else ## User Fortunately wanted a log file,
471 FAILED_FILE_NAME=`basename $LOGFILE_NAME` ## Extract log file name and use it to construct Failed file name
472 FAILCMDFILE="-C $LTPROOT/output/LTP_RUN_ON-$FAILED_FILE_NAME.failed"
subrata_modak6838ec32007-09-14 10:10:12 +0000473 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000474 else ## User Fortunately wanted a Output file
475 FAILED_FILE_NAME=`basename $OUTPUTFILE_NAME` ## Extract output file name and use it to construct Failed file name
476 FAILCMDFILE="-C $LTPROOT/output/LTP_RUN_ON-$FAILED_FILE_NAME.failed"
subrata_modak6838ec32007-09-14 10:10:12 +0000477 fi
478 fi
subrata_modaka1fd64b2007-04-11 11:24:49 +0000479
Xiaoguang Wang5f71cf92014-09-23 15:59:43 +0800480 if [ ! "$TCONFCMDFILE" ]; then
481 ALT_DIR_OUT=1
482 if [ ! "$OUTPUTFILE" ]; then
483 if [ ! "$LOGFILE" ]; then
484 TCONF_FILE_NAME="$DEFAULT_FILE_NAME_GENERATION_TIME"
485 TCONFCMDFILE="-T $LTPROOT/output/LTP_RUN_ON-${TCONF_FILE_NAME}.tconf"
486 else
487 TCONF_FILE_NAME=`basename $LOGFILE_NAME`
488 TCONFCMDFILE="-T $LTPROOT/output/LTP_RUN_ON-${TCONF_FILE_NAME}.tconf"
489 fi
490 else
491 TCONF_FILE_NAME=`basename $OUTPUTFILE_NAME`
492 TCONFCMDFILE="-T $LTPROOT/output/LTP_RUN_ON-${TCONF_FILE_NAME}.tconf"
493 fi
494 fi
495
subrata_modakd48c4d02008-01-23 12:59:40 +0000496 if [ "$ALT_HTML_OUT" -eq 1 ] ; then ## User wants the HTML version of the output
yaberauneya6d41cc32010-01-28 16:24:16 +0000497 QUIET_MODE="" ## Suppressing this guy as it will prevent generation of proper output
subrata_modakd48c4d02008-01-23 12:59:40 +0000498 ## which the HTML parser will require
yaberauneya6d41cc32010-01-28 16:24:16 +0000499 if [ ! "$OUTPUTFILE" ]; then ## User has not mentioned about the Outputfile name, then we need to definitely generate one
look69f39f52014-04-30 09:55:44 +0800500 OUTPUTFILE_NAME="$DEFAULT_FILE_NAME_GENERATION_TIME"
subrata_modake47fb352007-11-25 17:03:49 +0000501 OUTPUTFILE="-o $LTPROOT/output/LTP_RUN_ON-$OUTPUTFILE_NAME.output"
subrata_modak08dde6f2007-11-28 11:02:51 +0000502 ALT_DIR_OUT=1
yaberauneya6d41cc32010-01-28 16:24:16 +0000503 if [ ! "$HTMLFILE" ] ; then ## User has not mentioned HTML File name, We need to create one
504 HTMLFILE_NAME=`basename $OUTPUTFILE_NAME`
subrata_modake47fb352007-11-25 17:03:49 +0000505 HTMLFILE="$LTPROOT/output/$HTMLFILE_NAME.html"
506 fi
507 fi
508 fi
509
subrata_modak5d7deea2007-09-15 13:51:36 +0000510 # If we need, create the output directory
yaberauneya6d41cc32010-01-28 16:24:16 +0000511 [ "$ALT_DIR_OUT" -eq 1 ] && \
512 {
513 [ ! -d $LTPROOT/output ] && \
514 {
515 echo "INFO: creating $LTPROOT/output directory"
516 mkdir -p $LTPROOT/output || \
517 {
518 echo "ERROR: failed to create $LTPROOT/output"
519 exit 1
520 }
521 }
522 }
subrata_modak5d7deea2007-09-15 13:51:36 +0000523 # If we need, create the results directory
yaberauneya6d41cc32010-01-28 16:24:16 +0000524 [ "$ALT_DIR_RES" -eq 1 ] && \
525 {
526 echo "INFO: creating $LTPROOT/results directory"
527 [ ! -d $LTPROOT/results ] && \
528 {
529 mkdir -p $LTPROOT/results || \
530 {
531 echo "ERROR: failed to create $LTPROOT/results"
532 exit 1
533 }
534 }
535 }
subrata_modak5d7deea2007-09-15 13:51:36 +0000536
Chris Dearman37550cf2012-10-17 19:54:01 -0700537 # Added -m 777 for tests that call tst_tmpdir() and try to
subrata_modaka1fd64b2007-04-11 11:24:49 +0000538 # write to it as user nobody
yaberauneya6d41cc32010-01-28 16:24:16 +0000539 mkdir -m 777 -p $TMPBASE || \
540 {
541 echo "FATAL: Unable to make temporary directory $TMPBASE"
542 exit 1
543 }
subrata_modak5ee3e892008-10-21 13:17:56 +0000544 # use mktemp to create "safe" temporary directories
545 export TMPTEMPLATE="${TMPBASE}/ltp-XXXXXXXXXX"
yaberauneya6d41cc32010-01-28 16:24:16 +0000546 TMP=`mktemp -d $TMPTEMPLATE` || \
547 {
548 echo "FATAL: Unable to make temporary directory: $TMP"
549 exit 1
550 }
551 export TMP
subrata_modak225cfbe2009-06-23 14:01:26 +0000552 # To be invoked by tst_tmpdir()
553 # write to it as user nobody
554 export TMPDIR=$TMP
subrata_modak6edfbda2008-10-17 12:25:48 +0000555
yaberauneya6d41cc32010-01-28 16:24:16 +0000556 chmod 777 $TMP || \
557 {
558 echo "unable to chmod 777 $TMP ... aborting"
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800559 exit 1
yaberauneya6d41cc32010-01-28 16:24:16 +0000560 }
Chris Dearman37550cf2012-10-17 19:54:01 -0700561
yaberauneya6d41cc32010-01-28 16:24:16 +0000562 cd $TMP || \
563 {
564 echo "could not cd ${TMP} ... exiting"
565 exit 1
566 }
Chris Dearman37550cf2012-10-17 19:54:01 -0700567
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800568 [ -n "$INSTANCES" ] && \
yaberauneya6d41cc32010-01-28 16:24:16 +0000569 {
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800570 INSTANCES="$INSTANCES -O ${TMP}"
yaberauneya6d41cc32010-01-28 16:24:16 +0000571 }
Chris Dearman37550cf2012-10-17 19:54:01 -0700572
plars4a120e82004-09-02 18:56:06 +0000573 # If user does not provide a command file select a default set of testcases
574 # to execute.
Petr Vorelabfbb2d2018-09-03 12:17:08 +0200575 if [ -z "$CMDFILES" ] && [ -z "$CMDFILEADDR" ]; then
plars4a120e82004-09-02 18:56:06 +0000576
Petr Vorelabfbb2d2018-09-03 12:17:08 +0200577 SCENARIO_LISTS="$LTPROOT/scenario_groups/default"
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800578 if [ "$RUN_NETEST" -eq 1 ]; then
Sun Lianwenaeeccaf2018-09-04 08:58:09 +0800579 SCENARIO_LISTS="$LTPROOT/scenario_groups/network"
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800580 fi
plars4a120e82004-09-02 18:56:06 +0000581
Petr Vorelabfbb2d2018-09-03 12:17:08 +0200582 cat <<-EOF >&1
583INFO: no command files were provided. Executing following runtest scenario files:
584`cat $SCENARIO_LISTS | tr '\012' ' '`
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800585
Petr Vorelabfbb2d2018-09-03 12:17:08 +0200586EOF
587 cat_ok_sentinel=$TMP/cat_ok.$$
588 touch "$cat_ok_sentinel"
589 cat $SCENARIO_LISTS | while read scenfile; do
590 scenfile=${LTPROOT}/runtest/$scenfile
591 [ -f "$scenfile" ] || continue
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800592
Petr Vorelabfbb2d2018-09-03 12:17:08 +0200593 cat $scenfile >> "$TMP/alltests" || {
594 echo "FATAL: unable to append to command file"
595 rm -Rf "$TMP"
596 rm -f "$cat_ok_sentinel"
597 exit 1
598 }
599 done
600 rm -f "$cat_ok_sentinel"
subrata_modakbc833d32007-07-25 10:12:02 +0000601 fi
602
yaberauneya6d41cc32010-01-28 16:24:16 +0000603 [ -n "$CMDFILES" ] && \
604 {
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800605 for scenfile in `echo "$CMDFILES" | tr ',' ' '`
yaberauneya6d41cc32010-01-28 16:24:16 +0000606 do
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800607 [ -f "$scenfile" ] || scenfile="$LTPROOT/runtest/$scenfile"
608 cat "$scenfile" >> ${TMP}/alltests || \
yaberauneya6d41cc32010-01-28 16:24:16 +0000609 {
610 echo "FATAL: unable to create command file"
Garrett Coopercf86b8b2010-11-16 21:46:41 -0800611 rm -Rf "$TMP"
yaberauneya6d41cc32010-01-28 16:24:16 +0000612 exit 1
613 }
plars4a120e82004-09-02 18:56:06 +0000614 done
yaberauneya6d41cc32010-01-28 16:24:16 +0000615 }
Chris Dearman37550cf2012-10-17 19:54:01 -0700616
yaberauneya6d41cc32010-01-28 16:24:16 +0000617 [ -n "$CMDFILEADDR" ] && \
618 {
619 wget -q "${CMDFILEADDR}" -O ${TMP}/wgetcmdfile
620 if [ $? -ne 0 ]; then
621 echo "FATAL: error while getting the command file with wget (address $CMDFILEADDR)"
622 exit 1
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000623 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000624 cat "${TMP}/wgetcmdfile" >> ${TMP}/alltests || \
625 {
626 echo "FATAL: unable to create command file"
627 exit 1
628 }
629 }
yaberauneyad8f1f5d2010-01-28 15:46:58 +0000630
plars4a120e82004-09-02 18:56:06 +0000631 # The fsx-linux tests use the SCRATCHDEV environment variable as a location
Chris Dearman37550cf2012-10-17 19:54:01 -0700632 # that can be reformatted and run on. Set SCRATCHDEV if you want to run
plars4a120e82004-09-02 18:56:06 +0000633 # these tests. As a safeguard, this is disabled.
634 unset SCRATCHDEV
yaberauneya6d41cc32010-01-28 16:24:16 +0000635 [ -n "$SCRATCHDEV" ] && \
636 {
637 cat ${LTPROOT}/runtest/fsx >> ${TMP}/alltests ||
638 {
639 echo "FATAL: unable to create fsx-linux tests command file"
640 exit 1
641 }
642 }
subrata_modakbc833d32007-07-25 10:12:02 +0000643
644 # If enabled, execute only test cases that match the PATTERN
yaberauneya6d41cc32010-01-28 16:24:16 +0000645 if [ -n "$TAG_RESTRICT_STRING" ]
646 then
647 mv -f ${TMP}/alltests ${TMP}/alltests.orig
648 grep $TAG_RESTRICT_STRING ${TMP}/alltests.orig > ${TMP}/alltests #Not worth checking return codes for this case
subrata_modakbc833d32007-07-25 10:12:02 +0000649 fi
subrata_modak2f6c9812009-08-14 17:07:48 +0000650
651 # Blacklist or skip tests if a SKIPFILE was specified with -S
Naresh Kambojufe857cb2017-12-20 18:33:57 +0530652 if [ -n "${SKIPFILE}" ]; then
653 for test_name in $(awk '{print $1}' "${SKIPFILE}"); do
654 case "${test_name}" in \#*) continue;; esac
655 sed -i "/\<${test_name}\>/c\\${test_name} exit 32;" alltests
subrata_modak2f6c9812009-08-14 17:07:48 +0000656 done
657 fi
Chris Dearman37550cf2012-10-17 19:54:01 -0700658
plars4a120e82004-09-02 18:56:06 +0000659 # check for required users and groups
Cyril Hrubisb88fa5b2013-06-25 15:50:08 +0200660 ${LTPROOT}/IDcheck.sh || \
yaberauneya6d41cc32010-01-28 16:24:16 +0000661 {
662 echo "WARNING: required users and groups not present"
663 echo "WARNING: some test cases may fail"
664 }
Chris Dearman37550cf2012-10-17 19:54:01 -0700665
plars4a120e82004-09-02 18:56:06 +0000666 # display versions of installed software
yaberauneya6d41cc32010-01-28 16:24:16 +0000667 [ -z "$QUIET_MODE" ] && \
Chris Dearman37550cf2012-10-17 19:54:01 -0700668 {
yaberauneya6d41cc32010-01-28 16:24:16 +0000669 ${LTPROOT}/ver_linux || \
670 {
671 echo "WARNING: unable to display versions of software installed"
672 exit 1
673 }
674 }
675
Harald Weppner8bdf0a02014-03-03 14:10:07 -0800676 set_block_device
subrata_modakd9fb3862008-12-29 11:25:36 +0000677
Xiaoguang Wang5b42a1e2013-12-12 19:10:58 +0800678 # here even if the user don't specify a big block device, we
679 # also don't create the big block device.
680 if [ -z "$BIG_DEVICE" ]; then
681 echo "no big block device was specified on commandline."
682 echo "Tests which require a big block device are disabled."
683 echo "You can specify it with option -z"
684 else
Xiaoguang Wangcb1a4ae2014-04-15 19:33:21 +0800685 export LTP_BIG_DEV=$BIG_DEVICE
686 if [ -z "$BIG_DEVICE_FS_TYPE" ]; then
687 export LTP_BIG_DEV_FS_TYPE="ext2"
688 else
689 export LTP_BIG_DEV_FS_TYPE=$BIG_DEVICE_FS_TYPE
690 fi
subrata_modakd9fb3862008-12-29 11:25:36 +0000691 fi
692
subrata_modak8c138332008-01-28 11:19:32 +0000693 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 +0000694 echo "PAN will run these test cases $RUN_REPEATED times....."
695 echo "Test Tags will be Prepended with ITERATION NO.s....."
696 inc=1
697 sed -e '/^$/ d' -e 's/^[ ,\t]*//' -e '/^#/ d' < ${TMP}/alltests > ${TMP}/alltests.temp ##This removes all newlines, leading spaces, tabs, #
698 sed 's/^[0-9,a-z,A-Z]*/'"$inc"'_ITERATION_&/' < ${TMP}/alltests.temp > ${TMP}/alltests ## .temp is kept as Base file
699 while [ $inc -lt $RUN_REPEATED ] ; do
700 inc=`expr $inc + 1`
701 sed 's/^[0-9,a-z,A-Z]*/'"$inc"'_ITERATION_&/' < ${TMP}/alltests.temp >> ${TMP}/alltests #Keep appending with Iteration No.s
702 done
subrata_modak8c138332008-01-28 11:19:32 +0000703 fi
704
Zorro Lang8aa21022016-09-26 21:19:49 +0800705 if [ "$RANDOMRUN" != "0" ]; then
706 sort -R ${TMP}/alltests -o ${TMP}/alltests
707 fi
708
yaberauneya6d41cc32010-01-28 16:24:16 +0000709 [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test start time: $(date)" ; }
Petr Vorel82835202017-08-22 15:33:47 +0200710 PAN_COMMAND="${LTPROOT}/bin/ltp-pan $QUIET_MODE $NO_KMSG -e -S $INSTANCES $DURATION -a $$ \
Xiaoguang Wang5f71cf92014-09-23 15:59:43 +0800711 -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE $FAILCMDFILE $TCONFCMDFILE"
yaberauneya6d41cc32010-01-28 16:24:16 +0000712 echo "COMMAND: $PAN_COMMAND"
713 if [ ! -z "$TAG_RESTRICT_STRING" ] ; then
714 echo "INFO: Restricted to $TAG_RESTRICT_STRING"
robbiew7d43d772005-02-07 20:07:30 +0000715 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000716 #$PAN_COMMAND #Duplicated code here, because otherwise if we fail, only "PAN_COMMAND" gets output
Chris Dearman37550cf2012-10-17 19:54:01 -0700717
subrata_modak43938212008-05-19 08:48:46 +0000718 ## Display the Output/Log/Failed/HTML file names here
Anders Roxell4691f012013-09-03 09:42:35 +0200719 printf "LOG File: "
yaberauneya6d41cc32010-01-28 16:24:16 +0000720 echo $LOGFILE | cut -b4-
subrata_modak43938212008-05-19 08:48:46 +0000721
yaberauneya6d41cc32010-01-28 16:24:16 +0000722 if [ "$OUTPUTFILE" ]; then
Anders Roxell4691f012013-09-03 09:42:35 +0200723 printf "OUTPUT File: "
yaberauneya6d41cc32010-01-28 16:24:16 +0000724 echo $OUTPUTFILE | cut -b4-
subrata_modak43938212008-05-19 08:48:46 +0000725 fi
726
Anders Roxell4691f012013-09-03 09:42:35 +0200727 printf "FAILED COMMAND File: "
yaberauneya6d41cc32010-01-28 16:24:16 +0000728 echo $FAILCMDFILE | cut -b4-
729
Xiaoguang Wang5f71cf92014-09-23 15:59:43 +0800730 printf "TCONF COMMAND File: "
731 echo $TCONFCMDFILE | cut -b4-
732
yaberauneya6d41cc32010-01-28 16:24:16 +0000733 if [ "$HTMLFILE" ]; then
734 echo "HTML File: $HTMLFILE"
735 fi
736
737 echo "Running tests......."
subrata_modake47fb352007-11-25 17:03:49 +0000738 test_start_time=$(date)
subrata_modak724098e2009-03-19 08:49:18 +0000739
yaberauneya6d41cc32010-01-28 16:24:16 +0000740 # User wants testing with Kernel Fault Injection
741 if [ $INJECT_KERNEL_FAULT ] ; then
742 #See if Debugfs is mounted, and
743 #Fault Injection Framework available through Debugfs
Garrett Coopercb66da52012-04-03 22:09:42 -0700744 use_faultinjection=true
745 for debug_subdir in \
746 fail_io_timeout \
747 fail_make_request \
748 fail_page_alloc \
749 failslab \
750 ; do
751 if [ -d "/sys/kernel/debug/$debug_subdir" ]
752 then
753 use_faultinjection=true
754 break
755 fi
756 done
757 if $use_faultinjection; then
yaberauneya6d41cc32010-01-28 16:24:16 +0000758 #If atleast one of the Framework is available
759 #Go ahead to Inject Fault & Create required
760 #Command Files for LTP run
761 echo Running tests with Fault Injection Enabled in the Kernel...
Garrett Coopercb66da52012-04-03 22:09:42 -0700762 awk -v LOOPS=$INJECT_FAULT_LOOPS_PER_TEST \
763 -v PERCENTAGE=$INJECT_KERNEL_FAULT_PERCENTAGE \
764 -f ${LTPROOT}/bin/create_kernel_faults_in_loops_and_probability.awk \
765 ${TMP}/alltests > ${TMP}/alltests.tmp
yaberauneya6d41cc32010-01-28 16:24:16 +0000766 cp ${TMP}/alltests.tmp ${TMP}/alltests
767 rm -rf ${TMP}/alltests.tmp
768 else
769 echo Fault Injection not enabled in the Kernel..
770 echo Running tests normally...
771 fi
772 fi
773
774 ## Valgrind Check will work only when Kernel Fault Injection is not expected,
775 ## We do not want to test Faults when valgrind is running
776 if [ $VALGRIND_CHECK ]; then
777 if [ ! $INJECT_KERNEL_FAULT ]; then
778 which valgrind || VALGRIND_CHECK_TYPE=XYZ
779 case $VALGRIND_CHECK_TYPE in
Garrett Cooper3920fd12012-04-03 19:47:16 -0700780 [1-3])
781 awk -v CHECK_LEVEL=$VALGRIND_CHECK_TYPE \
782 -f ${LTPROOT}/bin/create_valgrind_check.awk \
783 ${TMP}/alltests $VALGRIND_CHECK_TYPE > \
784 ${TMP}/alltests.tmp
yaberauneya6d41cc32010-01-28 16:24:16 +0000785 cp ${TMP}/alltests.tmp ${TMP}/alltests
Garrett Cooper3920fd12012-04-03 19:47:16 -0700786 rm -rf ${TMP}/alltests.tmp
787 ;;
788 *)
789 echo "Invalid Memory Check Type, or, Valgrind is not available"
790 ;;
yaberauneya6d41cc32010-01-28 16:24:16 +0000791 esac
792 fi
793 fi
794
Subrata Modakbd9d4402010-05-12 22:03:21 +0530795 if [ $ALT_DMESG_OUT -eq 1 ] ; then
796 #We want to print dmesg output for each test,lets do the trick inside the script
797 echo Enabling dmesg output logging for each test...
Garrett Cooper66030122012-04-03 20:22:14 -0700798 awk -v DMESG_DIR=$DMESG_DIR \
799 -f ${LTPROOT}/bin/create_dmesg_entries_for_each_test.awk \
800 ${TMP}/alltests > ${TMP}/alltests.tmp
Subrata Modakbd9d4402010-05-12 22:03:21 +0530801 cp ${TMP}/alltests.tmp ${TMP}/alltests
802 rm -rf ${TMP}/alltests.tmp
803 fi
subrata_modak724098e2009-03-19 08:49:18 +0000804 # Some tests need to run inside the "bin" directory.
805 cd "${LTPROOT}/testcases/bin"
Petr Vorel82835202017-08-22 15:33:47 +0200806 "${LTPROOT}/bin/ltp-pan" $QUIET_MODE $NO_KMSG -e -S $INSTANCES $DURATION -a $$ -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE $FAILCMDFILE $TCONFCMDFILE
Chris Dearman37550cf2012-10-17 19:54:01 -0700807
plars4a120e82004-09-02 18:56:06 +0000808 if [ $? -eq 0 ]; then
yaberauneya6d41cc32010-01-28 16:24:16 +0000809 echo "INFO: ltp-pan reported all tests PASS"
810 VALUE=0
811 export LTP_EXIT_VALUE=0;
plars4a120e82004-09-02 18:56:06 +0000812 else
yaberauneya6d41cc32010-01-28 16:24:16 +0000813 echo "INFO: ltp-pan reported some tests FAIL"
814 VALUE=1
815 export LTP_EXIT_VALUE=1;
plars4a120e82004-09-02 18:56:06 +0000816 fi
subrata_modak724098e2009-03-19 08:49:18 +0000817 cd ..
yaberauneya6d41cc32010-01-28 16:24:16 +0000818 echo "LTP Version: $version_date"
mreed1091696422006-05-03 19:07:22 +0000819
Subrata Modake3bc3752010-07-03 23:32:27 +0530820 # $DMESG_DIR is used to cache messages obtained from dmesg after a test run.
821 # Proactively reap all of the 0-byte files in $DMESG_DIR as they have zero value
822 # and only clutter up the filesystem.
823
824 if [ $ALT_DMESG_OUT -eq 1 ] ; then
825 if ! find "$DMESG_DIR" -size 0 -exec rm {} + ; then
826 echo "cd to $DMESG_DIR failed: $?"
827 fi
828 if [ -n "$(ls "$DMESG_DIR")" ] ; then
829 echo "Kernel messages were generated for LTP tests $version_date"
830 else
831 echo "No Kernel messages were generated for LTP tests $version_date"
832 fi
833 fi
834
subrata_modake47fb352007-11-25 17:03:49 +0000835 if [ "$ALT_HTML_OUT" -eq 1 ] ; then #User wants the HTML output to be created, it then needs to be generated
836 export LTP_VERSION=$version_date
Jungsu Sohn0b08cf12016-10-26 15:29:41 -0700837 export TEST_START_TIME="$test_start_time"
838 export TEST_END_TIME="$(date)"
yaberauneya6d41cc32010-01-28 16:24:16 +0000839 OUTPUT_DIRECTORY=`echo $OUTPUTFILE | cut -c4-`
subrata_modake47fb352007-11-25 17:03:49 +0000840 LOGS_DIRECTORY="$LTPROOT/results"
841 export TEST_OUTPUT_DIRECTORY="$LTPROOT/output"
842 export TEST_LOGS_DIRECTORY=$LOGS_DIRECTORY
yaberauneya6d41cc32010-01-28 16:24:16 +0000843 echo "Generating HTML Output.....!!"
Chris Dearman37550cf2012-10-17 19:54:01 -0700844 ( 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 +0000845 echo "Generated HTML Output.....!!"
846 echo "Location: $HTMLFILE";
847
subrata_modake47fb352007-11-25 17:03:49 +0000848 fi
Chris Dearman37550cf2012-10-17 19:54:01 -0700849
Yixin Zhang0540c482018-07-26 16:34:26 +0800850 if [ "$ALT_EMAIL_OUT" -eq 1 ] ; then ## User wants reports to be e-mailed
851 TAR_FILE_NAME=LTP_RUN_$version_date$DEFAULT_FILE_NAME_GENERATION_TIME.tar
852 if [ "$HTMLFILE_NAME" ] ; then ## HTML file Exists
853 if [ "$ALT_HTML_OUT" -ne 1 ] ; then ## The HTML file path is absolute and not $LTPROOT/output
854 mkdir -p $LTPROOT/output ## We need to create this Directory
855 cp $HTMLFILE_NAME $LTPROOT/output/
856 fi
857 fi
858 if [ "$OUTPUTFILE_NAME" ] ; then ## Output file exists
859 if [ "$ALT_DIR_OUT" -ne 1 ] ; then ## The Output file path is absolute and not $LTPROOT/output
860 mkdir -p $LTPROOT/output ## We need to create this Directory
861 cp $OUTPUTFILE_NAME $LTPROOT/output/
862 fi
863 fi
864 if [ "$LOGFILE_NAME" ] ; then ## Log file exists
865 if [ "$ALT_DIR_RES" -ne 1 ] ; then ## The Log file path is absolute and not $LTPROOT/results
866 mkdir -p $LTPROOT/results ## We need to create this Directory
867 cp $LOGFILE_NAME $LTPROOT/results/
868 fi
869 fi
870 if [ -d $LTPROOT/output ] ; then
871 tar -cf ./$TAR_FILE_NAME $LTPROOT/output
872 if [ $? -eq 0 ]; then
873 echo "Created TAR File: ./$TAR_FILE_NAME successfully, added $LTPROOT/output"
874 else
875 echo "Cannot Create TAR File: ./$TAR_FILE_NAME for adding $LTPROOT/output"
876 fi
877 fi
878 if [ -d $LTPROOT/results ] ; then
879 tar -uf ./$TAR_FILE_NAME $LTPROOT/results
880 if [ $? -eq 0 ]; then
881 echo "Updated TAR File: ./$TAR_FILE_NAME successfully, added $LTPROOT/results"
882 else
883 echo "Cannot Update TAR File: ./$TAR_FILE_NAME for adding $LTPROOT/results"
884 fi
885 fi
886 if [ -e $LTPROOT/nohup.out ] ; then ## If User would have Chosen nohup to do ltprun
887 tar -uf ./$TAR_FILE_NAME $LTPROOT/nohup.out
888 if [ $? -eq 0 ]; then
889 echo "Updated TAR File: ./$TAR_FILE_NAME successfully, added $LTPROOT/nohup.out"
890 else
891 echo "Cannot Update TAR File: ./$TAR_FILE_NAME for adding $LTPROOT/nohup.out"
892 fi
893 fi
894 gzip ./$TAR_FILE_NAME ## gzip this guy
895 if [ $? -eq 0 ]; then
896 echo "Gunzipped TAR File: ./$TAR_FILE_NAME"
897 else
898 echo "Cannot Gunzip TAR File: ./$TAR_FILE_NAME"
899 fi
900 if which mutt >/dev/null 2>&1; then
901 echo "Starting mailing reports to: $EMAIL_TO, file: ./$TAR_FILE_NAME.gz"
902 mutt -a ./$TAR_FILE_NAME.gz -s "LTP Reports on $test_start_time" -- $EMAIL_TO < /dev/null
903 if [ $? -eq 0 ]; then
904 echo "Reports Successfully mailed to: $EMAIL_TO"
905 else
906 echo "Reports cannot be mailed to: $EMAIL_TO"
907 fi
908 else ## Use our Ageold mail program
909 echo "Starting mailing reports to: $EMAIL_TO, file: ./$TAR_FILE_NAME.gz"
910 uuencode ./$TAR_FILE_NAME.gz $TAR_FILE_NAME.gz | mail $EMAIL_TO -s "LTP Reports on $test_start_time"
911 if [ $? -eq 0 ]; then
912 echo "Reports Successfully mailed to: $EMAIL_TO"
913 else
914 echo "Reports cannot be mailed to: $EMAIL_TO"
915 fi
916 fi
yaberauneya6d41cc32010-01-28 16:24:16 +0000917 fi
Chris Dearman37550cf2012-10-17 19:54:01 -0700918
yaberauneya6d41cc32010-01-28 16:24:16 +0000919 [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test end time: $(date)" ; }
Chris Dearman37550cf2012-10-17 19:54:01 -0700920
yaberauneya6d41cc32010-01-28 16:24:16 +0000921 [ "$GENLOAD" -eq 1 ] && { killall -9 genload >/dev/null 2>&1; }
922 [ "$NETPIPE" -eq 1 ] && { killall -9 NPtcp >/dev/null 2>&1; }
Chris Dearman37550cf2012-10-17 19:54:01 -0700923
yaberauneya6d41cc32010-01-28 16:24:16 +0000924 [ "$ALT_DIR_OUT" -eq 1 ] || [ "$ALT_DIR_RES" -eq 1 ] && \
925 {
926 cat <<-EOF >&1
Chris Dearman37550cf2012-10-17 19:54:01 -0700927
Markos Chandras11328662012-03-06 10:28:59 +0000928 ###############################################################
Chris Dearman37550cf2012-10-17 19:54:01 -0700929
Markos Chandras11328662012-03-06 10:28:59 +0000930 Done executing testcases.
mreed1091696422006-05-03 19:07:22 +0000931 LTP Version: $version_date
Markos Chandras11328662012-03-06 10:28:59 +0000932 ###############################################################
Chris Dearman37550cf2012-10-17 19:54:01 -0700933
yaberauneya6d41cc32010-01-28 16:24:16 +0000934 EOF
935 }
936 exit $VALUE
plars4a120e82004-09-02 18:56:06 +0000937}
938
Ramesh YR0a78f232013-04-16 09:31:28 +0800939create_block()
940{
DAN LI189c4412013-09-10 10:53:34 +0800941 #create a block device
Cyril Hrubis7eb77fb2017-02-08 12:01:47 +0100942 dd if=/dev/zero of=${TMP}/test.img bs=1024 count=262144 >/dev/null 2>&1
Ramesh YR0a78f232013-04-16 09:31:28 +0800943 if [ $? -ne 0 ]; then
944 echo "Failed to create loopback device image, please check disk space and re-run"
945 return 1
946 else
947 ##search for an unused loop dev
948 LOOP_DEV=$(losetup -f)
949 if [ $? -ne 0 ]; then
950 echo "no unused loop device is found"
951 return 1
952 else
953 ##attach the created file to loop dev.
Cyril Hrubisb88fa5b2013-06-25 15:50:08 +0200954 losetup $LOOP_DEV ${TMP}/test.img
Ramesh YR0a78f232013-04-16 09:31:28 +0800955 if [ $? -ne 0 ]; then
956 echo "losetup failed to create block device"
957 return 1
Ramesh YR0a78f232013-04-16 09:31:28 +0800958 fi
Cyril Hrubisc381f582013-08-08 18:19:35 +0200959 DEVICE=$LOOP_DEV
960 return 0
Ramesh YR0a78f232013-04-16 09:31:28 +0800961 fi
962 fi
963}
964
Harald Weppner8bdf0a02014-03-03 14:10:07 -0800965set_block_device()
966{
967 if [ -z "$DEVICE" ]; then
968 create_block
969 if [ $? -ne 0 ]; then
970 echo "no block device was specified on commandline."
971 echo "Block device could not be created using loopback device"
972 echo "Tests which require block device are disabled."
973 echo "You can specify it with option -b"
974 else
Jan Stancek977bdf22015-01-20 14:35:49 +0100975 export LTP_DEV=$DEVICE
Harald Weppner8bdf0a02014-03-03 14:10:07 -0800976 fi
977 else
Jan Stancek977bdf22015-01-20 14:35:49 +0100978 export LTP_DEV=$DEVICE
Harald Weppner8bdf0a02014-03-03 14:10:07 -0800979 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
Harald Weppner8bdf0a02014-03-03 14:10:07 -0800988
989LTP_SCRIPT="$(basename $0)"
990
Cyril Hrubise8776ea2014-03-24 13:32:01 +0100991if [ "$LTP_SCRIPT" = "runltp" ]; then
Harald Weppner8bdf0a02014-03-03 14:10:07 -0800992 trap "cleanup" 0
993 setup
994 main "$@"
995fi