]> git.sur5r.net Git - openldap/blob - tests/run.in
1) existing matching rules support in component filter
[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 AC_syncprov=syncprov@BUILD_SYNCPROV@
41
42 # misc
43 AC_WITH_SASL=@WITH_SASL@
44 AC_WITH_TLS=@WITH_TLS@
45 AC_WITH_MODULES_ENABLED=@WITH_MODULES_ENABLED@
46
47 export AC_bdb AC_hdb AC_ldap AC_ldbm AC_monitor AC_relay AC_sql 
48 export AC_pcache AC_ppolicy AC_refint AC_unique AC_rwm AC_syncprov
49 export AC_WITH_SASL AC_WITH_TLS AC_WITH_MODULES_ENABLED
50
51 if test ! -x ../servers/slapd/slapd ; then
52         echo "Could not locate slapd(8)"
53         exit 1
54 fi
55
56 if test $AC_bdb != no ; then
57         BACKEND=bdb
58 elif test $AC_ldbm != no ; then
59         BACKEND=ldbm
60 elif test $AC_hdb != no ; then
61         BACKEND=hdb
62 else
63         echo "Not configured with a suitable database backend"
64         exit 1
65 fi
66
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; 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 BACKENDTYPE=`eval 'echo $AC_'$BACKEND`
113 export BACKEND BACKENDTYPE WAIT KILLSERVERS PRESERVE USERDATA
114
115 if test $# = 0 ; then
116         echo "$USAGE"; exit 1
117 fi
118
119 SCRIPTDIR="${SRCDIR}/scripts"
120 SCRIPTNAME="$1"
121 shift
122
123 if test -x "${SCRIPTDIR}/${SCRIPTNAME}" ; then
124         SCRIPT="${SCRIPTDIR}/${SCRIPTNAME}"
125 elif test -x "`echo ${SCRIPTDIR}/test*-${SCRIPTNAME}`"; then
126         SCRIPT="`echo ${SCRIPTDIR}/test*-${SCRIPTNAME}`"
127 elif test -x "`echo ${SCRIPTDIR}/${SCRIPTNAME}-*`"; then
128         SCRIPT="`echo ${SCRIPTDIR}/${SCRIPTNAME}-*`"
129 else
130         echo "run: ${SCRIPTNAME} not found (or not executable)"
131         exit 1;
132 fi
133
134 if test ! -r testdata/test.ldif ; then
135         ${LN_S} ${SRCDIR}/data testdata
136 fi
137 if test ! -r schema/core.schema ; then
138         ${LN_S} ${TOPSRCDIR}/servers/slapd/schema schema
139 fi
140
141 if test -d testrun ; then
142         if test $PRESERVE = no ; then
143                 echo "Cleaning up test run directory leftover from previous run."
144                 /bin/rm -rf testrun
145         elif test $PRESERVE = yes ; then
146                 echo "Cleaning up only database directories leftover from previous run."
147                 /bin/rm -rf testrun/db.*
148         fi
149 fi
150
151 if test $USERDATA = yes ; then
152         if test ! -d userdata ; then
153                 echo "User data directory (userdata) does not exist."
154                 exit 1
155         fi
156         mkdir -p testrun
157         cp -R userdata/* testrun
158 fi
159
160 # disable LDAP initialization
161 LDAPNOINIT=true; export LDAPNOINIT
162
163 echo "Running ${SCRIPT}..."
164 $SCRIPT $*
165 RC=$?
166
167 if test $CLEAN = yes ; then
168         echo "Cleaning up test run directory from this run."
169         /bin/rm -rf testrun
170         echo "Cleaning up symlinks."
171         /bin/rm -f testdata schema
172 fi
173
174 exit $RC