]> git.sur5r.net Git - openldap/blob - tests/scripts/test005-modrdn
Update lutil_lockf (aka: ldap_lockf) to hide implementation in
[openldap] / tests / scripts / test005-modrdn
1 #!/bin/sh
2
3 if [ $# -eq 0 ]; then
4         SRCDIR="."
5 else
6         SRCDIR=$1; shift
7 fi
8 if [ $# -eq 1 ]; then
9         BDB2=$1; shift
10 fi
11
12 . $SRCDIR/scripts/defines.sh $SRCDIR $BDB2
13
14 echo "Cleaning up in $DBDIR..."
15
16 rm -f $DBDIR/[!C]*
17
18 echo "Running ldif2ldbm to build slapd database..."
19 $LDIF2LDBM -f $CONF -i $LDIF -e ../servers/slapd/tools
20 RC=$?
21 if [ $RC != 0 ]; then
22         echo "ldif2ldbm failed!"
23         exit $RC
24 fi
25
26 echo "Starting slapd on TCP/IP port $PORT..."
27 $SLAPD -f $CONF -p $PORT -d $LVL $TIMING > $MASTERLOG 2>&1 &
28 PID=$!
29 echo "Testing slapd modrdn operations..."
30
31 # Make sure we can search the database
32 for i in 0 1 2 3 4 5; do
33         $LDAPSEARCH -L -S "" -b "$BASEDN" -h localhost -p $PORT \
34                 'cn=Manager' > /dev/null 2>&1
35         RC=$?
36         if [ $RC = 1 ]; then
37                 echo "Waiting 5 seconds for slapd to start..."
38                 sleep 5
39         fi
40 done
41
42 if [ $RC != 0 ]; then
43         echo "ldapsearch failed!"
44         kill -HUP $PID
45         exit $RC
46 fi
47
48 cat /dev/null > $TESTOUT
49
50
51 # -r used to do remove of old rdn
52
53 echo "Testing modrdn(deleteoldrdn=0)..."
54 $LDAPMODRDN -v -D "$MANAGERDN" -h localhost -p $PORT -w $PASSWD > \
55         /dev/null 2>&1 'cn=James A Jones 1, ou=Alumni Association, ou=People, o=University of Michigan, c=US' 'cn=James A Jones III'
56
57 RC=$?
58 if [ $RC != 0 ]; then
59         echo "ldapmodrdn failed!"
60         kill -HUP $PID
61         exit $RC
62 fi
63
64 echo "Testing modrdn(deleteoldrdn=1)..."
65 $LDAPMODRDN -v -D "$MANAGERDN" -r -h localhost -p $PORT -w $PASSWD > \
66         /dev/null 2>&1 'cn=James A Jones 2, ou=Information Technology Division, ou=People, o=University of Michigan, c=US' 'cn=James A Jones II'
67
68 RC=$?
69 if [ $RC != 0 ]; then
70         echo "ldapmodrdn failed!"
71         kill -HUP $PID
72         exit $RC
73 fi
74
75 echo "Using ldapsearch to retrieve all the entries..."
76 $LDAPSEARCH -L -S "" -b "$BASEDN" -h localhost -p $PORT \
77             'objectClass=*' | egrep -iv '^createtimestamp:|^modifytimestamp:' \
78             > $SEARCHOUT 2>&1
79 RC=$?
80 kill -HUP $PID
81 if [ $RC != 0 ]; then
82         echo "ldapsearch failed!"
83         exit $RC
84 fi
85
86 echo "Comparing database to reference file"
87 cmp $SEARCHOUT $MODRDNOUTMASTER
88 if [ $? != 0 ]; then
89         echo "comparison failed - modrdn operations did not complete correctly"
90         exit 1
91 fi
92
93 echo ">>>>> Test succeeded"
94
95
96
97 # echo "modrdn test not yet written"
98
99 exit 0