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