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