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