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