summaryrefslogtreecommitdiffstats
path: root/runtests
blob: 76d3d90ea202be1b790171519c04466e9afe63a4 (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
:
#!/bin/sh
#
#       @(#)runtests	1.5 00/07/10 Connectathon testsuite
#
# Master runtests script.  Default is to run tests in each of
# basic, general, special, and lock subdirectories.  $NFSTESTDIR is
# removed before general and special tests (if previous test done)
# so that tests.init invoked from their respective runtests script
# will not ask if the test dir should be removed (since this was
# verified in the preceeding test).
#

Program=`basename $0`

passes=1
if test $# -ge 2
then
	if test x$1 = "x-N"
	then
		passes=$2
		shift
		shift
	fi
fi

if test $# = 1
then
	TESTS=$1
elif test $# = 2
then
	TESTS=$1
	TESTARG=$2
elif test $# = 3
then
	TESTS=$1
	TESTARG=$2
	TESTPATH=$3
	NFSTESTDIR=$TESTPATH
else
	InitFile="./tests.init"
	if test -f $InitFile
	then
		echo "$Program: using test defaults in $InitFile"
		. $InitFile
	else
		echo "$Program: no test defaults file ($InitFile)"
		echo "usage: $Program [-N passes] [tests [testargs [testpath]]]"
		echo "tests: -a=all, -b=basic, -g=general, -s=special, -l=lock"
		echo "testargs: -f=functional, -t=timing"
		exit 1
	fi
fi
if test x$NFSTESTDIR = x
then
	if test x$TESTPATH = x
	then
		echo "$Program: NFSTESTDIR environment variable not set"
		echo "usage: $Program [-N passes] [tests [testargs [testpath]]]"
		echo "tests: -a=all, -b=basic, -g=general, -s=special, -l=lock"
		echo "testargs: -f=functional, -t=timing"
		exit 1
	fi
	NFSTESTDIR=$TESTPATH
fi

export PATH CFLAGS LIBS NFSTESTDIR

case $TESTS in
	-a)	dirs="basic general special lock"	;;
	-b)	dirs="basic"		;;
	-g)	dirs="general"		;;
	-s)	dirs="special"		;;
	-l)	dirs="lock"		;;
esac

if test x"$dirs" = x
then
	echo "$Program: no tests specified"
	echo "usage: $Program [tests [testargs [testpath]]]"
	echo "tests: -a=all, -b=basic, -g=general, -s=special, -l=lock"
	echo "testargs: -f=functional, -t=timing"
	exit 1

fi

if test x$TESTARG = x
then
	TESTARG=-a
fi

passnum=1
while test $passnum -le $passes
do
	if test $passes -ne 1
	then
		echo "... Pass $passnum ..."
	fi

	for dir in $dirs
	do
		echo ""
		if test -d $NFSTESTDIR
		then
			rm -rf $NFSTESTDIR
		fi
		cd $dir
		sh runtests $TESTARG
		if [ $? -ne 0 ]
		then
			echo $dir tests failed
			exit 1
		fi
		cd ..
	done
	passnum=`expr $passnum + 1`
done

echo ""
rm -rf $NFSTESTDIR

echo "All tests completed"