]> git.sur5r.net Git - openldap/blob - tests/scripts/test015-xsearch
Fix typo in killpid
[openldap] / tests / scripts / test015-xsearch
1 #! /bin/sh
2 # $OpenLDAP$
3
4 echo "running defines.sh"
5 . $SRCDIR/scripts/defines.sh
6
7 mkdir -p $TESTDIR $DBDIR1
8
9 echo "Running slapadd to build slapd database..."
10 . $CONFFILTER $BACKEND $MONITORDB < $MCONF > $ADDCONF
11 $SLAPADD -f $ADDCONF -l $LDIFORDERED
12 RC=$?
13 if test $RC != 0 ; then
14         echo "slapadd failed ($RC)!"
15         exit $RC
16 fi
17
18 echo "Running slapindex to index slapd database..."
19 . $CONFFILTER $BACKEND $MONITORDB < $CONF > $CONF1
20 $SLAPINDEX -f $CONF1
21 RC=$?
22 if test $RC != 0 ; then
23         echo "warning: slapindex failed ($RC)"
24         echo "  assuming no indexing support"
25 fi
26
27 echo "Starting slapd on TCP/IP port $PORT1..."
28 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
29 PID=$!
30 if test $WAIT != 0 ; then
31     echo PID $PID
32     read foo
33 fi
34 KILLPIDS="$PID"
35
36 echo "Testing slapd searching..."
37 for i in 0 1 2 3 4 5; do
38         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
39                 'objectclass=*' > /dev/null 2>&1
40         RC=$?
41         if test $RC = 0 ; then
42                 break
43         fi
44         echo "Waiting 5 seconds for slapd to start..."
45         sleep 5
46 done
47
48 if test $RC != 0 ; then
49         echo "ldapsearch failed ($RC)!"
50         test $KILLSERVERS != no && kill -HUP $KILLPIDS
51         exit $RC
52 fi
53
54 cat /dev/null > $SEARCHOUT
55
56 echo "Testing exact searching..."
57 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
58         '(sn:=jensen)' >> $SEARCHOUT 2>&1
59 RC=$?
60 if test $RC != 0 ; then
61         echo "ldapsearch failed ($RC)!"
62         test $KILLSERVERS != no && kill -HUP $KILLPIDS
63         exit $RC
64 fi
65
66 echo "Testing OR searching..."
67 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
68         '(|(givenName=XX*YY*Z)(cn=)(undef=*)(objectclass=groupofnames)(objectclass=groupofuniquenames)(sn:caseExactMatch:=Jones))' >> $SEARCHOUT 2>&1
69 RC=$?
70 if test $RC != 0 ; then
71         echo "ldapsearch failed ($RC)!"
72         test $KILLSERVERS != no && kill -HUP $KILLPIDS
73         exit $RC
74 fi
75
76 echo "Testing AND matching and ends-with searching..."
77 $LDAPSEARCH -S "" -b "ou=groups,$BASEDN" -s one -h $LOCALHOST -p $PORT1 \
78         '(&(|(objectclass=groupofnames)(objectclass=groupofuniquenames))(cn=A*))' >> $SEARCHOUT 2>&1
79 RC=$?
80 if test $RC != 0 ; then
81         echo "ldapsearch failed ($RC)!"
82         test $KILLSERVERS != no && kill -HUP $KILLPIDS
83         exit $RC
84 fi
85
86 echo "Testing NOT searching..."
87 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
88         '(!(objectclass=pilotPerson))' >> $SEARCHOUT 2>&1
89 RC=$?
90 if test $RC != 0 ; then
91         echo "ldapsearch failed ($RC)!"
92         test $KILLSERVERS != no && kill -HUP $KILLPIDS
93         exit $RC
94 fi
95
96 echo "Testing objectClass/attributeType inheritance ..."
97 $LDAPSEARCH -M -a never -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
98         '(&(objectClass=inetorgperson)(userid=uham))' \
99         "2.5.4.0" "userid" >> $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 echo "Testing extended RFC2254 searching..."
108 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
109         '(:dn:caseExactMatch:=University of Michigan)' >> $SEARCHOUT 2>&1
110
111 RC=$?
112 if test $RC != 0 ; then
113         echo "ldapsearch failed ($RC)!"
114         test $KILLSERVERS != no && kill -HUP $KILLPIDS
115         exit $RC
116 fi
117
118 echo "Testing values return filter searching..."
119 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
120         -E '!mv=(o=University of Michigan)' \
121         '(o=University of Michigan)' >> $SEARCHOUT 2>&1
122 RC=$?
123 if test $RC != 0 ; then
124         echo "ldapsearch failed ($RC)!"
125         test $KILLSERVERS != no && kill -HUP $KILLPIDS
126         exit $RC
127 fi
128
129 test $KILLSERVERS != no && kill -HUP $KILLPIDS
130
131 LDIF=$SEARCHOUTMASTER
132 LDIF2=$SEARCHOUTX
133
134 echo "Filtering ldapsearch results..."
135 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
136 echo "Filtering original ldif used to create database..."
137 . $LDIFFILTER < $LDIF > $LDIFFLT
138 . $LDIFFILTER < $LDIF2 >> $LDIFFLT
139 echo "Comparing filter output..."
140 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
141
142 if test $? != 0 ; then
143         echo "Comparison failed"
144         exit 1
145 fi
146
147 echo ">>>>> Test succeeded"
148 exit 0