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