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