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