]> git.sur5r.net Git - openldap/blob - tests/run.in
d085d51320e42071e7a9845e096ef7e4b783a985
[openldap] / tests / run.in
1 #!/bin/sh
2 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
3 ##
4 ## Copyright 1998-2003 The OpenLDAP Foundation.
5 ## All rights reserved.
6 ##
7 ## Redistribution and use in source and binary forms, with or without
8 ## modification, are permitted only as authorized by the OpenLDAP
9 ## Public License.
10 ##
11 ## A copy of this license is available in the file LICENSE in the
12 ## top-level directory of the distribution or, alternatively, at
13 ## <http://www.OpenLDAP.org/license.html>.
14
15 USAGE="$0 [-b <backend>] [-c] [-k] [-p] [-u] [-w] <script>"
16
17 # configure generated
18 SRCDIR="@srcdir@"
19 TOPSRCDIR="@top_srcdir@"
20 LN_S="@LN_S@"
21
22 export SRCDIR TOPSRCDIR LN_S
23
24 AC_BDB=@BUILD_BDB@
25 AC_HDB=@BUILD_HDB@
26 AC_LDBM=@BUILD_LDBM@
27 AC_MONITOR=@BUILD_MONITOR@
28 AC_CACHE=@BUILD_CACHE@
29 AC_WITH_TLS=@WITH_TLS@
30
31 export AC_MONITOR AC_CACHE AC_WITH_TLS
32
33 if test ! -x ../servers/slapd/slapd ; then
34         echo "Could not locate slapd(8)"
35         exit 1
36 fi
37
38 if test $AC_BDB = yes ; then
39         BACKEND=bdb
40 elif test $AC_LDBM = yes ; then
41         BACKEND=ldbm
42 elif test $AC_HDB = yes ; then
43         BACKEND=hdbm
44 else
45         echo "Not configured with a suitable database backend"
46         exit 1
47 fi
48
49 CLEAN=no
50 WAIT=0
51 KILLSERVERS=yes
52 PRESERVE=${PRESERVE-no}
53 USERDATA=no
54
55 while test $# -gt 0 ; do
56         case "$1" in
57                 -b | -backend)
58                         BACKEND="$2"
59                         shift; shift ;;
60
61                 -c | -clean)
62                         CLEAN=yes
63                         shift; shift ;;
64
65                 -k | -kill)
66                         KILLSERVERS=no
67                         shift ;;
68
69                 -p | -preserve)
70                         PRESERVE=yes
71                         shift ;;
72
73                 -u | -userdata)
74                         USERDATA=yes
75                         shift ;;
76
77                 -w | -wait)
78                         WAIT=1
79                         shift ;;
80
81                 -)
82                         shift
83                         break ;;
84
85                 -*)
86                         echo "$USAGE"; exit 1
87                         ;;
88
89                 *)
90                         break ;;
91         esac
92 done
93
94 export BACKEND WAIT KILLSERVERS PRESERVE USERDATA
95
96 if test $# = 0 ; then
97         echo "$USAGE"; exit 1
98 fi
99
100 SCRIPTDIR="${SRCDIR}/scripts"
101 SCRIPTNAME="$1"
102 shift
103
104 if test -x "${SCRIPTDIR}/${SCRIPTNAME}" ; then
105         SCRIPT="${SCRIPTDIR}/${SCRIPTNAME}"
106 elif test -x "`echo ${SCRIPTDIR}/test*-${SCRIPTNAME}`"; then
107         SCRIPT="`echo ${SCRIPTDIR}/test*-${SCRIPTNAME}`"
108 elif test -x "`echo ${SCRIPTDIR}/${SCRIPTNAME}-*`"; then
109         SCRIPT="`echo ${SCRIPTDIR}/${SCRIPTNAME}-*`"
110 else
111         echo "run: ${SCRIPTNAME} not found (or not executable)"
112         exit 1;
113 fi
114
115 if test ! -r testdata/test.ldif ; then
116         ${LN_S} ${SRCDIR}/data testdata
117 fi
118 if test ! -r schema/core.schema ; then
119         ${LN_S} ${TOPSRCDIR}/servers/slapd/schema schema
120 fi
121 if test ! -r ucdata/UnicodeData.txt ; then
122         ${LN_S} ../libraries/liblunicode ucdata
123 fi
124
125 if test -d testrun ; then
126         if test $PRESERVE = no ; then
127                 echo "Cleaning up test run directory leftover from previous run."
128                 /bin/rm -rf testrun
129         elif test $PRESERVE = yes ; then
130                 echo "Cleaning up only database directories leftover from previous run."
131                 /bin/rm -rf testrun/db.*
132         fi
133 fi
134
135 if test $USERDATA = yes ; then
136         if test ! -d userdata ; then
137                 echo "User data directory (userdata) does not exist."
138                 exit 1
139         fi
140         mkdir -p testrun
141         cp -R userdata/* testrun
142 fi
143
144 # disable LDAP initialization
145 LDAPNOINIT=true; export LDAPNOINIT
146
147 echo "Running ${SCRIPT}..."
148 $SCRIPT $*
149 RC=$?
150
151 if test $CLEAN = yes ; then
152         echo "Cleaning up test run directory from this run."
153         /bin/rm -rf testrun
154         echo "Cleaning up symlinks."
155         /bin/rm -f testdata schema ucdata
156 fi
157
158 exit $RC