: #!/bin/sh # # @(#)server 1.8 2003/12/29 Connectathon testsuite # 1.1 Lachman ONC Test Suite source # # run tests given a server name. mounts, tests, and unmounts # arguments: # -a|-b|-g|-s|-l test selectors, passed to runtests # -f|-t|-n test arguments, passed to runtests # -c use cachefs; need to specify cachefs mount # options with -o # -N passes repeat "passes" times # -A Ask before doing the mount [default: no] # mnt_options arg to -o mount options # server_path path to mount from server # mntpoint path to mount on locally # server_name server to mount from # Program=`basename $0` InitFile="./tests.init" USAGE="usage: $Program [-a|-b|-B|-g|-s|-l|-c] [-f|-t|-n|-h|-C] [-o mnt_options] [-p server_path] [-m mntpoint] [-N passes] server_name" # defaults . $InitFile export PATH CFLAGS LIBS MOUNT UMOUNT MNTOPTIONS FSOPT passes="1" askt2mnt="no" set - `getopt aAbcCfF:glhm:N:no:p:st $*` if [ $? != 0 ] then echo $USAGE exit 1 fi for c in $* do case $c in -a|-b|-g|-s|-l) TEST=$c; shift ;; -f|-n|-t) TESTARG=$c; shift ;; -c) cachefs="yes"; shift ;; -A) ask2mnt="yes"; shift ;; -C) CIFS="yes"; export CIFS; shift ;; -h) HARDLINKS=n; export HARDLINKS; shift ;; -m) USRMNTPOINT=$2; shift; shift ;; -o) MNTOPTIONS=$2; export MNTOPTIONS; shift; shift ;; -F) FSOPT=$2; export FSOPT; shift; shift ;; -p) SERVPATH=$2; shift; shift ;; -N) passes=$2; shift; shift ;; --) shift; break ;; esac done if test $# -gt 0 then SERVER=$1 shift if test $# -gt 0 then echo $USAGE exit 1 fi fi # if no server specified, exit if test x$SERVER = x then echo $USAGE exit 1 fi # If the user specified a particular moint point, use that. # Otherwise, use /mnt/. The reason for the default name # is twofold: # 1. If the mount point is in / (e.g., /mnt.) and the # server dies, things like getcwd() might hang. # 2. Having a server-specific name makes administration and concurrent # test runs a little easier. if test x$USRMNTPOINT != x then MNTPOINT=$USRMNTPOINT else MNTPOINT="/mnt/$SERVER" fi # If the mount point doesn't exist, create it and note that we should # remove it when done. This is a bit of a hack, but combined with # tying the mountpoint to the server name, it makes it easier to run # multiple tests at the same time. if test ! -d $MNTPOINT then mkdir -p $MNTPOINT || mkdir $MNTPOINT dormdir="yes" fi # make sure nothing is mounted on the mountpoint eval $UMOUNTCMD > /dev/null 2>&1 if test -z "$cachefs" then eval $MOUNTCMD else if test -z "$CFSMOUNTCMD" then echo "error: no cachefs mount command (CFSMOUNTCMD) specified" exit 1 else eval $CFSMOUNTCMD fi fi case $? in 0) ;; *) echo "Can't mount $SERVER:$SERVPATH on $MNTPOINT" exit 1 ;; esac # mount doesn't always return error code if it fails, so lets # ask here just in case HOSTNAME=`hostname` HOSTNAME=`expr $HOSTNAME : '\([^.]*\)'` NFSTESTDIR=$MNTPOINT/$HOSTNAME.test export NFSTESTDIR if test $ask2mnt = "yes" then echo $DASHN "Start tests on path $NFSTESTDIR [y/n]?" "$BLC" read ans case $ans in Y*|y*) ;; *) echo "Terminating ($MNTPOINT left mounted)." exit 1 ;; esac echo "" fi if test $passes = "1" then passarg="" else passarg="-N $passes" fi echo "sh ./runtests $passarg $TEST $TESTARG $NFSTESTDIR" sh ./runtests $passarg $TEST $TESTARG $NFSTESTDIR if [ $? -ne 0 ] then echo Tests failed, leaving $MNTPOINT mounted 2>&1 exit 1 fi eval $UMOUNTCMD if test x$dormdir = xyes then rmdir $MNTPOINT fi exit 0