]> git.sur5r.net Git - openldap/blob - tests/run.in
fix test006
[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_TLS=@WITH_TLS@
35
36 export AC_MONITOR AC_WITH_TLS AC_ldap AC_pcache AC_ppolicy
37 export AC_refint AC_unique
38
39 if test ! -x ../servers/slapd/slapd ; then
40         echo "Could not locate slapd(8)"
41         exit 1
42 fi
43
44 if test $AC_bdb != no ; then
45         BACKEND=bdb
46 elif test $AC_ldbm != no ; then
47         BACKEND=ldbm
48 elif test $AC_hdb != no ; then
49         BACKEND=hdb
50 else
51         echo "Not configured with a suitable database backend"
52         exit 1
53 fi
54
55 CLEAN=no
56 WAIT=0
57 KILLSERVERS=yes
58 PRESERVE=${PRESERVE-no}
59 USERDATA=no
60
61 while test $# -gt 0 ; do
62         case "$1" in
63                 -b | -backend)
64                         BACKEND="$2"
65                         shift; shift ;;
66
67                 -c | -clean)
68                         CLEAN=yes
69                         shift; shift ;;
70
71                 -k | -kill)
72                         KILLSERVERS=no
73                         shift ;;
74
75                 -p | -preserve)
76                         PRESERVE=yes
77                         shift ;;
78
79                 -u | -userdata)
80                         USERDATA=yes
81                         shift ;;
82
83                 -w | -wait)
84                         WAIT=1
85                         shift ;;
86
87                 -)
88                         shift
89                         break ;;
90
91                 -*)
92                         echo "$USAGE"; exit 1
93                         ;;
94
95                 *)
96                         break ;;
97         esac
98 done
99
100 BACKENDTYPE=`eval 'echo $AC_'$BACKEND`
101 export BACKEND BACKENDTYPE WAIT KILLSERVERS PRESERVE USERDATA
102
103 if test $# = 0 ; then
104         echo "$USAGE"; exit 1
105 fi
106
107 SCRIPTDIR="${SRCDIR}/scripts"
108 SCRIPTNAME="$1"
109 shift
110
111 if test -x "${SCRIPTDIR}/${SCRIPTNAME}" ; then
112         SCRIPT="${SCRIPTDIR}/${SCRIPTNAME}"
113 elif test -x "`echo ${SCRIPTDIR}/test*-${SCRIPTNAME}`"; then
114         SCRIPT="`echo ${SCRIPTDIR}/test*-${SCRIPTNAME}`"
115 elif test -x "`echo ${SCRIPTDIR}/${SCRIPTNAME}-*`"; then
116         SCRIPT="`echo ${SCRIPTDIR}/${SCRIPTNAME}-*`"
117 else
118         echo "run: ${SCRIPTNAME} not found (or not executable)"
119         exit 1;
120 fi
121
122 if test ! -r testdata/test.ldif ; then
123         ${LN_S} ${SRCDIR}/data testdata
124 fi
125 if test ! -r schema/core.schema ; then
126         ${LN_S} ${TOPSRCDIR}/servers/slapd/schema schema
127 fi
128 if test ! -r ucdata/UnicodeData.txt ; then
129         ${LN_S} ../libraries/liblunicode ucdata
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 ucdata
163 fi
164
165 exit $RC