]> git.sur5r.net Git - openldap/blob - tests/scripts/test016-subref
Fix typo in killpid
[openldap] / tests / scripts / test016-subref
1 #! /bin/sh
2 # $OpenLDAP$
3
4 RCODE=10
5
6 echo "running defines.sh"
7 . $SRCDIR/scripts/defines.sh
8
9 mkdir $TESTDIR $DBDIR1
10
11 echo "Running slapadd to build slapd database..."
12 . $CONFFILTER $BACKEND $MONITORDB < $RCONF > $CONF1
13 $SLAPADD -f $CONF1 -l $LDIFREF
14 RC=$?
15 if test $RC != 0 ; then
16         echo "slapadd failed ($RC)!"
17         exit $RC
18 fi
19
20 echo "Starting slapd on TCP/IP port $PORT1..."
21 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
22 PID=$!
23 if test $WAIT != 0 ; then
24     echo PID $PID
25     read foo
26 fi
27 KILLPIDS="$PID"
28
29 echo "Testing slapd searching..."
30 for i in 0 1 2 3 4 5; do
31         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
32                 '(objectclass=*)' > /dev/null 2>&1
33         RC=$?
34         if test $RC = 0 ; then
35                 break
36         fi
37         echo "Waiting 5 seconds for slapd to start..."
38         sleep 5
39 done
40
41 if test $RC != 0 ; then
42         echo "ldapsearch failed ($RC)!"
43         test $KILLSERVERS != no && kill -HUP $KILLPIDS
44         exit $RC
45 fi
46
47 cat /dev/null > $SEARCHOUT
48
49 echo "Testing ManageDsaIT searching at $REFDN..."
50 $LDAPRSEARCH -S "" -MM -b "$REFDN" -h $LOCALHOST -p $PORT1 \
51         '(objectClass=referral)' '*' ref >> $SEARCHOUT 2>&1
52 RC=$?
53 if test $RC != 0 ; then
54         echo "ldapsearch failed ($RC)!"
55         test $KILLSERVERS != no && kill -HUP $KILLPIDS
56         exit $RC
57 fi
58
59 echo "Testing ManageDsaIT searching at referral object..."
60 $LDAPRSEARCH -S "" -MM -b "o=abc,$REFDN" -h $LOCALHOST -p $PORT1 \
61         '(objectClass=referral)' '*' ref >> $SEARCHOUT 2>&1
62 RC=$?
63 if test $RC != 0 ; then
64         echo "ldapsearch failed ($RC)!"
65         test $KILLSERVERS != no && kill -HUP $KILLPIDS
66         exit $RC
67 fi
68
69 echo "Testing ManageDsaIT searching below referral object..."
70 $LDAPRSEARCH -S "" -MM -b "uid=xxx,o=abc,$REFDN" -h $LOCALHOST -p $PORT1 \
71         '(objectClass=referral)' '*' ref >> $SEARCHOUT 2>&1
72 RC=$?
73 if test $RC != $RCODE ; then
74         echo "ldapsearch: unexpected result ($RC)! (referral expected)"
75         test $KILLSERVERS != no && kill -HUP $KILLPIDS
76         exit $RC
77 fi
78
79 XREFDN="$REFDN"
80 echo "Testing base searching at $XREFDN..."
81 $LDAPRSEARCH -S "" -s base -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1
82 RC=$?
83 if test $RC != 0 ; then
84         echo "ldapsearch failed ($RC)!"
85         test $KILLSERVERS != no && kill -HUP $KILLPIDS
86         exit $RC
87 fi
88
89 echo "Testing one-level searching at $XREFDN..."
90 $LDAPRSEARCH -S "" -s one -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1
91 RC=$?
92 if test $RC != 0 ; then
93         echo "ldapsearch failed ($RC)!"
94         test $KILLSERVERS != no && kill -HUP $KILLPIDS
95         exit $RC
96 fi
97
98 echo "Testing subtree searching at $XREFDN..."
99 $LDAPRSEARCH -S "" -s sub -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1
100 RC=$?
101 if test $RC != 0 ; then
102         echo "ldapsearch failed ($RC)!"
103         test $KILLSERVERS != no && kill -HUP $KILLPIDS
104         exit $RC
105 fi
106
107 XREFDN="o=abc,$REFDN"
108 echo "Testing base searching at $XREFDN..."
109 $LDAPRSEARCH -S "" -s base -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1
110 RC=$?
111 if test $RC != $RCODE ; then
112         echo "ldapsearch: unexpected result ($RC)! (referral expected)"
113         test $KILLSERVERS != no && kill -HUP $KILLPIDS
114         exit $RC
115 fi
116
117 echo "Testing one-level searching at $XREFDN..."
118 $LDAPRSEARCH -S "" -s one -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1
119 RC=$?
120 if test $RC != $RCODE ; then
121         echo "ldapsearch: unexpected result ($RC)! (referral expected)"
122         test $KILLSERVERS != no && kill -HUP $KILLPIDS
123         exit $RC
124 fi
125
126 echo "Testing subtree searching at $XREFDN..."
127 $LDAPRSEARCH -S "" -s sub -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1
128 RC=$?
129 if test $RC != $RCODE ; then
130         echo "ldapsearch: unexpected result ($RC)! (referral expected)"
131         test $KILLSERVERS != no && kill -HUP $KILLPIDS
132         exit $RC
133 fi
134
135 XREFDN="uid=xxx,o=abc,$REFDN"
136 echo "Testing base searching at $XREFDN..."
137 $LDAPRSEARCH -S "" -s base -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1
138 RC=$?
139 if test $RC != $RCODE ; then
140         echo "ldapsearch: unexpected result ($RC)! (referral expected)"
141         test $KILLSERVERS != no && kill -HUP $KILLPIDS
142         exit $RC
143 fi
144
145 echo "Testing one-level searching at $XREFDN..."
146 $LDAPRSEARCH -S "" -s one -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1
147 RC=$?
148 if test $RC != $RCODE ; then
149         echo "ldapsearch: unexpected result ($RC)! (referral expected)"
150         test $KILLSERVERS != no && kill -HUP $KILLPIDS
151         exit $RC
152 fi
153
154 echo "Testing subtree searching at $XREFDN..."
155 $LDAPRSEARCH -S "" -s sub -b "$XREFDN" -h $LOCALHOST -p $PORT1 1.1 >> $SEARCHOUT 2>&1
156 RC=$?
157 if test $RC != $RCODE ; then
158         echo "ldapsearch: unexpected result ($RC)! (referral expected)"
159         test $KILLSERVERS != no && kill -HUP $KILLPIDS
160         exit $RC
161 fi
162
163 test $KILLSERVERS != no && kill -HUP $KILLPIDS
164
165 LDIF=$SEARCHOUTMASTER
166 echo "Filtering ldapsearch results..."
167 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
168 echo "Filtering expected LDIF for comparison..."
169 . $LDIFFILTER < $REFERRALOUT > $LDIFFLT
170 echo "Comparing filter output..."
171 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
172
173 if test $? != 0 ; then
174         echo "Comparison failed"
175         exit 1
176 fi
177
178 echo ">>>>> Test succeeded"
179 exit 0