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