2 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ## Copyright 2004-2005 The OpenLDAP Foundation.
5 ## All rights reserved.
7 ## Redistribution and use in source and binary forms, with or without
8 ## modification, are permitted only as authorized by the OpenLDAP
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>.
15 echo "running defines.sh"
16 . $SRCDIR/scripts/defines.sh
18 mkdir -p $TESTDIR $DBDIR1 $DBDIR2
20 . $CONFFILTER $BACKEND $MONITORDB < $EMPTYDNCONF > $CONF1
22 echo "Running slapadd to build \"dc=example,dc=com\" slapd database..."
23 $SLAPADD -f $CONF1 -n 1 -l $LDIFEMPTYDN1
25 if test $RC != 0 ; then
26 echo "slapadd failed ($RC)!"
30 echo "Running slapadd to build empty DN slapd database..."
31 $SLAPADD -f $CONF1 -b "" -l $LDIFEMPTYDN2
33 if test $RC != 0 ; then
34 echo "slapadd failed ($RC)!"
38 echo "Starting slapd on TCP/IP port $PORT1..."
39 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
41 if test $WAIT != 0 ; then
47 echo "Testing slapd empty DN handling..."
48 for i in 0 1 2 3 4 5; do
49 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
50 'objectclass=*' > /dev/null 2>&1
52 if test $RC = 0 ; then
55 echo "Waiting 5 seconds for slapd to start..."
59 if test $RC != 0 ; then
60 echo "ldapsearch failed ($RC)!"
61 test $KILLSERVERS != no && kill -HUP $KILLPIDS
65 echo "Searching database..."
67 $LDAPSEARCH -b "" -h $LOCALHOST -p $PORT1 > $SEARCHOUT 2>&1
70 if test $RC != 0 ; then
71 echo "ldapsearch failed ($RC)!"
72 test $KILLSERVERS != no && kill -HUP $KILLPIDS
76 test $KILLSERVERS != no && kill -HUP $KILLPIDS
81 echo "Filtering ldapsearch results..."
82 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
83 echo "Comparing ldapsearch results against original..."
84 $CMP $SEARCHFLT $LDIFOUT > $CMPOUT
86 if test $? != 0 ; then
87 echo "comparison failed - empty DN write operations did not complete correctly"
91 echo "Comparison of database generated via slapadd succeeded"
93 echo "Cleaning up database directories..."
94 /bin/rm -rf $TESTDIR/db.*
96 mkdir -p $TESTDIR $DBDIR1 $DBDIR2
98 echo "Starting slapd on TCP/IP port $PORT1..."
99 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
101 if test $WAIT != 0 ; then
107 echo "Testing slapd empty DN handling..."
108 for i in 0 1 2 3 4 5; do
109 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
110 'objectclass=*' > /dev/null 2>&1
112 if test $RC = 0 ; then
115 echo "Waiting 5 seconds for slapd to start..."
119 if test $RC != 0 ; then
120 echo "ldapsearch failed ($RC)!"
121 test $KILLSERVERS != no && kill -HUP $KILLPIDS
125 echo "Loading database..."
126 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
127 -f $LDIFEMPTYDN1 > /dev/null 2>&1
128 $LDAPADD -D "$EMPTYDNDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
129 -f $LDIFEMPTYDN2 > /dev/null 2>&1
131 $LDAPMODIFY -D "$EMPTYDNDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
132 > /dev/null 2>&1 << EOF
140 echo "Searching database..."
142 $LDAPSEARCH -b "" -h $LOCALHOST -p $PORT1 > $SEARCHOUT 2>&1
145 if test $RC != 0 ; then
146 echo "ldapsearch failed ($RC)!"
147 test $KILLSERVERS != no && kill -HUP $KILLPIDS
151 test $KILLSERVERS != no && kill -HUP $KILLPIDS
155 echo "Filtering ldapsearch results..."
156 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
157 echo "Comparing ldapsearch results against original..."
158 $CMP $SEARCHFLT $LDIFOUT > $CMPOUT
160 if test $? != 0 ; then
161 echo "comparison failed - empty DN write operations did not complete correctly"
167 echo ">>>>> Test succeeded"