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