]> git.sur5r.net Git - openldap/blob - tests/scripts/test001-slapadd
Check LOCK_ID() return
[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 = 1 ; then
53                 echo "Waiting 5 seconds for slapd to start..."
54                 sleep 5
55         fi
56 done
57
58 kill -HUP $PID
59
60 if test $RC != 0 ; then
61         echo "ldapsearch failed ($RC)!"
62         exit $RC
63 fi
64
65 echo "Filtering ldapsearch results..."
66 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
67 echo "Filtering original ldif used to create database..."
68 . $LDIFFILTER < $LDIF > $LDIFFLT
69 echo "Comparing filter output..."
70 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
71
72 if test $? != 0 ; then
73         echo "comparison failed - database was not created correctly"
74         echo $SEARCHFLT $LDIFFLT
75         $DIFF $SEARCHFLT $LDIFFLT
76         exit 1
77 fi
78
79 echo ">>>>> Test succeeded"
80
81
82 exit 0