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