run.in revision 1.1.1.3
1#!/bin/sh 2# OpenLDAP: pkg/ldap/tests/run.in,v 1.47.2.16 2010/04/19 19:14:26 quanah Exp 3## This work is part of OpenLDAP Software <http://www.openldap.org/>. 4## 5## Copyright 1998-2010 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_null=@BUILD_NULL@ 31 32# other backends 33AC_ldap=ldap@BUILD_LDAP@ 34AC_meta=meta@BUILD_META@ 35AC_monitor=@BUILD_MONITOR@ 36AC_relay=relay@BUILD_RELAY@ 37AC_sql=sql@BUILD_SQL@ 38 39# overlays 40AC_accesslog=accesslog@BUILD_ACCESSLOG@ 41AC_dds=dds@BUILD_DDS@ 42AC_dynlist=dynlist@BUILD_DYNLIST@ 43AC_memberof=memberof@BUILD_MEMBEROF@ 44AC_pcache=pcache@BUILD_PROXYCACHE@ 45AC_ppolicy=ppolicy@BUILD_PPOLICY@ 46AC_refint=refint@BUILD_REFINT@ 47AC_retcode=retcode@BUILD_RETCODE@ 48AC_translucent=translucent@BUILD_TRANSLUCENT@ 49AC_unique=unique@BUILD_UNIQUE@ 50AC_rwm=rwm@BUILD_RWM@ 51AC_syncprov=syncprov@BUILD_SYNCPROV@ 52AC_valsort=valsort@BUILD_VALSORT@ 53 54# misc 55AC_WITH_SASL=@WITH_SASL@ 56AC_WITH_TLS=@WITH_TLS@ 57AC_WITH_MODULES_ENABLED=@WITH_MODULES_ENABLED@ 58AC_ACI_ENABLED=aci@WITH_ACI_ENABLED@ 59AC_THREADS=threads@BUILD_THREAD@ 60AC_LIBS_DYNAMIC=lib@BUILD_LIBS_DYNAMIC@ 61 62# sanitize 63if test "${AC_ldap}" = "ldapmod" && test "${AC_LIBS_DYNAMIC}" = "static" ; then 64 AC_ldap="ldapno" 65fi 66if test "${AC_meta}" = "metamod" && test "${AC_LIBS_DYNAMIC}" = "static" ; then 67 AC_meta="metano" 68fi 69 70export 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 \ 73 AC_valsort \ 74 AC_WITH_SASL AC_WITH_TLS AC_WITH_MODULES_ENABLED AC_ACI_ENABLED \ 75 AC_THREADS AC_LIBS_DYNAMIC 76 77if test ! -x ../servers/slapd/slapd ; then 78 echo "Could not locate slapd(8)" 79 exit 1 80fi 81 82BACKEND= 83CLEAN=no 84WAIT=0 85KILLSERVERS=yes 86PRESERVE=${PRESERVE-no} 87SYNCMODE=${SYNCMODE-rp} 88USERDATA=no 89LOOP=1 90COUNTER=1 91 92while test $# -gt 0 ; do 93 case "$1" in 94 -b | -backend) 95 BACKEND="$2" 96 shift; shift ;; 97 98 -c | -clean) 99 CLEAN=yes 100 shift ;; 101 102 -k | -kill) 103 KILLSERVERS=no 104 shift ;; 105 -l | -loop) 106 NUM="`echo $2 | sed 's/[0-9]//g'`" 107 if [ -z "$NUM" ]; then 108 LOOP=$2 109 else 110 echo "Loop variable not an int: $2" 111 echo "$USAGE"; exit 1 112 fi 113 shift ; 114 shift ;; 115 116 -p | -preserve) 117 PRESERVE=yes 118 shift ;; 119 120 -s | -syncmode) 121 case "$2" in 122 ro | rp) 123 SYNCMODE="$2" 124 ;; 125 *) 126 echo "unknown sync mode $2" 127 echo "$USAGE"; exit 1 128 ;; 129 esac 130 shift; shift ;; 131 132 -u | -userdata) 133 USERDATA=yes 134 shift ;; 135 136 -w | -wait) 137 WAIT=1 138 shift ;; 139 140 -) 141 shift 142 break ;; 143 144 -*) 145 echo "$USAGE"; exit 1 146 ;; 147 148 *) 149 break ;; 150 esac 151done 152 153if test -z "$BACKEND" ; then 154 for b in bdb hdb ; do 155 if eval "test \"\$AC_$b\" != no" ; then 156 BACKEND=$b 157 break 158 fi 159 done 160 if test -z "$BACKEND" ; then 161 echo "No suitable default database backend configured" >&2 162 exit 1 163 fi 164fi 165BACKENDTYPE=`eval 'echo $AC_'$BACKEND` 166if test "x$BACKENDTYPE" = "x" ; then 167 BACKENDTYPE="unknown" 168fi 169export BACKEND BACKENDTYPE WAIT KILLSERVERS PRESERVE SYNCMODE USERDATA 170 171if test $# = 0 ; then 172 echo "$USAGE"; exit 1 173fi 174 175# need defines.sh for the definitions of the directories 176. $SRCDIR/scripts/defines.sh 177 178SCRIPTDIR="${SRCDIR}/scripts" 179SCRIPTNAME="$1" 180shift 181 182if test -x "${SCRIPTDIR}/${SCRIPTNAME}" ; then 183 SCRIPT="${SCRIPTDIR}/${SCRIPTNAME}" 184elif test -x "`echo ${SCRIPTDIR}/test*-${SCRIPTNAME}`"; then 185 SCRIPT="`echo ${SCRIPTDIR}/test*-${SCRIPTNAME}`" 186elif test -x "`echo ${SCRIPTDIR}/${SCRIPTNAME}-*`"; then 187 SCRIPT="`echo ${SCRIPTDIR}/${SCRIPTNAME}-*`" 188else 189 echo "run: ${SCRIPTNAME} not found (or not executable)" 190 exit 1; 191fi 192 193if test ! -r ${DATADIR}/test.ldif ; then 194 ${LN_S} ${SRCDIR}/data ${DATADIR} 195fi 196if test ! -r ${SCHEMADIR}/core.schema ; then 197 ${LN_S} ${TOPSRCDIR}/servers/slapd/schema ${SCHEMADIR} 198fi 199 200if 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.* 207 fi 208fi 209if 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; 217EOF 218fi 219mkdir -p ${TESTDIR} 220 221if test $USERDATA = yes ; then 222 if test ! -d userdata ; then 223 echo "User data directory (userdata) does not exist." 224 exit 1 225 fi 226 cp -R userdata/* ${TESTDIR} 227fi 228 229# disable LDAP initialization 230LDAPNOINIT=true; export LDAPNOINIT 231 232echo "Running ${SCRIPT} for ${BACKEND}..." 233while [ $COUNTER -le $LOOP ]; do 234 if [ $LOOP -gt 1 ]; then 235 echo "Running $COUNTER of $LOOP iterations" 236 fi 237 $SCRIPT $* 238 RC=$? 239 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} 245 fi 246 247 if [ $RC -ne 0 ]; then 248 exit $RC 249 else 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} 254 fi 255 fi 256done 257exit $RC 258