Sync usage with man page.
[netbsd-mini2440.git] / external / bsd / openldap / dist / tests / scripts / test027-emptydn
blob60cdb0e397506930201b88948fa50c79903a9dad
1 #! /bin/sh
2 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
3 ##
4 ## Copyright 2004-2008 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.
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
24 RC=$?
25 if test $RC != 0 ; then
26 echo "slapadd failed ($RC)!"
27 exit $RC
30 echo "Running slapadd to build empty DN slapd database..."
31 $SLAPADD -f $CONF1 -b "" -l $LDIFEMPTYDN2
32 RC=$?
33 if test $RC != 0 ; then
34 echo "slapadd failed ($RC)!"
35 exit $RC
38 echo "Starting slapd on TCP/IP port $PORT1..."
39 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
40 PID=$!
41 if test $WAIT != 0 ; then
42 echo PID $PID
43 read foo
45 KILLPIDS="$PID"
47 sleep 1
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
53 RC=$?
54 if test $RC = 0 ; then
55 break
57 echo "Waiting 5 seconds for slapd to start..."
58 sleep 5
59 done
61 if test $RC != 0 ; then
62 echo "ldapsearch failed ($RC)!"
63 test $KILLSERVERS != no && kill -HUP $KILLPIDS
64 exit $RC
67 echo "Searching database..."
69 $LDAPSEARCH -S "" -b "" -h $LOCALHOST -p $PORT1 > $SEARCHOUT 2>&1
71 RC=$?
72 if test $RC != 0 ; then
73 echo "ldapsearch failed ($RC)!"
74 test $KILLSERVERS != no && kill -HUP $KILLPIDS
75 exit $RC
78 kill -HUP $KILLPIDS
79 wait
81 LDIFOUT=$EMPTYDNOUT1
83 echo "Filtering ldapsearch results..."
84 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
85 echo "Comparing ldapsearch results against original..."
86 $CMP $SEARCHFLT $LDIFOUT > $CMPOUT
88 if test $? != 0 ; then
89 echo "comparison failed - empty DN write operations did not complete correctly"
90 exit 1
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 &
102 PID=$!
103 if test $WAIT != 0 ; then
104 echo PID $PID
105 read foo
107 KILLPIDS="$PID"
109 sleep 1
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
115 RC=$?
116 if test $RC = 0 ; then
117 break
119 echo "Waiting 5 seconds for slapd to start..."
120 sleep 5
121 done
123 if test $RC != 0 ; then
124 echo "ldapsearch failed ($RC)!"
125 test $KILLSERVERS != no && kill -HUP $KILLPIDS
126 exit $RC
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
137 dn: o=Beispiel,c=DE
138 changetype: delete
140 dn: c=DE
141 changetype: delete
144 echo "Searching database..."
146 $LDAPSEARCH -S "" -b "" -h $LOCALHOST -p $PORT1 > $SEARCHOUT 2>&1
148 RC=$?
149 if test $RC != 0 ; then
150 echo "ldapsearch failed ($RC)!"
151 test $KILLSERVERS != no && kill -HUP $KILLPIDS
152 exit $RC
155 test $KILLSERVERS != no && kill -HUP $KILLPIDS
157 LDIFOUT=$EMPTYDNOUT2
159 echo "Filtering ldapsearch results..."
160 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
161 echo "Comparing ldapsearch results against original..."
162 $CMP $SEARCHFLT $LDIFOUT > $CMPOUT
164 if test $? != 0 ; then
165 echo "comparison failed - empty DN write operations did not complete correctly"
166 exit 1
169 #####
171 echo ">>>>> Test succeeded"
173 test $KILLSERVERS != no && wait
175 exit 0