1f08c3bdfSopenharmony_ci#!/bin/sh
2f08c3bdfSopenharmony_ci################################################################################
3f08c3bdfSopenharmony_ci##                                                                            ##
4f08c3bdfSopenharmony_ci## Copyright (c) International Business Machines  Corp., 2001                 ##
5f08c3bdfSopenharmony_ci##                                                                            ##
6f08c3bdfSopenharmony_ci## This program is free software;  you can redistribute it and#or modify      ##
7f08c3bdfSopenharmony_ci## it under the terms of the GNU General Public License as published by       ##
8f08c3bdfSopenharmony_ci## the Free Software Foundation; either version 2 of the License, or          ##
9f08c3bdfSopenharmony_ci## (at your option) any later version.                                        ##
10f08c3bdfSopenharmony_ci##                                                                            ##
11f08c3bdfSopenharmony_ci## This program is distributed in the hope that it will be useful, but        ##
12f08c3bdfSopenharmony_ci## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
13f08c3bdfSopenharmony_ci## or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License   ##
14f08c3bdfSopenharmony_ci## for more details.                                                          ##
15f08c3bdfSopenharmony_ci##                                                                            ##
16f08c3bdfSopenharmony_ci## You should have received a copy of the GNU General Public License          ##
17f08c3bdfSopenharmony_ci## along with this program;  if not, write to the Free Software               ##
18f08c3bdfSopenharmony_ci## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    ##
19f08c3bdfSopenharmony_ci##                                                                            ##
20f08c3bdfSopenharmony_ci################################################################################
21f08c3bdfSopenharmony_ci# File: runltp
22f08c3bdfSopenharmony_ci#
23f08c3bdfSopenharmony_ci# Description:  This script can be used to the tests in the LTP test suite
24f08c3bdfSopenharmony_ci#
25f08c3bdfSopenharmony_ci# Authors:      Manoj Iyer - manjo@mail.utexas.edu
26f08c3bdfSopenharmony_ci#               Robbe Williamson - robbiew@us.ibm.com
27f08c3bdfSopenharmony_ci#
28f08c3bdfSopenharmony_ci# History:      Oct 07 2003 - Modified - Manoj Iyer
29f08c3bdfSopenharmony_ci#               - use functions
30f08c3bdfSopenharmony_ci#               - clean up on script exit
31f08c3bdfSopenharmony_ci#               - error checking etc.
32f08c3bdfSopenharmony_ci#
33f08c3bdfSopenharmony_ci#               Oct 08 2003 - Modified - Manoj Iyer
34f08c3bdfSopenharmony_ci#               - fixed bug in creating results directory
35f08c3bdfSopenharmony_ci#               - all checks should be enlclosed in " " to avoid bash error
36f08c3bdfSopenharmony_ci#               - exit with error if ltp-pan is not found in pan directory
37f08c3bdfSopenharmony_ci#
38f08c3bdfSopenharmony_ci#               Jul 22 2007 - Modified - Ricardo Salveti de Araujo
39f08c3bdfSopenharmony_ci#               - added support to put more then one file at CMDLINE (-f)
40f08c3bdfSopenharmony_ci#               - added a new option, that the user can pass the address of
41f08c3bdfSopenharmony_ci#               the command file, and it'll use wget to get it (-w)
42f08c3bdfSopenharmony_ci#               - now -s does the grep at the selected command files (default,
43f08c3bdfSopenharmony_ci#               -f or -w)
44f08c3bdfSopenharmony_ci#
45f08c3bdfSopenharmony_ci#               Jul 23 2007 - Modified - Ricardo Salveti de Araujo
46f08c3bdfSopenharmony_ci#               - added flag to get the command file that has all failed tests
47f08c3bdfSopenharmony_ci#
48f08c3bdfSopenharmony_ci#               Sep 11 2007 - Modified - Subrata Modak
49f08c3bdfSopenharmony_ci#               - added option to create Failed File if it is not an absolute path
50f08c3bdfSopenharmony_ci#               - added option to create Output File if it is not an absolute path
51f08c3bdfSopenharmony_ci#               - added option to create Failed File compulsory, even if user has not mentioned it
52f08c3bdfSopenharmony_ci#
53f08c3bdfSopenharmony_ci#               Sep 14 2007 - Modified - Ricardo Salveti de Araujo
54f08c3bdfSopenharmony_ci#               - cleaning and removing duplicated code
55f08c3bdfSopenharmony_ci#
56f08c3bdfSopenharmony_ci#               Oct 27 2007 - Modified - Ricardo Salveti de Araujo and Subrata Modak
57f08c3bdfSopenharmony_ci#               - better ways to integrate "ltp/tools/genload/stress" with "ltp/runltp"
58f08c3bdfSopenharmony_ci#               Nov 24 2007 - Modified - Subrata Modak
59f08c3bdfSopenharmony_ci#               - Added a new option to generate output in HTML format also. Also retaining
60f08c3bdfSopenharmony_ci#                 the original test format
61f08c3bdfSopenharmony_ci#               Nov 28 2007 - Modified - Subrata Modak
62f08c3bdfSopenharmony_ci#               - Added a new option to mail back LTP reports
63f08c3bdfSopenharmony_ci#               May 19 2008 - Modified - Subrata Modak
64f08c3bdfSopenharmony_ci#               - Added capability for default Log file generation
65f08c3bdfSopenharmony_ci#		Aug 17 2009 - Modified - Subrata Modak
66f08c3bdfSopenharmony_ci#		- Added Fault Injection generation Capability through -F Option
67f08c3bdfSopenharmony_ci#
68f08c3bdfSopenharmony_ci#################################################################################
69f08c3bdfSopenharmony_ci
70f08c3bdfSopenharmony_ci
71f08c3bdfSopenharmony_ci
72f08c3bdfSopenharmony_cisetup()
73f08c3bdfSopenharmony_ci{
74f08c3bdfSopenharmony_ci    cd `dirname $0` || \
75f08c3bdfSopenharmony_ci    {
76f08c3bdfSopenharmony_ci        echo "FATAL: unable to change directory to $(dirname $0)"
77f08c3bdfSopenharmony_ci        exit 1
78f08c3bdfSopenharmony_ci    }
79f08c3bdfSopenharmony_ci    export LTPROOT=${PWD}
80f08c3bdfSopenharmony_ci    export TMPBASE="/tmp"
81f08c3bdfSopenharmony_ci    export PATH="${PATH}:${LTPROOT}/testcases/bin:${LTPROOT}/bin"
82f08c3bdfSopenharmony_ci
83f08c3bdfSopenharmony_ci    export LTP_DEV_FS_TYPE="ext2"
84f08c3bdfSopenharmony_ci
85f08c3bdfSopenharmony_ci    [ -d "$LTPROOT/testcases/bin" ] ||
86f08c3bdfSopenharmony_ci    {
87f08c3bdfSopenharmony_ci        echo "FATAL: LTP not installed correctly"
88f08c3bdfSopenharmony_ci        echo "INFO:  Follow directions in INSTALL!"
89f08c3bdfSopenharmony_ci        exit 1
90f08c3bdfSopenharmony_ci    }
91f08c3bdfSopenharmony_ci
92f08c3bdfSopenharmony_ci    [ -e "$LTPROOT/bin/ltp-pan" ] ||
93f08c3bdfSopenharmony_ci    {
94f08c3bdfSopenharmony_ci        echo "FATAL: Test suite driver 'ltp-pan' not found"
95f08c3bdfSopenharmony_ci        echo "INFO:  Follow directions in INSTALL!"
96f08c3bdfSopenharmony_ci        exit 1
97f08c3bdfSopenharmony_ci    }
98f08c3bdfSopenharmony_ci}
99f08c3bdfSopenharmony_ci
100f08c3bdfSopenharmony_civersion_of_ltp()
101f08c3bdfSopenharmony_ci{
102f08c3bdfSopenharmony_ci    cat "$LTPROOT/Version"
103f08c3bdfSopenharmony_ci    exit 0
104f08c3bdfSopenharmony_ci}
105f08c3bdfSopenharmony_ci
106f08c3bdfSopenharmony_ciusage()
107f08c3bdfSopenharmony_ci{
108f08c3bdfSopenharmony_ci    cat <<-EOF >&2
109f08c3bdfSopenharmony_ci
110f08c3bdfSopenharmony_ci    usage: ${0##*/} [ -a EMAIL_TO ] [ -c NUM_PROCS ] [ -C FAILCMDFILE ] [ -T TCONFCMDFILE ]
111f08c3bdfSopenharmony_ci    [ -d TMPDIR ] [ -D NUM_PROCS,NUM_FILES,NUM_BYTES,CLEAN_FLAG ] -e [ -f CMDFILES(,...) ]
112f08c3bdfSopenharmony_ci    [ -g HTMLFILE] [ -i NUM_PROCS ] [ -l LOGFILE ] [ -m NUM_PROCS,CHUNKS,BYTES,HANGUP_FLAG ]
113f08c3bdfSopenharmony_ci    -N -n [ -o OUTPUTFILE ] -p -q -Q [ -r LTPROOT ] [ -s PATTERN ] [ -t DURATION ]
114f08c3bdfSopenharmony_ci    -v [ -w CMDFILEADDR ] [ -x INSTANCES ] [ -b DEVICE ] [-B LTP_DEV_FS_TYPE]
115f08c3bdfSopenharmony_ci	[ -F LOOPS,PERCENTAGE ] [ -z BIG_DEVICE ] [-Z  LTP_BIG_DEV_FS_TYPE]
116f08c3bdfSopenharmony_ci
117f08c3bdfSopenharmony_ci    -a EMAIL_TO     EMAIL all your Reports to this E-mail Address
118f08c3bdfSopenharmony_ci    -c NUM_PROCS    Run LTP under additional background CPU load
119f08c3bdfSopenharmony_ci                    [NUM_PROCS = no. of processes creating the CPU Load by spinning over sqrt()
120f08c3bdfSopenharmony_ci                                 (Defaults to 1 when value)]
121f08c3bdfSopenharmony_ci    -C FAILCMDFILE  Command file with all failed test cases.
122f08c3bdfSopenharmony_ci    -T TCONFCMDFILE Command file with all test cases that are not fully tested.
123f08c3bdfSopenharmony_ci    -d TMPDIR       Directory where temporary files will be created.
124f08c3bdfSopenharmony_ci    -D NUM_PROCS,NUM_FILES,NUM_BYTES,CLEAN_FLAG
125f08c3bdfSopenharmony_ci                    Run LTP under additional background Load on Secondary Storage (separated by comma)
126f08c3bdfSopenharmony_ci                    [NUM_PROCS   = no. of processes creating Storage Load by spinning over write()]
127f08c3bdfSopenharmony_ci                    [NUM_FILES   = Write() to these many files (Defaults to 1 when value 0 or undefined)]
128f08c3bdfSopenharmony_ci                    [NUM_BYTES   = write these many bytes (defaults to 1GB, when value 0 or undefined)]
129f08c3bdfSopenharmony_ci                    [CLEAN_FLAG  = unlink file to which random data written, when value 1]
130f08c3bdfSopenharmony_ci    -e              Prints the date of the current LTP release
131f08c3bdfSopenharmony_ci    -f CMDFILES     Execute user defined list of testcases (separate with ',')
132f08c3bdfSopenharmony_ci	-F LOOPS,PERCENTAGE Induce PERCENTAGE Fault in the Kernel Subsystems, and, run each test for LOOPS loop
133f08c3bdfSopenharmony_ci    -g HTMLFILE     Create an additional HTML output format
134f08c3bdfSopenharmony_ci    -h              Help. Prints all available options.
135f08c3bdfSopenharmony_ci    -i NUM_PROCS    Run LTP under additional background Load on IO Bus
136f08c3bdfSopenharmony_ci                    [NUM_PROCS   = no. of processes creating IO Bus Load by spinning over sync()]
137f08c3bdfSopenharmony_ci    -K DMESG_LOG_DIR
138f08c3bdfSopenharmony_ci			Log Kernel messages generated for each test cases inside this directory
139f08c3bdfSopenharmony_ci    -l LOGFILE      Log results of test in a logfile.
140f08c3bdfSopenharmony_ci    -m NUM_PROCS,CHUNKS,BYTES,HANGUP_FLAG
141f08c3bdfSopenharmony_ci                    Run LTP under additional background Load on Main memory (separated by comma)
142f08c3bdfSopenharmony_ci                    [NUM_PROCS   = no. of processes creating main Memory Load by spinning over malloc()]
143f08c3bdfSopenharmony_ci                    [CHUNKS      = malloc these many chunks (default is 1 when value 0 or undefined)]
144f08c3bdfSopenharmony_ci                    [BYTES       = malloc CHUNKS of BYTES bytes (default is 256MB when value 0 or undefined) ]
145f08c3bdfSopenharmony_ci                    [HANGUP_FLAG = hang in a sleep loop after memory allocated, when value 1]
146f08c3bdfSopenharmony_ci	-M CHECK_TYPE
147f08c3bdfSopenharmony_ci		[CHECK_TYPE=1 => Full Memory Leak Check tracing children as well]
148f08c3bdfSopenharmony_ci		[CHECK_TYPE=2 => Thread Concurrency Check tracing children as well]
149f08c3bdfSopenharmony_ci		[CHECK_TYPE=3 => Full Memory Leak & Thread Concurrency Check tracing children as well]
150f08c3bdfSopenharmony_ci    -N              Run all the networking tests.
151f08c3bdfSopenharmony_ci    -o OUTPUTFILE   Redirect test output to a file.
152f08c3bdfSopenharmony_ci    -p              Human readable format logfiles.
153f08c3bdfSopenharmony_ci    -q              Print less verbose output to screen. This implies
154f08c3bdfSopenharmony_ci                    not logging start of the test in kernel log.
155f08c3bdfSopenharmony_ci    -Q              Don't log start of test in kernel log.
156f08c3bdfSopenharmony_ci    -r LTPROOT      Fully qualified path where testsuite is installed.
157f08c3bdfSopenharmony_ci    -R              Randomize test order.
158f08c3bdfSopenharmony_ci    -s PATTERN      Only run test cases which match PATTERN.
159f08c3bdfSopenharmony_ci    -S SKIPFILE     Skip tests specified in SKIPFILE
160f08c3bdfSopenharmony_ci    -t DURATION     Execute the testsuite for given duration. Examples:
161f08c3bdfSopenharmony_ci                      -t 60s = 60 seconds
162f08c3bdfSopenharmony_ci                      -t 45m = 45 minutes
163f08c3bdfSopenharmony_ci                      -t 24h = 24 hours
164f08c3bdfSopenharmony_ci                      -t 2d  = 2 days
165f08c3bdfSopenharmony_ci    -I ITERATIONS   Execute the testsuite ITERATIONS times.
166f08c3bdfSopenharmony_ci    -w CMDFILEADDR  Uses wget to get the user's list of testcases.
167f08c3bdfSopenharmony_ci    -x INSTANCES    Run multiple instances of this testsuite.
168f08c3bdfSopenharmony_ci    -b DEVICE       Some tests require an unmounted block device
169f08c3bdfSopenharmony_ci                    to run correctly.
170f08c3bdfSopenharmony_ci    -B LTP_DEV_FS_TYPE The file system of test block devices.
171f08c3bdfSopenharmony_ci    -z BIG_DEVICE   Some tests require a big unmounted block device
172f08c3bdfSopenharmony_ci                    to run correctly.
173f08c3bdfSopenharmony_ci    -Z  LTP_BIG_DEV_FS_TYPE The file system of the big device
174f08c3bdfSopenharmony_ci    -W ZOOFILE      Specify the zoo file used to record current test tags (default PID of this script)
175f08c3bdfSopenharmony_ci
176f08c3bdfSopenharmony_ci
177f08c3bdfSopenharmony_ci
178f08c3bdfSopenharmony_ci    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}
179f08c3bdfSopenharmony_ci
180f08c3bdfSopenharmony_ci
181f08c3bdfSopenharmony_ci	EOF
182f08c3bdfSopenharmony_ciexit 0
183f08c3bdfSopenharmony_ci}
184f08c3bdfSopenharmony_ci
185f08c3bdfSopenharmony_cimain()
186f08c3bdfSopenharmony_ci{
187f08c3bdfSopenharmony_ci    local CMDFILES=
188f08c3bdfSopenharmony_ci    local PRETTY_PRT=
189f08c3bdfSopenharmony_ci    local ALT_DIR_OUT=0
190f08c3bdfSopenharmony_ci    local ALT_DIR_RES=0
191f08c3bdfSopenharmony_ci    local ALT_HTML_OUT=0
192f08c3bdfSopenharmony_ci    local ALT_EMAIL_OUT=0
193f08c3bdfSopenharmony_ci    local ALT_DMESG_OUT=0
194f08c3bdfSopenharmony_ci    local RUN_NETEST=0
195f08c3bdfSopenharmony_ci    local RUN_REPEATED=0
196f08c3bdfSopenharmony_ci    local QUIET_MODE=
197f08c3bdfSopenharmony_ci    local NO_KMSG=
198f08c3bdfSopenharmony_ci    local NETPIPE=0
199f08c3bdfSopenharmony_ci    local GENLOAD=0
200f08c3bdfSopenharmony_ci    local MEMSIZE=0
201f08c3bdfSopenharmony_ci    local DURATION=
202f08c3bdfSopenharmony_ci    local CMDFILEADDR=
203f08c3bdfSopenharmony_ci    local FAILCMDFILE=
204f08c3bdfSopenharmony_ci    local TCONFCMDFILE=
205f08c3bdfSopenharmony_ci    local INJECT_KERNEL_FAULT=
206f08c3bdfSopenharmony_ci    local INJECT_KERNEL_FAULT_PERCENTAGE=
207f08c3bdfSopenharmony_ci    local INJECT_FAULT_LOOPS_PER_TEST=
208f08c3bdfSopenharmony_ci    local VALGRIND_CHECK=
209f08c3bdfSopenharmony_ci    local VALGRIND_CHECK_TYPE=
210f08c3bdfSopenharmony_ci    local LOGFILE_NAME=
211f08c3bdfSopenharmony_ci    local LOGFILE=
212f08c3bdfSopenharmony_ci    local OUTPUTFILE_NAME=
213f08c3bdfSopenharmony_ci    local OUTPUTFILE=
214f08c3bdfSopenharmony_ci    local HTMLFILE_NAME=
215f08c3bdfSopenharmony_ci    local HTMLFILE=
216f08c3bdfSopenharmony_ci    local DMESG_DIR=
217f08c3bdfSopenharmony_ci    local EMAIL_TO=
218f08c3bdfSopenharmony_ci    local TAG_RESTRICT_STRING=
219f08c3bdfSopenharmony_ci    local PAN_COMMAND=
220f08c3bdfSopenharmony_ci    local RANDOMRUN=0
221f08c3bdfSopenharmony_ci    local DEFAULT_FILE_NAME_GENERATION_TIME=`date +"%Y_%m_%d-%Hh_%Mm_%Ss"`
222f08c3bdfSopenharmony_ci    local scenfile=
223f08c3bdfSopenharmony_ci    local ZOOFILE=$$
224f08c3bdfSopenharmony_ci
225f08c3bdfSopenharmony_ci    version_date=$(cat "$LTPROOT/Version")
226f08c3bdfSopenharmony_ci
227f08c3bdfSopenharmony_ci    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:W: arg
228f08c3bdfSopenharmony_ci    do  case $arg in
229f08c3bdfSopenharmony_ci        a)  EMAIL_TO=$OPTARG
230f08c3bdfSopenharmony_ci            ALT_EMAIL_OUT=1;;
231f08c3bdfSopenharmony_ci        c)
232f08c3bdfSopenharmony_ci            NUM_PROCS=$(($OPTARG))
233f08c3bdfSopenharmony_ci            if   [ "$NUM_PROCS" -eq 0 ]; then
234f08c3bdfSopenharmony_ci                # User Did not Define the Value ,or, User Defined Zero,
235f08c3bdfSopenharmony_ci                # hence, prevent from creating infinite processes
236f08c3bdfSopenharmony_ci                NUM_PROCS=1
237f08c3bdfSopenharmony_ci            fi
238f08c3bdfSopenharmony_ci            $LTPROOT/testcases/bin/genload --cpu $NUM_PROCS >/dev/null 2>&1 &
239f08c3bdfSopenharmony_ci            GENLOAD=1 ;;
240f08c3bdfSopenharmony_ci
241f08c3bdfSopenharmony_ci        C)
242f08c3bdfSopenharmony_ci            case $OPTARG in
243f08c3bdfSopenharmony_ci            /*)
244f08c3bdfSopenharmony_ci                FAILCMDFILE="-C $OPTARG" ;;
245f08c3bdfSopenharmony_ci            *)
246f08c3bdfSopenharmony_ci                FAILCMDFILE="-C $LTPROOT/output/$OPTARG"
247f08c3bdfSopenharmony_ci                ALT_DIR_OUT=1 ;;
248f08c3bdfSopenharmony_ci            esac ;;
249f08c3bdfSopenharmony_ci
250f08c3bdfSopenharmony_ci        T)
251f08c3bdfSopenharmony_ci            case $OPTARG in
252f08c3bdfSopenharmony_ci            /*)
253f08c3bdfSopenharmony_ci                TCONFCMDFILE="-T $OPTARG" ;;
254f08c3bdfSopenharmony_ci            *)
255f08c3bdfSopenharmony_ci                TCONFCMDFILE="-T $LTPROOT/output/$OPTARG"
256f08c3bdfSopenharmony_ci                ALT_DIR_OUT=1 ;;
257f08c3bdfSopenharmony_ci            esac ;;
258f08c3bdfSopenharmony_ci
259f08c3bdfSopenharmony_ci        d)  # convert the user path to absolute path.
260f08c3bdfSopenharmony_ci            export TMPBASE=$(readlink -f ${OPTARG}) ;;
261f08c3bdfSopenharmony_ci
262f08c3bdfSopenharmony_ci        D)  NUM_PROCS=1; NUM_FILES=1; NUM_BYTES=$((1024 * 1024 * 1024)); CLEAN_FLAG=0
263f08c3bdfSopenharmony_ci            ARGUMENT_LIST=$OPTARG
264f08c3bdfSopenharmony_ci            TOTAL_ARGUMENTS=1
265f08c3bdfSopenharmony_ci            for ARGUMENT in `echo "$ARGUMENT_LIST" | tr ',' ' '`
266f08c3bdfSopenharmony_ci            do
267f08c3bdfSopenharmony_ci                case $TOTAL_ARGUMENTS in
268f08c3bdfSopenharmony_ci                    1) NUM_PROCS="$ARGUMENT" ;;
269f08c3bdfSopenharmony_ci                    2) NUM_FILES="$ARGUMENT" ;;
270f08c3bdfSopenharmony_ci                    3) NUM_BYTES="$ARGUMENT" ;;
271f08c3bdfSopenharmony_ci                    4) CLEAN_FLAG="$ARGUMENT" ;;
272f08c3bdfSopenharmony_ci                esac
273f08c3bdfSopenharmony_ci                TOTAL_ARGUMENTS=`expr $TOTAL_ARGUMENTS + 1`
274f08c3bdfSopenharmony_ci            done
275f08c3bdfSopenharmony_ci            # just to get the default values if the user passed 0
276f08c3bdfSopenharmony_ci            if [ "$NUM_PROCS" -eq 0 ]; then
277f08c3bdfSopenharmony_ci                NUM_PROCS=1
278f08c3bdfSopenharmony_ci            fi
279f08c3bdfSopenharmony_ci            if [ "$NUM_FILES" -eq 0 ]; then
280f08c3bdfSopenharmony_ci                NUM_FILES=1
281f08c3bdfSopenharmony_ci            fi
282f08c3bdfSopenharmony_ci            if [ "$NUM_BYTES" -eq 0 ]; then
283f08c3bdfSopenharmony_ci                NUM_BYTES=$((1024 * 1024 * 1024))
284f08c3bdfSopenharmony_ci            fi
285f08c3bdfSopenharmony_ci            if [ "$CLEAN_FLAG" -ne 1 ]; then
286f08c3bdfSopenharmony_ci                CLEAN_FLAG=0
287f08c3bdfSopenharmony_ci            fi
288f08c3bdfSopenharmony_ci            if [ "$CLEAN_FLAG" -eq 1 ]; then
289f08c3bdfSopenharmony_ci                # Do not unlink file in this case
290f08c3bdfSopenharmony_ci                $LTPROOT/testcases/bin/genload --hdd $NUM_PROCS --hdd-files \
291f08c3bdfSopenharmony_ci                    $NUM_FILES --hdd-bytes $NUM_BYTES >/dev/null 2>&1 &
292f08c3bdfSopenharmony_ci            else
293f08c3bdfSopenharmony_ci                # Cleanup otherwise
294f08c3bdfSopenharmony_ci                $LTPROOT/testcases/bin/genload --hdd $NUM_PROCS --hdd-files \
295f08c3bdfSopenharmony_ci                    $NUM_FILES --hdd-bytes $NUM_BYTES --hdd-noclean >/dev/null 2>&1 &
296f08c3bdfSopenharmony_ci            fi
297f08c3bdfSopenharmony_ci            GENLOAD=1;;
298f08c3bdfSopenharmony_ci
299f08c3bdfSopenharmony_ci        e)  # Print out the version of LTP
300f08c3bdfSopenharmony_ci            version_of_ltp
301f08c3bdfSopenharmony_ci	    ;;
302f08c3bdfSopenharmony_ci        f)  # Execute user defined set of testcases.
303f08c3bdfSopenharmony_ci            # Can be more than one file, just separate it with ',', like:
304f08c3bdfSopenharmony_ci            # -f nfs,commands,/tmp/testfile
305f08c3bdfSopenharmony_ci            CMDFILES=$OPTARG;;
306f08c3bdfSopenharmony_ci	F)	INJECT_KERNEL_FAULT=1
307f08c3bdfSopenharmony_ci		# Separate out the NO_OF_LOOPS & FAULT_PERCENTAGE
308f08c3bdfSopenharmony_ci		INJECT_FAULT_LOOPS_PER_TEST=`echo $OPTARG |cut -d',' -f1 | tr -d '\n' | tr -d ' '`
309f08c3bdfSopenharmony_ci		INJECT_KERNEL_FAULT_PERCENTAGE=`echo $OPTARG |cut -d',' -f2 | tr -d '\n' | tr -d ' '`
310f08c3bdfSopenharmony_ci		if [ ! $INJECT_FAULT_LOOPS_PER_TEST ]; then
311f08c3bdfSopenharmony_ci			echo "Loops not properly defined. Resorting to default 5..."
312f08c3bdfSopenharmony_ci			export INJECT_FAULT_LOOPS_PER_TEST=5
313f08c3bdfSopenharmony_ci		fi
314f08c3bdfSopenharmony_ci		if [ ! $INJECT_KERNEL_FAULT_PERCENTAGE ]; then
315f08c3bdfSopenharmony_ci			echo "Fault Persentage not properly defined. Resorting to default 10..."
316f08c3bdfSopenharmony_ci			export INJECT_KERNEL_FAULT_PERCENTAGE=10
317f08c3bdfSopenharmony_ci		fi;;
318f08c3bdfSopenharmony_ci        g)  HTMLFILE_NAME="$OPTARG"
319f08c3bdfSopenharmony_ci            case $OPTARG in
320f08c3bdfSopenharmony_ci            /*)
321f08c3bdfSopenharmony_ci                HTMLFILE="$OPTARG";;
322f08c3bdfSopenharmony_ci            *)
323f08c3bdfSopenharmony_ci                HTMLFILE="$LTPROOT/output/$OPTARG"
324f08c3bdfSopenharmony_ci                ALT_DIR_OUT=1;;
325f08c3bdfSopenharmony_ci            esac
326f08c3bdfSopenharmony_ci            ALT_HTML_OUT=1;;
327f08c3bdfSopenharmony_ci        h)  usage;;
328f08c3bdfSopenharmony_ci
329f08c3bdfSopenharmony_ci        i)
330f08c3bdfSopenharmony_ci            NUM_PROCS=$(($OPTARG))
331f08c3bdfSopenharmony_ci            if   [ "$NUM_PROCS" -eq 0 ]; then
332f08c3bdfSopenharmony_ci                # User Did not Define the Value ,or, User Defined Zero,
333f08c3bdfSopenharmony_ci                # hence, prevent from creating infinite processes
334f08c3bdfSopenharmony_ci                NUM_PROCS=1
335f08c3bdfSopenharmony_ci            fi
336f08c3bdfSopenharmony_ci            $LTPROOT/testcases/bin/genload --io $NUM_PROCS >/dev/null 2>&1 &
337f08c3bdfSopenharmony_ci            GENLOAD=1 ;;
338f08c3bdfSopenharmony_ci
339f08c3bdfSopenharmony_ci        K)
340f08c3bdfSopenharmony_ci	    case $OPTARG in
341f08c3bdfSopenharmony_ci        	   /*)
342f08c3bdfSopenharmony_ci			DMESG_DIR="$OPTARG-dmesg-output-`echo $$-``date +%X | tr -d ' '`";;
343f08c3bdfSopenharmony_ci	            *)
344f08c3bdfSopenharmony_ci		        DMESG_DIR="$LTPROOT/output/$OPTARG-dmesg-output-`echo $$-``date +%X | tr -d ' '`";;
345f08c3bdfSopenharmony_ci	    esac
346f08c3bdfSopenharmony_ci            mkdir -p $DMESG_DIR
347f08c3bdfSopenharmony_ci            ALT_DMESG_OUT=1;;
348f08c3bdfSopenharmony_ci        l)
349f08c3bdfSopenharmony_ci            LOGFILE_NAME="$OPTARG"
350f08c3bdfSopenharmony_ci            case $OPTARG in
351f08c3bdfSopenharmony_ci            /*)
352f08c3bdfSopenharmony_ci                LOGFILE="-l $OPTARG" ;;
353f08c3bdfSopenharmony_ci            *)
354f08c3bdfSopenharmony_ci                LOGFILE="-l $LTPROOT/results/$OPTARG"
355f08c3bdfSopenharmony_ci                ALT_DIR_RES=1 ;;
356f08c3bdfSopenharmony_ci            esac ;;
357f08c3bdfSopenharmony_ci
358f08c3bdfSopenharmony_ci        m)  NUM_PROCS=1; CHUNKS=1; BYTES=$((256 * 1024 * 1024)); HANGUP_FLAG=0
359f08c3bdfSopenharmony_ci            ARGUMENT_LIST=$OPTARG
360f08c3bdfSopenharmony_ci            TOTAL_ARGUMENTS=1
361f08c3bdfSopenharmony_ci            for ARGUMENT in `echo "$ARGUMENT_LIST" | tr ',' ' '`
362f08c3bdfSopenharmony_ci            do
363f08c3bdfSopenharmony_ci                case $TOTAL_ARGUMENTS in
364f08c3bdfSopenharmony_ci                    1) NUM_PROCS="$ARGUMENT" ;;
365f08c3bdfSopenharmony_ci                    2) CHUNKS="$ARGUMENT" ;;
366f08c3bdfSopenharmony_ci                    3) BYTES="$ARGUMENT" ;;
367f08c3bdfSopenharmony_ci                    4) HANGUP_FLAG="$ARGUMENT" ;;
368f08c3bdfSopenharmony_ci                esac
369f08c3bdfSopenharmony_ci                TOTAL_ARGUMENTS=`expr $TOTAL_ARGUMENTS + 1`
370f08c3bdfSopenharmony_ci            done
371f08c3bdfSopenharmony_ci            # just to get the default values if the user passed 0
372f08c3bdfSopenharmony_ci            if [ "$NUM_PROCS" -eq 0 ]; then
373f08c3bdfSopenharmony_ci                NUM_PROCS=1
374f08c3bdfSopenharmony_ci            fi
375f08c3bdfSopenharmony_ci            if [ "$CHUNKS" -eq 0 ]; then
376f08c3bdfSopenharmony_ci                CHUNKS=1
377f08c3bdfSopenharmony_ci            fi
378f08c3bdfSopenharmony_ci            if [ "$BYTES" -eq 0 ]; then
379f08c3bdfSopenharmony_ci                BYTES=$((256 * 1024 * 1024))
380f08c3bdfSopenharmony_ci            fi
381f08c3bdfSopenharmony_ci            if [ "$HANGUP_FLAG" -ne 1 ]; then
382f08c3bdfSopenharmony_ci                HANGUP_FLAG=0
383f08c3bdfSopenharmony_ci            fi
384f08c3bdfSopenharmony_ci            if [ "$HANGUP_FLAG" -eq 1 ]; then
385f08c3bdfSopenharmony_ci                # Hang in a Sleep loop after memory allocated
386f08c3bdfSopenharmony_ci                $LTPROOT/testcases/bin/genload --vm $NUM_PROCS --vm-chunks \
387f08c3bdfSopenharmony_ci                    $CHUNKS --vm-bytes $BYTES --vm-hang >/dev/null 2>&1 &
388f08c3bdfSopenharmony_ci            else
389f08c3bdfSopenharmony_ci                # Otherwise Do not Hangup
390f08c3bdfSopenharmony_ci                $LTPROOT/testcases/bin/genload --vm $NUM_PROCS --vm-chunks \
391f08c3bdfSopenharmony_ci                    $CHUNKS --vm-bytes $BYTES >/dev/null 2>&1 &
392f08c3bdfSopenharmony_ci            fi
393f08c3bdfSopenharmony_ci            GENLOAD=1;;
394f08c3bdfSopenharmony_ci	M)
395f08c3bdfSopenharmony_ci		VALGRIND_CHECK=1
396f08c3bdfSopenharmony_ci		VALGRIND_CHECK_TYPE="$OPTARG";;
397f08c3bdfSopenharmony_ci
398f08c3bdfSopenharmony_ci        N)  RUN_NETEST=1;;
399f08c3bdfSopenharmony_ci
400f08c3bdfSopenharmony_ci        o)  OUTPUTFILE_NAME="$OPTARG"
401f08c3bdfSopenharmony_ci            case $OPTARG in
402f08c3bdfSopenharmony_ci            /*)
403f08c3bdfSopenharmony_ci                OUTPUTFILE="-o $OPTARG";;
404f08c3bdfSopenharmony_ci            *)
405f08c3bdfSopenharmony_ci                OUTPUTFILE="-o $LTPROOT/output/$OPTARG"
406f08c3bdfSopenharmony_ci                ALT_DIR_OUT=1 ;;
407f08c3bdfSopenharmony_ci            esac ;;
408f08c3bdfSopenharmony_ci
409f08c3bdfSopenharmony_ci        p)  PRETTY_PRT="-p";;
410f08c3bdfSopenharmony_ci
411f08c3bdfSopenharmony_ci        q)  QUIET_MODE="-q";;
412f08c3bdfSopenharmony_ci
413f08c3bdfSopenharmony_ci        Q)  NO_KMSG="-Q";;
414f08c3bdfSopenharmony_ci
415f08c3bdfSopenharmony_ci        r)  LTPROOT=$OPTARG;;
416f08c3bdfSopenharmony_ci
417f08c3bdfSopenharmony_ci        R)  RANDOMRUN=1;;
418f08c3bdfSopenharmony_ci
419f08c3bdfSopenharmony_ci        s)  TAG_RESTRICT_STRING=$OPTARG;;
420f08c3bdfSopenharmony_ci
421f08c3bdfSopenharmony_ci	S)  case $OPTARG in
422f08c3bdfSopenharmony_ci            /*)
423f08c3bdfSopenharmony_ci                SKIPFILE=$OPTARG;;
424f08c3bdfSopenharmony_ci            *)
425f08c3bdfSopenharmony_ci                SKIPFILE="$LTPROOT/$OPTARG";;
426f08c3bdfSopenharmony_ci            esac ;;
427f08c3bdfSopenharmony_ci
428f08c3bdfSopenharmony_ci        t)  # In case you want to specify the time
429f08c3bdfSopenharmony_ci            # to run from the command line
430f08c3bdfSopenharmony_ci            # (2m = two minutes, 2h = two hours, etc)
431f08c3bdfSopenharmony_ci            DURATION="-t $OPTARG" ;;
432f08c3bdfSopenharmony_ci
433f08c3bdfSopenharmony_ci        I)  # In case you want the testcases to runsequentially RUN_REPEATED times
434f08c3bdfSopenharmony_ci            RUN_REPEATED=$OPTARG;;
435f08c3bdfSopenharmony_ci
436f08c3bdfSopenharmony_ci        w)  CMDFILEADDR=$OPTARG;;
437f08c3bdfSopenharmony_ci
438f08c3bdfSopenharmony_ci        x)  # number of ltp's to run
439f08c3bdfSopenharmony_ci            cat <<-EOF >&1
440f08c3bdfSopenharmony_ci            WARNING: The use of -x can cause unpredictable failures, as a
441f08c3bdfSopenharmony_ci                     result of concurrently running multiple tests designed
442f08c3bdfSopenharmony_ci                     to be ran exclusively.
443f08c3bdfSopenharmony_ci                     Pausing for 10 seconds..."
444f08c3bdfSopenharmony_ci	EOF
445f08c3bdfSopenharmony_ci            sleep 10
446f08c3bdfSopenharmony_ci            INSTANCES="-x $OPTARG";;
447f08c3bdfSopenharmony_ci        b) DEVICE=$OPTARG;;
448f08c3bdfSopenharmony_ci        B) LTP_DEV_FS_TYPE=$OPTARG;;
449f08c3bdfSopenharmony_ci        z) BIG_DEVICE=$OPTARG;;
450f08c3bdfSopenharmony_ci        Z) BIG_DEVICE_FS_TYPE=$OPTARG;;
451f08c3bdfSopenharmony_ci        W) ZOOFILE=$OPTARG;;
452f08c3bdfSopenharmony_ci        \?) usage;;
453f08c3bdfSopenharmony_ci        esac
454f08c3bdfSopenharmony_ci    done
455f08c3bdfSopenharmony_ci
456f08c3bdfSopenharmony_ci    ## It would be nice to create a default log file even if the user has not mentioned
457f08c3bdfSopenharmony_ci    if [ ! "$LOGFILE" ]; then                                ## User has not mentioned about Log File name
458f08c3bdfSopenharmony_ci       LOGFILE_NAME="$DEFAULT_FILE_NAME_GENERATION_TIME"
459f08c3bdfSopenharmony_ci       LOGFILE="-l $LTPROOT/results/LTP_RUN_ON-$LOGFILE_NAME.log"
460f08c3bdfSopenharmony_ci       ALT_DIR_RES=1
461f08c3bdfSopenharmony_ci       PRETTY_PRT="-p"
462f08c3bdfSopenharmony_ci    fi
463f08c3bdfSopenharmony_ci
464f08c3bdfSopenharmony_ci    ## It would be nice if a Failed File is compulsorily created (gives User better Idea of Tests that failed)
465f08c3bdfSopenharmony_ci
466f08c3bdfSopenharmony_ci    if [ ! "$FAILCMDFILE" ]; then                            ## User has not mentioned about Failed File name
467f08c3bdfSopenharmony_ci         ALT_DIR_OUT=1
468f08c3bdfSopenharmony_ci         if [ ! "$OUTPUTFILE" ]; then		             ## User has not mentioned about Output File name either
469f08c3bdfSopenharmony_ci            if [ ! "$LOGFILE" ]; then                        ## User has not mentioned about Log File name either
470f08c3bdfSopenharmony_ci               FAILED_FILE_NAME="$DEFAULT_FILE_NAME_GENERATION_TIME"
471f08c3bdfSopenharmony_ci               FAILCMDFILE="-C $LTPROOT/output/LTP_RUN_ON-$FAILED_FILE_NAME.failed"
472f08c3bdfSopenharmony_ci            else					     ## User Fortunately wanted a log file,
473f08c3bdfSopenharmony_ci               FAILED_FILE_NAME=`basename $LOGFILE_NAME`     ## Extract log file name and use it to construct Failed file name
474f08c3bdfSopenharmony_ci               FAILCMDFILE="-C $LTPROOT/output/LTP_RUN_ON-$FAILED_FILE_NAME.failed"
475f08c3bdfSopenharmony_ci            fi
476f08c3bdfSopenharmony_ci         else                                                ## User Fortunately wanted a Output file
477f08c3bdfSopenharmony_ci               FAILED_FILE_NAME=`basename $OUTPUTFILE_NAME`  ## Extract output file name and use it to construct Failed file name
478f08c3bdfSopenharmony_ci               FAILCMDFILE="-C $LTPROOT/output/LTP_RUN_ON-$FAILED_FILE_NAME.failed"
479f08c3bdfSopenharmony_ci         fi
480f08c3bdfSopenharmony_ci    fi
481f08c3bdfSopenharmony_ci
482f08c3bdfSopenharmony_ci    if [ ! "$TCONFCMDFILE" ]; then
483f08c3bdfSopenharmony_ci         ALT_DIR_OUT=1
484f08c3bdfSopenharmony_ci         if [ ! "$OUTPUTFILE" ]; then
485f08c3bdfSopenharmony_ci            if [ ! "$LOGFILE" ]; then
486f08c3bdfSopenharmony_ci               TCONF_FILE_NAME="$DEFAULT_FILE_NAME_GENERATION_TIME"
487f08c3bdfSopenharmony_ci               TCONFCMDFILE="-T $LTPROOT/output/LTP_RUN_ON-${TCONF_FILE_NAME}.tconf"
488f08c3bdfSopenharmony_ci            else
489f08c3bdfSopenharmony_ci               TCONF_FILE_NAME=`basename $LOGFILE_NAME`
490f08c3bdfSopenharmony_ci               TCONFCMDFILE="-T $LTPROOT/output/LTP_RUN_ON-${TCONF_FILE_NAME}.tconf"
491f08c3bdfSopenharmony_ci            fi
492f08c3bdfSopenharmony_ci         else
493f08c3bdfSopenharmony_ci               TCONF_FILE_NAME=`basename $OUTPUTFILE_NAME`
494f08c3bdfSopenharmony_ci               TCONFCMDFILE="-T $LTPROOT/output/LTP_RUN_ON-${TCONF_FILE_NAME}.tconf"
495f08c3bdfSopenharmony_ci         fi
496f08c3bdfSopenharmony_ci    fi
497f08c3bdfSopenharmony_ci
498f08c3bdfSopenharmony_ci    if [ "$ALT_HTML_OUT" -eq 1 ] ; then                      ## User wants the HTML version of the output
499f08c3bdfSopenharmony_ci       QUIET_MODE=""                                         ## Suppressing this guy as it will prevent generation of proper output
500f08c3bdfSopenharmony_ci                                                             ## which the HTML parser will require
501f08c3bdfSopenharmony_ci       if [ ! "$OUTPUTFILE" ]; then                          ## User has not mentioned about the Outputfile name, then we need to definitely generate one
502f08c3bdfSopenharmony_ci          OUTPUTFILE_NAME="$DEFAULT_FILE_NAME_GENERATION_TIME"
503f08c3bdfSopenharmony_ci          OUTPUTFILE="-o $LTPROOT/output/LTP_RUN_ON-$OUTPUTFILE_NAME.output"
504f08c3bdfSopenharmony_ci          ALT_DIR_OUT=1
505f08c3bdfSopenharmony_ci       fi
506f08c3bdfSopenharmony_ci    fi
507f08c3bdfSopenharmony_ci
508f08c3bdfSopenharmony_ci    # If we need, create the output directory
509f08c3bdfSopenharmony_ci    [ "$ALT_DIR_OUT" -eq 1 ] && \
510f08c3bdfSopenharmony_ci    {
511f08c3bdfSopenharmony_ci        [ ! -d $LTPROOT/output ] && \
512f08c3bdfSopenharmony_ci        {
513f08c3bdfSopenharmony_ci           echo "INFO: creating $LTPROOT/output directory"
514f08c3bdfSopenharmony_ci           mkdir -p $LTPROOT/output || \
515f08c3bdfSopenharmony_ci           {
516f08c3bdfSopenharmony_ci               echo "ERROR: failed to create $LTPROOT/output"
517f08c3bdfSopenharmony_ci               exit 1
518f08c3bdfSopenharmony_ci            }
519f08c3bdfSopenharmony_ci        }
520f08c3bdfSopenharmony_ci    }
521f08c3bdfSopenharmony_ci
522f08c3bdfSopenharmony_ci    # If we need, create the results directory
523f08c3bdfSopenharmony_ci    [ "$ALT_DIR_RES" -eq 1 ] && \
524f08c3bdfSopenharmony_ci    {
525f08c3bdfSopenharmony_ci        [ ! -d $LTPROOT/results ] && \
526f08c3bdfSopenharmony_ci        {
527f08c3bdfSopenharmony_ci            echo "INFO: creating $LTPROOT/results directory"
528f08c3bdfSopenharmony_ci            mkdir -p $LTPROOT/results || \
529f08c3bdfSopenharmony_ci            {
530f08c3bdfSopenharmony_ci                echo "ERROR: failed to create $LTPROOT/results"
531f08c3bdfSopenharmony_ci                exit 1
532f08c3bdfSopenharmony_ci            }
533f08c3bdfSopenharmony_ci        }
534f08c3bdfSopenharmony_ci    }
535f08c3bdfSopenharmony_ci
536f08c3bdfSopenharmony_ci    # Added -m 777 for tests that call tst_tmpdir() and try to
537f08c3bdfSopenharmony_ci    #  write to it as user nobody
538f08c3bdfSopenharmony_ci    mkdir -m 777 -p $TMPBASE || \
539f08c3bdfSopenharmony_ci    {
540f08c3bdfSopenharmony_ci        echo "FATAL: Unable to make temporary directory $TMPBASE"
541f08c3bdfSopenharmony_ci        exit 1
542f08c3bdfSopenharmony_ci    }
543f08c3bdfSopenharmony_ci    # use mktemp to create "safe" temporary directories
544f08c3bdfSopenharmony_ci    export TMPTEMPLATE="${TMPBASE}/ltp-XXXXXXXXXX"
545f08c3bdfSopenharmony_ci    TMP=`mktemp -d $TMPTEMPLATE` || \
546f08c3bdfSopenharmony_ci    {
547f08c3bdfSopenharmony_ci        echo "FATAL: Unable to make temporary directory: $TMP"
548f08c3bdfSopenharmony_ci        exit 1
549f08c3bdfSopenharmony_ci    }
550f08c3bdfSopenharmony_ci    export TMP
551f08c3bdfSopenharmony_ci    # To be invoked by tst_tmpdir()
552f08c3bdfSopenharmony_ci    # write to it as user nobody
553f08c3bdfSopenharmony_ci    export TMPDIR=$TMP
554f08c3bdfSopenharmony_ci
555f08c3bdfSopenharmony_ci    trap "cleanup" 0
556f08c3bdfSopenharmony_ci
557f08c3bdfSopenharmony_ci    chmod 777 $TMP || \
558f08c3bdfSopenharmony_ci    {
559f08c3bdfSopenharmony_ci      echo "unable to chmod 777 $TMP ... aborting"
560f08c3bdfSopenharmony_ci      exit 1
561f08c3bdfSopenharmony_ci    }
562f08c3bdfSopenharmony_ci
563f08c3bdfSopenharmony_ci    cd $TMP || \
564f08c3bdfSopenharmony_ci    {
565f08c3bdfSopenharmony_ci      echo "could not cd ${TMP} ... exiting"
566f08c3bdfSopenharmony_ci      exit 1
567f08c3bdfSopenharmony_ci    }
568f08c3bdfSopenharmony_ci
569f08c3bdfSopenharmony_ci    [ -n "$INSTANCES" ] && \
570f08c3bdfSopenharmony_ci    {
571f08c3bdfSopenharmony_ci      INSTANCES="$INSTANCES -O ${TMP}"
572f08c3bdfSopenharmony_ci    }
573f08c3bdfSopenharmony_ci
574f08c3bdfSopenharmony_ci    # If user does not provide a command file select a default set of testcases
575f08c3bdfSopenharmony_ci    # to execute.
576f08c3bdfSopenharmony_ci    if [ -z "$CMDFILES" ] && [ -z "$CMDFILEADDR" ]; then
577f08c3bdfSopenharmony_ci
578f08c3bdfSopenharmony_ci        SCENARIO_LISTS="$LTPROOT/scenario_groups/default"
579f08c3bdfSopenharmony_ci        if [ "$RUN_NETEST" -eq 1 ]; then
580f08c3bdfSopenharmony_ci            SCENARIO_LISTS="$LTPROOT/scenario_groups/network"
581f08c3bdfSopenharmony_ci        fi
582f08c3bdfSopenharmony_ci
583f08c3bdfSopenharmony_ci        cat <<-EOF >&1
584f08c3bdfSopenharmony_ciINFO: no command files were provided. Executing following runtest scenario files:
585f08c3bdfSopenharmony_ci`cat $SCENARIO_LISTS | tr '\012' ' '`
586f08c3bdfSopenharmony_ci
587f08c3bdfSopenharmony_ciEOF
588f08c3bdfSopenharmony_ci        cat_ok_sentinel=$TMP/cat_ok.$$
589f08c3bdfSopenharmony_ci        touch "$cat_ok_sentinel"
590f08c3bdfSopenharmony_ci        cat $SCENARIO_LISTS | while read scenfile; do
591f08c3bdfSopenharmony_ci            scenfile=${LTPROOT}/runtest/$scenfile
592f08c3bdfSopenharmony_ci            [ -f "$scenfile" ] || continue
593f08c3bdfSopenharmony_ci
594f08c3bdfSopenharmony_ci            cat $scenfile >> "$TMP/alltests" || {
595f08c3bdfSopenharmony_ci                echo "FATAL: unable to append to command file"
596f08c3bdfSopenharmony_ci                rm -Rf "$TMP"
597f08c3bdfSopenharmony_ci                rm -f "$cat_ok_sentinel"
598f08c3bdfSopenharmony_ci                exit 1
599f08c3bdfSopenharmony_ci            }
600f08c3bdfSopenharmony_ci        done
601f08c3bdfSopenharmony_ci        rm -f "$cat_ok_sentinel"
602f08c3bdfSopenharmony_ci    fi
603f08c3bdfSopenharmony_ci
604f08c3bdfSopenharmony_ci    [ -n "$CMDFILES" ] && \
605f08c3bdfSopenharmony_ci    {
606f08c3bdfSopenharmony_ci        for scenfile in `echo "$CMDFILES" | tr ',' ' '`
607f08c3bdfSopenharmony_ci        do
608f08c3bdfSopenharmony_ci            [ -f "$scenfile" ] || scenfile="$LTPROOT/runtest/$scenfile"
609f08c3bdfSopenharmony_ci            cat "$scenfile" >> ${TMP}/alltests || \
610f08c3bdfSopenharmony_ci            {
611f08c3bdfSopenharmony_ci                echo "FATAL: unable to create command file"
612f08c3bdfSopenharmony_ci                rm -Rf "$TMP"
613f08c3bdfSopenharmony_ci                exit 1
614f08c3bdfSopenharmony_ci            }
615f08c3bdfSopenharmony_ci        done
616f08c3bdfSopenharmony_ci    }
617f08c3bdfSopenharmony_ci
618f08c3bdfSopenharmony_ci    [ -n "$CMDFILEADDR" ] && \
619f08c3bdfSopenharmony_ci    {
620f08c3bdfSopenharmony_ci        wget -q "${CMDFILEADDR}" -O ${TMP}/wgetcmdfile
621f08c3bdfSopenharmony_ci        if [ $? -ne 0 ]; then
622f08c3bdfSopenharmony_ci            echo "FATAL: error while getting the command file with wget (address $CMDFILEADDR)"
623f08c3bdfSopenharmony_ci            exit 1
624f08c3bdfSopenharmony_ci        fi
625f08c3bdfSopenharmony_ci        cat "${TMP}/wgetcmdfile" >> ${TMP}/alltests || \
626f08c3bdfSopenharmony_ci        {
627f08c3bdfSopenharmony_ci            echo "FATAL: unable to create command file"
628f08c3bdfSopenharmony_ci            exit 1
629f08c3bdfSopenharmony_ci        }
630f08c3bdfSopenharmony_ci    }
631f08c3bdfSopenharmony_ci
632f08c3bdfSopenharmony_ci    # The fsx-linux tests use the SCRATCHDEV environment variable as a location
633f08c3bdfSopenharmony_ci    # that can be reformatted and run on.  Set SCRATCHDEV if you want to run
634f08c3bdfSopenharmony_ci    # these tests.  As a safeguard, this is disabled.
635f08c3bdfSopenharmony_ci    unset SCRATCHDEV
636f08c3bdfSopenharmony_ci    [ -n "$SCRATCHDEV" ] && \
637f08c3bdfSopenharmony_ci    {
638f08c3bdfSopenharmony_ci         cat ${LTPROOT}/runtest/fsx >> ${TMP}/alltests ||
639f08c3bdfSopenharmony_ci         {
640f08c3bdfSopenharmony_ci             echo "FATAL: unable to create  fsx-linux tests command file"
641f08c3bdfSopenharmony_ci             exit 1
642f08c3bdfSopenharmony_ci         }
643f08c3bdfSopenharmony_ci    }
644f08c3bdfSopenharmony_ci
645f08c3bdfSopenharmony_ci    # If enabled, execute only test cases that match the PATTERN
646f08c3bdfSopenharmony_ci    if [ -n "$TAG_RESTRICT_STRING" ]
647f08c3bdfSopenharmony_ci    then
648f08c3bdfSopenharmony_ci        mv -f ${TMP}/alltests ${TMP}/alltests.orig
649f08c3bdfSopenharmony_ci	    grep $TAG_RESTRICT_STRING ${TMP}/alltests.orig > ${TMP}/alltests #Not worth checking return codes for this case
650f08c3bdfSopenharmony_ci    fi
651f08c3bdfSopenharmony_ci
652f08c3bdfSopenharmony_ci    # Blacklist or skip tests if a SKIPFILE was specified with -S
653f08c3bdfSopenharmony_ci    if [ -n "${SKIPFILE}" ]; then
654f08c3bdfSopenharmony_ci        for test_name in $(awk '{print $1}' "${SKIPFILE}"); do
655f08c3bdfSopenharmony_ci            case "${test_name}" in \#*) continue;; esac
656f08c3bdfSopenharmony_ci            sed -i "/\<${test_name}\>/c\\${test_name} exit 32;" alltests
657f08c3bdfSopenharmony_ci        done
658f08c3bdfSopenharmony_ci    fi
659f08c3bdfSopenharmony_ci
660f08c3bdfSopenharmony_ci    # check for required users and groups
661f08c3bdfSopenharmony_ci    ${LTPROOT}/IDcheck.sh || \
662f08c3bdfSopenharmony_ci    {
663f08c3bdfSopenharmony_ci        echo "WARNING: required users and groups not present"
664f08c3bdfSopenharmony_ci        echo "WARNING: some test cases may fail"
665f08c3bdfSopenharmony_ci    }
666f08c3bdfSopenharmony_ci
667f08c3bdfSopenharmony_ci    # display versions of installed software
668f08c3bdfSopenharmony_ci    [ -z "$QUIET_MODE" ] && \
669f08c3bdfSopenharmony_ci    {
670f08c3bdfSopenharmony_ci        ${LTPROOT}/ver_linux || \
671f08c3bdfSopenharmony_ci        {
672f08c3bdfSopenharmony_ci            echo "WARNING: unable to display versions of software installed"
673f08c3bdfSopenharmony_ci            exit 1
674f08c3bdfSopenharmony_ci    }
675f08c3bdfSopenharmony_ci    }
676f08c3bdfSopenharmony_ci
677f08c3bdfSopenharmony_ci    set_block_device
678f08c3bdfSopenharmony_ci
679f08c3bdfSopenharmony_ci    # here even if the user don't specify a big block device, we
680f08c3bdfSopenharmony_ci    # also don't create the big block device.
681f08c3bdfSopenharmony_ci    if [ -z "$BIG_DEVICE" ]; then
682f08c3bdfSopenharmony_ci        echo "no big block device was specified on commandline."
683f08c3bdfSopenharmony_ci        echo "Tests which require a big block device are disabled."
684f08c3bdfSopenharmony_ci        echo "You can specify it with option -z"
685f08c3bdfSopenharmony_ci    else
686f08c3bdfSopenharmony_ci        export LTP_BIG_DEV=$BIG_DEVICE
687f08c3bdfSopenharmony_ci        if [ -z "$BIG_DEVICE_FS_TYPE" ]; then
688f08c3bdfSopenharmony_ci            export LTP_BIG_DEV_FS_TYPE="ext2"
689f08c3bdfSopenharmony_ci        else
690f08c3bdfSopenharmony_ci            export LTP_BIG_DEV_FS_TYPE=$BIG_DEVICE_FS_TYPE
691f08c3bdfSopenharmony_ci        fi
692f08c3bdfSopenharmony_ci    fi
693f08c3bdfSopenharmony_ci
694f08c3bdfSopenharmony_ci    if [ $RUN_REPEATED -gt 1 ]; then # You need to specify at least more than 1 sequential run, else it runs default
695f08c3bdfSopenharmony_ci         echo "PAN will run these test cases $RUN_REPEATED times....."
696f08c3bdfSopenharmony_ci         echo "Test Tags will be Prepended with ITERATION NO.s....."
697f08c3bdfSopenharmony_ci         inc=1
698f08c3bdfSopenharmony_ci         sed -e '/^$/ d' -e 's/^[ ,\t]*//' -e '/^#/ d' < ${TMP}/alltests > ${TMP}/alltests.temp ##This removes all newlines, leading spaces, tabs, #
699f08c3bdfSopenharmony_ci         sed 's/^[0-9,a-z,A-Z]*/'"$inc"'_ITERATION_&/' < ${TMP}/alltests.temp > ${TMP}/alltests ## .temp is kept as Base file
700f08c3bdfSopenharmony_ci         while [ $inc -lt $RUN_REPEATED ] ; do
701f08c3bdfSopenharmony_ci               inc=`expr $inc + 1`
702f08c3bdfSopenharmony_ci               sed 's/^[0-9,a-z,A-Z]*/'"$inc"'_ITERATION_&/' < ${TMP}/alltests.temp >> ${TMP}/alltests #Keep appending with Iteration No.s
703f08c3bdfSopenharmony_ci         done
704f08c3bdfSopenharmony_ci    fi
705f08c3bdfSopenharmony_ci
706f08c3bdfSopenharmony_ci    if [ "$RANDOMRUN" != "0" ]; then
707f08c3bdfSopenharmony_ci        sort -R ${TMP}/alltests -o ${TMP}/alltests
708f08c3bdfSopenharmony_ci    fi
709f08c3bdfSopenharmony_ci
710f08c3bdfSopenharmony_ci    [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test start time: $(date)" ; }
711f08c3bdfSopenharmony_ci    PAN_COMMAND="${LTPROOT}/bin/ltp-pan $QUIET_MODE $NO_KMSG -e -S $INSTANCES $DURATION -a ${ZOOFILE} \
712f08c3bdfSopenharmony_ci    -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE $FAILCMDFILE $TCONFCMDFILE"
713f08c3bdfSopenharmony_ci    echo "COMMAND:    $PAN_COMMAND"
714f08c3bdfSopenharmony_ci    if [ ! -z "$TAG_RESTRICT_STRING" ] ; then
715f08c3bdfSopenharmony_ci      echo "INFO: Restricted to $TAG_RESTRICT_STRING"
716f08c3bdfSopenharmony_ci    fi
717f08c3bdfSopenharmony_ci    #$PAN_COMMAND #Duplicated code here, because otherwise if we fail, only "PAN_COMMAND" gets output
718f08c3bdfSopenharmony_ci
719f08c3bdfSopenharmony_ci    ## Display the Output/Log/Failed/HTML file names here
720f08c3bdfSopenharmony_ci    printf "LOG File: "
721f08c3bdfSopenharmony_ci    echo $LOGFILE | cut -b4-
722f08c3bdfSopenharmony_ci
723f08c3bdfSopenharmony_ci    if [ "$OUTPUTFILE" ]; then
724f08c3bdfSopenharmony_ci       printf "OUTPUT File: "
725f08c3bdfSopenharmony_ci       echo $OUTPUTFILE | cut -b4-
726f08c3bdfSopenharmony_ci    fi
727f08c3bdfSopenharmony_ci
728f08c3bdfSopenharmony_ci    printf "FAILED COMMAND File: "
729f08c3bdfSopenharmony_ci    echo $FAILCMDFILE | cut -b4-
730f08c3bdfSopenharmony_ci
731f08c3bdfSopenharmony_ci   printf "TCONF COMMAND File: "
732f08c3bdfSopenharmony_ci   echo $TCONFCMDFILE | cut -b4-
733f08c3bdfSopenharmony_ci
734f08c3bdfSopenharmony_ci    if [ "$HTMLFILE" ]; then
735f08c3bdfSopenharmony_ci       echo "HTML File: $HTMLFILE"
736f08c3bdfSopenharmony_ci    fi
737f08c3bdfSopenharmony_ci
738f08c3bdfSopenharmony_ci    echo "Running tests......."
739f08c3bdfSopenharmony_ci    test_start_time=$(date)
740f08c3bdfSopenharmony_ci
741f08c3bdfSopenharmony_ci	# User wants testing with Kernel Fault Injection
742f08c3bdfSopenharmony_ci	if [ $INJECT_KERNEL_FAULT ] ; then
743f08c3bdfSopenharmony_ci		#See if Debugfs is mounted, and
744f08c3bdfSopenharmony_ci		#Fault Injection Framework available through Debugfs
745f08c3bdfSopenharmony_ci		use_faultinjection=true
746f08c3bdfSopenharmony_ci		for debug_subdir in \
747f08c3bdfSopenharmony_ci			fail_io_timeout \
748f08c3bdfSopenharmony_ci			fail_make_request \
749f08c3bdfSopenharmony_ci			fail_page_alloc \
750f08c3bdfSopenharmony_ci			failslab \
751f08c3bdfSopenharmony_ci		; do
752f08c3bdfSopenharmony_ci			if [ -d "/sys/kernel/debug/$debug_subdir" ]
753f08c3bdfSopenharmony_ci			then
754f08c3bdfSopenharmony_ci				use_faultinjection=true
755f08c3bdfSopenharmony_ci				break
756f08c3bdfSopenharmony_ci			fi
757f08c3bdfSopenharmony_ci		done
758f08c3bdfSopenharmony_ci		if $use_faultinjection; then
759f08c3bdfSopenharmony_ci			#If at least one of the Framework is available
760f08c3bdfSopenharmony_ci			#Go ahead to Inject Fault & Create required
761f08c3bdfSopenharmony_ci			#Command Files for LTP run
762f08c3bdfSopenharmony_ci			echo Running tests with Fault Injection Enabled in the Kernel...
763f08c3bdfSopenharmony_ci			awk -v LOOPS=$INJECT_FAULT_LOOPS_PER_TEST \
764f08c3bdfSopenharmony_ci				-v PERCENTAGE=$INJECT_KERNEL_FAULT_PERCENTAGE \
765f08c3bdfSopenharmony_ci				-f ${LTPROOT}/bin/create_kernel_faults_in_loops_and_probability.awk \
766f08c3bdfSopenharmony_ci				${TMP}/alltests > ${TMP}/alltests.tmp
767f08c3bdfSopenharmony_ci			cp ${TMP}/alltests.tmp ${TMP}/alltests
768f08c3bdfSopenharmony_ci			rm -rf ${TMP}/alltests.tmp
769f08c3bdfSopenharmony_ci		else
770f08c3bdfSopenharmony_ci			echo Fault Injection not enabled in the Kernel..
771f08c3bdfSopenharmony_ci			echo Running tests normally...
772f08c3bdfSopenharmony_ci		fi
773f08c3bdfSopenharmony_ci	fi
774f08c3bdfSopenharmony_ci
775f08c3bdfSopenharmony_ci	## Valgrind Check will work only when Kernel Fault Injection is not expected,
776f08c3bdfSopenharmony_ci	## We do not want to test Faults when valgrind is running
777f08c3bdfSopenharmony_ci	if [ $VALGRIND_CHECK ]; then
778f08c3bdfSopenharmony_ci		if [ ! $INJECT_KERNEL_FAULT ]; then
779f08c3bdfSopenharmony_ci			which valgrind || VALGRIND_CHECK_TYPE=XYZ
780f08c3bdfSopenharmony_ci			case $VALGRIND_CHECK_TYPE in
781f08c3bdfSopenharmony_ci			[1-3])
782f08c3bdfSopenharmony_ci				awk -v CHECK_LEVEL=$VALGRIND_CHECK_TYPE \
783f08c3bdfSopenharmony_ci					-f ${LTPROOT}/bin/create_valgrind_check.awk \
784f08c3bdfSopenharmony_ci					${TMP}/alltests $VALGRIND_CHECK_TYPE > \
785f08c3bdfSopenharmony_ci					${TMP}/alltests.tmp
786f08c3bdfSopenharmony_ci				cp ${TMP}/alltests.tmp ${TMP}/alltests
787f08c3bdfSopenharmony_ci				rm -rf ${TMP}/alltests.tmp
788f08c3bdfSopenharmony_ci				;;
789f08c3bdfSopenharmony_ci			*)
790f08c3bdfSopenharmony_ci				echo "Invalid Memory Check Type, or, Valgrind is not available"
791f08c3bdfSopenharmony_ci				;;
792f08c3bdfSopenharmony_ci			esac
793f08c3bdfSopenharmony_ci		fi
794f08c3bdfSopenharmony_ci	fi
795f08c3bdfSopenharmony_ci
796f08c3bdfSopenharmony_ci	if [ $ALT_DMESG_OUT -eq 1 ] ; then
797f08c3bdfSopenharmony_ci		#We want to print dmesg output for each test,lets do the trick inside the script
798f08c3bdfSopenharmony_ci		echo Enabling dmesg output logging for each test...
799f08c3bdfSopenharmony_ci		awk -v DMESG_DIR=$DMESG_DIR \
800f08c3bdfSopenharmony_ci			-f ${LTPROOT}/bin/create_dmesg_entries_for_each_test.awk \
801f08c3bdfSopenharmony_ci			${TMP}/alltests > ${TMP}/alltests.tmp
802f08c3bdfSopenharmony_ci		cp ${TMP}/alltests.tmp ${TMP}/alltests
803f08c3bdfSopenharmony_ci		rm -rf ${TMP}/alltests.tmp
804f08c3bdfSopenharmony_ci	fi
805f08c3bdfSopenharmony_ci    # Some tests need to run inside the "bin" directory.
806f08c3bdfSopenharmony_ci    cd "${LTPROOT}/testcases/bin"
807f08c3bdfSopenharmony_ci    "${LTPROOT}/bin/ltp-pan" $QUIET_MODE $NO_KMSG -e -S $INSTANCES $DURATION -a ${ZOOFILE} -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE $FAILCMDFILE $TCONFCMDFILE
808f08c3bdfSopenharmony_ci
809f08c3bdfSopenharmony_ci    if [ $? -eq 0 ]; then
810f08c3bdfSopenharmony_ci      echo "INFO: ltp-pan reported all tests PASS"
811f08c3bdfSopenharmony_ci      VALUE=0
812f08c3bdfSopenharmony_ci      export LTP_EXIT_VALUE=0;
813f08c3bdfSopenharmony_ci    else
814f08c3bdfSopenharmony_ci      echo "INFO: ltp-pan reported some tests FAIL"
815f08c3bdfSopenharmony_ci      VALUE=1
816f08c3bdfSopenharmony_ci      export LTP_EXIT_VALUE=1;
817f08c3bdfSopenharmony_ci    fi
818f08c3bdfSopenharmony_ci    cd ..
819f08c3bdfSopenharmony_ci    echo "LTP Version: $version_date"
820f08c3bdfSopenharmony_ci
821f08c3bdfSopenharmony_ci	# $DMESG_DIR is used to cache messages obtained from dmesg after a test run.
822f08c3bdfSopenharmony_ci	# Proactively reap all of the 0-byte files in $DMESG_DIR as they have zero value
823f08c3bdfSopenharmony_ci	# and only clutter up the filesystem.
824f08c3bdfSopenharmony_ci
825f08c3bdfSopenharmony_ci	if [ $ALT_DMESG_OUT -eq 1 ] ; then
826f08c3bdfSopenharmony_ci		if ! find "$DMESG_DIR" -size 0 -exec rm {} + ; then
827f08c3bdfSopenharmony_ci			echo "cd to $DMESG_DIR failed: $?"
828f08c3bdfSopenharmony_ci		fi
829f08c3bdfSopenharmony_ci		if [ -n "$(ls "$DMESG_DIR")" ] ; then
830f08c3bdfSopenharmony_ci			echo "Kernel messages were generated for LTP tests $version_date"
831f08c3bdfSopenharmony_ci		else
832f08c3bdfSopenharmony_ci			echo "No Kernel messages were generated for LTP tests $version_date"
833f08c3bdfSopenharmony_ci		fi
834f08c3bdfSopenharmony_ci	fi
835f08c3bdfSopenharmony_ci
836f08c3bdfSopenharmony_ci    if [ "$ALT_HTML_OUT" -eq 1 ] ; then        #User wants the HTML output to be created, it then needs to be generated
837f08c3bdfSopenharmony_ci       export LTP_VERSION=$version_date
838f08c3bdfSopenharmony_ci       export TEST_START_TIME="$test_start_time"
839f08c3bdfSopenharmony_ci       export TEST_END_TIME="$(date)"
840f08c3bdfSopenharmony_ci       OUTPUT_FILE=`echo $OUTPUTFILE | cut -c4-`
841f08c3bdfSopenharmony_ci       LOGS_DIRECTORY="$LTPROOT/results"
842f08c3bdfSopenharmony_ci       export TEST_OUTPUT_DIRECTORY="$LTPROOT/output"
843f08c3bdfSopenharmony_ci       export TEST_LOGS_DIRECTORY=$LOGS_DIRECTORY
844f08c3bdfSopenharmony_ci       echo "Generating HTML Output.....!!"
845f08c3bdfSopenharmony_ci       ( perl $LTPROOT/bin/genhtml.pl $LTPROOT/bin/html_report_header.txt test_start test_end test_output execution_status $OUTPUT_FILE  > $HTMLFILE; )
846f08c3bdfSopenharmony_ci       echo "Generated HTML Output.....!!"
847f08c3bdfSopenharmony_ci       echo "Location: $HTMLFILE";
848f08c3bdfSopenharmony_ci
849f08c3bdfSopenharmony_ci    fi
850f08c3bdfSopenharmony_ci
851f08c3bdfSopenharmony_ci    if [ "$ALT_EMAIL_OUT" -eq 1 ] ; then                    ## User wants reports to be e-mailed
852f08c3bdfSopenharmony_ci        TAR_FILE_NAME=LTP_RUN_$version_date$DEFAULT_FILE_NAME_GENERATION_TIME.tar
853f08c3bdfSopenharmony_ci        if [ "$HTMLFILE_NAME" ] ; then                      ## HTML file Exists
854f08c3bdfSopenharmony_ci            if [ "$ALT_HTML_OUT" -ne 1 ] ; then             ## The HTML file path is absolute and not $LTPROOT/output
855f08c3bdfSopenharmony_ci                mkdir -p $LTPROOT/output                    ## We need to create this Directory
856f08c3bdfSopenharmony_ci                cp $HTMLFILE_NAME $LTPROOT/output/
857f08c3bdfSopenharmony_ci            fi
858f08c3bdfSopenharmony_ci        fi
859f08c3bdfSopenharmony_ci        if [ "$OUTPUTFILE_NAME" ] ; then                    ## Output file exists
860f08c3bdfSopenharmony_ci            if [ "$ALT_DIR_OUT" -ne 1 ] ; then              ## The Output file path is absolute and not $LTPROOT/output
861f08c3bdfSopenharmony_ci                mkdir -p $LTPROOT/output                    ## We need to create this Directory
862f08c3bdfSopenharmony_ci                cp $OUTPUTFILE_NAME $LTPROOT/output/
863f08c3bdfSopenharmony_ci            fi
864f08c3bdfSopenharmony_ci        fi
865f08c3bdfSopenharmony_ci        if [ "$LOGFILE_NAME" ] ; then                       ## Log file exists
866f08c3bdfSopenharmony_ci            if [ "$ALT_DIR_RES" -ne 1 ] ; then              ## The Log file path is absolute and not $LTPROOT/results
867f08c3bdfSopenharmony_ci                mkdir -p $LTPROOT/results                   ## We need to create this Directory
868f08c3bdfSopenharmony_ci                cp $LOGFILE_NAME $LTPROOT/results/
869f08c3bdfSopenharmony_ci            fi
870f08c3bdfSopenharmony_ci        fi
871f08c3bdfSopenharmony_ci        if [ -d $LTPROOT/output ] ; then
872f08c3bdfSopenharmony_ci            tar -cf  ./$TAR_FILE_NAME $LTPROOT/output
873f08c3bdfSopenharmony_ci            if [ $? -eq 0 ]; then
874f08c3bdfSopenharmony_ci                echo "Created TAR File: ./$TAR_FILE_NAME successfully, added $LTPROOT/output"
875f08c3bdfSopenharmony_ci            else
876f08c3bdfSopenharmony_ci                echo "Cannot Create TAR File: ./$TAR_FILE_NAME for adding $LTPROOT/output"
877f08c3bdfSopenharmony_ci            fi
878f08c3bdfSopenharmony_ci        fi
879f08c3bdfSopenharmony_ci        if [ -d $LTPROOT/results ] ; then
880f08c3bdfSopenharmony_ci            tar -uf ./$TAR_FILE_NAME $LTPROOT/results
881f08c3bdfSopenharmony_ci            if [ $? -eq 0 ]; then
882f08c3bdfSopenharmony_ci                echo "Updated TAR File: ./$TAR_FILE_NAME successfully, added $LTPROOT/results"
883f08c3bdfSopenharmony_ci            else
884f08c3bdfSopenharmony_ci                echo "Cannot Update TAR File: ./$TAR_FILE_NAME for adding $LTPROOT/results"
885f08c3bdfSopenharmony_ci            fi
886f08c3bdfSopenharmony_ci        fi
887f08c3bdfSopenharmony_ci        if [ -e $LTPROOT/nohup.out ] ; then                 ## If User would have Chosen nohup to do ltprun
888f08c3bdfSopenharmony_ci            tar -uf ./$TAR_FILE_NAME $LTPROOT/nohup.out
889f08c3bdfSopenharmony_ci            if [ $? -eq 0 ]; then
890f08c3bdfSopenharmony_ci                echo "Updated TAR File: ./$TAR_FILE_NAME successfully, added $LTPROOT/nohup.out"
891f08c3bdfSopenharmony_ci            else
892f08c3bdfSopenharmony_ci                echo "Cannot Update TAR File: ./$TAR_FILE_NAME for adding $LTPROOT/nohup.out"
893f08c3bdfSopenharmony_ci            fi
894f08c3bdfSopenharmony_ci        fi
895f08c3bdfSopenharmony_ci        gzip ./$TAR_FILE_NAME                               ## gzip this guy
896f08c3bdfSopenharmony_ci        if [ $? -eq 0 ]; then
897f08c3bdfSopenharmony_ci            echo "Gunzipped TAR File: ./$TAR_FILE_NAME"
898f08c3bdfSopenharmony_ci        else
899f08c3bdfSopenharmony_ci            echo "Cannot Gunzip TAR File: ./$TAR_FILE_NAME"
900f08c3bdfSopenharmony_ci        fi
901f08c3bdfSopenharmony_ci        if which mutt >/dev/null 2>&1; then
902f08c3bdfSopenharmony_ci            echo "Starting mailing reports to: $EMAIL_TO, file: ./$TAR_FILE_NAME.gz"
903f08c3bdfSopenharmony_ci            mutt -a ./$TAR_FILE_NAME.gz -s "LTP Reports on $test_start_time" -- $EMAIL_TO < /dev/null
904f08c3bdfSopenharmony_ci            if [ $? -eq 0 ]; then
905f08c3bdfSopenharmony_ci                echo "Reports Successfully mailed to: $EMAIL_TO"
906f08c3bdfSopenharmony_ci            else
907f08c3bdfSopenharmony_ci                echo "Reports cannot be mailed to: $EMAIL_TO"
908f08c3bdfSopenharmony_ci            fi
909f08c3bdfSopenharmony_ci        else ## Use our Ageold mail program
910f08c3bdfSopenharmony_ci            echo "Starting mailing reports to: $EMAIL_TO, file: ./$TAR_FILE_NAME.gz"
911f08c3bdfSopenharmony_ci            uuencode ./$TAR_FILE_NAME.gz $TAR_FILE_NAME.gz | mail  $EMAIL_TO -s "LTP Reports on $test_start_time"
912f08c3bdfSopenharmony_ci            if [ $? -eq 0 ]; then
913f08c3bdfSopenharmony_ci                echo "Reports Successfully mailed to: $EMAIL_TO"
914f08c3bdfSopenharmony_ci            else
915f08c3bdfSopenharmony_ci                echo "Reports cannot be mailed to: $EMAIL_TO"
916f08c3bdfSopenharmony_ci            fi
917f08c3bdfSopenharmony_ci        fi
918f08c3bdfSopenharmony_ci    fi
919f08c3bdfSopenharmony_ci
920f08c3bdfSopenharmony_ci    [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test end time: $(date)" ; }
921f08c3bdfSopenharmony_ci
922f08c3bdfSopenharmony_ci    [ "$GENLOAD" -eq 1 ] && { killall -9 genload  >/dev/null 2>&1; }
923f08c3bdfSopenharmony_ci    [ "$NETPIPE" -eq 1 ] && { killall -9 NPtcp  >/dev/null 2>&1; }
924f08c3bdfSopenharmony_ci
925f08c3bdfSopenharmony_ci    [ "$ALT_DIR_OUT" -eq 1 ] || [ "$ALT_DIR_RES" -eq 1 ] && \
926f08c3bdfSopenharmony_ci    {
927f08c3bdfSopenharmony_ci    cat <<-EOF >&1
928f08c3bdfSopenharmony_ci
929f08c3bdfSopenharmony_ci       ###############################################################
930f08c3bdfSopenharmony_ci
931f08c3bdfSopenharmony_ci            Done executing testcases.
932f08c3bdfSopenharmony_ci            LTP Version:  $version_date
933f08c3bdfSopenharmony_ci       ###############################################################
934f08c3bdfSopenharmony_ci
935f08c3bdfSopenharmony_ci	EOF
936f08c3bdfSopenharmony_ci    }
937f08c3bdfSopenharmony_ci    exit $VALUE
938f08c3bdfSopenharmony_ci}
939f08c3bdfSopenharmony_ci
940f08c3bdfSopenharmony_ciset_block_device()
941f08c3bdfSopenharmony_ci{
942f08c3bdfSopenharmony_ci    if [ -n "$DEVICE" ]; then
943f08c3bdfSopenharmony_ci        export LTP_DEV=$DEVICE
944f08c3bdfSopenharmony_ci    fi
945f08c3bdfSopenharmony_ci}
946f08c3bdfSopenharmony_ci
947f08c3bdfSopenharmony_cicleanup()
948f08c3bdfSopenharmony_ci{
949f08c3bdfSopenharmony_ci    [ "$LOOP_DEV" ] && losetup -d $LOOP_DEV
950f08c3bdfSopenharmony_ci    rm -rf ${TMP}
951f08c3bdfSopenharmony_ci}
952f08c3bdfSopenharmony_ci
953f08c3bdfSopenharmony_ci
954f08c3bdfSopenharmony_ciLTP_SCRIPT="$(basename $0)"
955f08c3bdfSopenharmony_ci
956f08c3bdfSopenharmony_ciif [ "$LTP_SCRIPT" = "runltp" ]; then
957f08c3bdfSopenharmony_ci    setup
958f08c3bdfSopenharmony_ci    main "$@"
959f08c3bdfSopenharmony_cifi
960