]> git.sur5r.net Git - openldap/blob - tests/scripts/test003-search
Search for pilotPerson instead of person to test objectClass handling
[openldap] / tests / scripts / test003-search
1 #! /bin/sh
2 # $OpenLDAP$
3
4 SRCDIR="."
5 if test $# -ge 1 ; then
6         SRCDIR=$1; shift
7 fi
8 BACKEND=bdb
9 if test $# -ge 1 ; then
10         BACKEND=$1; shift
11 fi
12 WAIT=0
13 if test $# -ge 1 ; then
14         WAIT=1; shift
15 fi
16
17 echo "running defines.sh"
18 . $SRCDIR/scripts/defines.sh
19
20 echo "Cleaning up in $DBDIR..."
21
22 rm -f $DBDIR/[!C]*
23
24 echo "Running slapadd to build slapd database..."
25 . $CONFFILTER $BACKEND < $MCONF > $ADDCONF
26 $SLAPADD -f $ADDCONF -l $LDIFORDERED
27 RC=$?
28 if test $RC != 0 ; then
29         echo "slapadd failed ($RC)!"
30         exit $RC
31 fi
32
33 echo "Running slapindex to index slapd database..."
34 . $CONFFILTER $BACKEND < $CONF > $DBCONF
35 $SLAPINDEX -f $DBCONF
36 RC=$?
37 if test $RC != 0 ; then
38         echo "warning: slapindex failed ($RC)"
39         echo "  assuming no indexing support"
40 fi
41
42 echo "Starting slapd on TCP/IP port $PORT..."
43 $SLAPD -f $DBCONF -h $MASTERURI -d $LVL $TIMING > $MASTERLOG 2>&1 &
44 PID=$!
45 if test $WAIT != 0 ; then
46     echo PID $PID
47     read foo
48 fi
49
50 echo "Testing slapd searching..."
51 for i in 0 1 2 3 4 5; do
52         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT \
53                 'objectclass=*' > /dev/null 2>&1
54         RC=$?
55         if test $RC = 1 ; then
56                 echo "Waiting 5 seconds for slapd to start..."
57                 sleep 5
58         fi
59 done
60
61 if test $RC != 0 ; then
62         echo "ldapsearch failed ($RC)!"
63         kill -HUP $PID
64         exit $RC
65 fi
66
67 cat /dev/null > $SEARCHOUT
68
69 echo "Testing exact searching..."
70 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT \
71         'sn=jensen' >> $SEARCHOUT 2>&1
72 if test $RC != 0 ; then
73         echo "ldapsearch failed ($RC)!"
74         kill -HUP $PID
75         exit $RC
76 fi
77
78 echo "Testing OR searching..."
79 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT \
80         '(|(undefined=fubar)(objectclass=groupofnames)(sn=jones))' >> $SEARCHOUT 2>&1
81 if test $RC != 0 ; then
82         echo "ldapsearch failed ($RC)!"
83         kill -HUP $PID
84         exit $RC
85 fi
86
87 echo "Testing AND matching and ends-with searching..."
88 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT \
89         '(&(objectclass=groupofnames)(cn=A*))' >> $SEARCHOUT 2>&1
90 if test $RC != 0 ; then
91         echo "ldapsearch failed ($RC)!"
92         kill -HUP $PID
93         exit $RC
94 fi
95
96 echo "Testing NOT searching..."
97 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT \
98         '(!(objectclass=pilotPerson))' >> $SEARCHOUT 2>&1
99 if test $RC != 0 ; then
100         echo "ldapsearch failed ($RC)!"
101         kill -HUP $PID
102         exit $RC
103 fi
104
105 kill -HUP $PID
106
107 LDIF=$SEARCHOUTMASTER
108
109 echo "Filtering ldapsearch results..."
110 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
111 echo "Filtering original ldif used to create database..."
112 . $LDIFFILTER < $LDIF > $LDIFFLT
113 echo "Comparing filter output..."
114 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
115
116 if test $? != 0 ; then
117         echo "Comparison failed"
118         exit 1
119 fi
120
121 echo ">>>>> Test succeeded"
122
123
124 exit 0