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