-
Notifications
You must be signed in to change notification settings - Fork 1
/
runltplite.sh
executable file
·361 lines (304 loc) · 10.5 KB
/
runltplite.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
#!/bin/sh
################################################################################
## ##
## Copyright (c) International Business Machines Corp., 2001,2005 ##
## ##
## This program is free software; you can redistribute it and#or modify ##
## it under the terms of the GNU General Public License as published by ##
## the Free Software Foundation; either version 2 of the License, or ##
## (at your option) any later version. ##
## ##
## This program is distributed in the hope that it will be useful, but ##
## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ##
## for more details. ##
## ##
## You should have received a copy of the GNU General Public License ##
## along with this program; if not, write to the Free Software ##
## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ##
## ##
################################################################################
# File: runltplite
#
# Description: This script can be used to run a subset the tests in the LTP test suite
# This script is typically used as a quick test to check an install base.
#
# Authors: Manoj Iyer - [email protected]
# Robbie Williamson - [email protected]
# Marty Ridgeway - [email protected]
#
# History: Created runltplite script to run a subset of the LTP testsuite
#
#
#
#
#
#
#
#
setup()
{
cd `dirname $0` || \
{
echo "FATAL: unable to change directory to $(dirname $0)"
exit 1
}
export LTPROOT=${PWD}
export TMPBASE="/tmp"
export TMP="${TMPBASE}/ltp-$$"
export PATH="${PATH}:${LTPROOT}/testcases/bin"
[ -d $LTPROOT/testcases/bin ] ||
{
echo "FATAL: LTP not installed correctly"
echo "INFO: Follow directions in INSTALL!"
exit 1
}
[ -e $LTPROOT/bin/ltp-pan ] ||
{
echo "FATAL: Test suite driver 'ltp-pan' not found"
echo "INFO: Follow directions in INSTALL!"
exit 1
}
}
usage()
{
cat <<-EOF >&2
usage: ${0##*/} -c [-d TMPDIR] [-i # (in Mb)]
[ -l LOGFILE ] [ -o OUTPUTFILE ] [ -m # (in Mb)] -N -q
[ -r LTPROOT ] -v
-c NUM_PROCS Run LTP under additional background CPU load.
-d TMPDIR Directory where temporary files will be created.
-h Help. Prints all available options.
-i # (in Mb) Run LTP with a _min_ IO load of # Mb in background.
-l LOGFILE Log results of test in a logfile.
-m # (in Mb) Run LTP with a _min_ memory load of # Mb in background.
-N Run all the networking tests.
-o OUTPUTFILE Redirect test output to a file.
-p Human readable format logfiles.
-q Print less verbose output to screen.
-r LTPROOT Fully qualified path where testsuite is installed.
example: ${0##*/} -i 1024 -m 128 -p -q -l /tmp/resultlog.$$ -d ${PWD}
EOF
exit 0
}
main()
{
local CMDFILE="ltplite"
local PRETTY_PRT=""
local ALT_DIR=0
local RUN_NETEST=0
local QUIET_MODE=""
local VERBOSE_MODE=""
local NETPIPE=0
local GENLOAD=0
local MEMSIZE=0
local DURATION=""
local BYTESIZE=0
local LOGFILE=""
local PRETTY_PRT=""
local TAG_RESTRICT_STRING=""
local PAN_COMMAND=""
local scenfile=""
while getopts c:d:hi:l:m:No:pqr: arg
do case $arg in
c)
NUM_PROCS=$(($OPTARG))
$LTPROOT/testcases/bin/genload --cpu $NUM_PROCS >/dev/null 2>&1 &
GENLOAD=1 ;;
d) # append $$ to TMP, as it is recursively
# removed at end of script.
TMPBASE=$OPTARG
TMP="${TMPBASE}/ltp-$$"
export TMPDIR="$TMP";;
h) usage;;
i)
BYTESIZE=$(($OPTARG * 1024 * 1024))
$LTPROOT/testcases/bin/genload --io 1 >/dev/null 2>&1 &
$LTPROOT/testcases/bin/genload --hdd 0 --hdd-bytes $BYTESIZE \
>/dev/null 2>&1 &
GENLOAD=1 ;;
l)
[ ! -d $LTPROOT/results ] && \
{
echo "INFO: creating $LTPROOT/results directory"
mkdir -p $LTPROOT/results || \
{
echo "ERROR: failed to create $LTPROOT/results"
exit 1
}
}
case $OPTARG in
/*)
LOGFILE="-l $OPTARG" ;;
*)
LOGFILE="-l $LTPROOT/results/$OPTARG"
ALT_DIR=1 ;;
esac ;;
m)
MEMSIZE=$(($OPTARG * 1024 * 1024))
$LTPROOT/testcases/bin/genload --vm 0 --vm-bytes $MEMSIZE \
>/dev/null 2>&1 &
GENLOAD=1;;
N) RUN_NETEST=1;;
o) OUTPUTFILE="-o $OPTARG" ;;
p) PRETTY_PRT=" -p ";;
q) QUIET_MODE=" -q ";;
r) LTPROOT=$OPTARG;;
\?) usage;;
esac
done
mkdir -p $TMP || \
{
echo "FATAL: Unable to make temporary directory $TMP"
exit 1
}
cd $TMP || \
{
echo "could not cd ${TMP} ... exiting"
exit 1
}
# Run Networking tests ?
[ "$RUN_NETEST" -eq 1 ] && \
{
[ -z "$RHOST" ] || [ -z "$PASSWD" ] && \
{
[ -z "$RHOST" ] && \
{
echo \
"INFO: Enter RHOST = 'name of the remote host machine'"
echo -n "-> "
read RHOST
}
[ -z "$PASSWD" ] && \
{
echo " "
echo \
"INFO: Enter PASSWD = 'root passwd of the remote host machine'"
echo -n "-> "
read PASSWD
}
export RHOST=$RHOST
export PASSWD=$PASSWD
echo "WARNING: security of $RHOST may be compromised"
}
}
# If user does not provide a command file select a default set of testcases
# to execute.
if [ -f $CMDFILE ] || \
CMDFILE="$LTPROOT/runtest/$CMDFILE"
then
cat $CMDFILE > ${TMP}/alltests || \
{
echo "FATAL: Unable to create command file"
exit 1
}
fi
if [ "$RUN_NETEST" -eq 1 ]; then
SCENARIO_LISTS="$SCENARIO_LISTS $LTPROOT/scenario_groups/network"
fi
# DO NOT INDENT/DEDENT!
if [ -n "$SCENARIO_LISTS" ]; then
# Insurance to make sure that the first element in the pipe
# completed successfully.
cat_ok_sentinel=$TMP/cat_ok.$$
(cat $SCENARIO_LISTS && touch "$cat_ok_sentinel") | \
while read scenfile; do
scenfile=${LTPROOT}/runtest/$scenfile
# Skip over non-existent scenario files; things are
# robust enough now that the build will fail if these
# files don't exist.
[ -f "$scenfile" ] || continue
cat $scenfile >> "$TMP/alltests" || {
echo "FATAL: unable to append to command file"
rm -Rf "$TMP"
rm -f "$cat_ok_sentinel"
exit 1
}
done
rm -f "$cat_ok_sentinel"
fi
# ^^DO NOT INDENT/DEDENT!^^
# The fsx-linux tests use the SCRATCHDEV environment variable as a location
# that can be reformatted and run on. Set SCRATCHDEV if you want to run
# these tests. As a safeguard, this is disabled.
unset SCRATCHDEV
[ -n "$SCRATCHDEV" ] && \
{
cat ${LTPROOT}/runtest/fsx >> ${TMP}/alltests ||
{
echo "FATAL: unable to create fsx-linux tests command file"
exit 1
}
}
# check for required users and groups
${LTPROOT}/IDcheck.sh &>/dev/null || \
{
echo "WARNING: required users and groups not present"
echo "WARNING: some test cases may fail"
}
[ -n "$CMDFILES" ] && \
{
for scenfile in `echo "$CMDFILES" | tr ',' ' '`
do
[ -f "$scenfile" ] || scenfile="$LTPROOT/runtest/$scenfile"
cat "$scenfile" >> ${TMP}/alltests || \
{
echo "FATAL: unable to create command file"
rm -Rf "$TMP"
exit 1
}
done
}
# display versions of installed software
[ -z "$QUIET_MODE" ] && \
{
${LTPROOT}/ver_linux || \
{
echo "WARNING: unable to display versions of software installed"
exit 1
}
}
[ ! -z "$QUIET_MODE" ] && { echo "INFO: Test start time: $(date)" ; }
PAN_COMMAND="${LTPROOT}/bin/ltp-pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ \
-n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE"
if [ ! -z "$VERBOSE_MODE" ] ; then
echo "COMMAND: $PAN_COMMAND"
if [ ! -z "$TAG_RESTRICT_STRING" ] ; then
echo "INFO: Restricted to $TAG_RESTRICT_STRING"
fi
fi
#$PAN_COMMAND #Duplicated code here, because otherwise if we fail, only "PAN_COMMAND" gets output
# Some tests need to run inside the "bin" directory.
cd "${LTPROOT}/testcases/bin"
${LTPROOT}/bin/ltp-pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ \
-n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE
if [ $? -eq 0 ]; then
echo "INFO: ltp-pan reported all tests PASS"
VALUE=0
else
echo "INFO: ltp-pan reported some tests FAIL"
VALUE=1
fi
cd ..
[ ! -z "$QUIET_MODE" ] && { echo "INFO: Test end time: $(date)" ; }
[ "$GENLOAD" -eq 1 ] && { killall -9 genload ; }
[ "$NETPIPE" -eq 1 ] && { killall -9 NPtcp ; }
[ "$ALT_DIR" -eq 1 ] && \
{
cat <<-EOF >&1
###############################################################"
Done executing testcases."
result log is in the $LTPROOT/results directory"
###############################################################"
EOF
}
exit $VALUE
}
cleanup()
{
rm -rf ${TMP}
}
trap "cleanup" 0
setup
main "$@"
#vim: syntax=sh