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