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