]> git.sur5r.net Git - openldap/blob - tests/run.in
add experimental, non-advertised support for obsolete version of proxyAuthz
[openldap] / tests / run.in
1 #!/bin/sh
2 # $OpenLDAP$
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ##
5 ## Copyright 1998-2006 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
16 USAGE="$0 [-b <backend>] [-c] [-k] [-p] [-u] [-w] <script>"
17
18 # configure generated
19 SRCDIR="@srcdir@"
20 TOPSRCDIR="@top_srcdir@"
21 LN_S="@LN_S@"
22 EGREP_CMD="@EGREP@"
23
24 export SRCDIR TOPSRCDIR LN_S EGREP_CMD
25
26 # backends
27 AC_bdb=@BUILD_BDB@
28 AC_hdb=@BUILD_HDB@
29 AC_ldap=ldap@BUILD_LDAP@
30 AC_ldbm=@BUILD_LDBM@
31 AC_meta=meta@BUILD_META@
32 AC_monitor=@BUILD_MONITOR@
33 AC_relay=relay@BUILD_RELAY@
34 AC_sql=sql@BUILD_SQL@
35
36 # overlays
37 AC_accesslog=accesslog@BUILD_ACCESSLOG@
38 AC_dds=dds@BUILD_DDS@
39 AC_dynlist=dynlist@BUILD_DYNLIST@
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@
46 AC_rwm=rwm@BUILD_RWM@
47 AC_syncprov=syncprov@BUILD_SYNCPROV@
48 AC_valsort=valsort@BUILD_VALSORT@
49
50 # misc
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
57 export AC_bdb AC_hdb AC_ldap AC_ldbm AC_meta AC_monitor AC_relay AC_sql \
58         AC_accesslog AC_dynlist AC_pcache AC_ppolicy AC_refint AC_retcode \
59         AC_rwm AC_unique AC_syncprov AC_translucent AC_valsort \
60         AC_dds \
61         AC_WITH_SASL AC_WITH_TLS AC_WITH_MODULES_ENABLED AC_ACI_ENABLED \
62         AC_THREADS
63
64 if test ! -x ../servers/slapd/slapd ; then
65         echo "Could not locate slapd(8)"
66         exit 1
67 fi
68
69 BACKEND=
70 CLEAN=no
71 WAIT=0
72 KILLSERVERS=yes
73 PRESERVE=${PRESERVE-no}
74 USERDATA=no
75
76 while test $# -gt 0 ; do
77         case "$1" in
78                 -b | -backend)
79                         BACKEND="$2"
80                         shift; shift ;;
81
82                 -c | -clean)
83                         CLEAN=yes
84                         shift ;;
85
86                 -k | -kill)
87                         KILLSERVERS=no
88                         shift ;;
89
90                 -p | -preserve)
91                         PRESERVE=yes
92                         shift ;;
93
94                 -u | -userdata)
95                         USERDATA=yes
96                         shift ;;
97
98                 -w | -wait)
99                         WAIT=1
100                         shift ;;
101
102                 -)
103                         shift
104                         break ;;
105
106                 -*)
107                         echo "$USAGE"; exit 1
108                         ;;
109
110                 *)
111                         break ;;
112         esac
113 done
114
115 if test -z "$BACKEND" ; then
116         for b in bdb ldbm hdb ; do
117                 if eval "test \"\$AC_$b\" != no" ; then
118                         BACKEND=$b
119                         break
120                 fi
121         done
122         if test -z "$BACKEND" ; then
123                 echo "No suitable default database backend configured" >&2
124                 exit 1
125         fi
126 fi
127 BACKENDTYPE=`eval 'echo $AC_'$BACKEND`
128 if test "x$BACKENDTYPE" = "x" ; then
129         BACKENDTYPE="unknown"
130 fi
131 export BACKEND BACKENDTYPE WAIT KILLSERVERS PRESERVE USERDATA
132
133 if test $# = 0 ; then
134         echo "$USAGE"; exit 1
135 fi
136
137 # need defines.sh for the definitions of the directories
138 . $SRCDIR/scripts/defines.sh
139
140 SCRIPTDIR="${SRCDIR}/scripts"
141 SCRIPTNAME="$1"
142 shift
143
144 if test -x "${SCRIPTDIR}/${SCRIPTNAME}" ; then
145         SCRIPT="${SCRIPTDIR}/${SCRIPTNAME}"
146 elif test -x "`echo ${SCRIPTDIR}/test*-${SCRIPTNAME}`"; then
147         SCRIPT="`echo ${SCRIPTDIR}/test*-${SCRIPTNAME}`"
148 elif test -x "`echo ${SCRIPTDIR}/${SCRIPTNAME}-*`"; then
149         SCRIPT="`echo ${SCRIPTDIR}/${SCRIPTNAME}-*`"
150 else
151         echo "run: ${SCRIPTNAME} not found (or not executable)"
152         exit 1;
153 fi
154
155 if test ! -r ${DATADIR}/test.ldif ; then
156         ${LN_S} ${SRCDIR}/data ${DATADIR}
157 fi
158 if test ! -r ${SCHEMADIR}/core.schema ; then
159         ${LN_S} ${TOPSRCDIR}/servers/slapd/schema ${SCHEMADIR}
160 fi
161
162 if test -d ${TESTDIR} ; then
163         if test $PRESERVE = no ; then
164                 echo "Cleaning up test run directory leftover from previous run."
165                 /bin/rm -rf ${TESTDIR}
166         elif test $PRESERVE = yes ; then
167                 echo "Cleaning up only database directories leftover from previous run."
168                 /bin/rm -rf ${TESTDIR}/db.*
169         fi
170 fi
171
172 if test $USERDATA = yes ; then
173         if test ! -d userdata ; then
174                 echo "User data directory (userdata) does not exist."
175                 exit 1
176         fi
177         mkdir -p ${TESTDIR}
178         cp -R userdata/* ${TESTDIR}
179 fi
180
181 # disable LDAP initialization
182 LDAPNOINIT=true; export LDAPNOINIT
183
184 echo "Running ${SCRIPT}..."
185 $SCRIPT $*
186 RC=$?
187
188 if test $CLEAN = yes ; then
189         echo "Cleaning up test run directory from this run."
190         /bin/rm -rf ${TESTDIR}
191         echo "Cleaning up symlinks."
192         /bin/rm -f ${DATADIR} ${SCHEMADIR}
193 fi
194
195 exit $RC