]> git.sur5r.net Git - openldap/blob - tests/run.in
Rework test suite to use run script.
[openldap] / tests / run.in
1 #!/bin/sh
2
3 USAGE="$0 [-b <backend>] <script>"
4
5 # configure generated
6 SRCDIR="@srcdir@"
7 TOPSRCDIR="@top_srcdir@"
8 LN_S="@LN_S@"
9
10 export SRCDIR TOPSRCDIR LN_S
11
12 AC_BDB=@BUILD_BDB@
13 AC_HDB=@BUILD_HDB@
14 AC_LDBM=@BUILD_LDBM@
15 AC_MONITOR=@BUILD_MONITOR@
16 AC_CACHE=@BUILD_CACHE@
17 AC_WITH_TLS=@WITH_TLS@
18
19 export AC_MONITOR AC_CACHE AC_WITH_TLS
20
21 if test ! -x ../servers/slapd/slapd ; then
22         echo "Could not locate slapd(8)"
23         exit 1
24 fi
25
26 if test $AC_BDB = yes ; then
27         BACKEND=bdb
28 elif test $AC_LDBM = yes ; then
29         BACKEND=ldbm
30 elif test $AC_HDB = yes ; then
31         BACKEND=hdbm
32 else
33         echo "Not configured with a suitable database backend"
34         exit 1
35 fi
36
37 CLEAN=no
38 WAIT=0
39
40 while test $# -gt 0 ; do
41         case "$1" in
42                 -b | -backend)
43                         BACKEND="$2"
44                         shift; shift ;;
45
46                 -c | -clean)
47                         CLEAN=yes
48                         shift; shift ;;
49
50                 -w | -wait)
51                         CLEAN=1
52                         shift ;;
53
54                 -)
55                         shift
56                         break ;;
57
58                 -*)
59                         echo "$USAGE"; exit 1
60                         ;;
61
62                 *)
63                         break ;;
64         esac
65 done
66
67 export BACKEND WAIT
68
69 if test $# = 0 ; then
70         echo "$USAGE"; exit 1
71 fi
72 SCRIPT="${SRCDIR}/scripts/$1"
73 shift
74
75 if test ! -x "${SCRIPT}" ; then
76         echo "run: ${SCRIPT} not found (or not executable)"
77         exit 1;
78 fi
79
80 if test ! -e testdata/test.ldif ; then
81         ${LN_S} ${SRCDIR}/data testdata
82 fi
83 if test ! -e schema/core.schema ; then
84         ${LN_S} ${TOPSRCDIR}/servers/slapd/schema schema
85 fi
86 if test ! -e ucdata/UnicodeData.txt ; then
87         ${LN_S} ${TOPSRCDIR}/libraries/liblunicode ucdata
88 fi
89
90 echo "Cleaning up directories leftover from previous run."
91 /bin/rm -rf test-db test-repl test-db2 test-repl2 test-db3 test-repl3
92
93 # disable LDAP initialization
94 LDAPNOINIT=true; export LDAPNOINIT
95
96 echo "Running ${SCRIPT}..."
97 $SCRIPT $*
98 RC=$?
99
100 if test $CLEAN = yes ; then
101         echo "Cleaning up directories leftover from this run."
102         /bin/rm -rf test-db test-repl test-db2 test-repl2 test-db3 test-repl3
103         echo "Cleaning up symlinks."
104         /bin/rm -f testdata schema ucdata
105 fi
106
107 exit $RC