]> git.sur5r.net Git - openldap/blob - tests/run.in
Fix use of generated passwords
[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 AC_LIBS_DYNAMIC=lib@BUILD_LIBS_DYNAMIC@
56
57 # sanitize
58 if test "${AC_ldap}" = "ldapmod" -a "${AC_LIBS_DYNAMIC}" = "static" ; then
59         AC_ldap="ldapno"
60 fi
61 if test "${AC_meta}" = "metamod" -a "${AC_LIBS_DYNAMIC}" = "static" ; then
62         AC_meta="metano"
63 fi
64
65 export AC_bdb AC_hdb AC_ldap AC_meta AC_monitor AC_relay AC_sql \
66         AC_accesslog AC_dynlist AC_pcache AC_ppolicy AC_refint AC_retcode \
67         AC_rwm AC_unique AC_syncprov AC_translucent AC_valsort \
68         AC_dds \
69         AC_WITH_SASL AC_WITH_TLS AC_WITH_MODULES_ENABLED AC_ACI_ENABLED \
70         AC_THREADS AC_LIBS_DYNAMIC
71
72 if test ! -x ../servers/slapd/slapd ; then
73         echo "Could not locate slapd(8)"
74         exit 1
75 fi
76
77 BACKEND=
78 CLEAN=no
79 WAIT=0
80 KILLSERVERS=yes
81 PRESERVE=${PRESERVE-no}
82 USERDATA=no
83
84 while test $# -gt 0 ; do
85         case "$1" in
86                 -b | -backend)
87                         BACKEND="$2"
88                         shift; shift ;;
89
90                 -c | -clean)
91                         CLEAN=yes
92                         shift ;;
93
94                 -k | -kill)
95                         KILLSERVERS=no
96                         shift ;;
97
98                 -p | -preserve)
99                         PRESERVE=yes
100                         shift ;;
101
102                 -u | -userdata)
103                         USERDATA=yes
104                         shift ;;
105
106                 -w | -wait)
107                         WAIT=1
108                         shift ;;
109
110                 -)
111                         shift
112                         break ;;
113
114                 -*)
115                         echo "$USAGE"; exit 1
116                         ;;
117
118                 *)
119                         break ;;
120         esac
121 done
122
123 if test -z "$BACKEND" ; then
124         for b in bdb hdb ; do
125                 if eval "test \"\$AC_$b\" != no" ; then
126                         BACKEND=$b
127                         break
128                 fi
129         done
130         if test -z "$BACKEND" ; then
131                 echo "No suitable default database backend configured" >&2
132                 exit 1
133         fi
134 fi
135 BACKENDTYPE=`eval 'echo $AC_'$BACKEND`
136 if test "x$BACKENDTYPE" = "x" ; then
137         BACKENDTYPE="unknown"
138 fi
139 export BACKEND BACKENDTYPE WAIT KILLSERVERS PRESERVE USERDATA
140
141 if test $# = 0 ; then
142         echo "$USAGE"; exit 1
143 fi
144
145 # need defines.sh for the definitions of the directories
146 . $SRCDIR/scripts/defines.sh
147
148 SCRIPTDIR="${SRCDIR}/scripts"
149 SCRIPTNAME="$1"
150 shift
151
152 if test -x "${SCRIPTDIR}/${SCRIPTNAME}" ; then
153         SCRIPT="${SCRIPTDIR}/${SCRIPTNAME}"
154 elif test -x "`echo ${SCRIPTDIR}/test*-${SCRIPTNAME}`"; then
155         SCRIPT="`echo ${SCRIPTDIR}/test*-${SCRIPTNAME}`"
156 elif test -x "`echo ${SCRIPTDIR}/${SCRIPTNAME}-*`"; then
157         SCRIPT="`echo ${SCRIPTDIR}/${SCRIPTNAME}-*`"
158 else
159         echo "run: ${SCRIPTNAME} not found (or not executable)"
160         exit 1;
161 fi
162
163 if test ! -r ${DATADIR}/test.ldif ; then
164         ${LN_S} ${SRCDIR}/data ${DATADIR}
165 fi
166 if test ! -r ${SCHEMADIR}/core.schema ; then
167         ${LN_S} ${TOPSRCDIR}/servers/slapd/schema ${SCHEMADIR}
168 fi
169
170 if test -d ${TESTDIR} ; then
171         if test $PRESERVE = no ; then
172                 echo "Cleaning up test run directory leftover from previous run."
173                 /bin/rm -rf ${TESTDIR}
174         elif test $PRESERVE = yes ; then
175                 echo "Cleaning up only database directories leftover from previous run."
176                 /bin/rm -rf ${TESTDIR}/db.*
177         fi
178 fi
179
180 if test $USERDATA = yes ; then
181         if test ! -d userdata ; then
182                 echo "User data directory (userdata) does not exist."
183                 exit 1
184         fi
185         mkdir -p ${TESTDIR}
186         cp -R userdata/* ${TESTDIR}
187 fi
188
189 # disable LDAP initialization
190 LDAPNOINIT=true; export LDAPNOINIT
191
192 $SLAPPASSWD -g -n >$CONFIGPWF
193 echo "rootpw `$SLAPPASSWD -T $CONFIGPWF`" >configpw.conf
194
195 echo "Running ${SCRIPT}..."
196 $SCRIPT $*
197 RC=$?
198
199 if test $CLEAN = yes ; then
200         echo "Cleaning up test run directory from this run."
201         /bin/rm -rf ${TESTDIR}
202         echo "Cleaning up symlinks."
203         /bin/rm -f ${DATADIR} ${SCHEMADIR}
204 fi
205
206 exit $RC