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 "@(#)runit.ksh 1.1 08/10/20 SMI" 28 # 29 # runit: Executes go_setup, runtests control script 30 # to run the tests, and go_cleanup scripts. 31 # 32 33 [ -n "$DEBUG" ] && [ "$DEBUG" != "0" ] && set -x 34 35 NAME=`basename $0` 36 DIR=`dirname $0` 37 38 function usage { 39 echo "usage: runit <test subdir> [-t loop-time, default=1]" 40 echo " -a=all tests listed below" 41 echo " -t=number of times to loop the tests, except '-r'" 42 echo " -l=acl" 43 echo " -b=basic_ops" 44 echo " -n=num_attrs" 45 echo " -m=named_attrs" 46 echo " -o=other_tests" 47 echo " -r=recovery" 48 echo " -s=srv_namespc" 49 exit 1 50 } 51 52 # Execute the tests; LOOPIT is set to run 53 # once by default. To modify number of times 54 # to loop tests, user must specify using 55 # "-t <# to loop tests>" option in runit. 56 LOOPIT=1 57 ARGS="" 58 while getopts "ablnmorst:" options 59 do 60 case $options in 61 a) ARGS="$ARGS -a";; 62 b) ARGS="$ARGS -b";; 63 l) ARGS="$ARGS -l";; 64 n) ARGS="$ARGS -n";; 65 m) ARGS="$ARGS -m";; 66 o) ARGS="$ARGS -o";; 67 r) ARGS="$ARGS -r";; 68 s) ARGS="$ARGS -s";; 69 t) LOOPIT=$OPTARG;; 70 *) usage;; 71 esac 72 done 73 shift `expr $OPTIND - 1` 74 75 [ $# -eq 0 ] && [ -z "$ARGS" ] && usage 76 77 recovery=0 78 # run all options? 79 res=`echo $ARGS | grep 'a' 2>&1` 80 if [ $? -eq 0 ]; then 81 recovery=1 82 # NOTE, these "blnmos" are the current options different from recovery 83 # this list need to be updated if any other option is added 84 # or if any option letter is changed 85 ARGS="-blnmos" 86 fi 87 88 # run recovery tests independently from the rest 89 res=`echo $ARGS | grep 'r' 2>&1` 90 if [ $? -eq 0 ]; then 91 recovery=1 92 ARGS=`echo $ARGS | sed 's/-r//g'` 93 fi 94 95 #Sourcing framework Global environment variables 96 ENVFILE="./nfs4test.env" 97 if [ ! -f $ENVFILE ]; then 98 echo "$NAME: ENVFILE[$ENVFILE] not found;" 99 echo "\texit UNINITIATED." 100 exit 6 101 fi 102 . $ENVFILE 103 104 # This is where we want the logs to go 105 if [ ! -d ${LOGDIR} ]; then 106 mkdir -m 777 -p $LOGDIR > /dev/null 2>&1 107 if (( $? != 0 )); then 108 echo "WARNING: unable to create $LOGDIR" 109 exit 6 110 fi 111 fi 112 113 # Go setup the server with exported filesystem and 114 # files/directories for testing purposes. 115 JOURNAL_SETUP=$LOGDIR/journal.setup 116 JOURNAL_CLEANUP=$LOGDIR/journal.cleanup 117 echo "Setting up test systems CLIENT<$(uname -n)> & SERVER<$SERVER>," 118 echo "\tit could take a few minutes..." 119 > $JOURNAL_SETUP 120 su root -c "./go_setup" >> $JOURNAL_SETUP 2>&1 121 if [ $? -ne 0 ]; then 122 cat $JOURNAL_SETUP 123 echo "ERROR: go_setup failed to setup systems" 124 echo "\ttrying to cleanup the partial setup" 125 > $JOURNAL_CLEANUP 126 su root -c "./go_cleanup" >> $JOURNAL_CLEANUP 2>&1 127 [ -n "$DEBUG" ] && [ "$DEBUG" = "1" ] && \ 128 cat $JOURNAL_CLEANUP 129 exit 1 130 fi 131 cat $JOURNAL_SETUP 132 133 LOOPF=0 134 # Execute any requested tests other than recovery 135 if [ $LOOPIT -gt 1 ]; then 136 [ "$recovery" = "1" ] && echo \ 137 "Recovery tests will be executed only once, the rest $LOOPIT times" 138 LOOPF=1 139 fi 140 141 if [ -n "$ARGS" ];then 142 i=1 143 while : 144 do 145 echo Runtests pass $i 146 [ "$LOOPF" -eq 1 ] && export RUNIT_LOOP=$i 147 ./runtests $ARGS "$@" 148 if [ $i -eq $LOOPIT ]; then 149 break; 150 fi 151 i=`expr $i + 1` 152 done 153 fi 154 155 [ "$recovery" = "1" ] && ./runtests -r "$@" 156 157 # sourcing framework global environment variables created after go_setup 158 # and for this purpose only this file should be sourced 159 CONFIGFILE=/var/tmp/nfsv4/config/config.suite 160 if [[ ! -f $CONFIGFILE ]]; then 161 echo "$NAME: CONFIGFILE[$CONFIGFILE] not found;" 162 echo "\texit UNINITIATED." 163 exit 6 164 fi 165 . $CONFIGFILE 166 167 # Go cleanup server files/directories, and unshare $BASEDIR 168 # If NOCLEANUP is set to non-zero, DONNOT run go_cleanup 169 if [ -z "$NOCLEANUP" -o "$NOCLEANUP" = "0" ]; then 170 echo "Journal for cleanup is at: $JOURNAL_CLEANUP" 171 > $JOURNAL_CLEANUP 172 su root -c "./go_cleanup" >> $JOURNAL_CLEANUP 2>&1 173 if [ $? -ne 0 ]; then 174 echo "ERROR: go_cleanup failed to cleanup $SERVER" 175 cat $JOURNAL_CLEANUP 176 exit 1 177 fi 178 cat $JOURNAL_CLEANUP 179 fi 180