1#!/bin/sh 2# $OpenLDAP$ 3## This work is part of OpenLDAP Software <http://www.openldap.org/>. 4## 5## Copyright 1998-2011 The OpenLDAP Foundation. 6## All rights reserved. 7## 8## Redistribution and use in source and binary forms, with or without 9## modification, are permitted only as authorized by the OpenLDAP 10## Public License. 11## 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>. 15 16USAGE="$0 [-b <backend>] [-c] [-k] [-l #] [-p] [-s {ro|rp}] [-u] [-w] <script>" 17 18# configure generated 19SRCDIR="@srcdir@" 20TOPSRCDIR="@top_srcdir@" 21LN_S="@LN_S@" 22EGREP_CMD="@EGREP@" 23 24export SRCDIR TOPSRCDIR LN_S EGREP_CMD 25 26# backends known to ./run -b <backend> (used to deduce $BACKENDTYPE) 27AC_bdb=@BUILD_BDB@ 28AC_hdb=@BUILD_HDB@ 29AC_ldif=yes 30AC_mdb=@BUILD_MDB@ 31AC_null=@BUILD_NULL@ 32 33# other backends 34AC_ldap=ldap@BUILD_LDAP@ 35AC_meta=meta@BUILD_META@ 36AC_monitor=@BUILD_MONITOR@ 37AC_relay=relay@BUILD_RELAY@ 38AC_sql=sql@BUILD_SQL@ 39 40# overlays 41AC_accesslog=accesslog@BUILD_ACCESSLOG@ 42AC_dds=dds@BUILD_DDS@ 43AC_dynlist=dynlist@BUILD_DYNLIST@ 44AC_memberof=memberof@BUILD_MEMBEROF@ 45AC_pcache=pcache@BUILD_PROXYCACHE@ 46AC_ppolicy=ppolicy@BUILD_PPOLICY@ 47AC_refint=refint@BUILD_REFINT@ 48AC_retcode=retcode@BUILD_RETCODE@ 49AC_translucent=translucent@BUILD_TRANSLUCENT@ 50AC_unique=unique@BUILD_UNIQUE@ 51AC_rwm=rwm@BUILD_RWM@ 52AC_syncprov=syncprov@BUILD_SYNCPROV@ 53AC_valsort=valsort@BUILD_VALSORT@ 54 55# misc 56AC_WITH_SASL=@WITH_SASL@ 57AC_WITH_TLS=@WITH_TLS@ 58AC_WITH_MODULES_ENABLED=@WITH_MODULES_ENABLED@ 59AC_ACI_ENABLED=aci@WITH_ACI_ENABLED@ 60AC_THREADS=threads@BUILD_THREAD@ 61AC_LIBS_DYNAMIC=lib@BUILD_LIBS_DYNAMIC@ 62 63# sanitize 64if test "${AC_ldap}" = "ldapmod" && test "${AC_LIBS_DYNAMIC}" = "static" ; then 65 AC_ldap="ldapno" 66fi 67if test "${AC_meta}" = "metamod" && test "${AC_LIBS_DYNAMIC}" = "static" ; then 68 AC_meta="metano" 69fi 70 71export AC_bdb AC_hdb AC_ldap AC_mdb AC_meta AC_monitor AC_null AC_relay AC_sql \ 72 AC_accesslog AC_dds AC_dynlist AC_memberof AC_pcache AC_ppolicy \ 73 AC_refint AC_retcode AC_rwm AC_unique AC_syncprov AC_translucent \ 74 AC_valsort \ 75 AC_WITH_SASL AC_WITH_TLS AC_WITH_MODULES_ENABLED AC_ACI_ENABLED \ 76 AC_THREADS AC_LIBS_DYNAMIC 77 78if test ! -x ../servers/slapd/slapd ; then 79 echo "Could not locate slapd(8)" 80 exit 1 81fi 82 83BACKEND= 84CLEAN=no 85WAIT=0 86KILLSERVERS=yes 87PRESERVE=${PRESERVE-no} 88SYNCMODE=${SYNCMODE-rp} 89USERDATA=no 90LOOP=1 91COUNTER=1 92 93while test $# -gt 0 ; do 94 case "$1" in 95 -b | -backend) 96 BACKEND="$2" 97 shift; shift ;; 98 99 -c | -clean) 100 CLEAN=yes 101 shift ;; 102 103 -k | -kill) 104 KILLSERVERS=no 105 shift ;; 106 -l | -loop) 107 NUM="`echo $2 | sed 's/[0-9]//g'`" 108 if [ -z "$NUM" ]; then 109 LOOP=$2 110 else 111 echo "Loop variable not an int: $2" 112 echo "$USAGE"; exit 1 113 fi 114 shift ; 115 shift ;; 116 117 -p | -preserve) 118 PRESERVE=yes 119 shift ;; 120 121 -s | -syncmode) 122 case "$2" in 123 ro | rp) 124 SYNCMODE="$2" 125 ;; 126 *) 127 echo "unknown sync mode $2" 128 echo "$USAGE"; exit 1 129 ;; 130 esac 131 shift; shift ;; 132 133 -u | -userdata) 134 USERDATA=yes 135 shift ;; 136 137 -w | -wait) 138 WAIT=1 139 shift ;; 140 141 -) 142 shift 143 break ;; 144 145 -*) 146 echo "$USAGE"; exit 1 147 ;; 148 149 *) 150 break ;; 151 esac 152done 153 154if test -z "$BACKEND" ; then 155 for b in bdb hdb mdb ; do 156 if eval "test \"\$AC_$b\" != no" ; then 157 BACKEND=$b 158 break 159 fi 160 done 161 if test -z "$BACKEND" ; then 162 echo "No suitable default database backend configured" >&2 163 exit 1 164 fi 165fi 166 167BACKENDTYPE=`eval 'echo $AC_'$BACKEND` 168if test "x$BACKENDTYPE" = "x" ; then 169 BACKENDTYPE="unknown" 170fi 171 172# Backend features. indexdb: indexing and unchecked limit. 173# maindb: main storage backend. Currently index,limits,mode,paged results. 174INDEXDB=noindexdb MAINDB=nomaindb 175case $BACKEND in 176 bdb|hdb|mdb) INDEXDB=indexdb MAINDB=maindb ;; 177 ndb) INDEXDB=indexdb ;; 178esac 179 180export BACKEND BACKENDTYPE INDEXDB MAINDB \ 181 WAIT KILLSERVERS PRESERVE SYNCMODE USERDATA 182 183if test $# = 0 ; then 184 echo "$USAGE"; exit 1 185fi 186 187# need defines.sh for the definitions of the directories 188. $SRCDIR/scripts/defines.sh 189 190SCRIPTDIR="${SRCDIR}/scripts" 191SCRIPTNAME="$1" 192shift 193 194if test -x "${SCRIPTDIR}/${SCRIPTNAME}" ; then 195 SCRIPT="${SCRIPTDIR}/${SCRIPTNAME}" 196elif test -x "`echo ${SCRIPTDIR}/test*-${SCRIPTNAME}`"; then 197 SCRIPT="`echo ${SCRIPTDIR}/test*-${SCRIPTNAME}`" 198elif test -x "`echo ${SCRIPTDIR}/${SCRIPTNAME}-*`"; then 199 SCRIPT="`echo ${SCRIPTDIR}/${SCRIPTNAME}-*`" 200else 201 echo "run: ${SCRIPTNAME} not found (or not executable)" 202 exit 1; 203fi 204 205if test ! -r ${DATADIR}/test.ldif ; then 206 ${LN_S} ${SRCDIR}/data ${DATADIR} 207fi 208if test ! -r ${SCHEMADIR}/core.schema ; then 209 ${LN_S} ${TOPSRCDIR}/servers/slapd/schema ${SCHEMADIR} 210fi 211 212if test -d ${TESTDIR} ; then 213 if test $PRESERVE = no ; then 214 echo "Cleaning up test run directory leftover from previous run." 215 /bin/rm -rf ${TESTDIR} 216 elif test $PRESERVE = yes ; then 217 echo "Cleaning up only database directories leftover from previous run." 218 /bin/rm -rf ${TESTDIR}/db.* 219 fi 220fi 221if test $BACKEND = ndb ; then 222 mysql --user root <<EOF 223 drop database if exists db_1; 224 drop database if exists db_2; 225 drop database if exists db_3; 226 drop database if exists db_4; 227 drop database if exists db_5; 228 drop database if exists db_6; 229EOF 230fi 231mkdir -p ${TESTDIR} 232 233if test $USERDATA = yes ; then 234 if test ! -d userdata ; then 235 echo "User data directory (userdata) does not exist." 236 exit 1 237 fi 238 cp -R userdata/* ${TESTDIR} 239fi 240 241# disable LDAP initialization 242LDAPNOINIT=true; export LDAPNOINIT 243 244echo "Running ${SCRIPT} for ${BACKEND}..." 245while [ $COUNTER -le $LOOP ]; do 246 if [ $LOOP -gt 1 ]; then 247 echo "Running $COUNTER of $LOOP iterations" 248 fi 249 $SCRIPT $* 250 RC=$? 251 252 if test $CLEAN = yes ; then 253 echo "Cleaning up test run directory from this run." 254 /bin/rm -rf ${TESTDIR} 255 echo "Cleaning up symlinks." 256 /bin/rm -f ${DATADIR} ${SCHEMADIR} 257 fi 258 259 if [ $RC -ne 0 ]; then 260 if [ $LOOP -gt 1 ]; then 261 echo "Failed after $COUNTER of $LOOP iterations" 262 fi 263 exit $RC 264 else 265 COUNTER=`expr $COUNTER + 1` 266 if [ $COUNTER -le $LOOP ]; then 267 echo "Cleaning up test run directory from this run." 268 /bin/rm -rf ${TESTDIR} 269 fi 270 fi 271done 272exit $RC 273