3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2012 The OpenLDAP Foundation.
6 ## All rights reserved.
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted only as authorized by the OpenLDAP
12 ## A copy of this license is available in the file LICENSE in the
13 ## top-level directory of the distribution or, alternatively, at
14 ## <http://www.OpenLDAP.org/license.html>.
16 USAGE="$0 [-b <backend>] [-c] [-k] [-l #] [-p] [-s {ro|rp}] [-u] [-w] <script>"
20 TOPSRCDIR="@top_srcdir@"
24 export SRCDIR TOPSRCDIR LN_S EGREP_CMD
26 # backends known to ./run -b <backend> (used to deduce $BACKENDTYPE)
34 AC_ldap=ldap@BUILD_LDAP@
35 AC_meta=meta@BUILD_META@
36 AC_monitor=@BUILD_MONITOR@
37 AC_relay=relay@BUILD_RELAY@
41 AC_accesslog=accesslog@BUILD_ACCESSLOG@
42 AC_constraint=constraint@BUILD_CONSTRAINT@
44 AC_dynlist=dynlist@BUILD_DYNLIST@
45 AC_memberof=memberof@BUILD_MEMBEROF@
46 AC_pcache=pcache@BUILD_PROXYCACHE@
47 AC_ppolicy=ppolicy@BUILD_PPOLICY@
48 AC_refint=refint@BUILD_REFINT@
49 AC_retcode=retcode@BUILD_RETCODE@
50 AC_translucent=translucent@BUILD_TRANSLUCENT@
51 AC_unique=unique@BUILD_UNIQUE@
53 AC_syncprov=syncprov@BUILD_SYNCPROV@
54 AC_valsort=valsort@BUILD_VALSORT@
57 AC_WITH_SASL=@WITH_SASL@
58 AC_WITH_TLS=@WITH_TLS@
59 AC_WITH_MODULES_ENABLED=@WITH_MODULES_ENABLED@
60 AC_ACI_ENABLED=aci@WITH_ACI_ENABLED@
61 AC_THREADS=threads@BUILD_THREAD@
62 AC_LIBS_DYNAMIC=lib@BUILD_LIBS_DYNAMIC@
65 if test "${AC_ldap}" = "ldapmod" && test "${AC_LIBS_DYNAMIC}" = "static" ; then
68 if test "${AC_meta}" = "metamod" && test "${AC_LIBS_DYNAMIC}" = "static" ; then
72 export AC_bdb AC_hdb AC_ldap AC_mdb AC_meta AC_monitor AC_null AC_relay AC_sql \
73 AC_accesslog AC_constraint AC_dds AC_dynlist AC_memberof AC_pcache AC_ppolicy \
74 AC_refint AC_retcode AC_rwm AC_unique AC_syncprov AC_translucent \
76 AC_WITH_SASL AC_WITH_TLS AC_WITH_MODULES_ENABLED AC_ACI_ENABLED \
77 AC_THREADS AC_LIBS_DYNAMIC
79 if test ! -x ../servers/slapd/slapd ; then
80 echo "Could not locate slapd(8)"
88 PRESERVE=${PRESERVE-no}
89 SYNCMODE=${SYNCMODE-rp}
94 while test $# -gt 0 ; do
108 NUM="`echo $2 | sed 's/[0-9]//g'`"
109 if [ -z "$NUM" ]; then
112 echo "Loop variable not an int: $2"
113 echo "$USAGE"; exit 1
128 echo "unknown sync mode $2"
129 echo "$USAGE"; exit 1
147 echo "$USAGE"; exit 1
155 if test -z "$BACKEND" ; then
156 for b in bdb hdb mdb ; do
157 if eval "test \"\$AC_$b\" != no" ; then
162 if test -z "$BACKEND" ; then
163 echo "No suitable default database backend configured" >&2
168 BACKENDTYPE=`eval 'echo $AC_'$BACKEND`
169 if test "x$BACKENDTYPE" = "x" ; then
170 BACKENDTYPE="unknown"
173 # Backend features. indexdb: indexing and unchecked limit.
174 # maindb: main storage backend. Currently index,limits,mode,paged results.
175 INDEXDB=noindexdb MAINDB=nomaindb
177 bdb|hdb|mdb) INDEXDB=indexdb MAINDB=maindb ;;
178 ndb) INDEXDB=indexdb ;;
181 export BACKEND BACKENDTYPE INDEXDB MAINDB \
182 WAIT KILLSERVERS PRESERVE SYNCMODE USERDATA
184 if test $# = 0 ; then
185 echo "$USAGE"; exit 1
188 # need defines.sh for the definitions of the directories
189 . $SRCDIR/scripts/defines.sh
191 SCRIPTDIR="${SRCDIR}/scripts"
195 if test -x "${SCRIPTDIR}/${SCRIPTNAME}" ; then
196 SCRIPT="${SCRIPTDIR}/${SCRIPTNAME}"
197 elif test -x "`echo ${SCRIPTDIR}/test*-${SCRIPTNAME}`"; then
198 SCRIPT="`echo ${SCRIPTDIR}/test*-${SCRIPTNAME}`"
199 elif test -x "`echo ${SCRIPTDIR}/${SCRIPTNAME}-*`"; then
200 SCRIPT="`echo ${SCRIPTDIR}/${SCRIPTNAME}-*`"
202 echo "run: ${SCRIPTNAME} not found (or not executable)"
206 if test ! -r ${DATADIR}/test.ldif ; then
207 ${LN_S} ${SRCDIR}/data ${DATADIR}
209 if test ! -r ${SCHEMADIR}/core.schema ; then
210 ${LN_S} ${TOPSRCDIR}/servers/slapd/schema ${SCHEMADIR}
213 if test -d ${TESTDIR} ; then
214 if test $PRESERVE = no ; then
215 echo "Cleaning up test run directory leftover from previous run."
216 /bin/rm -rf ${TESTDIR}
217 elif test $PRESERVE = yes ; then
218 echo "Cleaning up only database directories leftover from previous run."
219 /bin/rm -rf ${TESTDIR}/db.*
222 if test $BACKEND = ndb ; then
223 mysql --user root <<EOF
224 drop database if exists db_1;
225 drop database if exists db_2;
226 drop database if exists db_3;
227 drop database if exists db_4;
228 drop database if exists db_5;
229 drop database if exists db_6;
234 if test $USERDATA = yes ; then
235 if test ! -d userdata ; then
236 echo "User data directory (userdata) does not exist."
239 cp -R userdata/* ${TESTDIR}
242 # disable LDAP initialization
243 LDAPNOINIT=true; export LDAPNOINIT
245 echo "Running ${SCRIPT} for ${BACKEND}..."
246 while [ $COUNTER -le $LOOP ]; do
247 if [ $LOOP -gt 1 ]; then
248 echo "Running $COUNTER of $LOOP iterations"
253 if test $CLEAN = yes ; then
254 echo "Cleaning up test run directory from this run."
255 /bin/rm -rf ${TESTDIR}
256 echo "Cleaning up symlinks."
257 /bin/rm -f ${DATADIR} ${SCHEMADIR}
260 if [ $RC -ne 0 ]; then
261 if [ $LOOP -gt 1 ]; then
262 echo "Failed after $COUNTER of $LOOP iterations"
266 COUNTER=`expr $COUNTER + 1`
267 if [ $COUNTER -le $LOOP ]; then
268 echo "Cleaning up test run directory from this run."
269 /bin/rm -rf ${TESTDIR}