xref: /netbsd-src/external/bsd/openldap/dist/tests/data/regressions/its6794/its6794 (revision 15a984a0d95c8f96abe9717ee6241762c55dc106)
1#! /bin/sh
2# $OpenLDAP$
3## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4##
5## Copyright 1998-2021 The OpenLDAP Foundation.
6## All rights reserved.
7##
8## Redistribution and use in source and binary forms, with or without
9## modification, are permitted only as authorized by the OpenLDAP
10## Public License.
11##
12## A copy of this license is available in the file LICENSE in the
13## top-level directory of the distribution or, alternatively, at
14## <http://www.OpenLDAP.org/license.html>.
15
16echo "running defines.sh"
17. $SRCDIR/scripts/defines.sh
18
19rm -rf $TESTDIR
20
21mkdir -p $TESTDIR $DBDIR1A $DBDIR1B $DBDIR1C
22ITS=6794
23ITSDIR=$DATADIR/regressions/its$ITS
24ITSCONF=$ITSDIR/slapd-glue.conf
25
26echo "Running multi-threaded slapadd in quick mode to build glued slapd databases..."
27. $CONFFILTER $BACKEND < $ITSCONF > $CONF1
28$SLAPADD -q -d $LVL -f $CONF1 -l $LDIFORDERED > $SLAPADDLOG1 2>&1
29RC=$?
30if test $RC != 0 ; then
31	echo "slapadd failed ($RC)!"
32	exit $RC
33fi
34
35echo "Starting slapd on TCP/IP port $PORT1..."
36$SLAPD -f $CONF1 -h $URI1 -d $LVL > $LOG1 2>&1 &
37PID=$!
38if test $WAIT != 0 ; then
39    echo PID $PID
40    read foo
41fi
42KILLPIDS="$PID"
43
44sleep 1
45
46echo "Using ldapsearch to retrieve all the entries..."
47for i in 0 1 2 3 4 5; do
48	$LDAPSEARCH -b "$BASEDN" -H $URI1 > $SEARCHOUT 2>&1
49	RC=$?
50	if test $RC = 0 ; then
51		break
52	fi
53	echo "Waiting 5 seconds for slapd to start..."
54	sleep 5
55done
56
57if test $RC != 0 ; then
58	echo "ldapsearch failed ($RC)!"
59	test $KILLSERVERS != no && kill -HUP $KILLPIDS
60	exit $RC
61fi
62
63echo "Filtering ldapsearch results..."
64$LDIFFILTER -s ldif=e < $SEARCHOUT > $SEARCHFLT
65echo "Filtering original ldif used to create database..."
66$LDIFFILTER -s ldif=e < $LDIFGLUED > $LDIFFLT
67echo "Comparing filter output..."
68$CMP $SEARCHFLT $LDIFFLT > $CMPOUT
69
70if test $? != 0 ; then
71	echo "comparison failed - database was not created correctly"
72	echo $SEARCHFLT $LDIFFLT
73	$DIFF $SEARCHFLT $LDIFFLT
74	test $KILLSERVERS != no && kill -HUP $KILLPIDS
75	exit 1
76fi
77
78test $KILLSERVERS != no && kill -HUP $KILLPIDS
79
80echo ">>>>> Test succeeded"
81
82test $KILLSERVERS != no && wait
83
84exit 0
85