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