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