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