3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2010 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)
33 AC_ldap=ldap@BUILD_LDAP@
34 AC_meta=meta@BUILD_META@
35 AC_monitor=@BUILD_MONITOR@
36 AC_relay=relay@BUILD_RELAY@
40 AC_accesslog=accesslog@BUILD_ACCESSLOG@
42 AC_dynlist=dynlist@BUILD_DYNLIST@
43 AC_memberof=memberof@BUILD_MEMBEROF@
44 AC_pcache=pcache@BUILD_PROXYCACHE@
45 AC_ppolicy=ppolicy@BUILD_PPOLICY@
46 AC_refint=refint@BUILD_REFINT@
47 AC_retcode=retcode@BUILD_RETCODE@
48 AC_translucent=translucent@BUILD_TRANSLUCENT@
49 AC_unique=unique@BUILD_UNIQUE@
51 AC_syncprov=syncprov@BUILD_SYNCPROV@
52 AC_valsort=valsort@BUILD_VALSORT@
55 AC_WITH_SASL=@WITH_SASL@
56 AC_WITH_TLS=@WITH_TLS@
57 AC_WITH_MODULES_ENABLED=@WITH_MODULES_ENABLED@
58 AC_ACI_ENABLED=aci@WITH_ACI_ENABLED@
59 AC_THREADS=threads@BUILD_THREAD@
60 AC_LIBS_DYNAMIC=lib@BUILD_LIBS_DYNAMIC@
63 if test "${AC_ldap}" = "ldapmod" && test "${AC_LIBS_DYNAMIC}" = "static" ; then
66 if test "${AC_meta}" = "metamod" && test "${AC_LIBS_DYNAMIC}" = "static" ; then
70 export AC_bdb AC_hdb AC_ldap AC_meta AC_monitor AC_null AC_relay AC_sql \
71 AC_accesslog AC_dds AC_dynlist AC_memberof AC_pcache AC_ppolicy \
72 AC_refint AC_retcode AC_rwm AC_unique AC_syncprov AC_translucent \
74 AC_WITH_SASL AC_WITH_TLS AC_WITH_MODULES_ENABLED AC_ACI_ENABLED \
75 AC_THREADS AC_LIBS_DYNAMIC
77 if test ! -x ../servers/slapd/slapd ; then
78 echo "Could not locate slapd(8)"
86 PRESERVE=${PRESERVE-no}
87 SYNCMODE=${SYNCMODE-rp}
92 while test $# -gt 0 ; do
106 NUM="`echo $2 | sed 's/[0-9]//g'`"
107 if [ -z "$NUM" ]; then
110 echo "Loop variable not an int: $2"
111 echo "$USAGE"; exit 1
126 echo "unknown sync mode $2"
127 echo "$USAGE"; exit 1
145 echo "$USAGE"; exit 1
153 if test -z "$BACKEND" ; then
154 for b in bdb hdb ; do
155 if eval "test \"\$AC_$b\" != no" ; then
160 if test -z "$BACKEND" ; then
161 echo "No suitable default database backend configured" >&2
165 BACKENDTYPE=`eval 'echo $AC_'$BACKEND`
166 if test "x$BACKENDTYPE" = "x" ; then
167 BACKENDTYPE="unknown"
169 export BACKEND BACKENDTYPE WAIT KILLSERVERS PRESERVE SYNCMODE USERDATA
171 if test $# = 0 ; then
172 echo "$USAGE"; exit 1
175 # need defines.sh for the definitions of the directories
176 . $SRCDIR/scripts/defines.sh
178 SCRIPTDIR="${SRCDIR}/scripts"
182 if test -x "${SCRIPTDIR}/${SCRIPTNAME}" ; then
183 SCRIPT="${SCRIPTDIR}/${SCRIPTNAME}"
184 elif test -x "`echo ${SCRIPTDIR}/test*-${SCRIPTNAME}`"; then
185 SCRIPT="`echo ${SCRIPTDIR}/test*-${SCRIPTNAME}`"
186 elif test -x "`echo ${SCRIPTDIR}/${SCRIPTNAME}-*`"; then
187 SCRIPT="`echo ${SCRIPTDIR}/${SCRIPTNAME}-*`"
189 echo "run: ${SCRIPTNAME} not found (or not executable)"
193 if test ! -r ${DATADIR}/test.ldif ; then
194 ${LN_S} ${SRCDIR}/data ${DATADIR}
196 if test ! -r ${SCHEMADIR}/core.schema ; then
197 ${LN_S} ${TOPSRCDIR}/servers/slapd/schema ${SCHEMADIR}
200 if test -d ${TESTDIR} ; then
201 if test $PRESERVE = no ; then
202 echo "Cleaning up test run directory leftover from previous run."
203 /bin/rm -rf ${TESTDIR}
204 elif test $PRESERVE = yes ; then
205 echo "Cleaning up only database directories leftover from previous run."
206 /bin/rm -rf ${TESTDIR}/db.*
209 if test $BACKEND = ndb ; then
210 mysql --user root <<EOF
211 drop database if exists db_1;
212 drop database if exists db_2;
213 drop database if exists db_3;
214 drop database if exists db_4;
215 drop database if exists db_5;
216 drop database if exists db_6;
221 if test $USERDATA = yes ; then
222 if test ! -d userdata ; then
223 echo "User data directory (userdata) does not exist."
226 cp -R userdata/* ${TESTDIR}
229 # disable LDAP initialization
230 LDAPNOINIT=true; export LDAPNOINIT
232 echo "Running ${SCRIPT} for ${BACKEND}..."
233 while [ $COUNTER -le $LOOP ]; do
234 if [ $LOOP -gt 1 ]; then
235 echo "Running $COUNTER of $LOOP iterations"
240 if test $CLEAN = yes ; then
241 echo "Cleaning up test run directory from this run."
242 /bin/rm -rf ${TESTDIR}
243 echo "Cleaning up symlinks."
244 /bin/rm -f ${DATADIR} ${SCHEMADIR}
247 if [ $RC -ne 0 ]; then
250 COUNTER=`expr $COUNTER + 1`
251 if [ $COUNTER -le $LOOP ]; then
252 echo "Cleaning up test run directory from this run."
253 /bin/rm -rf ${TESTDIR}