]> git.sur5r.net Git - openldap/blob - tests/scripts/test002-populate
Extend TLS/SSL detection for use RSAref if necessary.
[openldap] / tests / scripts / test002-populate
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 "Starting slapd on TCP/IP port $PORT..."
19 $SLAPD -f $CONF -p $PORT -d $LVL $TIMING > $MASTERLOG 2>&1 &
20 PID=$!
21
22 echo "Using ldapsearch to check that slapd is running..."
23 for i in 0 1 2 3 4 5; do
24         $LDAPSEARCH -L -b "$BASEDN" -h localhost -p $PORT \
25                 'cn=Monitor' > /dev/null 2>&1
26         RC=$?
27         if [ $RC = 1 ]; then
28                 echo "Waiting 5 seconds for slapd to start..."
29                 sleep 5
30         fi
31 done
32
33 echo "Using ldapmodify to populate the database..."
34 $LDAPMODIFY -a -D "$MANAGERDN" -h localhost -p $PORT -w $PASSWD < \
35         $LDIFORDERED > /dev/null 2>&1
36 RC=$?
37 if [ $RC != 0 ]; then
38         echo "ldapmodify failed!"
39         kill -HUP $PID
40         exit $RC
41 fi
42
43 echo "Using ldapsearch to read all the entries..."
44 $LDAPSEARCH -L -S "" -b "$BASEDN" -h localhost -p $PORT \
45         'objectclass=*' | egrep -iv '^creatorsname:|^createtimestamp:' > \
46         $SEARCHOUT 2>&1
47
48 kill -HUP $PID
49
50 if [ $RC != 0 ]; then
51         echo "ldapsearch failed!"
52         exit $RC
53 fi
54
55 echo "Filtering ldapsearch results..."
56 . $SRCDIR/scripts/acfilter.sh < $SEARCHOUT > $SEARCHFLT
57 echo "Filtering original ldif used to create database..."
58 . $SRCDIR/scripts/acfilter.sh < $LDIF > $LDIFFLT
59 echo "Comparing filter output..."
60 cmp $SEARCHFLT $LDIFFLT
61
62 if [ $? != 0 ]; then
63         echo "comparison failed - database was not created correctly"
64         exit 1
65 fi
66
67 echo ">>>>> Test succeeded"
68
69
70 exit 0