]> git.sur5r.net Git - openldap/blob - tests/run.in
clarify the required access to add the suffix of a database (consequence of ITS#4552)
[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_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_pcache=pcache@BUILD_PROXYCACHE@
40 AC_ppolicy=ppolicy@BUILD_PPOLICY@
41 AC_refint=refint@BUILD_REFINT@
42 AC_retcode=retcode@BUILD_RETCODE@
43 AC_translucent=translucent@BUILD_TRANSLUCENT@
44 AC_unique=unique@BUILD_UNIQUE@
45 AC_rwm=rwm@BUILD_RWM@
46 AC_syncprov=syncprov@BUILD_SYNCPROV@
47 AC_valsort=valsort@BUILD_VALSORT@
48
49 # misc
50 AC_WITH_SASL=@WITH_SASL@
51 AC_WITH_TLS=@WITH_TLS@
52 AC_WITH_MODULES_ENABLED=@WITH_MODULES_ENABLED@
53 AC_ACI_ENABLED=aci@WITH_ACI_ENABLED@
54 AC_THREADS=threads@BUILD_THREAD@
55
56 export AC_bdb AC_hdb AC_ldap AC_meta AC_monitor AC_relay AC_sql \
57         AC_accesslog AC_dynlist AC_pcache AC_ppolicy AC_refint AC_retcode \
58         AC_rwm AC_unique AC_syncprov AC_translucent AC_valsort \
59         AC_dds \
60         AC_WITH_SASL AC_WITH_TLS AC_WITH_MODULES_ENABLED AC_ACI_ENABLED \
61         AC_THREADS
62
63 if test ! -x ../servers/slapd/slapd ; then
64         echo "Could not locate slapd(8)"
65         exit 1
66 fi
67
68 BACKEND=
69 CLEAN=no
70 WAIT=0
71 KILLSERVERS=yes
72 PRESERVE=${PRESERVE-no}
73 USERDATA=no
74
75 while test $# -gt 0 ; do
76         case "$1" in
77                 -b | -backend)
78                         BACKEND="$2"
79                         shift; shift ;;
80
81                 -c | -clean)
82                         CLEAN=yes
83                         shift ;;
84
85                 -k | -kill)
86                         KILLSERVERS=no
87                         shift ;;
88
89                 -p | -preserve)
90                         PRESERVE=yes
91                         shift ;;
92
93                 -u | -userdata)
94                         USERDATA=yes
95                         shift ;;
96
97                 -w | -wait)
98                         WAIT=1
99                         shift ;;
100
101                 -)
102                         shift
103                         break ;;
104
105                 -*)
106                         echo "$USAGE"; exit 1
107                         ;;
108
109                 *)
110                         break ;;
111         esac
112 done
113
114 if test -z "$BACKEND" ; then
115         for b in bdb hdb ; do
116                 if eval "test \"\$AC_$b\" != no" ; then
117                         BACKEND=$b
118                         break
119                 fi
120         done
121         if test -z "$BACKEND" ; then
122                 echo "No suitable default database backend configured" >&2
123                 exit 1
124         fi
125 fi
126 BACKENDTYPE=`eval 'echo $AC_'$BACKEND`
127 if test "x$BACKENDTYPE" = "x" ; then
128         BACKENDTYPE="unknown"
129 fi
130 export BACKEND BACKENDTYPE WAIT KILLSERVERS PRESERVE USERDATA
131
132 if test $# = 0 ; then
133         echo "$USAGE"; exit 1
134 fi
135
136 # need defines.sh for the definitions of the directories
137 . $SRCDIR/scripts/defines.sh
138
139 SCRIPTDIR="${SRCDIR}/scripts"
140 SCRIPTNAME="$1"
141 shift
142
143 if test -x "${SCRIPTDIR}/${SCRIPTNAME}" ; then
144         SCRIPT="${SCRIPTDIR}/${SCRIPTNAME}"
145 elif test -x "`echo ${SCRIPTDIR}/test*-${SCRIPTNAME}`"; then
146         SCRIPT="`echo ${SCRIPTDIR}/test*-${SCRIPTNAME}`"
147 elif test -x "`echo ${SCRIPTDIR}/${SCRIPTNAME}-*`"; then
148         SCRIPT="`echo ${SCRIPTDIR}/${SCRIPTNAME}-*`"
149 else
150         echo "run: ${SCRIPTNAME} not found (or not executable)"
151         exit 1;
152 fi
153
154 if test ! -r ${DATADIR}/test.ldif ; then
155         ${LN_S} ${SRCDIR}/data ${DATADIR}
156 fi
157 if test ! -r ${SCHEMADIR}/core.schema ; then
158         ${LN_S} ${TOPSRCDIR}/servers/slapd/schema ${SCHEMADIR}
159 fi
160
161 if test -d ${TESTDIR} ; then
162         if test $PRESERVE = no ; then
163                 echo "Cleaning up test run directory leftover from previous run."
164                 /bin/rm -rf ${TESTDIR}
165         elif test $PRESERVE = yes ; then
166                 echo "Cleaning up only database directories leftover from previous run."
167                 /bin/rm -rf ${TESTDIR}/db.*
168         fi
169 fi
170
171 if test $USERDATA = yes ; then
172         if test ! -d userdata ; then
173                 echo "User data directory (userdata) does not exist."
174                 exit 1
175         fi
176         mkdir -p ${TESTDIR}
177         cp -R userdata/* ${TESTDIR}
178 fi
179
180 # disable LDAP initialization
181 LDAPNOINIT=true; export LDAPNOINIT
182
183 echo "Running ${SCRIPT}..."
184 $SCRIPT $*
185 RC=$?
186
187 if test $CLEAN = yes ; then
188         echo "Cleaning up test run directory from this run."
189         /bin/rm -rf ${TESTDIR}
190         echo "Cleaning up symlinks."
191         /bin/rm -f ${DATADIR} ${SCHEMADIR}
192 fi
193
194 exit $RC