1#!/bin/bash 2 3 4# 5# 07/10/02 - Jeff Martin - martinjn@us.ibm.com: Added instance and 6# time command line options 7# 8# 12/15/02 - Manoj Iyer - manjo@mail.utexas.edu: Added options to run 9# LTP under CPU, IO and MM load. 10# 11# 01/26/03 - Manoj Iyer - manjo@mail.utexas.edu: Added -f option; Execute 12# user defined set of testcases. 13# 14# 01/27/03 - Manoj Iyer - manjo@mail.utexas.edu: Enabled formatted printing 15# of logfiles. 16# 17# 01/28/03 - Manoj Iyer - manjo@mail.utexas.edu: added option to enable 18# formatted printing of logfiles. 19# 20# 01/29/03 - Manoj Iyer - manjo@mail.utexas.edu: merged networktests.sh with 21# this script, added the -n option to run these 22# tests. Also, added -h option to print help messages. 23# 24# 01/29/03 - Manoj Iyer - manjo@mail.utexas.edu: 25# added code to cause pan to print less verbose 26# output. 27# 02/01/03 - Manoj Iyer - manjo@mail.utexas.edu: Removed variables 28# initialization of RHOST and PASSWD. 29# 30# 02/05/03 - Robbie Williamson - Added configurability to the optional load 31# generator sections. Also added network traffic 32# option. 33# 34 35cd `dirname $0` 36export LTPROOT=${PWD} 37export TMPBASE="/tmp" 38export TMP="${TMPBASE}/runalltests-$$" 39export PATH="${PATH}:${LTPROOT}/../testcases/bin" 40cmdfile="" 41pretty_prt=" " 42alt_dir=0 43run_netest=0 44quiet_mode=" " 45NetPipe=0 46GenLoad=0 47 48usage() 49{ 50 cat <<-END >&2 51 usage: ./${0##*/} -c [-d tmpdir] [-f cmdfile ] [-i # (in Mb)] [ -l logfile ] 52 [ -m # (in Mb)] -N -n -q [ -r ltproot ] [ -t duration ] [ -x instances ] 53 54 -c Run LTP under additional background CPU load. 55 -d tmpdir Directory where temporary files will be created. 56 -f cmdfile Execute user defined list of testcases. 57 -h Help. Prints all available options. 58 -i # (in Mb) Run LTP with a _minimum_ IO load of # megabytes in background. 59 -l logfile Log results of test in a logfile. 60 -m # (in Mb) Run LTP with a _minimum_ memory load of # megabytes in background. 61 -N Run all the networking tests. 62 (export RHOST = remote hostname) 63 (export PASSWD = passwd of remote host) 64 -n Run LTP with network traffic in background. 65 -p Human readable format logfiles. 66 -q Print less verbose output to screen. 67 -r ltproot Fully qualified path where testsuite is installed. 68 -t duration Execute the testsuite for given duration in hours. 69 -x instances Run multiple instances of this testsuite. 70 71 example: ./${0##*/} -i 1024 -m 128 -p -q -l /tmp/resultlog.$$ -d ${PWD} 72 END 73exit 74} 75 76mkdir -p ${TMP} 77 78cd ${TMP} 79if [ $? -ne 0 ]; then 80 echo "could not cd ${TMP} ... exiting" 81 exit 82fi 83 84while getopts cd:f:hi:l:m:Nnpqr:t:x arg 85do case $arg in 86 c) 87 $LTPROOT/../testcases/bin/genload --cpu 1 >/dev/null 2>&1 & 88 GenLoad=1 ;; 89 90 d) # append $$ to TMP, as it is recursively 91 # removed at end of script. 92 TMPBASE=$OPTARG;; 93 f) # Execute user defined set of testcases. 94 cmdfile=$OPTARG;; 95 96 h) usage;; 97 98 i) 99 bytesize=$(($OPTARG * 1024 * 1024)) 100 $LTPROOT/../testcases/bin/genload --io 1 >/dev/null 2>&1 & 101 $LTPROOT/../testcases/bin/genload --hdd 0 --hdd-bytes $bytesize \ 102 >/dev/null 2>&1 & 103 GenLoad=1 ;; 104 105 l) 106 if [ ${OPTARG:0:1} != "/" ] 107 then 108 if [ -d $LTPROOT/results ] 109 then 110 logfile="-l $LTPROOT/results/$OPTARG" 111 else 112 mkdir -p $LTPROOT/results 113 if [ $? -ne 0 ] 114 then 115 echo "ERROR: failed to create $LTPROOT/results" 116 exit 1 117 fi 118 logfile="-l $LTPROOT/results/$OPTARG" 119 fi 120 alt_dir=1 121 else 122 logfile="-l $OPTARG" 123 fi ;; 124 125 m) 126 memsize=$(($OPTARG * 1024 * 1024)) 127 $LTPROOT/../testcases/bin/genload --vm 0 --vm-bytes $memsize\ 128 >/dev/null 2>&1 & 129 GenLoad=1;; 130 131 N) run_netest=1;; 132 133 n) $LTPROOT/../testcases/bin/netpipe.sh 134 NetPipe=1;; 135 136 p) pretty_prt=" -p ";; 137 138 q) quiet_mode=" -q ";; 139 140 r) LTPROOT=$OPTARG;; 141 142 t) # In case you want to specify the time 143 # to run from the command line 144 # (2m = two minutes, 2h = two hours, etc) 145 duration="-t $OPTARG" ;; 146 147 x) # number of ltp's to run 148 instances="-x $OPTARG";; 149 150 \?) usage;; 151 esac 152done 153 154if [ -z $PASSWD ] 155then 156 echo " " 157 echo "ERROR:" 158 echo "Please export enviroment variable PASSWD" 159 echo "INFO: export PASSWD = 'root's password'" 160 exit 1 161fi 162 163#if [ $run_netest -eq 1 ] 164#then 165# if [[ -z $RHOST || -z $PASSWD ]] 166# then 167# echo " " 168# echo " " 169# echo "ERROR: Initializing networking tests." 170# echo "INFO: Please export RHOST = 'name of the remote host machine'" 171# echo "INFO: Please export PASSWD = 'passwd of the remote host machine'" 172# echo "INFO: before running the networking tests." 173# echo " " 174# echo " " 175# echo " " 176# usage 177# fi 178#fi 179 180if [ -n "$instances" ]; then 181 instances="$instances -O ${TMP}" 182fi 183 184 185# If user does not provide a command file select a default set of testcases 186# to execute. 187if [ -z $cmdfile ] 188then 189 cat ${LTPROOT}/../runtest/admin_tools > ${TMP}/alltests 190else 191 cat $cmdfile > ${TMP}/alltests 192fi 193 194if [ $run_netest -eq 1 ] 195then 196 cat ${LTPROOT}/../runtest/network_commands >> ${TMP}/alltests 197fi 198 199# The fsx-linux tests use the SCRATCHDEV environment variable as a location 200# that can be reformatted and run on. Set SCRATCHDEV if you want to run 201# these tests. As a safeguard, this is disabled. 202unset SCRATCHDEV 203if [ -n "$SCRATCHDEV" ]; then 204 cat ${LTPROOT}/../runtest/fsx >> ${TMP}/alltests 205fi 206 207# display versions of installed software 208${LTPROOT}/../ver_linux 209 210${LTPROOT}/../bin/ltp-pan $quiet_mode -e -S $instances $duration -a $$ -n $$ $pretty_prt -f ${TMP}/alltests $logfile 211 212if [ $? -eq 0 ]; then 213 echo ltp-pan reported PASS 214else 215 echo ltp-pan reported FAIL 216fi 217 218if [ $GenLoad -eq 1 ] 219then 220 killall -9 genload >/dev/null 2>&1 221fi 222 223if [ $NetPipe -eq 1 ] 224then 225 killall -9 NPtcp 226fi 227 228if [ $alt_dir -eq 1 ] 229then 230 echo " " 231 echo "###############################################################" 232 echo " " 233 echo " result log is in the $LTPROOT/results directory" 234 echo " " 235 echo "###############################################################" 236 echo " " 237fi 238rm -rf ${TMP} 239