2 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ## Copyright 2004 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 # FIXME: temporary! bdb doesn't work
16 if test "$BACKEND" != "ldbm" ; then
17 echo "Test does not support $BACKEND"
21 echo "running defines.sh"
22 . $SRCDIR/scripts/defines.sh
24 mkdir -p $TESTDIR $DBDIR1 $DBDIR2
26 . $CONFFILTER $BACKEND $MONITORDB < $EMPTYDNCONF > $CONF1
28 echo "Running slapadd to build \"dc=example,dc=com\" slapd database..."
29 $SLAPADD -f $CONF1 -n 1 -l $LDIFEMPTYDN1
31 if test $RC != 0 ; then
32 echo "slapadd failed ($RC)!"
36 echo "Running slapadd to build empty DN slapd database..."
37 $SLAPADD -f $CONF1 -n 2 -l $LDIFEMPTYDN2
39 if test $RC != 0 ; then
40 echo "slapadd failed ($RC)!"
44 echo "Starting slapd on TCP/IP port $PORT1..."
45 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
47 if test $WAIT != 0 ; then
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
58 if test $RC = 0 ; then
61 echo "Waiting 5 seconds for slapd to start..."
65 if test $RC != 0 ; then
66 echo "ldapsearch failed ($RC)!"
67 test $KILLSERVERS != no && kill -HUP $KILLPIDS
71 echo "Searching database..."
73 $LDAPSEARCH -b "" -h $LOCALHOST -p $PORT1 > $SEARCHOUT 2>&1
76 if test $RC != 0 ; then
77 echo "ldapsearch failed ($RC)!"
78 test $KILLSERVERS != no && kill -HUP $KILLPIDS
82 test $KILLSERVERS != no && kill -HUP $KILLPIDS
86 echo "Comparing ldapsearch results against original..."
87 $CMP $SEARCHOUT $LDIFOUT > $CMPOUT
89 if test $? != 0 ; then
90 echo "comparison failed - empty DN write operations did not complete correctly"
94 echo "Comparison of database generated via slapadd succeeded"
96 echo "Cleaning up database directories..."
97 /bin/rm -rf testrun/db.*
99 mkdir -p $TESTDIR $DBDIR1 $DBDIR2
101 echo "Starting slapd on TCP/IP port $PORT1..."
102 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
104 if test $WAIT != 0 ; then
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
115 if test $RC = 0 ; then
118 echo "Waiting 5 seconds for slapd to start..."
122 if test $RC != 0 ; then
123 echo "ldapsearch failed ($RC)!"
124 test $KILLSERVERS != no && kill -HUP $KILLPIDS
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
134 $LDAPMODIFY -D "$EMPTYDNDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
135 > /dev/null 2>&1 << EOF
143 echo "Searching database..."
145 $LDAPSEARCH -b "" -h $LOCALHOST -p $PORT1 > $SEARCHOUT 2>&1
148 if test $RC != 0 ; then
149 echo "ldapsearch failed ($RC)!"
150 test $KILLSERVERS != no && kill -HUP $KILLPIDS
154 test $KILLSERVERS != no && kill -HUP $KILLPIDS
158 echo "Comparing ldapsearch results against original..."
159 $CMP $SEARCHOUT $LDIFOUT > $CMPOUT
161 if test $? != 0 ; then
162 echo "comparison failed - empty DN write operations did not complete correctly"
168 echo ">>>>> Test succeeded"