2 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ## Copyright 2004-2017 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
49 echo "Testing slapd empty DN handling..."
50 for i in 0 1 2 3 4 5; do
51 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
52 'objectclass=*' > /dev/null 2>&1
54 if test $RC = 0 ; then
57 echo "Waiting 5 seconds for slapd to start..."
61 if test $RC != 0 ; then
62 echo "ldapsearch failed ($RC)!"
63 test $KILLSERVERS != no && kill -HUP $KILLPIDS
67 echo "Searching database..."
69 $LDAPSEARCH -S "" -b "" -h $LOCALHOST -p $PORT1 > $SEARCHOUT 2>&1
72 if test $RC != 0 ; then
73 echo "ldapsearch failed ($RC)!"
74 test $KILLSERVERS != no && kill -HUP $KILLPIDS
81 echo "Filtering ldapsearch results..."
82 $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
83 echo "Filtering expected results..."
84 $LDIFFILTER < $EMPTYDNOUT1 > $LDIFFLT
85 echo "Comparing ldapsearch results against original..."
86 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
88 if test $? != 0 ; then
89 echo "comparison failed - empty DN write operations did not complete correctly"
93 echo "Comparison of database generated via slapadd succeeded"
95 echo "Cleaning up database directories..."
96 /bin/rm -rf $TESTDIR/db.*
98 mkdir -p $TESTDIR $DBDIR1 $DBDIR2
100 echo "Starting slapd on TCP/IP port $PORT1..."
101 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
103 if test $WAIT != 0 ; then
111 echo "Testing slapd empty DN handling..."
112 for i in 0 1 2 3 4 5; do
113 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
114 'objectclass=*' > /dev/null 2>&1
116 if test $RC = 0 ; then
119 echo "Waiting 5 seconds for slapd to start..."
123 if test $RC != 0 ; then
124 echo "ldapsearch failed ($RC)!"
125 test $KILLSERVERS != no && kill -HUP $KILLPIDS
129 echo "Loading database..."
130 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
131 -f $LDIFEMPTYDN1 > /dev/null 2>&1
132 $LDAPADD -D "$EMPTYDNDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
133 -f $LDIFEMPTYDN2 > /dev/null 2>&1
135 $LDAPMODIFY -D "$EMPTYDNDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
136 > /dev/null 2>&1 << EOF
144 echo "Searching database..."
146 $LDAPSEARCH -S "" -b "" -h $LOCALHOST -p $PORT1 > $SEARCHOUT 2>&1
149 if test $RC != 0 ; then
150 echo "ldapsearch failed ($RC)!"
151 test $KILLSERVERS != no && kill -HUP $KILLPIDS
155 test $KILLSERVERS != no && kill -HUP $KILLPIDS
157 echo "Filtering ldapsearch results..."
158 $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
159 echo "Filtering expected results..."
160 $LDIFFILTER < $EMPTYDNOUT2 > $LDIFFLT
161 echo "Comparing ldapsearch results against original..."
162 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
164 if test $? != 0 ; then
165 echo "comparison failed - empty DN write operations did not complete correctly"
171 echo ">>>>> Test succeeded"
173 test $KILLSERVERS != no && wait