]> git.sur5r.net Git - openldap/blob - tests/scripts/test003-search
Filter timestamps, etc., from all test inputs before compare.
[openldap] / tests / scripts / test003-search
1 #! /bin/sh
2
3 if test $# -eq 0 ; then
4         SRCDIR="."
5 else
6         SRCDIR=$1; shift
7 fi
8 if test $# -eq 1 ; then
9         BACKEND=$1; shift
10 fi
11
12 echo "running defines.sh $SRCDIR $BACKEND"
13 . $SRCDIR/scripts/defines.sh
14
15 echo "Cleaning up in $DBDIR..."
16
17 rm -f $DBDIR/[!C]*
18
19 echo "Running ldif2ldbm to build slapd database..."
20 $LDIF2LDBM -f $CONF -i $LDIF -e ../servers/slapd/tools
21 RC=$?
22 if test $RC != 0 ; then
23         echo "ldif2ldbm failed!"
24         exit $RC
25 fi
26
27 echo "Starting slapd on TCP/IP port $PORT..."
28 $SLAPD -f $CONF -p $PORT -d $LVL $TIMING > $MASTERLOG 2>&1 &
29 PID=$!
30
31 echo "Testing slapd searching..."
32 for i in 0 1 2 3 4 5; do
33         $LDAPSEARCH -L -S "" -b "$BASEDN" -h localhost -p $PORT \
34                 'cn=Manager' > /dev/null 2>&1
35         RC=$?
36         if test $RC = 1 ; then
37                 echo "Waiting 5 seconds for slapd to start..."
38                 sleep 5
39         fi
40 done
41
42 if test $RC != 0 ; then
43         echo "ldapsearch failed!"
44         kill -HUP $PID
45         exit $RC
46 fi
47
48 cat /dev/null > $SEARCHOUT
49
50 echo "Testing exact searching..."
51 $LDAPSEARCH -L -S "" -b "$BASEDN" -h localhost -p $PORT \
52         'sn=jensen' >> $SEARCHOUT 2>&1
53 if test $RC != 0 ; then
54         echo "ldapsearch failed!"
55         kill -HUP $PID
56         exit $RC
57 fi
58
59 echo "Testing OR searching..."
60 $LDAPSEARCH -L -S "" -b "$BASEDN" -h localhost -p $PORT \
61         '(|(objectclass=rfc822mailgroup)(sn=jones))' >> $SEARCHOUT 2>&1
62 if test $RC != 0 ; then
63         echo "ldapsearch failed!"
64         kill -HUP $PID
65         exit $RC
66 fi
67
68 echo "Testing AND matching and ends-with searching..."
69 $LDAPSEARCH -L -S "" -b "$BASEDN" -h localhost -p $PORT \
70         '(&(objectclass=rfc822mailgroup)(cn=A*))' >> $SEARCHOUT 2>&1
71 if test $RC != 0 ; then
72         echo "ldapsearch failed!"
73         kill -HUP $PID
74         exit $RC
75 fi
76
77 echo "Testing NOT searching..."
78 $LDAPSEARCH -L -S "" -b "$BASEDN" -h localhost -p $PORT \
79         '(!(objectclass=person))' >> $SEARCHOUT 2>&1
80 if test $RC != 0 ; then
81         echo "ldapsearch failed!"
82         kill -HUP $PID
83         exit $RC
84 fi
85
86 kill -HUP $PID
87
88 TESTOUT=$SEARCHOUT
89 LDIF=$SEARCHOUTMASTER
90
91 echo "Filtering ldapsearch results..."
92 . $SRCDIR/scripts/acfilter.sh < $SEARCHOUT > $SEARCHFLT
93 echo "Filtering original ldif used to create database..."
94 . $SRCDIR/scripts/acfilter.sh < $LDIF > $LDIFFLT
95 echo "Comparing filter output..."
96 cmp $SEARCHFLT $LDIFFLT
97
98 if test $? != 0 ; then
99         echo "Comparison failed"
100         exit 1
101 fi
102
103 echo ">>>>> Test succeeded"
104
105
106 exit 0