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