1 #! /usr/bin/ksh -p 2 # 3 # CDDL HEADER START 4 # 5 # The contents of this file are subject to the terms of the 6 # Common Development and Distribution License (the "License"). 7 # You may not use this file except in compliance with the License. 8 # 9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 # or http://www.opensolaris.org/os/licensing. 11 # See the License for the specific language governing permissions 12 # and limitations under the License. 13 # 14 # When distributing Covered Code, include this CDDL HEADER in each 15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 # If applicable, add the following below this CDDL HEADER, with the 17 # fields enclosed by brackets "[]" replaced with your own identifying 18 # information: Portions Copyright [yyyy] [name of copyright owner] 19 # 20 # CDDL HEADER END 21 # 22 23 # 24 # Copyright 2008 Sun Microsystems, Inc. All rights reserved. 25 # Use is subject to license terms. 26 # 27 # ident "@(#)runtests.ksh 1.1 08/10/20 SMI" 28 # 29 # Control script to run all or user specified test suites 30 # 31 32 [ -n "$DEBUG" ] && [ "$DEBUG" != "0" ] && set -x 33 34 NAME=`basename $0` 35 DIR=`dirname $0` 36 37 function usage 38 { 39 echo "usage: runtests <tests>" 40 echo " tests: -a=all tests listed below" 41 echo " -l=acl" 42 echo " -b=basic_ops" 43 echo " -n=num_attrs" 44 echo " -m=named_attrs" 45 echo " -o=other_tests" 46 echo " -s=srv_namespc" 47 echo " -r=recovery" 48 exit 1 49 } 50 51 # runtests script requires an arguments to run. 52 # runtests requires "-a" option to run all tests. 53 # Or provide the associated option to run 54 # specific(s) tests. See usage message. 55 if [ $# -lt 1 ]; then 56 usage 57 fi 58 59 # sourcing framework global environment variables created after go_setup 60 # and for this purpose only this file should be sourced 61 CONFIGFILE=/var/tmp/nfsv4/config/config.suite 62 if [[ ! -f $CONFIGFILE ]]; then 63 echo "$NAME: CONFIGFILE[$CONFIGFILE] not found;" 64 echo "\texit UNINITIATED." 65 exit 6 66 fi 67 . $CONFIGFILE 68 69 # If using runtests script, set TESTROOT to directory 70 # test framework is installed in for testing purposes. 71 TESTROOT=`pwd` 72 73 # This will be expanded to include arguments to select 74 # new tests developed to test nfsv4 75 while getopts ablnmosr option 76 do 77 case "$option" 78 in 79 a) dirs="acl basic_ops num_attrs named_attrs \ 80 other_tests srv_namespc recovery" ;; 81 b) dirs="$dirs basic_ops" ;; 82 l) dirs="$dirs acl" ;; 83 n) dirs="$dirs num_attrs" ;; 84 m) dirs="$dirs named_attrs" ;; 85 o) dirs="$dirs other_tests" ;; 86 r) dirs="$dirs recovery" ;; 87 s) dirs="$dirs srv_namespc" ;; 88 *) usage 89 exit 1 ;; 90 esac 91 done 92 93 # Set the name of the test driver for all test suites 94 TDRIVER=`basename $0` 95 96 # This is where we want the logs to go 97 if [ ! -d ${LOGDIR} ]; then 98 mkdir -m 777 -p ${LOGDIR} > /dev/null 2>&1 99 if [ $? -ne 0 ]; then 100 echo "WARNING: unable to create $LOGDIR" 101 fi 102 fi 103 104 # journal for setup was saved at father dir of LOGDIR 105 oldjnl=$(dirname $LOGDIR)/$(basename $JOURNAL_SETUP) 106 if [[ -f $oldjnl && $oldjnl_setup != $JOURNAL_SETUP ]]; then 107 mv $oldjnl $JOURNAL_SETUP 108 echo "Journal for setup is at: $JOURNAL_SETUP" 109 fi 110 111 echo "" 112 # Start the tests with some information 113 echo "" 114 echo "running tests:" 115 echo "--------------" 116 echo "" 117 118 # Create a general & summary LOG file for each test suite 119 function logs 120 { 121 echo " " 122 echo "SUMMARY LOG :" 123 echo " $LOGDIR/${dir}/Summary.log" 124 echo "Detail journal file is : " 125 echo " $LOGDIR/${dir}/journal.${dir}" 126 echo " " 127 128 cd $LOGDIR/${dir} 129 # Remove Summary.log file from previous run 130 rm -rf Summary.log 131 nawk ' 132 /^[\.\/a-zA-Z0-9\-_\|\+]+{[a-zA-Z0-9\-\+_]+}:[ \t]+/,/^[ \t]+T[eE][sS][tT][ \t]+[A-Z]+$/ { 133 if ($1 ~ /^[\.\/a-zA-Z0-9\-_\|\+]+{[a-zA-Z0-9\-\+_]+}:/) { 134 testname = $1 135 sub(":$", "", testname) 136 } 137 138 if ($0 ~ /^[ \t]+T[eE][sS][tT][ \t]+[A-Z]+/) { 139 resname = $2 140 sub(":$","",resname) 141 testlist[count++] = testname 142 results[testname] = resname 143 rescount[resname]++ 144 } 145 146 } 147 END { 148 print "\nSummary:" 149 for (i=0; i < count; i++) { 150 testname = testlist[i] 151 resname = results[testname] 152 print "\t" testname ": " resname 153 } 154 155 print "\nResult Total:" 156 for (res in rescount) { 157 print "\t" res ": " rescount[res] 158 } 159 }' journal.${dir} > Summary.log 160 161 cd $cur_dir 162 } 163 164 # Keep track of the current directory for cleanup purposes 165 cur_dir=`pwd` 166 167 # run the tests, one by one 168 for dir in $dirs; do 169 if [ ! -d "${cur_dir}/${dir}" ]; then 170 echo "ERROR: $dirs: no such directory" 171 exit 1 172 fi 173 174 # first, check to see if test driver there 175 if [ ! -f ${TESTROOT}/${dir}/${TDRIVER} ]; then 176 echo "ERROR: $dir/$TDRIVER not found" 177 exit 1 178 fi 179 180 # create testdir log directory 181 if [ ! -d ${LOGDIR}/${dir} ]; then 182 mkdir -m 777 -p ${LOGDIR}/${dir} > /dev/null 2>&1 183 if [ $? -ne 0 ]; then 184 echo "ERROR: unable to create $LOGDIR/${dir}" 185 exit 1 186 fi 187 fi 188 189 touch $LOGDIR/${dir}/journal.${dir} 190 if [ $? -ne 0 ]; then 191 # if there's no log, don't bail out, just 192 # print an error. Run the test anyway 193 echo "WARNING: could not create log file $LOGDIR/journal.${dir}" 194 fi 195 196 # run the test 197 echo "$(date) : <$dir> ..." 198 cd ${dir} 199 ./${TDRIVER} > ${LOGDIR}/${dir}/journal.${dir} 2>&1 200 logs 201 if [ "0$RUNIT_LOOP" -gt 0 ]; then 202 mv ${LOGDIR}/${dir}/journal.${dir} \ 203 ${LOGDIR}/${dir}/journal.${dir}.${RUNIT_LOOP} 204 mv ${LOGDIR}/${dir}/Summary.log \ 205 ${LOGDIR}/${dir}/Summary.log.${RUNIT_LOOP} 206 fi 207 done 208