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