]> git.sur5r.net Git - openldap/blob - tests/scripts/test002-populate
Updates for back-bdb testing
[openldap] / tests / scripts / test002-populate
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 "Starting slapd on TCP/IP port $PORT..."
21 . $CONFFILTER $BACKEND < $CONF > $DBCONF
22 $SLAPD -f $DBCONF -h $MASTERURI -d $LVL $TIMING > $MASTERLOG 2>&1 &
23 PID=$!
24
25 echo "Using ldapsearch to check that slapd is running..."
26 for i in 0 1 2 3 4 5; do
27         $LDAPSEARCH -s base -b "$MONITOR" -h localhost -p $PORT \
28                 'objectclass=*' > /dev/null 2>&1
29         RC=$?
30         if test $RC = 1 ; then
31                 echo "Waiting 5 seconds for slapd to start..."
32                 sleep 5
33         fi
34 done
35
36 echo "Using ldapadd to populate the database..."
37 $LDAPADD -D "$MANAGERDN" -h localhost -p $PORT -w $PASSWD < \
38         $LDIFORDERED > $TESTOUT 2>&1
39 RC=$?
40 if test $RC != 0 ; then
41         echo "ldapadd failed ($RC)!"
42         kill -HUP $PID
43         exit $RC
44 fi
45
46 echo "Using ldapsearch to read all the entries..."
47 $LDAPSEARCH -S "" -b "$BASEDN" -h localhost -p $PORT \
48         'objectclass=*' > $SEARCHOUT 2>&1
49
50 kill -HUP $PID
51
52 if test $RC != 0 ; then
53         echo "ldapsearch failed ($RC)!"
54         exit $RC
55 fi
56
57 echo "Filtering ldapsearch results..."
58 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
59 echo "Filtering original ldif used to create database..."
60 . $LDIFFILTER < $LDIF > $LDIFFLT
61 echo "Comparing filter output..."
62 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
63
64 if test $? != 0 ; then
65         echo "comparison failed - database was not created correctly"
66         exit 1
67 fi
68
69 echo ">>>>> Test succeeded"
70
71
72 exit 0