]> git.sur5r.net Git - openldap/blob - tests/run.in
Update copyright for next release
[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-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
16 USAGE="$0 [-b <backend>] [-c] [-k] [-p] [-s {ro|rp}] [-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_meta=meta@BUILD_META@
31 AC_monitor=@BUILD_MONITOR@
32 AC_relay=relay@BUILD_RELAY@
33 AC_sql=sql@BUILD_SQL@
34
35 # overlays
36 AC_accesslog=accesslog@BUILD_ACCESSLOG@
37 AC_dds=dds@BUILD_DDS@
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@
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 AC_LIBS_DYNAMIC=lib@BUILD_LIBS_DYNAMIC@
57
58 # sanitize
59 if test "${AC_ldap}" = "ldapmod" && test "${AC_LIBS_DYNAMIC}" = "static" ; then
60         AC_ldap="ldapno"
61 fi
62 if test "${AC_meta}" = "metamod" && test "${AC_LIBS_DYNAMIC}" = "static" ; then
63         AC_meta="metano"
64 fi
65
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 \
69         AC_valsort \
70         AC_WITH_SASL AC_WITH_TLS AC_WITH_MODULES_ENABLED AC_ACI_ENABLED \
71         AC_THREADS AC_LIBS_DYNAMIC
72
73 if test ! -x ../servers/slapd/slapd ; then
74         echo "Could not locate slapd(8)"
75         exit 1
76 fi
77
78 BACKEND=
79 CLEAN=no
80 WAIT=0
81 KILLSERVERS=yes
82 PRESERVE=${PRESERVE-no}
83 SYNCMODE=${SYNCMODE-rp}
84 USERDATA=no
85
86 while test $# -gt 0 ; do
87         case "$1" in
88                 -b | -backend)
89                         BACKEND="$2"
90                         shift; shift ;;
91
92                 -c | -clean)
93                         CLEAN=yes
94                         shift ;;
95
96                 -k | -kill)
97                         KILLSERVERS=no
98                         shift ;;
99
100                 -p | -preserve)
101                         PRESERVE=yes
102                         shift ;;
103
104                 -s | -syncmode)
105                         case "$2" in
106                                 ro | rp)
107                                         SYNCMODE="$2"
108                                         ;;
109                                 *)
110                                         echo "unknown sync mode $2"
111                                         echo "$USAGE"; exit 1
112                                         ;;
113                         esac
114                         shift; shift ;;
115
116                 -u | -userdata)
117                         USERDATA=yes
118                         shift ;;
119
120                 -w | -wait)
121                         WAIT=1
122                         shift ;;
123
124                 -)
125                         shift
126                         break ;;
127
128                 -*)
129                         echo "$USAGE"; exit 1
130                         ;;
131
132                 *)
133                         break ;;
134         esac
135 done
136
137 if test -z "$BACKEND" ; then
138         for b in bdb hdb ; do
139                 if eval "test \"\$AC_$b\" != no" ; then
140                         BACKEND=$b
141                         break
142                 fi
143         done
144         if test -z "$BACKEND" ; then
145                 echo "No suitable default database backend configured" >&2
146                 exit 1
147         fi
148 fi
149 BACKENDTYPE=`eval 'echo $AC_'$BACKEND`
150 if test "x$BACKENDTYPE" = "x" ; then
151         BACKENDTYPE="unknown"
152 fi
153 export BACKEND BACKENDTYPE WAIT KILLSERVERS PRESERVE SYNCMODE USERDATA
154
155 if test $# = 0 ; then
156         echo "$USAGE"; exit 1
157 fi
158
159 # need defines.sh for the definitions of the directories
160 . $SRCDIR/scripts/defines.sh
161
162 SCRIPTDIR="${SRCDIR}/scripts"
163 SCRIPTNAME="$1"
164 shift
165
166 if test -x "${SCRIPTDIR}/${SCRIPTNAME}" ; then
167         SCRIPT="${SCRIPTDIR}/${SCRIPTNAME}"
168 elif test -x "`echo ${SCRIPTDIR}/test*-${SCRIPTNAME}`"; then
169         SCRIPT="`echo ${SCRIPTDIR}/test*-${SCRIPTNAME}`"
170 elif test -x "`echo ${SCRIPTDIR}/${SCRIPTNAME}-*`"; then
171         SCRIPT="`echo ${SCRIPTDIR}/${SCRIPTNAME}-*`"
172 else
173         echo "run: ${SCRIPTNAME} not found (or not executable)"
174         exit 1;
175 fi
176
177 if test ! -r ${DATADIR}/test.ldif ; then
178         ${LN_S} ${SRCDIR}/data ${DATADIR}
179 fi
180 if test ! -r ${SCHEMADIR}/core.schema ; then
181         ${LN_S} ${TOPSRCDIR}/servers/slapd/schema ${SCHEMADIR}
182 fi
183
184 if test -d ${TESTDIR} ; then
185         if test $PRESERVE = no ; then
186                 echo "Cleaning up test run directory leftover from previous run."
187                 /bin/rm -rf ${TESTDIR}
188         elif test $PRESERVE = yes ; then
189                 echo "Cleaning up only database directories leftover from previous run."
190                 /bin/rm -rf ${TESTDIR}/db.*
191         fi
192 fi
193 if test $BACKEND = ndb ; then
194         mysql --user root <<EOF
195         drop database if exists db_1;
196         drop database if exists db_2;
197         drop database if exists db_3;
198         drop database if exists db_4;
199         drop database if exists db_5;
200         drop database if exists db_6;
201 EOF
202 fi
203 mkdir -p ${TESTDIR}
204
205 if test $USERDATA = yes ; then
206         if test ! -d userdata ; then
207                 echo "User data directory (userdata) does not exist."
208                 exit 1
209         fi
210         cp -R userdata/* ${TESTDIR}
211 fi
212
213 # disable LDAP initialization
214 LDAPNOINIT=true; export LDAPNOINIT
215
216 echo "Running ${SCRIPT}..."
217 $SCRIPT $*
218 RC=$?
219
220 if test $CLEAN = yes ; then
221         echo "Cleaning up test run directory from this run."
222         /bin/rm -rf ${TESTDIR}
223         echo "Cleaning up symlinks."
224         /bin/rm -f ${DATADIR} ${SCHEMADIR}
225 fi
226
227 exit $RC