]> git.sur5r.net Git - openldap/blob - tests/scripts/test001-slapadd
Fix last commit
[openldap] / tests / scripts / test001-slapadd
1 #! /bin/sh
2 # $OpenLDAP$
3
4 echo "running defines.sh"
5 . $SRCDIR/scripts/defines.sh
6
7 mkdir -p $TESTRUN $DBDIR1
8
9 echo "Running slapadd to build slapd database..."
10 . $CONFFILTER $BACKEND $MONITORDB < $CONF > $ADDCONF
11 $SLAPADD -f $ADDCONF -l $LDIFORDERED
12 RC=$?
13 if test $RC != 0 ; then
14         echo "slapadd failed ($RC)!"
15         exit $RC
16 fi
17
18 echo "Starting slapd on TCP/IP port $PORT1..."
19 . $CONFFILTER $BACKEND $MONITORDB < $CONF > $CONF1
20 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
21 PID=$!
22 if test $WAIT != 0 ; then
23     echo PID $PID
24     read foo
25 fi
26 KILLPIDS="$PID"
27
28 echo "Using ldapsearch to retrieve all the entries..."
29 for i in 0 1 2 3 4 5; do
30         $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 > $SEARCHOUT 2>&1
31         RC=$?
32         if test $RC = 0 ; then
33                 break
34         fi
35         echo "Waiting 5 seconds for slapd to start..."
36         sleep 5
37 done
38
39 test $KILLSERVERS != no && kill -HUP $KILLPIDS
40
41 if test $RC != 0 ; then
42         echo "ldapsearch failed ($RC)!"
43         exit $RC
44 fi
45
46 echo "Filtering ldapsearch results..."
47 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
48 echo "Filtering original ldif used to create database..."
49 . $LDIFFILTER < $LDIF > $LDIFFLT
50 echo "Comparing filter output..."
51 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
52
53 if test $? != 0 ; then
54         echo "comparison failed - database was not created correctly"
55         echo $SEARCHFLT $LDIFFLT
56         $DIFF $SEARCHFLT $LDIFFLT
57         exit 1
58 fi
59
60 echo ">>>>> Test succeeded"
61 exit 0