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