Sync usage with man page.
[netbsd-mini2440.git] / external / bsd / openldap / dist / tests / scripts / test016-subref
bloba4f769cb391eb1e7dcef6ae4ca1d72532c16ce56
1 #! /bin/sh
2 # $OpenLDAP: pkg/ldap/tests/scripts/test016-subref,v 1.12.2.3 2008/02/11 23:26:51 kurt Exp $
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ##
5 ## Copyright 1998-2008 The OpenLDAP Foundation.
6 ## All rights reserved.
7 ##
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted only as authorized by the OpenLDAP
10 ## Public License.
12 ## A copy of this license is available in the file LICENSE in the
13 ## top-level directory of the distribution or, alternatively, at
14 ## <http://www.OpenLDAP.org/license.html>.
16 RCODE=10
18 echo "running defines.sh"
19 . $SRCDIR/scripts/defines.sh
21 mkdir -p $TESTDIR $DBDIR1
23 echo "Running slapadd to build slapd database..."
24 . $CONFFILTER $BACKEND $MONITORDB < $RCONF > $CONF1
25 $SLAPADD -f $CONF1 -l $LDIFREF
26 RC=$?
27 if test $RC != 0 ; then
28 echo "slapadd failed ($RC)!"
29 exit $RC
32 echo "Starting slapd on TCP/IP port $PORT1..."
33 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
34 PID=$!
35 if test $WAIT != 0 ; then
36 echo PID $PID
37 read foo
39 KILLPIDS="$PID"
41 sleep 1
43 echo "Testing slapd searching..."
44 for i in 0 1 2 3 4 5; do
45 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
46 '(objectclass=*)' > /dev/null 2>&1
47 RC=$?
48 if test $RC = 0 ; then
49 break
51 echo "Waiting 5 seconds for slapd to start..."
52 sleep 5
53 done
55 if test $RC != 0 ; then
56 echo "ldapsearch failed ($RC)!"
57 test $KILLSERVERS != no && kill -HUP $KILLPIDS
58 exit $RC
61 cat /dev/null > $SEARCHOUT
63 echo "Testing ManageDsaIT searching at $REFDN..."
64 $LDAPRSEARCH -S "" -MM -b "$REFDN" -h $LOCALHOST -p $PORT1 \
65 '(objectClass=referral)' '*' ref >> $SEARCHOUT 2>&1
66 RC=$?
67 if test $RC != 0 ; then
68 echo "ldapsearch failed ($RC)!"
69 test $KILLSERVERS != no && kill -HUP $KILLPIDS
70 exit $RC
73 echo "Testing ManageDsaIT searching at referral object..."
74 $LDAPRSEARCH -S "" -MM -b "o=abc,$REFDN" -h $LOCALHOST -p $PORT1 \
75 '(objectClass=referral)' '*' ref >> $SEARCHOUT 2>&1
76 RC=$?
77 if test $RC != 0 ; then
78 echo "ldapsearch failed ($RC)!"
79 test $KILLSERVERS != no && kill -HUP $KILLPIDS
80 exit $RC
83 echo "Testing ManageDsaIT searching below referral object..."
84 $LDAPRSEARCH -S "" -MM -b "uid=xxx,o=abc,$REFDN" -h $LOCALHOST -p $PORT1 \
85 '(objectClass=referral)' '*' ref >> $SEARCHOUT 2>&1
86 RC=$?
87 if test $RC != $RCODE ; then
88 echo "ldapsearch: unexpected result ($RC)! (referral expected)"
89 test $KILLSERVERS != no && kill -HUP $KILLPIDS
90 exit $RC
93 XREFDN="$REFDN"
94 echo "Testing base searching at $XREFDN..."
95 $LDAPRSEARCH -S "" -s base -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1
96 RC=$?
97 if test $RC != 0 ; then
98 echo "ldapsearch failed ($RC)!"
99 test $KILLSERVERS != no && kill -HUP $KILLPIDS
100 exit $RC
103 echo "Testing one-level searching at $XREFDN..."
104 $LDAPRSEARCH -S "" -s one -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1
105 RC=$?
106 if test $RC != 0 ; then
107 echo "ldapsearch failed ($RC)!"
108 test $KILLSERVERS != no && kill -HUP $KILLPIDS
109 exit $RC
112 echo "Testing subtree searching at $XREFDN..."
113 $LDAPRSEARCH -S "" -s sub -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1
114 RC=$?
115 if test $RC != 0 ; then
116 echo "ldapsearch failed ($RC)!"
117 test $KILLSERVERS != no && kill -HUP $KILLPIDS
118 exit $RC
121 XREFDN="o=abc,$REFDN"
122 echo "Testing base searching at $XREFDN..."
123 $LDAPRSEARCH -S "" -s base -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1
124 RC=$?
125 if test $RC != $RCODE ; then
126 echo "ldapsearch: unexpected result ($RC)! (referral expected)"
127 test $KILLSERVERS != no && kill -HUP $KILLPIDS
128 exit $RC
131 echo "Testing one-level searching at $XREFDN..."
132 $LDAPRSEARCH -S "" -s one -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1
133 RC=$?
134 if test $RC != $RCODE ; then
135 echo "ldapsearch: unexpected result ($RC)! (referral expected)"
136 test $KILLSERVERS != no && kill -HUP $KILLPIDS
137 exit $RC
140 echo "Testing subtree searching at $XREFDN..."
141 $LDAPRSEARCH -S "" -s sub -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1
142 RC=$?
143 if test $RC != $RCODE ; then
144 echo "ldapsearch: unexpected result ($RC)! (referral expected)"
145 test $KILLSERVERS != no && kill -HUP $KILLPIDS
146 exit $RC
149 XREFDN="uid=xxx,o=abc,$REFDN"
150 echo "Testing base searching at $XREFDN..."
151 $LDAPRSEARCH -S "" -s base -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1
152 RC=$?
153 if test $RC != $RCODE ; then
154 echo "ldapsearch: unexpected result ($RC)! (referral expected)"
155 test $KILLSERVERS != no && kill -HUP $KILLPIDS
156 exit $RC
159 echo "Testing one-level searching at $XREFDN..."
160 $LDAPRSEARCH -S "" -s one -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1
161 RC=$?
162 if test $RC != $RCODE ; then
163 echo "ldapsearch: unexpected result ($RC)! (referral expected)"
164 test $KILLSERVERS != no && kill -HUP $KILLPIDS
165 exit $RC
168 echo "Testing subtree searching at $XREFDN..."
169 $LDAPRSEARCH -S "" -s sub -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1
170 RC=$?
171 if test $RC != $RCODE ; then
172 echo "ldapsearch: unexpected result ($RC)! (referral expected)"
173 test $KILLSERVERS != no && kill -HUP $KILLPIDS
174 exit $RC
177 test $KILLSERVERS != no && kill -HUP $KILLPIDS
179 LDIF=$SEARCHOUTMASTER
180 echo "Filtering ldapsearch results..."
181 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
182 echo "Filtering expected LDIF for comparison..."
183 . $LDIFFILTER < $REFERRALOUT > $LDIFFLT
184 echo "Comparing filter output..."
185 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
187 if test $? != 0 ; then
188 echo "Comparison failed"
189 exit 1
192 echo ">>>>> Test succeeded"
194 test $KILLSERVERS != no && wait
196 exit 0