run.in 6.38 KB
Newer Older
1
#!/bin/sh
Kurt Zeilenga's avatar
Kurt Zeilenga committed
2
# $OpenLDAP$
Kurt Zeilenga's avatar
notices    
Kurt Zeilenga committed
3
4
## This work is part of OpenLDAP Software <http://www.openldap.org/>.
##
Quanah Gibson-Mount's avatar
Quanah Gibson-Mount committed
5
## Copyright 1998-2020 The OpenLDAP Foundation.
Kurt Zeilenga's avatar
notices    
Kurt Zeilenga committed
6
7
8
9
10
11
12
13
14
## All rights reserved.
##
## Redistribution and use in source and binary forms, with or without
## modification, are permitted only as authorized by the OpenLDAP
## Public License.
##
## A copy of this license is available in the file LICENSE in the
## top-level directory of the distribution or, alternatively, at
## <http://www.OpenLDAP.org/license.html>.
15

16
USAGE="$0 [-b <backend>] [-c] [-k] [-l #] [-p] [-s {ro|rp}] [-u] [-w] <script>"
17
18

# configure generated
19
20
21
SRCDIR="@srcdir@"
TOPSRCDIR="@top_srcdir@"
LN_S="@LN_S@"
22
EGREP_CMD="@EGREP@"
23

24
export SRCDIR TOPSRCDIR LN_S EGREP_CMD
25

26
27
# backends known to ./run -b <backend> (used to deduce $BACKENDTYPE)
AC_ldif=yes
28
AC_mdb=@BUILD_MDB@
29
30
31
AC_null=@BUILD_NULL@

# other backends
32
AC_ldap=ldap@BUILD_LDAP@
33
AC_meta=meta@BUILD_META@
34
AC_asyncmeta=asyncmeta@BUILD_ASYNCMETA@
35
AC_monitor=@BUILD_MONITOR@
Ryan Tandy's avatar
Ryan Tandy committed
36
AC_perl=perl@BUILD_PERL@
37
AC_relay=relay@BUILD_RELAY@
38
39
40
AC_sql=sql@BUILD_SQL@

# overlays
Howard Chu's avatar
Howard Chu committed
41
AC_accesslog=accesslog@BUILD_ACCESSLOG@
42
AC_autoca=autoca@BUILD_AUTOCA@
Howard Chu's avatar
Howard Chu committed
43
AC_constraint=constraint@BUILD_CONSTRAINT@
44
AC_dds=dds@BUILD_DDS@
Pierangelo Masarati's avatar
Pierangelo Masarati committed
45
AC_dynlist=dynlist@BUILD_DYNLIST@
46
AC_memberof=memberof@BUILD_MEMBEROF@
Howard Chu's avatar
Howard Chu committed
47
AC_pcache=pcache@BUILD_PROXYCACHE@
48
AC_ppolicy=ppolicy@BUILD_PPOLICY@
49
AC_refint=refint@BUILD_REFINT@
50
AC_retcode=retcode@BUILD_RETCODE@
Howard Chu's avatar
Howard Chu committed
51
AC_translucent=translucent@BUILD_TRANSLUCENT@
52
AC_unique=unique@BUILD_UNIQUE@
53
AC_rwm=rwm@BUILD_RWM@
54
AC_syncprov=syncprov@BUILD_SYNCPROV@
55
AC_valsort=valsort@BUILD_VALSORT@
56
57

# misc
Pierangelo Masarati's avatar
Pierangelo Masarati committed
58
AC_WITH_SASL=@WITH_SASL@
59
AC_WITH_TLS=@WITH_TLS@
60
AC_TLS_TYPE=@WITH_TLS_TYPE@
Sang Seok Lim's avatar
Sang Seok Lim committed
61
AC_WITH_MODULES_ENABLED=@WITH_MODULES_ENABLED@
62
AC_ACI_ENABLED=aci@WITH_ACI_ENABLED@
63
64
65
AC_LIBS_DYNAMIC=lib@BUILD_LIBS_DYNAMIC@

# sanitize
66
if test "${AC_ldap}" = "ldapmod" && test "${AC_LIBS_DYNAMIC}" = "static" ; then
67
68
	AC_ldap="ldapno"
fi
69
if test "${AC_meta}" = "metamod" && test "${AC_LIBS_DYNAMIC}" = "static" ; then
70
71
	AC_meta="metano"
fi
72
if test "${AC_asyncmeta}" = "asyncmetamod" && test "${AC_LIBS_DYNAMIC}" = "static" ; then
73
74
	AC_meta="asyncmetano"
fi
Ryan Tandy's avatar
Ryan Tandy committed
75
export AC_ldap AC_mdb AC_meta AC_asyncmeta AC_monitor AC_null AC_perl AC_relay AC_sql \
76
	AC_accesslog AC_autoca AC_constraint AC_dds AC_dynlist AC_memberof AC_pcache AC_ppolicy \
77
78
	AC_refint AC_retcode AC_rwm AC_unique AC_syncprov AC_translucent \
	AC_valsort \
79
	AC_WITH_SASL AC_WITH_TLS AC_WITH_MODULES_ENABLED AC_ACI_ENABLED \
80
	AC_LIBS_DYNAMIC AC_WITH_TLS AC_TLS_TYPE
81
82
83
84
85
86

if test ! -x ../servers/slapd/slapd ; then
	echo "Could not locate slapd(8)"
	exit 1
fi

87
BACKEND=
88
89
CLEAN=no
WAIT=0
90
KILLSERVERS=yes
91
PRESERVE=${PRESERVE-no}
92
SYNCMODE=${SYNCMODE-rp}
93
USERDATA=no
94
95
LOOP=1
COUNTER=1
96

97
98
while test $# -gt 0 ; do
	case "$1" in
99
100
		-b | -backend)
			BACKEND="$2"
101
102
			shift; shift ;;

103
104
		-c | -clean)
			CLEAN=yes
105
			shift ;;
106

107
108
109
		-k | -kill)
			KILLSERVERS=no
			shift ;;
110
		-l | -loop)
111
			NUM="`echo $2 | sed 's/[0-9]//g'`"
112
113
114
115
116
117
118
119
			if [ -z "$NUM" ]; then
				LOOP=$2
			else
				echo "Loop variable not an int: $2"
				echo "$USAGE"; exit 1
			fi
			shift ;
			shift ;;
120
121
122
123
124

		-p | -preserve)
			PRESERVE=yes
			shift ;;

125
126
127
128
129
130
131
132
133
134
135
136
		-s | -syncmode)
			case "$2" in
				ro | rp)
					SYNCMODE="$2"
					;;
				*)
					echo "unknown sync mode $2"
					echo "$USAGE"; exit 1
					;;
			esac
			shift; shift ;;

137
138
139
140
		-u | -userdata)
			USERDATA=yes
			shift ;;

141
		-w | -wait)
Kurt Zeilenga's avatar
Kurt Zeilenga committed
142
			WAIT=1
143
144
			shift ;;

145
146
147
148
149
150
151
152
153
154
155
156
157
		-)
			shift
			break ;;

		-*)
			echo "$USAGE"; exit 1
			;;

		*)
			break ;;
	esac
done

158
if test -z "$BACKEND" ; then
159
	for b in mdb ; do
160
161
162
163
164
165
166
167
168
169
		if eval "test \"\$AC_$b\" != no" ; then
			BACKEND=$b
			break
		fi
	done
	if test -z "$BACKEND" ; then
		echo "No suitable default database backend configured" >&2
		exit 1
	fi
fi
170

Howard Chu's avatar
Howard Chu committed
171
BACKENDTYPE=`eval 'echo $AC_'$BACKEND`
172
173
174
if test "x$BACKENDTYPE" = "x" ; then
	BACKENDTYPE="unknown"
fi
175
176
177
178
179

# Backend features.  indexdb: indexing and unchecked limit.
# maindb: main storage backend.  Currently index,limits,mode,paged results.
INDEXDB=noindexdb MAINDB=nomaindb
case $BACKEND in
180
	mdb) INDEXDB=indexdb MAINDB=maindb ;;
181
182
183
184
185
	ndb) INDEXDB=indexdb ;;
esac

export	BACKEND BACKENDTYPE INDEXDB MAINDB \
	WAIT KILLSERVERS PRESERVE SYNCMODE USERDATA
186
187

if test $# = 0 ; then
188
189
	echo "$USAGE"; exit 1
fi
190

191
192
193
# need defines.sh for the definitions of the directories
. $SRCDIR/scripts/defines.sh

194
SCRIPTDIR="${SRCDIR}/scripts"
195
ITSDIR="${SRCDIR}/data/regressions"
196
SCRIPTNAME="$1"
197
shift
198

199
200
201
202
203
204
if test -x "${SCRIPTDIR}/${SCRIPTNAME}" ; then
	SCRIPT="${SCRIPTDIR}/${SCRIPTNAME}"
elif test -x "`echo ${SCRIPTDIR}/test*-${SCRIPTNAME}`"; then
	SCRIPT="`echo ${SCRIPTDIR}/test*-${SCRIPTNAME}`"
elif test -x "`echo ${SCRIPTDIR}/${SCRIPTNAME}-*`"; then
	SCRIPT="`echo ${SCRIPTDIR}/${SCRIPTNAME}-*`"
205
206
elif test -x "`echo ${ITSDIR}/${SCRIPTNAME}/${SCRIPTNAME}`"; then
	SCRIPT="`echo ${ITSDIR}/${SCRIPTNAME}/${SCRIPTNAME}`"
207
208
else
	echo "run: ${SCRIPTNAME} not found (or not executable)"
209
210
211
	exit 1;
fi

212
213
if test ! -r ${DATADIR}/test.ldif ; then
	${LN_S} ${SRCDIR}/data ${DATADIR}
214
fi
215
216
if test ! -r ${SCHEMADIR}/core.schema ; then
	${LN_S} ${TOPSRCDIR}/servers/slapd/schema ${SCHEMADIR}
217
218
fi

219
if test -d ${TESTDIR} ; then
220
221
	if test $PRESERVE = no ; then
		echo "Cleaning up test run directory leftover from previous run."
222
		/bin/rm -rf ${TESTDIR}
223
	elif test $PRESERVE = yes ; then
224
		echo "Cleaning up only database directories leftover from previous run."
225
		/bin/rm -rf ${TESTDIR}/db.*
226
227
	fi
fi
Howard Chu's avatar
Howard Chu committed
228
229
230
231
232
233
234
235
236
237
if test $BACKEND = ndb ; then
	mysql --user root <<EOF
	drop database if exists db_1;
	drop database if exists db_2;
	drop database if exists db_3;
	drop database if exists db_4;
	drop database if exists db_5;
	drop database if exists db_6;
EOF
fi
238
mkdir -p ${TESTDIR}
239
240
241
242
243
244

if test $USERDATA = yes ; then
	if test ! -d userdata ; then
		echo "User data directory (userdata) does not exist."
		exit 1
	fi
245
	cp -R userdata/* ${TESTDIR}
246
fi
247
248
249

# disable LDAP initialization
LDAPNOINIT=true; export LDAPNOINIT
Kurt Zeilenga's avatar
Kurt Zeilenga committed
250

251
echo "Running ${SCRIPT} for ${BACKEND}..."
252
while [ $COUNTER -le $LOOP ]; do
253
254
255
	if [ $LOOP -gt 1 ]; then
		echo "Running $COUNTER of $LOOP iterations"
	fi
256
	START=`date +%s`
257
258
	$SCRIPT $*
	RC=$?
259
	END=`date +%s`
260
261
262
263
264
265
266

	if test $CLEAN = yes ; then
		echo "Cleaning up test run directory from this run."
		/bin/rm -rf ${TESTDIR}
		echo "Cleaning up symlinks."
		/bin/rm -f ${DATADIR} ${SCHEMADIR}
	fi
267

268
	if [ $RC -ne 0 ]; then
Howard Chu's avatar
Howard Chu committed
269
270
271
		if [ $LOOP -gt 1 ]; then
			echo "Failed after $COUNTER of $LOOP iterations"
		fi
272
273
274
275
276
277
278
279
280
		exit $RC
	else
		COUNTER=`expr $COUNTER + 1`
		if [ $COUNTER -le $LOOP ]; then
			echo "Cleaning up test run directory from this run."
			/bin/rm -rf ${TESTDIR}
		fi
	fi
done
281
exit $RC