]> git.sur5r.net Git - openldap/blob - tests/scripts/test001-ldif2ldbm
ab92db145518c2f68b8cfe6ddf3ef223efbb5ea5
[openldap] / tests / scripts / test001-ldif2ldbm
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
14 . $SRCDIR/scripts/defines.sh
15
16 echo "Datadir is $DATADIR"
17
18 echo "Cleaning up in $DBDIR..."
19
20 rm -f $DBDIR/[!C]*
21
22 echo "Running ldif2ldbm to build slapd database..."
23 $LDIF2LDBM -f $CONF -i $LDIF -e ../servers/slapd/tools
24 RC=$?
25 if test $RC != 0 ; then
26         echo "ldif2ldbm failed!"
27         exit $RC
28 fi
29
30 echo "Starting slapd on TCP/IP port $PORT..."
31 $SLAPD -f $CONF -p $PORT -d $LVL $TIMING > $MASTERLOG 2>&1 &
32 PID=$!
33
34 echo "Using ldapsearch to retrieve all the entries..."
35 for i in 0 1 2 3 4 5; do
36         $LDAPSEARCH -L -S "" -b "$BASEDN" -h localhost -p $PORT \
37                 'objectClass=*' > $SEARCHOUT 2>&1
38         RC=$?
39         if test $RC = 1 ; then
40                 echo "Waiting 5 seconds for slapd to start..."
41                 sleep 5
42         fi
43 done
44
45 kill -HUP $PID
46
47 if test $RC != 0 ; then
48         echo "ldapsearch failed!"
49         exit $RC
50 fi
51
52 echo "Comparing retrieved entries to LDIF file used to create database"
53 cmp $SEARCHOUT $LDIF
54 if test $? != 0 ; then
55         echo "comparison failed - database was not created correctly"
56         exit 1
57 fi
58
59 echo ">>>>> Test succeeded"
60
61
62 exit 0