]> git.sur5r.net Git - openldap/blob - tests/scripts/test000-rootdse
Save a malloc
[openldap] / tests / scripts / test000-rootdse
1 #! /bin/sh
2 # $OpenLDAP$
3
4 SRCDIR="."
5 if test $# -ge 1 ; then
6         SRCDIR=$1; shift
7 fi
8 BACKEND=bdb
9 if test $# -ge 1 ; then
10         BACKEND=$1; shift
11 fi
12 MONITORDB=no
13 if test $# -ge 1 ; then
14         MONITORDB=$1; shift
15 fi
16
17 WAIT=0
18 if test $# -ge 1 ; then
19         WAIT=1; shift
20 fi
21
22 echo "running defines.sh"
23 . $SRCDIR/scripts/defines.sh
24
25 echo "Datadir is $DATADIR"
26
27 echo "Cleaning up in $DBDIR..."
28
29 rm -f $DBDIR/[!C]*
30
31 echo "Starting slapd on TCP/IP port $PORT..."
32 . $CONFFILTER $BACKEND $MONITORDB < $SCHEMACONF > $DBCONF
33 $SLAPD -f $DBCONF -h $MASTERURI -d $LVL $TIMING > $MASTERLOG 2>&1 &
34 PID=$!
35 if test $WAIT != 0 ; then
36     echo PID $PID
37     read foo
38 fi
39
40 echo "Using ldapsearch to retrieve the root DSE..."
41 for i in 0 1 2 3 4 5; do
42         $LDAPSEARCH -b "" -s base -h $LOCALHOST -p $PORT 'extensibleObject' > $SEARCHOUT 2>&1
43         RC=$?
44         if test $RC = 1 ; then
45                 echo "Waiting 5 seconds for slapd to start..."
46                 sleep 5
47         fi
48 done
49
50 if test $RC = 0 -a $MONITORDB = yes ; then
51         echo "Using ldapsearch to retrieve the cn=Monitor..."
52         $LDAPSEARCH -b "cn=Monitor" -s base -h $LOCALHOST -p $PORT 'extensibleObject' >> $SEARCHOUT 2>&1
53         RC=$?
54 fi
55
56 kill -HUP $PID
57
58 cat $SEARCHOUT
59
60 if test $RC != 0 ; then
61         echo ">>>>> Test failed"
62 else
63         if grep "TLS:" $SEARCHOUT; then
64                 RC=-1
65         else
66             echo ">>>>> Test succeeded"
67         fi
68 fi
69
70
71 exit $RC