summaryrefslogtreecommitdiffstats
path: root/server
blob: 94619ecc5dd520e6d4f32ac3c136d49a11f10721 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
:
#!/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/<server_name>.  The reason for the default name
# is twofold:
# 1. If the mount point is in / (e.g., /mnt.<server_name>) 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