]> git.sur5r.net Git - openldap/commitdiff
Client programs for test008-concurrency moved to subdir tests/progs.
authorKurt Spanier <ksp@openldap.org>
Mon, 22 Feb 1999 11:28:01 +0000 (11:28 +0000)
committerKurt Spanier <ksp@openldap.org>
Mon, 22 Feb 1999 11:28:01 +0000 (11:28 +0000)
Building tests/progs/*.c in the main build process.
==> Test-suite must be called by 'make test', or 'make test-bdb2'

16 files changed:
Makefile.in
configure
configure.in
tests/Makefile.in
tests/data/slapd-bdb2-master.conf
tests/progs/Makefile.in [new file with mode: 0644]
tests/progs/slapd-addel.c [new file with mode: 0644]
tests/progs/slapd-read.c [new file with mode: 0644]
tests/progs/slapd-search.c [new file with mode: 0644]
tests/progs/slapd-tester.c [new file with mode: 0644]
tests/scripts/defines.sh
tests/scripts/test008-concurrency
tests/slapd-addel.c [deleted file]
tests/slapd-read.c [deleted file]
tests/slapd-search.c [deleted file]
tests/slapd-tester.c [deleted file]

index aaac8d65039aaa38cb197c6c7da3368b3152b719..f832bd07e97bc21ddf78b0e6030c04b1ca46d336 100644 (file)
@@ -9,8 +9,8 @@
 ## in file LICENSE in the top-level directory of the distribution.
 ##
 
-SUBDIRS= include libraries clients servers # contrib
-CLEANDIRS= tests doc
+SUBDIRS= include libraries clients servers tests # contrib
+CLEANDIRS= doc # tests doc
 INSTALLDIRS= doc
 
 makefiles:     FORCE
index 573fb573d3e7d86020baf2738b7514dfe8085d51..4361158c11de59142f200cec83b5be594332f9db 100755 (executable)
--- a/configure
+++ b/configure
@@ -9830,7 +9830,8 @@ servers/slapd/back-tcl/Makefile:build/top.mk:servers/slapd/back-tcl/Makefile.in:
 servers/slapd/shell-backends/Makefile:build/top.mk:servers/slapd/shell-backends/Makefile.in:build/srv.mk \
 servers/slapd/tools/Makefile:build/top.mk:servers/slapd/tools/Makefile.in \
 servers/slurpd/Makefile:build/top.mk:servers/slurpd/Makefile.in:build/srv.mk \
-tests/Makefile:build/top.mk:tests/Makefile.in \
+tests/Makefile:build/top.mk:tests/Makefile.in:build/dir.mk \
+tests/progs/Makefile:build/top.mk:tests/progs/Makefile.in:build/rules.mk \
  include/portable.h include/ldap_features.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
 EOF
 cat >> $CONFIG_STATUS <<EOF
@@ -9995,7 +9996,8 @@ servers/slapd/back-tcl/Makefile:build/top.mk:servers/slapd/back-tcl/Makefile.in:
 servers/slapd/shell-backends/Makefile:build/top.mk:servers/slapd/shell-backends/Makefile.in:build/srv.mk \
 servers/slapd/tools/Makefile:build/top.mk:servers/slapd/tools/Makefile.in \
 servers/slurpd/Makefile:build/top.mk:servers/slurpd/Makefile.in:build/srv.mk \
-tests/Makefile:build/top.mk:tests/Makefile.in \
+tests/Makefile:build/top.mk:tests/Makefile.in:build/dir.mk \
+tests/progs/Makefile:build/top.mk:tests/progs/Makefile.in:build/rules.mk \
 "}
 EOF
 cat >> $CONFIG_STATUS <<\EOF
index 5b49908715507a5922f26cfd9f0c03c7d113967c..95f79d2982ce6f1a9bda0b3a43e2e98aca7092b8 100644 (file)
@@ -1691,7 +1691,8 @@ servers/slapd/back-tcl/Makefile:build/top.mk:servers/slapd/back-tcl/Makefile.in:
 servers/slapd/shell-backends/Makefile:build/top.mk:servers/slapd/shell-backends/Makefile.in:build/srv.mk \
 servers/slapd/tools/Makefile:build/top.mk:servers/slapd/tools/Makefile.in \
 servers/slurpd/Makefile:build/top.mk:servers/slurpd/Makefile.in:build/srv.mk \
-tests/Makefile:build/top.mk:tests/Makefile.in \
+tests/Makefile:build/top.mk:tests/Makefile.in:build/dir.mk \
+tests/progs/Makefile:build/top.mk:tests/progs/Makefile.in:build/rules.mk \
 ,[
 date > stamp-h
 echo Please \"make depend\" to build dependencies
index 7b4e6331093cbb246ce3122310e63e40824b1a5f..474ede5a79a41a04597c7be557a58ff5beeea776 100644 (file)
@@ -2,34 +2,11 @@
 ## COPYING RESTRICTIONS APPLY, see COPYRIGHT file
 ##
 ## tests Makefile.in for OpenLDAP
-BUILD_BDB2 = @BUILD_BDB2@
-
-SRC      = slapd-tester.c slapd-search.c
-PROGRAMS = slapd-tester slapd-search slapd-read slapd-addel
-
-LDAP_INCDIR= ../include
-LDAP_LIBDIR= ../libraries
-
-XLIBS    = -lldap_r -llber -llutil
-
-build-tools: FORCE
-       $(MAKE) $(MFLAGS) load-tools
+SUBDIRS= progs
 
-load-tools: $(PROGRAMS)
-
-slapd-tester: slapd-tester.o 
-       $(LTLINK) -o $@ slapd-tester.o
-
-slapd-search: slapd-search.o $(LDAP_LIBLBER_DEPEND) $(LDAP_LIBLDAP_DEPEND)
-       $(LTLINK) -o $@ slapd-search.o $(LIBS)
-
-slapd-read: slapd-read.o $(LDAP_LIBLBER_DEPEND) $(LDAP_LIBLDAP_DEPEND)
-       $(LTLINK) -o $@ slapd-read.o $(LIBS)
-
-slapd-addel: slapd-addel.o $(LDAP_LIBLBER_DEPEND) $(LDAP_LIBLDAP_DEPEND)
-       $(LTLINK) -o $@ slapd-addel.o $(LIBS)
+BUILD_BDB2 = @BUILD_BDB2@
 
-bdb2-local:    build-tools FORCE
+test-bdb2:     FORCE
        @if test "$(BUILD_BDB2)" = "yes" ; then \
                $(LN_S) $(srcdir)/data . ; \
                echo "Initiating LDAP tests..." ; \
@@ -39,7 +16,8 @@ bdb2-local:   build-tools FORCE
                echo "run configure with --enable-bdb2" ; \
        fi
 
-all-local:     build-tools FORCE
+test:          test-ldbm
+test-ldbm:     FORCE
        @-$(LN_S) $(srcdir)/data .
        @echo "Initiating LDAP tests..."; \
        $(MKDIR) test-db test-repl ; \
index 2dad68bfc0e294c0a6a380910511bcc015aba24e..374f7881ecd6f9b8f56f0cf0a262ef61d8769d30 100644 (file)
@@ -13,7 +13,7 @@ argsfile    ./test-db/slapd.args
 
 backend                bdb2
 home           ./test-db
-mpoolsize      2100000
+mpoolsize      21000000
 
 database       bdb2
 cachesize      4
diff --git a/tests/progs/Makefile.in b/tests/progs/Makefile.in
new file mode 100644 (file)
index 0000000..6e5bcb1
--- /dev/null
@@ -0,0 +1,31 @@
+## Copyright 1998 The OpenLDAP Foundation, All Rights Reserved.
+## COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+##
+## tests Makefile.in for OpenLDAP
+
+PROGRAMS = slapd-tester slapd-search slapd-read slapd-addel
+SRCS     = slapd-tester.c slapd-search.c slapd-read.c slapd-addel.c
+
+LDAP_INCDIR= ../../include
+LDAP_LIBDIR= ../../libraries
+
+XLIBS    = -lldap -llber -llutil
+
+# build-tools: FORCE
+# $(MAKE) $(MFLAGS) load-tools
+
+# load-tools: $(PROGRAMS)
+
+slapd-tester: slapd-tester.o 
+       $(LTLINK) -o $@ slapd-tester.o
+
+slapd-search: slapd-search.o $(LDAP_LIBLBER_DEPEND) $(LDAP_LIBLDAP_DEPEND)
+       $(LTLINK) -o $@ slapd-search.o $(LIBS)
+
+slapd-read: slapd-read.o $(LDAP_LIBLBER_DEPEND) $(LDAP_LIBLDAP_DEPEND)
+       $(LTLINK) -o $@ slapd-read.o $(LIBS)
+
+slapd-addel: slapd-addel.o $(LDAP_LIBLBER_DEPEND) $(LDAP_LIBLDAP_DEPEND)
+       $(LTLINK) -o $@ slapd-addel.o $(LIBS)
+
+
diff --git a/tests/progs/slapd-addel.c b/tests/progs/slapd-addel.c
new file mode 100644 (file)
index 0000000..e99fbf0
--- /dev/null
@@ -0,0 +1,280 @@
+#include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/string.h>
+#include <ac/ctype.h>
+#include <ac/socket.h>
+#include <ac/unistd.h>
+#include <ac/wait.h>
+
+#include <sys/param.h>
+
+#include "lber.h"
+#include "ldap.h"
+
+#define LOOPS  100
+
+static char *
+get_add_entry( char *filename, LDAPMod ***mods );
+
+static void
+do_addel( char *host, int port, char *manager, char *passwd,
+       char *dn, LDAPMod **attrs, int maxloop );
+
+static void
+usage( char *name )
+{
+       fprintf( stderr, "usage: %s [-h <host>] -p port -D <managerDN> -w <passwd> -f <addfile> [-l <loops>]\n",
+                       name );
+       exit( 1 );
+}
+
+int
+main( int argc, char **argv )
+{
+       int             i, j;
+       char        *host = "localhost";
+       int                     port = -1;
+       char            *manager = NULL;
+       char            *passwd = NULL;
+       char            *filename = NULL;
+       char            *entry = NULL;
+       int                     loops = LOOPS;
+       LDAPMod     **attrs = NULL;
+
+       while ( (i = getopt( argc, argv, "h:p:D:w:f:l:" )) != EOF ) {
+               switch( i ) {
+                       case 'h':               /* the servers host */
+                               host = strdup( optarg );
+                       break;
+
+                       case 'p':               /* the servers port */
+                               port = atoi( optarg );
+                               break;
+
+                       case 'D':               /* the servers manager */
+                               manager = strdup( optarg );
+                       break;
+
+                       case 'w':               /* the server managers password */
+                               passwd = strdup( optarg );
+                       break;
+
+                       case 'f':               /* file with entry search request */
+                               filename = strdup( optarg );
+                               break;
+
+                       case 'l':               /* the number of loops */
+                               loops = atoi( optarg );
+                               break;
+
+                       default:
+                               usage( argv[0] );
+                               break;
+               }
+       }
+
+       if (( filename == NULL ) || ( port == -1 ) ||
+                               ( manager == NULL ) || ( passwd == NULL ))
+               usage( argv[0] );
+
+       entry = get_add_entry( filename, &attrs );
+       if (( entry == NULL ) || ( *entry == '\0' )) {
+
+               fprintf( stderr, "%s: invalid entry DN in file \"%s\".\n",
+                               argv[0], filename );
+               exit( 1 );
+
+       }
+
+       if (( attrs == NULL ) || ( *attrs == '\0' )) {
+
+               fprintf( stderr, "%s: invalid attrs in file \"%s\".\n",
+                               argv[0], filename );
+               exit( 1 );
+
+       }
+
+       do_addel( host, port, manager, passwd, entry, attrs, loops );
+
+       exit( 0 );
+}
+
+
+#define safe_realloc( ptr, size )   ( ptr == NULL ? malloc( size ) : \
+                               realloc( ptr, size ))
+
+
+static void
+addmodifyop( LDAPMod ***pmodsp, int modop, char *attr, char *value, int vlen )
+{
+    LDAPMod            **pmods;
+    int                        i, j;
+    struct berval      *bvp;
+
+    pmods = *pmodsp;
+    modop |= LDAP_MOD_BVALUES;
+
+    i = 0;
+    if ( pmods != NULL ) {
+               for ( ; pmods[ i ] != NULL; ++i ) {
+               if ( strcasecmp( pmods[ i ]->mod_type, attr ) == 0 &&
+                       pmods[ i ]->mod_op == modop ) {
+                               break;
+               }
+               }
+    }
+
+    if ( pmods == NULL || pmods[ i ] == NULL ) {
+               if (( pmods = (LDAPMod **)safe_realloc( pmods, (i + 2) *
+                       sizeof( LDAPMod * ))) == NULL ) {
+                       perror( "safe_realloc" );
+                       exit( 1 );
+               }
+               *pmodsp = pmods;
+               pmods[ i + 1 ] = NULL;
+               if (( pmods[ i ] = (LDAPMod *)calloc( 1, sizeof( LDAPMod )))
+                       == NULL ) {
+                       perror( "calloc" );
+                       exit( 1 );
+               }
+               pmods[ i ]->mod_op = modop;
+               if (( pmods[ i ]->mod_type = strdup( attr )) == NULL ) {
+               perror( "strdup" );
+               exit( 1 );
+               }
+    }
+
+    if ( value != NULL ) {
+               j = 0;
+               if ( pmods[ i ]->mod_bvalues != NULL ) {
+               for ( ; pmods[ i ]->mod_bvalues[ j ] != NULL; ++j ) {
+                               ;
+               }
+               }
+               if (( pmods[ i ]->mod_bvalues =
+                       (struct berval **)safe_realloc( pmods[ i ]->mod_bvalues,
+                       (j + 2) * sizeof( struct berval * ))) == NULL ) {
+                       perror( "safe_realloc" );
+                       exit( 1 );
+               }
+               pmods[ i ]->mod_bvalues[ j + 1 ] = NULL;
+               if (( bvp = (struct berval *)malloc( sizeof( struct berval )))
+                       == NULL ) {
+                       perror( "malloc" );
+                       exit( 1 );
+               }
+               pmods[ i ]->mod_bvalues[ j ] = bvp;
+
+           bvp->bv_len = vlen;
+           if (( bvp->bv_val = (char *)malloc( vlen + 1 )) == NULL ) {
+                       perror( "malloc" );
+                       exit( 1 );
+           }
+           SAFEMEMCPY( bvp->bv_val, value, vlen );
+           bvp->bv_val[ vlen ] = '\0';
+    }
+}
+
+
+static char *
+get_add_entry( char *filename, LDAPMod ***mods )
+{
+       FILE    *fp;
+       char    *entry = NULL;
+
+       if ( fp = fopen( filename, "r" )) {
+               char  line[BUFSIZ];
+
+               if ( fgets( line, BUFSIZ, fp )) {
+                       char *nl;
+
+                       if (( nl = strchr( line, '\r' )) || ( nl = strchr( line, '\n' )))
+                               *nl = '\0';
+                       entry = strdup( line );
+
+               }
+
+               while ( fgets( line, BUFSIZ, fp )) {
+                       char    *nl;
+                       char    *value;
+
+                       if (( nl = strchr( line, '\r' )) || ( nl = strchr( line, '\n' )))
+                               *nl = '\0';
+
+                       if ( *line == '\0' ) break;
+                       if ( !( value = strchr( line, ':' ))) break;
+
+                       *value++ = '\0'; 
+                       while ( *value && isspace( *value )) value++;
+
+                       addmodifyop( mods, LDAP_MOD_ADD, line, value, strlen( value ));
+
+               }
+               fclose( fp );
+       }
+
+       return( entry );
+}
+
+
+static void
+do_addel(
+       char *host,
+       int port,
+       char *manager,
+       char *passwd,
+       char *entry,
+       LDAPMod **attrs,
+       int maxloop
+)
+{
+       LDAP    *ld;
+       int     i;
+       pid_t   pid = getpid();
+
+       if (( ld = ldap_init( host, port )) == NULL ) {
+               perror( "ldap_init" );
+               exit( 1 );
+       }
+
+       if ( ldap_bind_s( ld, manager, passwd, LDAP_AUTH_SIMPLE )
+                               != LDAP_SUCCESS ) {
+               ldap_perror( ld, "ldap_bind" );
+                exit( 1 );
+       }
+
+
+       fprintf( stderr, "PID=%ld - Add/Delete(%d): entry=\"%s\".\n",
+                                       pid, maxloop, entry );
+
+       for ( i = 0; i < maxloop; i++ ) {
+
+               /* add the entry */
+               if ( ldap_add_s( ld, entry, attrs ) != LDAP_SUCCESS ) {
+
+                       ldap_perror( ld, "ldap_add" );
+                       break;
+
+               }
+
+               /* wait a second for the add to really complete */
+               sleep( 1 );
+
+               /* now delete the entry again */
+               if ( ldap_delete_s( ld, entry ) != LDAP_SUCCESS ) {
+
+                       ldap_perror( ld, "ldap_delete" );
+                       break;
+
+               }
+
+       }
+
+       fprintf( stderr, " PID=%ld - Add/Delete done.\n", pid );
+
+       ldap_unbind( ld );
+}
+
+
diff --git a/tests/progs/slapd-read.c b/tests/progs/slapd-read.c
new file mode 100644 (file)
index 0000000..b94ec3e
--- /dev/null
@@ -0,0 +1,123 @@
+#include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/string.h>
+#include <ac/ctype.h>
+#include <ac/socket.h>
+#include <ac/unistd.h>
+#include <ac/wait.h>
+
+#include <sys/param.h>
+
+#include "lber.h"
+#include "ldap.h"
+
+#define LOOPS  100
+
+static void
+do_read( char *host, int port, char *entry, int maxloop );
+
+static void
+usage( char *name )
+{
+       fprintf( stderr, "usage: %s [-h <host>] -p port -e <entry> [-l <loops>]\n",
+                       name );
+       exit( 1 );
+}
+
+int
+main( int argc, char **argv )
+{
+       int             i, j;
+       char        *host = "localhost";
+       int                     port = -1;
+       char            *entry = NULL;
+       int                     loops = LOOPS;
+
+       while ( (i = getopt( argc, argv, "h:p:e:l:" )) != EOF ) {
+               switch( i ) {
+                       case 'h':               /* the servers host */
+                               host = strdup( optarg );
+                       break;
+
+                       case 'p':               /* the servers port */
+                               port = atoi( optarg );
+                               break;
+
+                       case 'e':               /* file with entry search request */
+                               entry = strdup( optarg );
+                               break;
+
+                       case 'l':               /* the number of loops */
+                               loops = atoi( optarg );
+                               break;
+
+                       default:
+                               usage( argv[0] );
+                               break;
+               }
+       }
+
+       if (( entry == NULL ) || ( port == -1 ))
+               usage( argv[0] );
+
+       if ( *entry == '\0' ) {
+
+               fprintf( stderr, "%s: invalid EMPTY entry DN.\n",
+                               argv[0] );
+               exit( 1 );
+
+       }
+
+       do_read( host, port, entry, ( 4 * loops ));
+
+       exit( 0 );
+}
+
+
+static void
+do_read( char *host, int port, char *entry, int maxloop )
+{
+       LDAP    *ld;
+       int     i;
+       char    *attrs[] = { "cn", "sn", NULL };
+       char    *filter = "(objectclass=*)";
+       pid_t   pid = getpid();
+
+       if (( ld = ldap_init( host, port )) == NULL ) {
+               perror( "ldap_init" );
+               exit( 1 );
+       }
+
+       if ( ldap_bind_s( ld, NULL, NULL, LDAP_AUTH_SIMPLE ) != LDAP_SUCCESS ) {
+               ldap_perror( ld, "ldap_bind" );
+                exit( 1 );
+       }
+
+
+       fprintf( stderr, "PID=%ld - Read(%d): entry=\"%s\".\n",
+                               pid, maxloop, entry );
+
+       for ( i = 0; i < maxloop; i++ ) {
+               LDAPMessage *res;
+               int         rc;
+
+               if (( rc = ldap_search_s( ld, entry, LDAP_SCOPE_BASE,
+                               filter, attrs, 0, &res )) != LDAP_SUCCESS ) {
+
+                       ldap_perror( ld, "ldap_read" );
+                       if ( rc != LDAP_NO_SUCH_OBJECT ) break;
+                       continue;
+
+               }
+
+               ldap_msgfree( res );
+       }
+
+       fprintf( stderr, " PID=%ld - Read done.\n", pid );
+
+       ldap_unbind( ld );
+}
+
+
diff --git a/tests/progs/slapd-search.c b/tests/progs/slapd-search.c
new file mode 100644 (file)
index 0000000..27fc421
--- /dev/null
@@ -0,0 +1,127 @@
+#include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/string.h>
+#include <ac/ctype.h>
+#include <ac/socket.h>
+#include <ac/unistd.h>
+#include <ac/wait.h>
+
+#include <sys/param.h>
+
+#include "lber.h"
+#include "ldap.h"
+
+#define LOOPS  100
+
+static void
+do_search( char *host, int port, char *sbase, char *filter, int maxloop );
+
+static void
+usage( char *name )
+{
+       fprintf( stderr, "usage: %s [-h <host>] -p port -b <searchbase> -f <searchfiter> [-l <loops>]\n",
+                       name );
+       exit( 1 );
+}
+
+int
+main( int argc, char **argv )
+{
+       int             i, j;
+       char        *host = "localhost";
+       int                     port = -1;
+       char        *sbase = NULL;
+       char            *filter  = NULL;
+       int                     loops = LOOPS;
+
+       while ( (i = getopt( argc, argv, "h:p:b:f:l:" )) != EOF ) {
+               switch( i ) {
+                       case 'h':               /* the servers host */
+                               host = strdup( optarg );
+                       break;
+
+                       case 'p':               /* the servers port */
+                               port = atoi( optarg );
+                               break;
+
+                       case 'b':               /* file with search base */
+                               sbase = strdup( optarg );
+                       break;
+
+                       case 'f':               /* the search request */
+                               filter = strdup( optarg );
+                               break;
+
+                       case 'l':               /* number of loops */
+                               loops = atoi( optarg );
+                               break;
+
+                       default:
+                               usage( argv[0] );
+                               break;
+               }
+       }
+
+       if (( sbase == NULL ) || ( filter == NULL ) || ( port == -1 ))
+               usage( argv[0] );
+
+       if ( *filter == '\0' ) {
+
+               fprintf( stderr, "%s: invalid EMPTY search filter.\n",
+                               argv[0] );
+               exit( 1 );
+
+       }
+
+       do_search( host, port, sbase, filter, ( 4 * loops ));
+
+       exit( 0 );
+}
+
+
+static void
+do_search( char *host, int port, char *sbase, char *filter, int maxloop )
+{
+       LDAP    *ld;
+       int     i;
+       char    *attrs[] = { "cn", "sn", NULL };
+       pid_t   pid = getpid();
+
+       if (( ld = ldap_init( host, port )) == NULL ) {
+               perror( "ldap_init" );
+               exit( 1 );
+       }
+
+       if ( ldap_bind_s( ld, NULL, NULL, LDAP_AUTH_SIMPLE ) != LDAP_SUCCESS ) {
+               ldap_perror( ld, "ldap_bind" );
+                exit( 1 );
+       }
+
+
+       fprintf( stderr, "PID=%ld - Search(%d): base=\"%s\", filter=\"%s\".\n",
+                               pid, maxloop, sbase, filter );
+
+       for ( i = 0; i < maxloop; i++ ) {
+               LDAPMessage *res;
+               int         rc;
+
+               if (( rc = ldap_search_s( ld, sbase, LDAP_SCOPE_SUBTREE,
+                               filter, attrs, 0, &res )) != LDAP_SUCCESS ) {
+
+                       ldap_perror( ld, "ldap_search" );
+                       if ( rc != LDAP_NO_SUCH_OBJECT ) break;
+                       continue;
+
+               }
+
+               ldap_msgfree( res );
+       }
+
+       fprintf( stderr, " PID=%ld - Search done.\n", pid );
+
+       ldap_unbind( ld );
+}
+
+
diff --git a/tests/progs/slapd-tester.c b/tests/progs/slapd-tester.c
new file mode 100644 (file)
index 0000000..2d63a1d
--- /dev/null
@@ -0,0 +1,357 @@
+#include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/string.h>
+#include <ac/ctype.h>
+#include <ac/socket.h>
+#include <ac/unistd.h>
+#include <ac/wait.h>
+#include <dirent.h>
+
+#include <sys/param.h>
+
+#include "ldapconfig.h"
+
+
+#define SEARCHCMD              "slapd-search"
+#define READCMD                        "slapd-read"
+#define ADDCMD                 "slapd-addel"
+#define MAXARGS        100
+#define MAXREQS                        20
+#define LOOPS                  "100"
+
+#define TSEARCHFILE            "do_search.0"
+#define TREADFILE              "do_read.0"
+#define TADDFILE               "do_add."
+
+static char *get_file_name( char *dirname, char *filename );
+static int  get_search_filters( char *filename, char *filters[] );
+static int  get_read_entries( char *filename, char *entries[] );
+static void fork_child( char *prog, char *args[] );
+static void    wait4kids( int nkidval );
+
+static int      maxkids = 20;
+static int      nkids;
+
+static void
+usage( char *name )
+{
+       fprintf( stderr, "usage: %s [-h <host>] -p <port> -D <manager> -w <passwd> -d <datadir> -b <baseDN> [-j <maxchild>] [-l <loops>] -P <progdir>\n", name );
+       exit( 1 );
+}
+
+int
+main( int argc, char **argv )
+{
+       int             i, j;
+       char            *host = "localhost";
+       char            *port = NULL;
+       char            *manager = NULL;
+       char            *passwd = NULL;
+       char            *dirname = NULL;
+       char        *sbase = NULL;
+       char            *progdir = NULL;
+       char            *loops = LOOPS;
+       DIR                     *datadir;
+       struct dirent   *file;
+       char            *sfile = NULL;
+       char            *sreqs[MAXREQS];
+       int         snum = 0;
+       char            *rfile = NULL;
+       char            *rreqs[MAXREQS];
+       int         rnum = 0;
+       char            *afiles[MAXREQS];
+       int         anum = 0;
+       char            *sargs[MAXARGS];
+       int                     sanum;
+       char            scmd[MAXPATHLEN];
+       char            *rargs[MAXARGS];
+       int                     ranum;
+       char            rcmd[MAXPATHLEN];
+       char            *aargs[MAXARGS];
+       int                     aanum;
+       char            acmd[MAXPATHLEN];
+
+       while ( (i = getopt( argc, argv, "h:p:D:w:b:d:j:l:P:" )) != EOF ) {
+               switch( i ) {
+                       case 'h':               /* slapd host */
+                               host = strdup( optarg );
+                       break;
+
+                       case 'p':               /* the servers port number */
+                               port = strdup( optarg );
+                               break;
+
+                       case 'D':               /* slapd manager */
+                               manager = strdup( optarg );
+                       break;
+
+                       case 'w':               /* the managers passwd */
+                               passwd = strdup( optarg );
+                               break;
+
+                       case 'b':               /* the base DN */
+                               sbase = strdup( optarg );
+                               break;
+
+                       case 'd':               /* data directory */
+                               dirname = strdup( optarg );
+                       break;
+
+                       case 'P':               /* prog directory */
+                               progdir = strdup( optarg );
+                       break;
+
+                       case 'j':               /* the number of parallel clients */
+                               maxkids = atoi( optarg );
+                               break;
+
+                       case 'l':               /* the number of loops per client */
+                               loops = strdup( optarg );
+                               break;
+
+                       default:
+                               usage( argv[0] );
+                               break;
+               }
+       }
+
+       if (( dirname == NULL ) || ( sbase == NULL ) || ( port == NULL ) ||
+                       ( manager == NULL ) || ( passwd == NULL ) || ( progdir == NULL ))
+               usage( argv[0] );
+
+       /* get the file list */
+       if ( ( datadir = opendir( dirname )) == NULL ) {
+
+               fprintf( stderr, "%s: couldn't open data directory \"%s\".\n",
+                                       argv[0], dirname );
+               exit( 1 );
+
+       }
+
+       /*  look for search, read, and add/delete files */
+       for ( file = readdir( datadir ); file; file = readdir( datadir )) {
+
+               if ( !strcasecmp( file->d_name, TSEARCHFILE )) {
+                       sfile = get_file_name( dirname, file->d_name );
+                       continue;
+               } else if ( !strcasecmp( file->d_name, TREADFILE )) {
+                       rfile = get_file_name( dirname, file->d_name );
+                       continue;
+               } else if ( !strncasecmp( file->d_name, TADDFILE, strlen( TADDFILE ))
+                       && ( anum < MAXREQS )) {
+                       afiles[anum++] = get_file_name( dirname, file->d_name );
+                       continue;
+               }
+       }
+
+       /* look for search requests */
+       if ( sfile ) {
+               snum = get_search_filters( sfile, sreqs );
+       }
+
+       /* look for read requests */
+       if ( rfile ) {
+               rnum = get_read_entries( rfile, rreqs );
+       }
+
+       /*
+        * generate the search clients
+        */
+
+       sanum = 0;
+       sprintf( scmd, "%s%s%s", progdir, DEFAULT_DIRSEP, SEARCHCMD );
+       sargs[sanum++] = scmd;
+       sargs[sanum++] = "-h";
+       sargs[sanum++] = host;
+       sargs[sanum++] = "-p";
+       sargs[sanum++] = port;
+       sargs[sanum++] = "-b";
+       sargs[sanum++] = sbase;
+       sargs[sanum++] = "-l";
+       sargs[sanum++] = loops;
+       sargs[sanum++] = "-f";
+       sargs[sanum++] = NULL;          /* will hold the search request */
+       sargs[sanum++] = NULL;
+
+       /*
+        * generate the read clients
+        */
+
+       ranum = 0;
+       sprintf( rcmd, "%s%s%s", progdir, DEFAULT_DIRSEP, READCMD );
+       rargs[ranum++] = rcmd;
+       rargs[ranum++] = "-h";
+       rargs[ranum++] = host;
+       rargs[ranum++] = "-p";
+       rargs[ranum++] = port;
+       rargs[ranum++] = "-l";
+       rargs[ranum++] = loops;
+       rargs[ranum++] = "-e";
+       rargs[ranum++] = NULL;          /* will hold the read entry */
+       rargs[ranum++] = NULL;
+
+       /*
+        * generate the add/delete clients
+        */
+
+       aanum = 0;
+       sprintf( acmd, "%s%s%s", progdir, DEFAULT_DIRSEP, ADDCMD );
+       aargs[aanum++] = acmd;
+       aargs[aanum++] = "-h";
+       aargs[aanum++] = host;
+       aargs[aanum++] = "-p";
+       aargs[aanum++] = port;
+       aargs[aanum++] = "-D";
+       aargs[aanum++] = manager;
+       aargs[aanum++] = "-w";
+       aargs[aanum++] = passwd;
+       aargs[aanum++] = "-l";
+       aargs[aanum++] = loops;
+       aargs[aanum++] = "-f";
+       aargs[aanum++] = NULL;          /* will hold the add data file */
+       aargs[aanum++] = NULL;
+
+       for ( j = 0; j < MAXREQS; j++ ) {
+
+               if ( j < snum ) {
+
+                       sargs[sanum - 2] = sreqs[j];
+                       fork_child( scmd, sargs );
+
+               }
+
+               if ( j < rnum ) {
+
+                       rargs[ranum - 2] = rreqs[j];
+                       fork_child( rcmd, rargs );
+
+               }
+
+               if ( j < anum ) {
+
+                       aargs[aanum - 2] = afiles[j];
+                       fork_child( acmd, aargs );
+
+               }
+
+       }
+
+       wait4kids( -1 );
+
+       exit( 0 );
+}
+
+static char *
+get_file_name( char *dirname, char *filename )
+{
+       char buf[MAXPATHLEN];
+
+       sprintf( buf, "%s%s%s", dirname, DEFAULT_DIRSEP, filename );
+       return( strdup( buf ));
+}
+
+
+static int
+get_search_filters( char *filename, char *filters[] )
+{
+       FILE    *fp;
+       int     filter = 0;
+
+       if ( fp = fopen( filename, "r" )) {
+               char  line[BUFSIZ];
+
+               while (( filter < MAXREQS ) && ( fgets( line, BUFSIZ, fp ))) {
+                       char *nl;
+
+                       if (( nl = strchr( line, '\r' )) || ( nl = strchr( line, '\n' )))
+                               *nl = '\0';
+                       filters[filter++] = strdup( line );
+
+               }
+               fclose( fp );
+       }
+
+       return( filter );
+}
+
+
+static int
+get_read_entries( char *filename, char *entries[] )
+{
+       FILE    *fp;
+       int     entry = 0;
+
+       if ( fp = fopen( filename, "r" )) {
+               char  line[BUFSIZ];
+
+               while (( entry < MAXREQS ) && ( fgets( line, BUFSIZ, fp ))) {
+                       char *nl;
+
+                       if (( nl = strchr( line, '\r' )) || ( nl = strchr( line, '\n' )))
+                               *nl = '\0';
+                       entries[entry++] = strdup( line );
+
+               }
+               fclose( fp );
+       }
+
+       return( entry );
+}
+
+
+static void
+fork_child( char *prog, char *args[] )
+{
+       int     status, pid;
+
+       wait4kids( maxkids );
+
+       switch ( pid = fork() ) {
+       case 0:         /* child */
+               execvp( prog, args );
+               fprintf( stderr, "%s: ", prog );
+               perror( "execv" );
+               exit( -1 );
+               break;
+
+       case -1:        /* trouble */
+               fprintf( stderr, "Could not fork to run %s\n", prog );
+               perror( "fork" );
+               break;
+
+       default:        /* parent */
+               nkids++;
+               break;
+       }
+}
+
+static void
+wait4kids( int nkidval )
+{
+       int             status;
+       unsigned char   *p;
+
+       while ( nkids >= nkidval ) {
+               wait( &status );
+               p = (unsigned char *) &status;
+               if ( p[sizeof(int) - 1] == 0177 ) {
+                       fprintf( stderr,
+                           "stopping: child stopped with signal %d\n",
+                           p[sizeof(int) - 2] );
+               } else if ( p[sizeof(int) - 1] != 0 ) {
+                       fprintf( stderr, 
+                           "stopping: child terminated with signal %d\n",
+                           p[sizeof(int) - 1] );
+                       exit( p[sizeof(int) - 1] );
+               } else if ( p[sizeof(int) - 2] != 0 ) {
+                       fprintf( stderr, 
+                           "stopping: child exited with status %d\n",
+                           p[sizeof(int) - 2] );
+                       exit( p[sizeof(int) - 2] );
+               } else {
+                       nkids--;
+               }
+       }
+}
index a03422aab2129fffcf45f0dcd400534c6c9555e2..803405b3f15e53caa65810184d6f8eb78e2a4446 100755 (executable)
@@ -10,6 +10,7 @@ else
 fi
 
 DATADIR=$SRCDIR/data
+PROGDIR=$SRCDIR/progs
 
 if test "$BACKEND" = "bdb2" ; then
        LDIF2LDBM=../servers/slapd/tools/ldif2ldbm-bdb2
@@ -31,7 +32,7 @@ SLURPD=../servers/slurpd/slurpd
 LDAPSEARCH=../clients/tools/ldapsearch
 LDAPMODIFY=../clients/tools/ldapmodify
 LDAPADD=../clients/tools/ldapadd
-SLAPDTESTER=./slapd-tester
+SLAPDTESTER=$PROGDIR/slapd-tester
 LVL=5
 PORT=9009
 SLAVEPORT=9010
index 88355b20e12749f42029304cd0e8e2d943968d7b..df78da1a560c0ff1f1ead20c92e58196902130ec 100755 (executable)
@@ -38,7 +38,7 @@ echo "Waiting 5 seconds for slapd to start..."
 sleep 5
 
 echo "Using tester for concurrent server access..."
-$SLAPDTESTER -b "$BASEDN" -d "$DATADIR" -h localhost -p $PORT -D "$MANAGERDN" -w $PASSWD -l 50
+$SLAPDTESTER -b "$BASEDN" -P "$PROGDIR" -d "$DATADIR" -h localhost -p $PORT -D "$MANAGERDN" -w $PASSWD -l 50
 RC=$?
 
 if [ $RC != 0 ]; then
diff --git a/tests/slapd-addel.c b/tests/slapd-addel.c
deleted file mode 100644 (file)
index e99fbf0..0000000
+++ /dev/null
@@ -1,280 +0,0 @@
-#include "portable.h"
-
-#include <stdio.h>
-
-#include <ac/string.h>
-#include <ac/ctype.h>
-#include <ac/socket.h>
-#include <ac/unistd.h>
-#include <ac/wait.h>
-
-#include <sys/param.h>
-
-#include "lber.h"
-#include "ldap.h"
-
-#define LOOPS  100
-
-static char *
-get_add_entry( char *filename, LDAPMod ***mods );
-
-static void
-do_addel( char *host, int port, char *manager, char *passwd,
-       char *dn, LDAPMod **attrs, int maxloop );
-
-static void
-usage( char *name )
-{
-       fprintf( stderr, "usage: %s [-h <host>] -p port -D <managerDN> -w <passwd> -f <addfile> [-l <loops>]\n",
-                       name );
-       exit( 1 );
-}
-
-int
-main( int argc, char **argv )
-{
-       int             i, j;
-       char        *host = "localhost";
-       int                     port = -1;
-       char            *manager = NULL;
-       char            *passwd = NULL;
-       char            *filename = NULL;
-       char            *entry = NULL;
-       int                     loops = LOOPS;
-       LDAPMod     **attrs = NULL;
-
-       while ( (i = getopt( argc, argv, "h:p:D:w:f:l:" )) != EOF ) {
-               switch( i ) {
-                       case 'h':               /* the servers host */
-                               host = strdup( optarg );
-                       break;
-
-                       case 'p':               /* the servers port */
-                               port = atoi( optarg );
-                               break;
-
-                       case 'D':               /* the servers manager */
-                               manager = strdup( optarg );
-                       break;
-
-                       case 'w':               /* the server managers password */
-                               passwd = strdup( optarg );
-                       break;
-
-                       case 'f':               /* file with entry search request */
-                               filename = strdup( optarg );
-                               break;
-
-                       case 'l':               /* the number of loops */
-                               loops = atoi( optarg );
-                               break;
-
-                       default:
-                               usage( argv[0] );
-                               break;
-               }
-       }
-
-       if (( filename == NULL ) || ( port == -1 ) ||
-                               ( manager == NULL ) || ( passwd == NULL ))
-               usage( argv[0] );
-
-       entry = get_add_entry( filename, &attrs );
-       if (( entry == NULL ) || ( *entry == '\0' )) {
-
-               fprintf( stderr, "%s: invalid entry DN in file \"%s\".\n",
-                               argv[0], filename );
-               exit( 1 );
-
-       }
-
-       if (( attrs == NULL ) || ( *attrs == '\0' )) {
-
-               fprintf( stderr, "%s: invalid attrs in file \"%s\".\n",
-                               argv[0], filename );
-               exit( 1 );
-
-       }
-
-       do_addel( host, port, manager, passwd, entry, attrs, loops );
-
-       exit( 0 );
-}
-
-
-#define safe_realloc( ptr, size )   ( ptr == NULL ? malloc( size ) : \
-                               realloc( ptr, size ))
-
-
-static void
-addmodifyop( LDAPMod ***pmodsp, int modop, char *attr, char *value, int vlen )
-{
-    LDAPMod            **pmods;
-    int                        i, j;
-    struct berval      *bvp;
-
-    pmods = *pmodsp;
-    modop |= LDAP_MOD_BVALUES;
-
-    i = 0;
-    if ( pmods != NULL ) {
-               for ( ; pmods[ i ] != NULL; ++i ) {
-               if ( strcasecmp( pmods[ i ]->mod_type, attr ) == 0 &&
-                       pmods[ i ]->mod_op == modop ) {
-                               break;
-               }
-               }
-    }
-
-    if ( pmods == NULL || pmods[ i ] == NULL ) {
-               if (( pmods = (LDAPMod **)safe_realloc( pmods, (i + 2) *
-                       sizeof( LDAPMod * ))) == NULL ) {
-                       perror( "safe_realloc" );
-                       exit( 1 );
-               }
-               *pmodsp = pmods;
-               pmods[ i + 1 ] = NULL;
-               if (( pmods[ i ] = (LDAPMod *)calloc( 1, sizeof( LDAPMod )))
-                       == NULL ) {
-                       perror( "calloc" );
-                       exit( 1 );
-               }
-               pmods[ i ]->mod_op = modop;
-               if (( pmods[ i ]->mod_type = strdup( attr )) == NULL ) {
-               perror( "strdup" );
-               exit( 1 );
-               }
-    }
-
-    if ( value != NULL ) {
-               j = 0;
-               if ( pmods[ i ]->mod_bvalues != NULL ) {
-               for ( ; pmods[ i ]->mod_bvalues[ j ] != NULL; ++j ) {
-                               ;
-               }
-               }
-               if (( pmods[ i ]->mod_bvalues =
-                       (struct berval **)safe_realloc( pmods[ i ]->mod_bvalues,
-                       (j + 2) * sizeof( struct berval * ))) == NULL ) {
-                       perror( "safe_realloc" );
-                       exit( 1 );
-               }
-               pmods[ i ]->mod_bvalues[ j + 1 ] = NULL;
-               if (( bvp = (struct berval *)malloc( sizeof( struct berval )))
-                       == NULL ) {
-                       perror( "malloc" );
-                       exit( 1 );
-               }
-               pmods[ i ]->mod_bvalues[ j ] = bvp;
-
-           bvp->bv_len = vlen;
-           if (( bvp->bv_val = (char *)malloc( vlen + 1 )) == NULL ) {
-                       perror( "malloc" );
-                       exit( 1 );
-           }
-           SAFEMEMCPY( bvp->bv_val, value, vlen );
-           bvp->bv_val[ vlen ] = '\0';
-    }
-}
-
-
-static char *
-get_add_entry( char *filename, LDAPMod ***mods )
-{
-       FILE    *fp;
-       char    *entry = NULL;
-
-       if ( fp = fopen( filename, "r" )) {
-               char  line[BUFSIZ];
-
-               if ( fgets( line, BUFSIZ, fp )) {
-                       char *nl;
-
-                       if (( nl = strchr( line, '\r' )) || ( nl = strchr( line, '\n' )))
-                               *nl = '\0';
-                       entry = strdup( line );
-
-               }
-
-               while ( fgets( line, BUFSIZ, fp )) {
-                       char    *nl;
-                       char    *value;
-
-                       if (( nl = strchr( line, '\r' )) || ( nl = strchr( line, '\n' )))
-                               *nl = '\0';
-
-                       if ( *line == '\0' ) break;
-                       if ( !( value = strchr( line, ':' ))) break;
-
-                       *value++ = '\0'; 
-                       while ( *value && isspace( *value )) value++;
-
-                       addmodifyop( mods, LDAP_MOD_ADD, line, value, strlen( value ));
-
-               }
-               fclose( fp );
-       }
-
-       return( entry );
-}
-
-
-static void
-do_addel(
-       char *host,
-       int port,
-       char *manager,
-       char *passwd,
-       char *entry,
-       LDAPMod **attrs,
-       int maxloop
-)
-{
-       LDAP    *ld;
-       int     i;
-       pid_t   pid = getpid();
-
-       if (( ld = ldap_init( host, port )) == NULL ) {
-               perror( "ldap_init" );
-               exit( 1 );
-       }
-
-       if ( ldap_bind_s( ld, manager, passwd, LDAP_AUTH_SIMPLE )
-                               != LDAP_SUCCESS ) {
-               ldap_perror( ld, "ldap_bind" );
-                exit( 1 );
-       }
-
-
-       fprintf( stderr, "PID=%ld - Add/Delete(%d): entry=\"%s\".\n",
-                                       pid, maxloop, entry );
-
-       for ( i = 0; i < maxloop; i++ ) {
-
-               /* add the entry */
-               if ( ldap_add_s( ld, entry, attrs ) != LDAP_SUCCESS ) {
-
-                       ldap_perror( ld, "ldap_add" );
-                       break;
-
-               }
-
-               /* wait a second for the add to really complete */
-               sleep( 1 );
-
-               /* now delete the entry again */
-               if ( ldap_delete_s( ld, entry ) != LDAP_SUCCESS ) {
-
-                       ldap_perror( ld, "ldap_delete" );
-                       break;
-
-               }
-
-       }
-
-       fprintf( stderr, " PID=%ld - Add/Delete done.\n", pid );
-
-       ldap_unbind( ld );
-}
-
-
diff --git a/tests/slapd-read.c b/tests/slapd-read.c
deleted file mode 100644 (file)
index b94ec3e..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-#include "portable.h"
-
-#include <stdio.h>
-
-#include <ac/string.h>
-#include <ac/ctype.h>
-#include <ac/socket.h>
-#include <ac/unistd.h>
-#include <ac/wait.h>
-
-#include <sys/param.h>
-
-#include "lber.h"
-#include "ldap.h"
-
-#define LOOPS  100
-
-static void
-do_read( char *host, int port, char *entry, int maxloop );
-
-static void
-usage( char *name )
-{
-       fprintf( stderr, "usage: %s [-h <host>] -p port -e <entry> [-l <loops>]\n",
-                       name );
-       exit( 1 );
-}
-
-int
-main( int argc, char **argv )
-{
-       int             i, j;
-       char        *host = "localhost";
-       int                     port = -1;
-       char            *entry = NULL;
-       int                     loops = LOOPS;
-
-       while ( (i = getopt( argc, argv, "h:p:e:l:" )) != EOF ) {
-               switch( i ) {
-                       case 'h':               /* the servers host */
-                               host = strdup( optarg );
-                       break;
-
-                       case 'p':               /* the servers port */
-                               port = atoi( optarg );
-                               break;
-
-                       case 'e':               /* file with entry search request */
-                               entry = strdup( optarg );
-                               break;
-
-                       case 'l':               /* the number of loops */
-                               loops = atoi( optarg );
-                               break;
-
-                       default:
-                               usage( argv[0] );
-                               break;
-               }
-       }
-
-       if (( entry == NULL ) || ( port == -1 ))
-               usage( argv[0] );
-
-       if ( *entry == '\0' ) {
-
-               fprintf( stderr, "%s: invalid EMPTY entry DN.\n",
-                               argv[0] );
-               exit( 1 );
-
-       }
-
-       do_read( host, port, entry, ( 4 * loops ));
-
-       exit( 0 );
-}
-
-
-static void
-do_read( char *host, int port, char *entry, int maxloop )
-{
-       LDAP    *ld;
-       int     i;
-       char    *attrs[] = { "cn", "sn", NULL };
-       char    *filter = "(objectclass=*)";
-       pid_t   pid = getpid();
-
-       if (( ld = ldap_init( host, port )) == NULL ) {
-               perror( "ldap_init" );
-               exit( 1 );
-       }
-
-       if ( ldap_bind_s( ld, NULL, NULL, LDAP_AUTH_SIMPLE ) != LDAP_SUCCESS ) {
-               ldap_perror( ld, "ldap_bind" );
-                exit( 1 );
-       }
-
-
-       fprintf( stderr, "PID=%ld - Read(%d): entry=\"%s\".\n",
-                               pid, maxloop, entry );
-
-       for ( i = 0; i < maxloop; i++ ) {
-               LDAPMessage *res;
-               int         rc;
-
-               if (( rc = ldap_search_s( ld, entry, LDAP_SCOPE_BASE,
-                               filter, attrs, 0, &res )) != LDAP_SUCCESS ) {
-
-                       ldap_perror( ld, "ldap_read" );
-                       if ( rc != LDAP_NO_SUCH_OBJECT ) break;
-                       continue;
-
-               }
-
-               ldap_msgfree( res );
-       }
-
-       fprintf( stderr, " PID=%ld - Read done.\n", pid );
-
-       ldap_unbind( ld );
-}
-
-
diff --git a/tests/slapd-search.c b/tests/slapd-search.c
deleted file mode 100644 (file)
index 27fc421..0000000
+++ /dev/null
@@ -1,127 +0,0 @@
-#include "portable.h"
-
-#include <stdio.h>
-
-#include <ac/string.h>
-#include <ac/ctype.h>
-#include <ac/socket.h>
-#include <ac/unistd.h>
-#include <ac/wait.h>
-
-#include <sys/param.h>
-
-#include "lber.h"
-#include "ldap.h"
-
-#define LOOPS  100
-
-static void
-do_search( char *host, int port, char *sbase, char *filter, int maxloop );
-
-static void
-usage( char *name )
-{
-       fprintf( stderr, "usage: %s [-h <host>] -p port -b <searchbase> -f <searchfiter> [-l <loops>]\n",
-                       name );
-       exit( 1 );
-}
-
-int
-main( int argc, char **argv )
-{
-       int             i, j;
-       char        *host = "localhost";
-       int                     port = -1;
-       char        *sbase = NULL;
-       char            *filter  = NULL;
-       int                     loops = LOOPS;
-
-       while ( (i = getopt( argc, argv, "h:p:b:f:l:" )) != EOF ) {
-               switch( i ) {
-                       case 'h':               /* the servers host */
-                               host = strdup( optarg );
-                       break;
-
-                       case 'p':               /* the servers port */
-                               port = atoi( optarg );
-                               break;
-
-                       case 'b':               /* file with search base */
-                               sbase = strdup( optarg );
-                       break;
-
-                       case 'f':               /* the search request */
-                               filter = strdup( optarg );
-                               break;
-
-                       case 'l':               /* number of loops */
-                               loops = atoi( optarg );
-                               break;
-
-                       default:
-                               usage( argv[0] );
-                               break;
-               }
-       }
-
-       if (( sbase == NULL ) || ( filter == NULL ) || ( port == -1 ))
-               usage( argv[0] );
-
-       if ( *filter == '\0' ) {
-
-               fprintf( stderr, "%s: invalid EMPTY search filter.\n",
-                               argv[0] );
-               exit( 1 );
-
-       }
-
-       do_search( host, port, sbase, filter, ( 4 * loops ));
-
-       exit( 0 );
-}
-
-
-static void
-do_search( char *host, int port, char *sbase, char *filter, int maxloop )
-{
-       LDAP    *ld;
-       int     i;
-       char    *attrs[] = { "cn", "sn", NULL };
-       pid_t   pid = getpid();
-
-       if (( ld = ldap_init( host, port )) == NULL ) {
-               perror( "ldap_init" );
-               exit( 1 );
-       }
-
-       if ( ldap_bind_s( ld, NULL, NULL, LDAP_AUTH_SIMPLE ) != LDAP_SUCCESS ) {
-               ldap_perror( ld, "ldap_bind" );
-                exit( 1 );
-       }
-
-
-       fprintf( stderr, "PID=%ld - Search(%d): base=\"%s\", filter=\"%s\".\n",
-                               pid, maxloop, sbase, filter );
-
-       for ( i = 0; i < maxloop; i++ ) {
-               LDAPMessage *res;
-               int         rc;
-
-               if (( rc = ldap_search_s( ld, sbase, LDAP_SCOPE_SUBTREE,
-                               filter, attrs, 0, &res )) != LDAP_SUCCESS ) {
-
-                       ldap_perror( ld, "ldap_search" );
-                       if ( rc != LDAP_NO_SUCH_OBJECT ) break;
-                       continue;
-
-               }
-
-               ldap_msgfree( res );
-       }
-
-       fprintf( stderr, " PID=%ld - Search done.\n", pid );
-
-       ldap_unbind( ld );
-}
-
-
diff --git a/tests/slapd-tester.c b/tests/slapd-tester.c
deleted file mode 100644 (file)
index 5bf9d4e..0000000
+++ /dev/null
@@ -1,352 +0,0 @@
-#include "portable.h"
-
-#include <stdio.h>
-
-#include <ac/string.h>
-#include <ac/ctype.h>
-#include <ac/socket.h>
-#include <ac/unistd.h>
-#include <ac/wait.h>
-#include <dirent.h>
-
-#include <sys/param.h>
-
-#include "ldapconfig.h"
-
-
-#define SEARCHCMD              "slapd-search"
-#define READCMD                        "slapd-read"
-#define ADDCMD                 "slapd-addel"
-#define MAXARGS        100
-#define MAXREQS                        20
-#define LOOPS                  "100"
-
-#define TSEARCHFILE            "do_search.0"
-#define TREADFILE              "do_read.0"
-#define TADDFILE               "do_add."
-
-static char *get_file_name( char *dirname, char *filename );
-static int  get_search_filters( char *filename, char *filters[] );
-static int  get_read_entries( char *filename, char *entries[] );
-static void fork_child( char *prog, char *args[] );
-static void    wait4kids( int nkidval );
-
-static int      maxkids = 20;
-static int      nkids;
-
-static void
-usage( char *name )
-{
-       fprintf( stderr, "usage: %s [-h <host>] -p <port> -D <manager> -w <passwd> -d <datadir> -b <baseDN> [-j <maxchild>] [-l <loops>]\n", name );
-       exit( 1 );
-}
-
-int
-main( int argc, char **argv )
-{
-       int             i, j;
-       char            *host = "localhost";
-       char            *port = NULL;
-       char            *manager = NULL;
-       char            *passwd = NULL;
-       char            *dirname = NULL;
-       char        *sbase = NULL;
-       char            *loops = LOOPS;
-       DIR                     *datadir;
-       struct dirent   *file;
-       char            *sfile = NULL;
-       char            *sreqs[MAXREQS];
-       int         snum = 0;
-       char            *rfile = NULL;
-       char            *rreqs[MAXREQS];
-       int         rnum = 0;
-       char            *afiles[MAXREQS];
-       int         anum = 0;
-       char            *sargs[MAXARGS];
-       int                     sanum;
-       char            scmd[MAXPATHLEN];
-       char            *rargs[MAXARGS];
-       int                     ranum;
-       char            rcmd[MAXPATHLEN];
-       char            *aargs[MAXARGS];
-       int                     aanum;
-       char            acmd[MAXPATHLEN];
-
-       while ( (i = getopt( argc, argv, "h:p:D:w:b:d:j:l:" )) != EOF ) {
-               switch( i ) {
-                       case 'h':               /* slapd host */
-                               host = strdup( optarg );
-                       break;
-
-                       case 'p':               /* the servers port number */
-                               port = strdup( optarg );
-                               break;
-
-                       case 'D':               /* slapd manager */
-                               manager = strdup( optarg );
-                       break;
-
-                       case 'w':               /* the managers passwd */
-                               passwd = strdup( optarg );
-                               break;
-
-                       case 'b':               /* the base DN */
-                               sbase = strdup( optarg );
-                               break;
-
-                       case 'd':               /* data directory */
-                               dirname = strdup( optarg );
-                       break;
-
-                       case 'j':               /* the number of parallel clients */
-                               maxkids = atoi( optarg );
-                               break;
-
-                       case 'l':               /* the number of loops per client */
-                               loops = strdup( optarg );
-                               break;
-
-                       default:
-                               usage( argv[0] );
-                               break;
-               }
-       }
-
-       if (( dirname == NULL ) || ( sbase == NULL ) || ( port == NULL ) ||
-                       ( manager == NULL ) || ( passwd == NULL ))
-               usage( argv[0] );
-
-       /* get the file list */
-       if ( ( datadir = opendir( dirname )) == NULL ) {
-
-               fprintf( stderr, "%s: couldn't open data directory \"%s\".\n",
-                                       argv[0], dirname );
-               exit( 1 );
-
-       }
-
-       /*  look for search, read, and add/delete files */
-       for ( file = readdir( datadir ); file; file = readdir( datadir )) {
-
-               if ( !strcasecmp( file->d_name, TSEARCHFILE )) {
-                       sfile = get_file_name( dirname, file->d_name );
-                       continue;
-               } else if ( !strcasecmp( file->d_name, TREADFILE )) {
-                       rfile = get_file_name( dirname, file->d_name );
-                       continue;
-               } else if ( !strncasecmp( file->d_name, TADDFILE, strlen( TADDFILE ))
-                       && ( anum < MAXREQS )) {
-                       afiles[anum++] = get_file_name( dirname, file->d_name );
-                       continue;
-               }
-       }
-
-       /* look for search requests */
-       if ( sfile ) {
-               snum = get_search_filters( sfile, sreqs );
-       }
-
-       /* look for read requests */
-       if ( rfile ) {
-               rnum = get_read_entries( rfile, rreqs );
-       }
-
-       /*
-        * generate the search clients
-        */
-
-       sanum = 0;
-       sprintf( scmd, "%s", SEARCHCMD );
-       sargs[sanum++] = scmd;
-       sargs[sanum++] = "-h";
-       sargs[sanum++] = host;
-       sargs[sanum++] = "-p";
-       sargs[sanum++] = port;
-       sargs[sanum++] = "-b";
-       sargs[sanum++] = sbase;
-       sargs[sanum++] = "-l";
-       sargs[sanum++] = loops;
-       sargs[sanum++] = "-f";
-       sargs[sanum++] = NULL;          /* will hold the search request */
-       sargs[sanum++] = NULL;
-
-       /*
-        * generate the read clients
-        */
-
-       ranum = 0;
-       sprintf( rcmd, "%s", READCMD );
-       rargs[ranum++] = rcmd;
-       rargs[ranum++] = "-h";
-       rargs[ranum++] = host;
-       rargs[ranum++] = "-p";
-       rargs[ranum++] = port;
-       rargs[ranum++] = "-l";
-       rargs[ranum++] = loops;
-       rargs[ranum++] = "-e";
-       rargs[ranum++] = NULL;          /* will hold the read entry */
-       rargs[ranum++] = NULL;
-
-       /*
-        * generate the add/delete clients
-        */
-
-       aanum = 0;
-       sprintf( acmd, "%s", ADDCMD );
-       aargs[aanum++] = acmd;
-       aargs[aanum++] = "-h";
-       aargs[aanum++] = host;
-       aargs[aanum++] = "-p";
-       aargs[aanum++] = port;
-       aargs[aanum++] = "-D";
-       aargs[aanum++] = manager;
-       aargs[aanum++] = "-w";
-       aargs[aanum++] = passwd;
-       aargs[aanum++] = "-l";
-       aargs[aanum++] = loops;
-       aargs[aanum++] = "-f";
-       aargs[aanum++] = NULL;          /* will hold the add data file */
-       aargs[aanum++] = NULL;
-
-       for ( j = 0; j < MAXREQS; j++ ) {
-
-               if ( j < snum ) {
-
-                       sargs[sanum - 2] = sreqs[j];
-                       fork_child( scmd, sargs );
-
-               }
-
-               if ( j < rnum ) {
-
-                       rargs[ranum - 2] = rreqs[j];
-                       fork_child( rcmd, rargs );
-
-               }
-
-               if ( j < anum ) {
-
-                       aargs[aanum - 2] = afiles[j];
-                       fork_child( acmd, aargs );
-
-               }
-
-       }
-
-       wait4kids( -1 );
-
-       exit( 0 );
-}
-
-static char *
-get_file_name( char *dirname, char *filename )
-{
-       char buf[MAXPATHLEN];
-
-       sprintf( buf, "%s%s%s", dirname, DEFAULT_DIRSEP, filename );
-       return( strdup( buf ));
-}
-
-
-static int
-get_search_filters( char *filename, char *filters[] )
-{
-       FILE    *fp;
-       int     filter = 0;
-
-       if ( fp = fopen( filename, "r" )) {
-               char  line[BUFSIZ];
-
-               while (( filter < MAXREQS ) && ( fgets( line, BUFSIZ, fp ))) {
-                       char *nl;
-
-                       if (( nl = strchr( line, '\r' )) || ( nl = strchr( line, '\n' )))
-                               *nl = '\0';
-                       filters[filter++] = strdup( line );
-
-               }
-               fclose( fp );
-       }
-
-       return( filter );
-}
-
-
-static int
-get_read_entries( char *filename, char *entries[] )
-{
-       FILE    *fp;
-       int     entry = 0;
-
-       if ( fp = fopen( filename, "r" )) {
-               char  line[BUFSIZ];
-
-               while (( entry < MAXREQS ) && ( fgets( line, BUFSIZ, fp ))) {
-                       char *nl;
-
-                       if (( nl = strchr( line, '\r' )) || ( nl = strchr( line, '\n' )))
-                               *nl = '\0';
-                       entries[entry++] = strdup( line );
-
-               }
-               fclose( fp );
-       }
-
-       return( entry );
-}
-
-
-static void
-fork_child( char *prog, char *args[] )
-{
-       int     status, pid;
-
-       wait4kids( maxkids );
-
-       switch ( pid = fork() ) {
-       case 0:         /* child */
-               execvp( prog, args );
-               fprintf( stderr, "%s: ", prog );
-               perror( "execv" );
-               exit( -1 );
-               break;
-
-       case -1:        /* trouble */
-               fprintf( stderr, "Could not fork to run %s\n", prog );
-               perror( "fork" );
-               break;
-
-       default:        /* parent */
-               nkids++;
-               break;
-       }
-}
-
-static void
-wait4kids( int nkidval )
-{
-       int             status;
-       unsigned char   *p;
-
-       while ( nkids >= nkidval ) {
-               wait( &status );
-               p = (unsigned char *) &status;
-               if ( p[sizeof(int) - 1] == 0177 ) {
-                       fprintf( stderr,
-                           "stopping: child stopped with signal %d\n",
-                           p[sizeof(int) - 2] );
-               } else if ( p[sizeof(int) - 1] != 0 ) {
-                       fprintf( stderr, 
-                           "stopping: child terminated with signal %d\n",
-                           p[sizeof(int) - 1] );
-                       exit( p[sizeof(int) - 1] );
-               } else if ( p[sizeof(int) - 2] != 0 ) {
-                       fprintf( stderr, 
-                           "stopping: child exited with status %d\n",
-                           p[sizeof(int) - 2] );
-                       exit( p[sizeof(int) - 2] );
-               } else {
-                       nkids--;
-               }
-       }
-}