]> git.sur5r.net Git - openldap/blob - tests/scripts/test001-slapadd
Import from devel
[openldap] / tests / scripts / test001-slapadd
1 #! /bin/sh
2 # $OpenLDAP$
3
4 if test $# -eq 0 ; then
5         SRCDIR="."
6 else
7         SRCDIR=$1; shift
8 fi
9 if test $# -eq 1 ; then
10         BACKEND=$1; shift
11 fi
12
13 echo "running defines.sh $SRCDIR $BACKEND"
14
15 . $SRCDIR/scripts/defines.sh
16
17 echo "Datadir is $DATADIR"
18
19 echo "Cleaning up in $DBDIR..."
20
21 rm -f $DBDIR/[!C]*
22
23 echo "Running slapadd to build slapd database..."
24 $LDIF2LDBM -f $CONF -l $LDIF
25 RC=$?
26 if test $RC != 0 ; then
27         echo "slapadd failed!"
28         exit $RC
29 fi
30
31 echo "Starting slapd on TCP/IP port $PORT..."
32 $SLAPD -f $CONF -p $PORT -d $LVL $TIMING > $MASTERLOG 2>&1 &
33 PID=$!
34
35 echo "Using ldapsearch to retrieve all the entries..."
36 for i in 0 1 2 3 4 5; do
37         $LDAPSEARCH -S "" -b "$BASEDN" -h localhost -p $PORT \
38                 'objectClass=*' > $SEARCHOUT 2>&1
39         RC=$?
40         if test $RC = 1 ; then
41                 echo "Waiting 5 seconds for slapd to start..."
42                 sleep 5
43         fi
44 done
45
46 kill -HUP $PID
47
48 if test $RC != 0 ; then
49         echo "ldapsearch failed!"
50         exit $RC
51 fi
52
53 echo "Filtering ldapsearch results..."
54 . $SRCDIR/scripts/acfilter.sh < $SEARCHOUT > $SEARCHFLT
55 echo "Filtering original ldif used to create database..."
56 . $SRCDIR/scripts/acfilter.sh < $LDIF > $LDIFFLT
57 echo "Comparing filter output..."
58 cmp $SEARCHFLT $LDIFFLT
59
60 if test $? != 0 ; then
61         echo "comparison failed - database was not created correctly"
62         exit 1
63 fi
64
65 echo ">>>>> Test succeeded"
66
67
68 exit 0