]> git.sur5r.net Git - openldap/blob - tests/scripts/test001-slapadd
5be29b8d2e7d0465c9431e634a6d28fa4957f69e
[openldap] / tests / scripts / test001-slapadd
1 #! /bin/sh
2 # $OpenLDAP$
3
4 echo "running defines.sh"
5 . $SRCDIR/scripts/defines.sh
6
7 mkdir $DBDIR
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 $PORT..."
19 . $CONFFILTER $BACKEND $MONITORDB < $CONF > $DBCONF
20 $SLAPD -f $DBCONF -h $MASTERURI -d $LVL $TIMING > $MASTERLOG 2>&1 &
21 PID=$!
22 if test $WAIT != 0 ; then
23     echo PID $PID
24     read foo
25 fi
26
27 echo "Using ldapsearch to retrieve all the entries..."
28 for i in 0 1 2 3 4 5; do
29         $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT > $SEARCHOUT 2>&1
30         RC=$?
31         if test $RC = 0 ; then
32                 break
33         fi
34         echo "Waiting 5 seconds for slapd to start..."
35         sleep 5
36 done
37
38 kill -HUP $PID
39
40 if test $RC != 0 ; then
41         echo "ldapsearch failed ($RC)!"
42         exit $RC
43 fi
44
45 echo "Filtering ldapsearch results..."
46 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
47 echo "Filtering original ldif used to create database..."
48 . $LDIFFILTER < $LDIF > $LDIFFLT
49 echo "Comparing filter output..."
50 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
51
52 if test $? != 0 ; then
53         echo "comparison failed - database was not created correctly"
54         echo $SEARCHFLT $LDIFFLT
55         $DIFF $SEARCHFLT $LDIFFLT
56         exit 1
57 fi
58
59 echo ">>>>> Test succeeded"
60 exit 0