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