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