3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2009 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
29 AC_ldap=ldap@BUILD_LDAP@
30 AC_meta=meta@BUILD_META@
31 AC_monitor=@BUILD_MONITOR@
32 AC_relay=relay@BUILD_RELAY@
36 AC_accesslog=accesslog@BUILD_ACCESSLOG@
38 AC_dynlist=dynlist@BUILD_DYNLIST@
39 AC_memberof=memberof@BUILD_MEMBEROF@
40 AC_pcache=pcache@BUILD_PROXYCACHE@
41 AC_ppolicy=ppolicy@BUILD_PPOLICY@
42 AC_refint=refint@BUILD_REFINT@
43 AC_retcode=retcode@BUILD_RETCODE@
44 AC_translucent=translucent@BUILD_TRANSLUCENT@
45 AC_unique=unique@BUILD_UNIQUE@
47 AC_syncprov=syncprov@BUILD_SYNCPROV@
48 AC_valsort=valsort@BUILD_VALSORT@
51 AC_WITH_SASL=@WITH_SASL@
52 AC_WITH_TLS=@WITH_TLS@
53 AC_WITH_MODULES_ENABLED=@WITH_MODULES_ENABLED@
54 AC_ACI_ENABLED=aci@WITH_ACI_ENABLED@
55 AC_THREADS=threads@BUILD_THREAD@
56 AC_LIBS_DYNAMIC=lib@BUILD_LIBS_DYNAMIC@
59 if test "${AC_ldap}" = "ldapmod" && test "${AC_LIBS_DYNAMIC}" = "static" ; then
62 if test "${AC_meta}" = "metamod" && test "${AC_LIBS_DYNAMIC}" = "static" ; then
66 export AC_bdb AC_hdb AC_ldap AC_meta AC_monitor AC_relay AC_sql \
67 AC_accesslog AC_dds AC_dynlist AC_memberof AC_pcache AC_ppolicy \
68 AC_refint AC_retcode AC_rwm AC_unique AC_syncprov AC_translucent \
70 AC_WITH_SASL AC_WITH_TLS AC_WITH_MODULES_ENABLED AC_ACI_ENABLED \
71 AC_THREADS AC_LIBS_DYNAMIC
73 if test ! -x ../servers/slapd/slapd ; then
74 echo "Could not locate slapd(8)"
82 PRESERVE=${PRESERVE-no}
83 SYNCMODE=${SYNCMODE-rp}
88 while test $# -gt 0 ; do
102 NUM="`echo $2 | sed 's/[0-9]//g'`"
103 if [ -z "$NUM" ]; then
106 echo "Loop variable not an int: $2"
107 echo "$USAGE"; exit 1
122 echo "unknown sync mode $2"
123 echo "$USAGE"; exit 1
141 echo "$USAGE"; exit 1
149 if test -z "$BACKEND" ; then
150 for b in bdb hdb ; do
151 if eval "test \"\$AC_$b\" != no" ; then
156 if test -z "$BACKEND" ; then
157 echo "No suitable default database backend configured" >&2
161 BACKENDTYPE=`eval 'echo $AC_'$BACKEND`
162 if test "x$BACKENDTYPE" = "x" ; then
163 BACKENDTYPE="unknown"
165 export BACKEND BACKENDTYPE WAIT KILLSERVERS PRESERVE SYNCMODE USERDATA
167 if test $# = 0 ; then
168 echo "$USAGE"; exit 1
171 # need defines.sh for the definitions of the directories
172 . $SRCDIR/scripts/defines.sh
174 SCRIPTDIR="${SRCDIR}/scripts"
178 if test -x "${SCRIPTDIR}/${SCRIPTNAME}" ; then
179 SCRIPT="${SCRIPTDIR}/${SCRIPTNAME}"
180 elif test -x "`echo ${SCRIPTDIR}/test*-${SCRIPTNAME}`"; then
181 SCRIPT="`echo ${SCRIPTDIR}/test*-${SCRIPTNAME}`"
182 elif test -x "`echo ${SCRIPTDIR}/${SCRIPTNAME}-*`"; then
183 SCRIPT="`echo ${SCRIPTDIR}/${SCRIPTNAME}-*`"
185 echo "run: ${SCRIPTNAME} not found (or not executable)"
189 if test ! -r ${DATADIR}/test.ldif ; then
190 ${LN_S} ${SRCDIR}/data ${DATADIR}
192 if test ! -r ${SCHEMADIR}/core.schema ; then
193 ${LN_S} ${TOPSRCDIR}/servers/slapd/schema ${SCHEMADIR}
196 if test -d ${TESTDIR} ; then
197 if test $PRESERVE = no ; then
198 echo "Cleaning up test run directory leftover from previous run."
199 /bin/rm -rf ${TESTDIR}
200 elif test $PRESERVE = yes ; then
201 echo "Cleaning up only database directories leftover from previous run."
202 /bin/rm -rf ${TESTDIR}/db.*
205 if test $BACKEND = ndb ; then
206 mysql --user root <<EOF
207 drop database if exists db_1;
208 drop database if exists db_2;
209 drop database if exists db_3;
210 drop database if exists db_4;
211 drop database if exists db_5;
212 drop database if exists db_6;
217 if test $USERDATA = yes ; then
218 if test ! -d userdata ; then
219 echo "User data directory (userdata) does not exist."
222 cp -R userdata/* ${TESTDIR}
225 # disable LDAP initialization
226 LDAPNOINIT=true; export LDAPNOINIT
228 echo "Running ${SCRIPT}..."
229 while [ $COUNTER -le $LOOP ]; do
230 if [ $LOOP -gt 1 ]; then
231 echo "Running $COUNTER of $LOOP iterations"
236 if test $CLEAN = yes ; then
237 echo "Cleaning up test run directory from this run."
238 /bin/rm -rf ${TESTDIR}
239 echo "Cleaning up symlinks."
240 /bin/rm -f ${DATADIR} ${SCHEMADIR}
243 if [ $RC -ne 0 ]; then
246 COUNTER=`expr $COUNTER + 1`
247 if [ $COUNTER -le $LOOP ]; then
248 echo "Cleaning up test run directory from this run."
249 /bin/rm -rf ${TESTDIR}