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