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