]> git.sur5r.net Git - openldap/blob - tests/scripts/test027-emptydn
fa38b5727d387c2fd4c09ff3480df0aca2062a52
[openldap] / tests / scripts / test027-emptydn
1 #! /bin/sh
2 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
3 ##
4 ## Copyright 2004 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 # FIXME: temporary! bdb doesn't work
16 if test "$BACKEND" != "ldbm" ; then
17         echo "Test does not support $BACKEND"
18         exit 0
19 fi
20
21 echo "running defines.sh"
22 . $SRCDIR/scripts/defines.sh
23
24 mkdir -p $TESTDIR $DBDIR1 $DBDIR2
25
26 . $CONFFILTER $BACKEND $MONITORDB < $EMPTYDNCONF > $CONF1
27
28 echo "Running slapadd to build \"dc=example,dc=com\" slapd database..."
29 $SLAPADD -f $CONF1 -n 1 -l $LDIFEMPTYDN1
30 RC=$?
31 if test $RC != 0 ; then
32         echo "slapadd failed ($RC)!"
33         exit $RC
34 fi
35
36 echo "Running slapadd to build empty DN slapd database..."
37 $SLAPADD -f $CONF1 -n 2 -l $LDIFEMPTYDN2
38 RC=$?
39 if test $RC != 0 ; then
40         echo "slapadd failed ($RC)!"
41         exit $RC
42 fi
43
44 echo "Starting slapd on TCP/IP port $PORT1..."
45 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
46 PID=$!
47 if test $WAIT != 0 ; then
48     echo PID $PID
49     read foo
50 fi
51 KILLPIDS="$PID"
52
53 echo "Testing slapd empty DN handling..."
54 for i in 0 1 2 3 4 5; do
55         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
56                 'objectclass=*' > /dev/null 2>&1
57         RC=$?
58         if test $RC = 0 ; then
59                 break
60         fi
61         echo "Waiting 5 seconds for slapd to start..."
62         sleep 5
63 done
64
65 if test $RC != 0 ; then
66         echo "ldapsearch failed ($RC)!"
67         test $KILLSERVERS != no && kill -HUP $KILLPIDS
68         exit $RC
69 fi
70
71 echo "Searching database..."
72
73 $LDAPSEARCH -b "" -h $LOCALHOST -p $PORT1 > $SEARCHOUT 2>&1
74
75 RC=$?
76 if test $RC != 0 ; then
77         echo "ldapsearch failed ($RC)!"
78         test $KILLSERVERS != no && kill -HUP $KILLPIDS
79         exit $RC
80 fi
81
82 test $KILLSERVERS != no && kill -HUP $KILLPIDS
83
84 LDIFOUT=$EMPTYDNOUT
85
86 echo "Comparing ldapsearch results against original..."
87 $CMP $SEARCHOUT $LDIFOUT > $CMPOUT
88
89 if test $? != 0 ; then
90         echo "comparison failed - empty DN write operations did not complete correctly"
91         exit 1
92 fi
93
94 echo "Comparison of database generated via slapadd succeeded"
95
96 echo "Cleaning up database directories..."
97 /bin/rm -rf testrun/db.*
98
99 mkdir -p $TESTDIR $DBDIR1 $DBDIR2
100
101 echo "Starting slapd on TCP/IP port $PORT1..."
102 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
103 PID=$!
104 if test $WAIT != 0 ; then
105     echo PID $PID
106     read foo
107 fi
108 KILLPIDS="$PID"
109
110 echo "Testing slapd empty DN handling..."
111 for i in 0 1 2 3 4 5; do
112         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
113                 'objectclass=*' > /dev/null 2>&1
114         RC=$?
115         if test $RC = 0 ; then
116                 break
117         fi
118         echo "Waiting 5 seconds for slapd to start..."
119         sleep 5
120 done
121
122 if test $RC != 0 ; then
123         echo "ldapsearch failed ($RC)!"
124         test $KILLSERVERS != no && kill -HUP $KILLPIDS
125         exit $RC
126 fi
127
128 echo "Loading database..."
129 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
130         -f $LDIFEMPTYDN1 > /dev/null 2>&1
131 $LDAPADD -D "$EMPTYDNDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
132         -f $LDIFEMPTYDN2 > /dev/null 2>&1
133
134 echo "Searching database..."
135
136 $LDAPSEARCH -b "" -h $LOCALHOST -p $PORT1 > $SEARCHOUT 2>&1
137
138 RC=$?
139 if test $RC != 0 ; then
140         echo "ldapsearch failed ($RC)!"
141         test $KILLSERVERS != no && kill -HUP $KILLPIDS
142         exit $RC
143 fi
144
145 test $KILLSERVERS != no && kill -HUP $KILLPIDS
146
147 LDIFOUT=$EMPTYDNOUT
148
149 echo "Comparing ldapsearch results against original..."
150 $CMP $SEARCHOUT $LDIFOUT > $CMPOUT
151
152 if test $? != 0 ; then
153         echo "comparison failed - empty DN write operations did not complete correctly"
154         exit 1
155 fi
156
157 #####
158
159 echo ">>>>> Test succeeded"
160 exit 0