From f5ef28a05582163a588e9b2259d41c7116447cd4 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Fri, 17 May 2002 01:36:35 +0000 Subject: [PATCH] Fixes for MingW: (test008 now succeeds) need liblutil for lutil_getopt must quote args with embedded whitespace must track child processes in order to wait() --- tests/progs/Makefile.in | 7 +++-- tests/progs/slapd-tester.c | 61 ++++++++++++++++++++++++++++++++------ 2 files changed, 56 insertions(+), 12 deletions(-) diff --git a/tests/progs/Makefile.in b/tests/progs/Makefile.in index 58ee142a0f..482975b8a1 100644 --- a/tests/progs/Makefile.in +++ b/tests/progs/Makefile.in @@ -4,15 +4,16 @@ ## ## tests Makefile.in for OpenLDAP -UNIX_PRGS = slapd-tester slapd-search slapd-read slapd-addel -PROGRAMS = $(@PLAT@_PRGS) +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 = $(LDAP_LIBLDAP_LA) $(LDAP_LIBLBER_LA) +NT_XLIBS = $(LDAP_LIBLUTIL_A) + +XLIBS = $(LDAP_LIBLDAP_LA) $(LDAP_LIBLBER_LA) $(@PLAT@_XLIBS) XXLIBS = $(SECURITY_LIBS) $(LUTIL_LIBS) # build-tools: FORCE diff --git a/tests/progs/slapd-tester.c b/tests/progs/slapd-tester.c index e925feff59..30362168ad 100644 --- a/tests/progs/slapd-tester.c +++ b/tests/progs/slapd-tester.c @@ -41,6 +41,14 @@ static void wait4kids( int nkidval ); static int maxkids = 20; static int nkids; +#ifdef HAVE_WINSOCK +static HANDLE *children; +static char argbuf[BUFSIZ]; +#define ArgDup(x) strdup(strcat(strcat(strcpy(argbuf,"\""),x),"\"")) +#else +#define ArgDup(x) strdup(x) +#endif + static void usage( char *name ) { @@ -91,15 +99,15 @@ main( int argc, char **argv ) break; case 'D': /* slapd manager */ - manager = strdup( optarg ); + manager = ArgDup( optarg ); break; case 'w': /* the managers passwd */ - passwd = strdup( optarg ); + passwd = ArgDup( optarg ); break; case 'b': /* the base DN */ - sbase = strdup( optarg ); + sbase = ArgDup( optarg ); break; case 'd': /* data directory */ @@ -128,6 +136,9 @@ main( int argc, char **argv ) ( manager == NULL ) || ( passwd == NULL ) || ( progdir == NULL )) usage( argv[0] ); +#ifdef HAVE_WINSOCK + children = malloc( maxkids * sizeof(HANDLE) ); +#endif /* get the file list */ if ( ( datadir = opendir( dirname )) == NULL ) { @@ -227,21 +238,21 @@ main( int argc, char **argv ) if ( j < snum ) { sargs[sanum - 2] = sreqs[j]; - fork_child( scmd, sargs ); + fork_child( scmd, &sargs[0] ); } if ( j < rnum ) { rargs[ranum - 2] = rreqs[j]; - fork_child( rcmd, rargs ); + fork_child( rcmd, &rargs[0] ); } if ( j < anum ) { aargs[aanum - 2] = afiles[j]; - fork_child( acmd, aargs ); + fork_child( acmd, &aargs[0] ); } @@ -276,7 +287,7 @@ get_search_filters( char *filename, char *filters[] ) if (( nl = strchr( line, '\r' )) || ( nl = strchr( line, '\n' ))) *nl = '\0'; - filters[filter++] = strdup( line ); + filters[filter++] = ArgDup( line ); } fclose( fp ); @@ -300,7 +311,7 @@ get_read_entries( char *filename, char *entries[] ) if (( nl = strchr( line, '\r' )) || ( nl = strchr( line, '\n' ))) *nl = '\0'; - entries[entry++] = strdup( line ); + entries[entry++] = ArgDup( line ); } fclose( fp ); @@ -309,7 +320,7 @@ get_read_entries( char *filename, char *entries[] ) return( entry ); } - +#ifndef HAVE_WINSOCK static void fork_child( char *prog, char *args[] ) { @@ -372,3 +383,35 @@ wait4kids( int nkidval ) } } } +#else + +static void +wait4kids( int nkidval ) +{ + int rc, i; + + while ( nkids >= nkidval ) { + rc = WaitForMultipleObjects( nkids, children, FALSE, INFINITE ); + for ( i=rc - WAIT_OBJECT_0; i