]> git.sur5r.net Git - openldap/blob - tests/scripts/test002-populate
Filter timestamps, etc., from all test inputs before compare.
[openldap] / tests / scripts / test002-populate
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 "Starting slapd on TCP/IP port $PORT..."
20 $SLAPD -f $CONF -p $PORT -d $LVL $TIMING > $MASTERLOG 2>&1 &
21 PID=$!
22
23 echo "Using ldapsearch to check that slapd is running..."
24 for i in 0 1 2 3 4 5; do
25         $LDAPSEARCH -L -b "$BASEDN" -h localhost -p $PORT \
26                 'cn=Monitor' > /dev/null 2>&1
27         RC=$?
28         if test $RC = 1 ; then
29                 echo "Waiting 5 seconds for slapd to start..."
30                 sleep 5
31         fi
32 done
33
34 echo "Using ldapmodify to populate the database..."
35 $LDAPMODIFY -a -D "$MANAGERDN" -h localhost -p $PORT -w $PASSWD < \
36         $LDIFORDERED > /dev/null 2>&1
37 RC=$?
38 if test $RC != 0 ; then
39         echo "ldapmodify failed!"
40         kill -HUP $PID
41         exit $RC
42 fi
43
44 echo "Using ldapsearch to read all the entries..."
45 $LDAPSEARCH -L -S "" -b "$BASEDN" -h localhost -p $PORT \
46         'objectclass=*' > $SEARCHOUT 2>&1
47
48 kill -HUP $PID
49
50 if test $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 test $? != 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