From 412479e6fe38f0cc46c102b52caa04c177abeae6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ond=C5=99ej=20Kuzn=C3=ADk?= Date: Tue, 16 Jan 2018 15:28:50 +0000 Subject: [PATCH] ITS#8798 Unify slapd-* tools setup --- tests/progs/slapd-addel.c | 162 +++++-------------------- tests/progs/slapd-bind.c | 162 +++++-------------------- tests/progs/slapd-common.c | 188 ++++++++++++++++++++++++++--- tests/progs/slapd-common.h | 37 +++++- tests/progs/slapd-modify.c | 157 +++++------------------- tests/progs/slapd-modrdn.c | 155 +++++------------------- tests/progs/slapd-mtread.c | 236 ++++++++---------------------------- tests/progs/slapd-read.c | 225 ++++++++-------------------------- tests/progs/slapd-search.c | 239 ++++++++----------------------------- 9 files changed, 482 insertions(+), 1079 deletions(-) diff --git a/tests/progs/slapd-addel.c b/tests/progs/slapd-addel.c index 49a3cacd76..74c9f89a5a 100644 --- a/tests/progs/slapd-addel.c +++ b/tests/progs/slapd-addel.c @@ -35,34 +35,25 @@ #include "slapd-common.h" -#define LOOPS 100 -#define RETRIES 0 - static char * get_add_entry( char *filename, LDAPMod ***mods ); static void -do_addel( char *uri, char *manager, struct berval *passwd, - char *dn, LDAPMod **attrs, int maxloop, int maxretries, int delay, - int friendly, int chaserefs ); +do_addel( struct tester_conn_args *config, + char *dn, LDAPMod **attrs, int friendly ); static void -usage( char *name ) +usage( char *name, char opt ) { - fprintf( stderr, - "usage: %s " - "-H | ([-h ] -p ) " - "-D " - "-w " + if ( opt ) { + fprintf( stderr, "%s: unable to handle option \'%c\'\n\n", + name, opt ); + } + + fprintf( stderr, "usage: %s " TESTER_COMMON_HELP "-f " - "[-i ] " - "[-l ] " - "[-L ] " - "[-r ] " - "[-t ] " - "[-F] " - "[-C]\n", - name ); + "[-F]\n", + name ); exit( EXIT_FAILURE ); } @@ -70,99 +61,40 @@ int main( int argc, char **argv ) { int i; - char *host = "localhost"; - char *uri = NULL; - int port = -1; - char *manager = NULL; - struct berval passwd = { 0, NULL }; char *filename = NULL; char *entry = NULL; - int loops = LOOPS; - int outerloops = 1; - int retries = RETRIES; - int delay = 0; int friendly = 0; - int chaserefs = 0; LDAPMod **attrs = NULL; + struct tester_conn_args *config; - tester_init( "slapd-addel", TESTER_ADDEL ); + config = tester_init( "slapd-addel", TESTER_ADDEL ); - while ( ( i = getopt( argc, argv, "CD:Ff:H:h:i:L:l:p:r:t:w:" ) ) != EOF ) + while ( ( i = getopt( argc, argv, TESTER_COMMON_OPTS "Ff:" ) ) != EOF ) { switch ( i ) { - case 'C': - chaserefs++; - break; - case 'F': friendly++; break; - case 'H': /* the server's URI */ - uri = strdup( optarg ); - break; - - case 'h': /* the servers host */ - host = strdup( optarg ); - break; - case 'i': /* ignored (!) by now */ break; - case 'p': /* the servers port */ - if ( lutil_atoi( &port, optarg ) != 0 ) { - usage( argv[0] ); - } - break; - - case 'D': /* the servers manager */ - manager = strdup( optarg ); - break; - - case 'w': /* the server managers password */ - passwd.bv_val = strdup( optarg ); - passwd.bv_len = strlen( optarg ); - memset( optarg, '*', passwd.bv_len ); - break; - case 'f': /* file with entry search request */ filename = strdup( optarg ); break; - case 'l': /* the number of loops */ - if ( lutil_atoi( &loops, optarg ) != 0 ) { - usage( argv[0] ); - } - break; - - case 'L': /* the number of outerloops */ - if ( lutil_atoi( &outerloops, optarg ) != 0 ) { - usage( argv[0] ); - } - break; - - case 'r': /* number of retries */ - if ( lutil_atoi( &retries, optarg ) != 0 ) { - usage( argv[0] ); - } - break; - - case 't': /* delay in seconds */ - if ( lutil_atoi( &delay, optarg ) != 0 ) { - usage( argv[0] ); - } - break; - default: - usage( argv[0] ); + if ( tester_config_opt( config, i, optarg ) == LDAP_SUCCESS ) { + break; + } + usage( argv[0], i ); break; } } - if (( filename == NULL ) || ( port == -1 && uri == NULL ) || - ( manager == NULL ) || ( passwd.bv_val == NULL )) - usage( argv[0] ); + if ( filename == NULL ) + usage( argv[0], 0 ); entry = get_add_entry( filename, &attrs ); if (( entry == NULL ) || ( *entry == '\0' )) { @@ -181,11 +113,10 @@ main( int argc, char **argv ) } - uri = tester_uri( uri, host, port ); + tester_config_finish( config ); - for ( i = 0; i < outerloops; i++ ) { - do_addel( uri, manager, &passwd, entry, attrs, - loops, retries, delay, friendly, chaserefs ); + for ( i = 0; i < config->outerloops; i++ ) { + do_addel( config, entry, attrs, friendly ); } exit( EXIT_SUCCESS ); @@ -311,59 +242,26 @@ get_add_entry( char *filename, LDAPMod ***mods ) static void do_addel( - char *uri, - char *manager, - struct berval *passwd, + struct tester_conn_args *config, char *entry, LDAPMod **attrs, - int maxloop, - int maxretries, - int delay, - int friendly, - int chaserefs ) + int friendly ) { LDAP *ld = NULL; - int i = 0, do_retry = maxretries; + int i = 0, do_retry = config->retries; int rc = LDAP_SUCCESS; - int version = LDAP_VERSION3; retry:; - ldap_initialize( &ld, uri ); if ( ld == NULL ) { - tester_perror( "ldap_initialize", NULL ); - exit( EXIT_FAILURE ); + tester_init_ld( &ld, config, 0 ); } - (void) ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version ); - (void) ldap_set_option( ld, LDAP_OPT_REFERRALS, - chaserefs ? LDAP_OPT_ON : LDAP_OPT_OFF ); - - if ( do_retry == maxretries ) { + if ( do_retry == config->retries ) { fprintf( stderr, "PID=%ld - Add/Delete(%d): entry=\"%s\".\n", - (long) pid, maxloop, entry ); - } - - rc = ldap_sasl_bind_s( ld, manager, LDAP_SASL_SIMPLE, passwd, NULL, NULL, NULL ); - if ( rc != LDAP_SUCCESS ) { - tester_ldap_error( ld, "ldap_sasl_bind_s", NULL ); - switch ( rc ) { - case LDAP_BUSY: - case LDAP_UNAVAILABLE: - if ( do_retry > 0 ) { - do_retry--; - if ( delay != 0 ) { - sleep( delay ); - } - goto retry; - } - /* fallthru */ - default: - break; - } - exit( EXIT_FAILURE ); + (long) pid, config->loops, entry ); } - for ( ; i < maxloop; i++ ) { + for ( ; i < config->loops; i++ ) { /* add the entry */ rc = ldap_add_ext_s( ld, entry, attrs, NULL, NULL ); diff --git a/tests/progs/slapd-bind.c b/tests/progs/slapd-bind.c index d51148d83b..541a473644 100644 --- a/tests/progs/slapd-bind.c +++ b/tests/progs/slapd-bind.c @@ -39,17 +39,13 @@ #include "slapd-common.h" -#define LOOPS 100 - static int -do_bind( char *uri, char *dn, struct berval *pass, int maxloop, - int force, int chaserefs, int noinit, LDAP **ldp, - int action_type, void *action ); +do_bind( struct tester_conn_args *config, char *dn, int maxloop, + int force, int noinit, LDAP **ldp, int action_type, void *action ); static int -do_base( char *uri, char *dn, struct berval *pass, char *base, char *filter, char *pwattr, - int maxloop, int force, int chaserefs, int noinit, int delay, - int action_type, void *action ); +do_base( struct tester_conn_args *config, char *dn, char *base, char *filter, char *pwattr, + int force, int noinit, int action_type, void *action ); /* This program can be invoked two ways: if -D is used to specify a Bind DN, * that DN will be used repeatedly for all of the Binds. If instead -b is used @@ -66,18 +62,11 @@ usage( char *name, char opt ) name, opt ); } - fprintf( stderr, "usage: %s " - "[-H uri | -h [-p port]] " - "[-D [-w ]] " + fprintf( stderr, "usage: %s " TESTER_COMMON_HELP "[-b [-f ] [-a pwattr]] " - "[-l ] " - "[-L ] " "[-B [,...]] " "[-F] " - "[-C] " - "[-I] " - "[-i ] " - "[-t delay]\n", + "[-I]\n", name ); exit( EXIT_FAILURE ); } @@ -86,20 +75,12 @@ int main( int argc, char **argv ) { int i; - char *uri = NULL; - char *host = "localhost"; - char *dn = NULL; char *base = NULL; char *filter = "(objectClass=person)"; - struct berval pass = { 0, NULL }; char *pwattr = NULL; - int port = -1; - int loops = LOOPS; - int outerloops = 1; int force = 0; - int chaserefs = 0; int noinit = 1; - int delay = 0; + struct tester_conn_args *config; /* extra action to do after bind... */ struct berval type[] = { @@ -115,12 +96,12 @@ main( int argc, char **argv ) LDAPURLDesc *extra_ludp = NULL; - tester_init( "slapd-bind", TESTER_BIND ); + config = tester_init( "slapd-bind", TESTER_BIND ); /* by default, tolerate invalid credentials */ tester_ignore_str2errlist( "INVALID_CREDENTIALS" ); - while ( ( i = getopt( argc, argv, "a:B:b:D:Ff:H:h:Ii:L:l:p:t:w:" ) ) != EOF ) + while ( ( i = getopt( argc, argv, TESTER_COMMON_OPTS "a:B:b:Ff:I" ) ) != EOF ) { switch ( i ) { case 'a': @@ -173,49 +154,6 @@ main( int argc, char **argv ) } break; - case 'C': - chaserefs++; - break; - - case 'H': /* the server uri */ - uri = optarg; - break; - - case 'h': /* the servers host */ - host = optarg; - break; - - case 'i': - tester_ignore_str2errlist( optarg ); - break; - - case 'p': /* the servers port */ - if ( lutil_atoi( &port, optarg ) != 0 ) { - usage( argv[0], 'p' ); - } - break; - - case 'D': - dn = optarg; - break; - - case 'w': - ber_str2bv( optarg, 0, 1, &pass ); - memset( optarg, '*', pass.bv_len ); - break; - - case 'l': /* the number of loops */ - if ( lutil_atoi( &loops, optarg ) != 0 ) { - usage( argv[0], 'l' ); - } - break; - - case 'L': /* the number of outerloops */ - if ( lutil_atoi( &outerloops, optarg ) != 0 ) { - usage( argv[0], 'L' ); - } - break; - case 'f': filter = optarg; break; @@ -229,34 +167,26 @@ main( int argc, char **argv ) noinit = 0; break; - case 't': - /* sleep between binds */ - if ( lutil_atoi( &delay, optarg ) != 0 ) { - usage( argv[0], 't' ); - } - break; - default: + if ( tester_config_opt( config, i, optarg ) == LDAP_SUCCESS ) { + break; + } usage( argv[0], i ); break; } } - if ( port == -1 && uri == NULL ) { - usage( argv[0], '\0' ); - } - - uri = tester_uri( uri, host, port ); + tester_config_finish( config ); - for ( i = 0; i < outerloops; i++ ) { + for ( i = 0; i < config->outerloops; i++ ) { int rc; if ( base != NULL ) { - rc = do_base( uri, dn, &pass, base, filter, pwattr, loops, - force, chaserefs, noinit, delay, -1, NULL ); + rc = do_base( config, config->binddn, base, + filter, pwattr, force, noinit, -1, NULL ); } else { - rc = do_bind( uri, dn, &pass, loops, - force, chaserefs, noinit, NULL, -1, NULL ); + rc = do_bind( config, config->binddn, + config->loops, force, noinit, NULL, -1, NULL ); } if ( rc == LDAP_SERVER_DOWN ) break; @@ -267,9 +197,8 @@ main( int argc, char **argv ) static int -do_bind( char *uri, char *dn, struct berval *pass, int maxloop, - int force, int chaserefs, int noinit, LDAP **ldp, - int action_type, void *action ) +do_bind( struct tester_conn_args *config, char *dn, int maxloop, + int force, int noinit, LDAP **ldp, int action_type, void *action ) { LDAP *ld = ldp ? *ldp : NULL; int i, rc = -1; @@ -327,21 +256,10 @@ do_bind( char *uri, char *dn, struct berval *pass, int maxloop, for ( i = 0; i < maxloop; i++ ) { if ( !noinit || ld == NULL ) { - int version = LDAP_VERSION3; - ldap_initialize( &ld, uri ); - if ( ld == NULL ) { - tester_perror( "ldap_initialize", NULL ); - rc = -1; - break; - } - - (void) ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, - &version ); - (void) ldap_set_option( ld, LDAP_OPT_REFERRALS, - chaserefs ? LDAP_OPT_ON: LDAP_OPT_OFF ); + tester_init_ld( &ld, config, TESTER_INIT_ONLY ); } - rc = ldap_sasl_bind_s( ld, dn, LDAP_SASL_SIMPLE, pass, NULL, NULL, NULL ); + rc = ldap_sasl_bind_s( ld, dn, LDAP_SASL_SIMPLE, &config->pass, NULL, NULL, NULL ); if ( rc ) { int first = tester_ignore_err( rc ); @@ -413,9 +331,8 @@ do_bind( char *uri, char *dn, struct berval *pass, int maxloop, static int -do_base( char *uri, char *dn, struct berval *pass, char *base, char *filter, char *pwattr, - int maxloop, int force, int chaserefs, int noinit, int delay, - int action_type, void *action ) +do_base( struct tester_conn_args *config, char *dn, char *base, char *filter, char *pwattr, + int force, int noinit, int action_type, void *action ) { LDAP *ld = NULL; int i = 0; @@ -431,27 +348,12 @@ do_base( char *uri, char *dn, struct berval *pass, char *base, char *filter, cha #else struct timeval beg, end; #endif - int version = LDAP_VERSION3; char *nullstr = ""; - ldap_initialize( &ld, uri ); - if ( ld == NULL ) { - tester_perror( "ldap_initialize", NULL ); - exit( EXIT_FAILURE ); - } - - (void) ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version ); - (void) ldap_set_option( ld, LDAP_OPT_REFERRALS, - chaserefs ? LDAP_OPT_ON: LDAP_OPT_OFF ); - - rc = ldap_sasl_bind_s( ld, dn, LDAP_SASL_SIMPLE, pass, NULL, NULL, NULL ); - if ( rc != LDAP_SUCCESS ) { - tester_ldap_error( ld, "ldap_sasl_bind_s", NULL ); - exit( EXIT_FAILURE ); - } + tester_init_ld( &ld, config, 0 ); fprintf( stderr, "PID=%ld - Bind(%d): base=\"%s\", filter=\"%s\" attr=\"%s\".\n", - (long) pid, maxloop, base, filter, pwattr ); + (long) pid, config->loops, base, filter, pwattr ); if ( pwattr != NULL ) { attrs[ 0 ] = pwattr; @@ -540,10 +442,8 @@ novals:; (long) pid, base, filter, ndns ); /* Ok, got list of DNs, now start binding to each */ - for ( i = 0; i < maxloop; i++ ) { + for ( i = 0; i < config->loops; i++ ) { int j; - struct berval cred = { 0, NULL }; - #if 0 /* use high-order bits for better randomness (Numerical Recipes in "C") */ j = rand() % ndns; @@ -551,17 +451,17 @@ novals:; j = ((double)ndns)*rand()/(RAND_MAX + 1.0); if ( creds && !BER_BVISEMPTY( &creds[j] ) ) { - cred = creds[j]; + config->pass = creds[j]; } - if ( do_bind( uri, dns[j], &cred, 1, force, chaserefs, noinit, &ld, + if ( do_bind( config, dns[j], 1, force, noinit, &ld, action_type, action ) && !force ) { break; } - if ( delay ) { - sleep( delay ); + if ( config->delay ) { + sleep( config->delay ); } } diff --git a/tests/progs/slapd-common.c b/tests/progs/slapd-common.c index da513efeed..81ce7e53c2 100644 --- a/tests/progs/slapd-common.c +++ b/tests/progs/slapd-common.c @@ -28,6 +28,7 @@ #include "ldap.h" +#include "lutil.h" #include "ldap_pvt.h" #include "slapd-common.h" @@ -127,6 +128,9 @@ static const struct { #define UNKNOWN_ERR (1234567890) +#define RETRIES 0 +#define LOOPS 100 + static int tester_ignore_str2err( const char *err ) { @@ -197,27 +201,26 @@ tester_ignore_err( int err ) return rc; } -void +struct tester_conn_args * tester_init( const char *pname, tester_t ptype ) { + static struct tester_conn_args config = { + .authmethod = -1, + .retries = RETRIES, + .loops = LOOPS, + .outerloops = 1, + + .uri = NULL, + .host = "localhost", + .port = 389, + }; + pid = getpid(); srand( pid ); snprintf( progname, sizeof( progname ), "%s PID=%d", pname, pid ); progtype = ptype; -} - -char * -tester_uri( char *uri, char *host, int port ) -{ - static char uribuf[ BUFSIZ ]; - if ( uri != NULL ) { - return uri; - } - - snprintf( uribuf, sizeof( uribuf ), "ldap://%s:%d", host, port ); - - return uribuf; + return &config; } void @@ -293,6 +296,163 @@ tester_perror( const char *fname, const char *msg ) msg ? msg : "" ); } +int +tester_config_opt( struct tester_conn_args *config, char opt, char *optarg ) +{ + switch ( opt ) { + case 'C': + config->chaserefs++; + break; + + case 'D': + config->binddn = strdup( optarg ); + break; + + case 'd': + { + int debug; + if ( lutil_atoi( &debug, optarg ) != 0 ) { + return -1; + } + + if ( ber_set_option( NULL, LBER_OPT_DEBUG_LEVEL, &debug ) + != LBER_OPT_SUCCESS ) + { + fprintf( stderr, + "Could not set LBER_OPT_DEBUG_LEVEL %d\n", debug ); + } + + if ( ldap_set_option( NULL, LDAP_OPT_DEBUG_LEVEL, &debug ) + != LDAP_OPT_SUCCESS ) + { + fprintf( stderr, + "Could not set LDAP_OPT_DEBUG_LEVEL %d\n", debug ); + } + break; + } + + case 'H': + config->uri = strdup( optarg ); + break; + + case 'h': + config->host = strdup( optarg ); + break; + + case 'i': + tester_ignore_str2errlist( optarg ); + break; + + case 'L': + if ( lutil_atoi( &config->outerloops, optarg ) != 0 ) { + return -1; + } + break; + + case 'l': + if ( lutil_atoi( &config->loops, optarg ) != 0 ) { + return -1; + } + break; + + case 'p': + if ( lutil_atoi( &config->port, optarg ) != 0 ) { + return -1; + } + break; + + case 'r': + if ( lutil_atoi( &config->retries, optarg ) != 0 ) { + return -1; + } + break; + + case 't': + if ( lutil_atoi( &config->delay, optarg ) != 0 ) { + return -1; + } + break; + + case 'w': + config->pass.bv_val = strdup( optarg ); + config->pass.bv_len = strlen( optarg ); + memset( optarg, '*', config->pass.bv_len ); + break; + + case 'x': + if ( config->authmethod != -1 && config->authmethod != LDAP_AUTH_SIMPLE ) { + return -1; + } + config->authmethod = LDAP_AUTH_SIMPLE; + break; + + default: + return -1; + } + + return LDAP_SUCCESS; +} + +void +tester_config_finish( struct tester_conn_args *config ) +{ + if ( !config->uri ) { + static char uribuf[ BUFSIZ ]; + + config->uri = uribuf; + snprintf( uribuf, sizeof( uribuf ), "ldap://%s:%d", + config->host, config->port ); + } + + if ( config->authmethod == -1 ) { + config->authmethod = LDAP_AUTH_SIMPLE; + } +} + +void +tester_init_ld( LDAP **ldp, struct tester_conn_args *config, int flags ) +{ + LDAP *ld; + int rc, do_retry = config->retries; + int version = LDAP_VERSION3; + +retry:; + ldap_initialize( &ld, config->uri ); + if ( ld == NULL ) { + tester_perror( "ldap_initialize", NULL ); + exit( EXIT_FAILURE ); + } + + (void) ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version ); + (void) ldap_set_option( ld, LDAP_OPT_REFERRALS, + config->chaserefs ? LDAP_OPT_ON: LDAP_OPT_OFF ); + + if ( !( flags & TESTER_INIT_ONLY ) ) { + rc = ldap_sasl_bind_s( ld, + config->binddn, LDAP_SASL_SIMPLE, + &config->pass, NULL, NULL, NULL ); + + if ( rc != LDAP_SUCCESS ) { + tester_ldap_error( ld, "ldap_sasl_bind_s", NULL ); + switch ( rc ) { + case LDAP_BUSY: + case LDAP_UNAVAILABLE: + if ( do_retry > 0 ) { + do_retry--; + if ( config->delay > 0 ) { + sleep( config->delay ); + } + goto retry; + } + } + tester_ldap_error( ld, "ldap_sasl_bind_s", NULL ); + exit( EXIT_FAILURE ); + } + } + + *ldp = ld; +} + void tester_error( const char *msg ) { diff --git a/tests/progs/slapd-common.h b/tests/progs/slapd-common.h index 1e3380ec84..fd440eaa7a 100644 --- a/tests/progs/slapd-common.h +++ b/tests/progs/slapd-common.h @@ -31,7 +31,7 @@ typedef enum { TESTER_LAST } tester_t; -extern void tester_init( const char *pname, tester_t ptype ); +extern struct tester_conn_args * tester_init( const char *pname, tester_t ptype ); extern char * tester_uri( char *uri, char *host, int port ); extern void tester_error( const char *msg ); extern void tester_perror( const char *fname, const char *msg ); @@ -39,6 +39,41 @@ extern void tester_ldap_error( LDAP *ld, const char *fname, const char *msg ); extern int tester_ignore_str2errlist( const char *err ); extern int tester_ignore_err( int err ); +struct tester_conn_args { + char *uri, *host; + int port; + + int outerloops; + int loops; + int retries; + int delay; + + int chaserefs; + + int authmethod; + + char *binddn; + struct berval pass; +}; + +#define TESTER_INIT_ONLY (1 << 0) +#define TESTER_COMMON_OPTS "CD:d:H:h:L:l:i:p:r:t:w:x" +#define TESTER_COMMON_HELP \ + "[-C] " \ + "[-D [-w ]] " \ + "[-d ] " \ + "[-H uri | -h [-p port]] " \ + "[-i ] " \ + "[-l ] " \ + "[-L ] " \ + "[-r ] " \ + "[-t ] " \ + "[-x] " + +extern int tester_config_opt( struct tester_conn_args *config, char opt, char *optarg ); +extern void tester_config_finish( struct tester_conn_args *config ); +extern void tester_init_ld( LDAP **ldp, struct tester_conn_args *conf, int flags ); + extern pid_t pid; #endif /* SLAPD_COMMON_H */ diff --git a/tests/progs/slapd-modify.c b/tests/progs/slapd-modify.c index eec14e565f..7525f281a1 100644 --- a/tests/progs/slapd-modify.c +++ b/tests/progs/slapd-modify.c @@ -32,31 +32,25 @@ #include "slapd-common.h" #define LOOPS 100 -#define RETRIES 0 static void -do_modify( char *uri, char *manager, struct berval *passwd, - char *entry, char *attr, char *value, int maxloop, - int maxretries, int delay, int friendly, int chaserefs ); +do_modify( struct tester_conn_args *config, char *entry, + char *attr, char *value, int friendly ); static void -usage( char *name ) +usage( char *name, int opt ) { - fprintf( stderr, - "usage: %s " - "-H | ([-h ] -p ) " - "-D " - "-w " + if ( opt ) { + fprintf( stderr, "%s: unable to handle option \'%c\'\n\n", + name, opt ); + } + + fprintf( stderr, "usage: %s " TESTER_COMMON_HELP + "-a " "-e " - "[-i ] " - "[-l ] " - "[-L ] " - "[-r ] " - "[-t ] " - "[-F] " - "[-C]\n", - name ); + "[-F]\n", + name ); exit( EXIT_FAILURE ); } @@ -64,62 +58,25 @@ int main( int argc, char **argv ) { int i; - char *uri = NULL; - char *host = "localhost"; - int port = -1; - char *manager = NULL; - struct berval passwd = { 0, NULL }; char *entry = NULL; char *ava = NULL; char *value = NULL; - int loops = LOOPS; - int outerloops = 1; - int retries = RETRIES; - int delay = 0; int friendly = 0; - int chaserefs = 0; + struct tester_conn_args *config; - tester_init( "slapd-modify", TESTER_MODIFY ); + config = tester_init( "slapd-modify", TESTER_MODIFY ); - while ( ( i = getopt( argc, argv, "a:CD:e:FH:h:i:L:l:p:r:t:w:" ) ) != EOF ) + while ( ( i = getopt( argc, argv, TESTER_COMMON_OPTS "a:e:F" ) ) != EOF ) { switch ( i ) { - case 'C': - chaserefs++; - break; - case 'F': friendly++; break; - case 'H': /* the server uri */ - uri = strdup( optarg ); - break; - - case 'h': /* the servers host */ - host = strdup( optarg ); - break; - case 'i': /* ignored (!) by now */ break; - case 'p': /* the servers port */ - if ( lutil_atoi( &port, optarg ) != 0 ) { - usage( argv[0] ); - } - break; - - case 'D': /* the servers manager */ - manager = strdup( optarg ); - break; - - case 'w': /* the server managers password */ - passwd.bv_val = strdup( optarg ); - passwd.bv_len = strlen( optarg ); - memset( optarg, '*', passwd.bv_len ); - break; - case 'e': /* entry to modify */ entry = strdup( optarg ); break; @@ -128,38 +85,17 @@ main( int argc, char **argv ) ava = strdup( optarg ); break; - case 'l': /* the number of loops */ - if ( lutil_atoi( &loops, optarg ) != 0 ) { - usage( argv[0] ); - } - break; - - case 'L': /* the number of outerloops */ - if ( lutil_atoi( &outerloops, optarg ) != 0 ) { - usage( argv[0] ); - } - break; - - case 'r': /* number of retries */ - if ( lutil_atoi( &retries, optarg ) != 0 ) { - usage( argv[0] ); - } - break; - - case 't': /* delay in seconds */ - if ( lutil_atoi( &delay, optarg ) != 0 ) { - usage( argv[0] ); - } - break; - default: - usage( argv[0] ); + if ( tester_config_opt( config, i, optarg ) == LDAP_SUCCESS ) { + break; + } + usage( argv[0], i ); break; } } - if (( entry == NULL ) || ( ava == NULL ) || ( port == -1 && uri == NULL )) - usage( argv[0] ); + if (( entry == NULL ) || ( ava == NULL )) + usage( argv[0], 0 ); if ( *entry == '\0' ) { @@ -183,11 +119,10 @@ main( int argc, char **argv ) while ( *value && isspace( (unsigned char) *value )) value++; - uri = tester_uri( uri, host, port ); + tester_config_finish( config ); - for ( i = 0; i < outerloops; i++ ) { - do_modify( uri, manager, &passwd, entry, ava, value, - loops, retries, delay, friendly, chaserefs ); + for ( i = 0; i < config->outerloops; i++ ) { + do_modify( config, entry, ava, value, friendly ); } exit( EXIT_SUCCESS ); @@ -195,18 +130,16 @@ main( int argc, char **argv ) static void -do_modify( char *uri, char *manager, - struct berval *passwd, char *entry, char* attr, char* value, - int maxloop, int maxretries, int delay, int friendly, int chaserefs ) +do_modify( struct tester_conn_args *config, + char *entry, char* attr, char* value, int friendly ) { LDAP *ld = NULL; - int i = 0, do_retry = maxretries; + int i = 0, do_retry = config->retries; int rc = LDAP_SUCCESS; struct ldapmod mod; struct ldapmod *mods[2]; char *values[2]; - int version = LDAP_VERSION3; values[0] = value; values[1] = NULL; @@ -217,42 +150,14 @@ do_modify( char *uri, char *manager, mods[1] = NULL; retry:; - ldap_initialize( &ld, uri ); - if ( ld == NULL ) { - tester_perror( "ldap_initialize", NULL ); - exit( EXIT_FAILURE ); - } - - (void) ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version ); - (void) ldap_set_option( ld, LDAP_OPT_REFERRALS, - chaserefs ? LDAP_OPT_ON : LDAP_OPT_OFF ); + tester_init_ld( &ld, config, 0 ); - if ( do_retry == maxretries ) { + if ( do_retry == config->retries ) { fprintf( stderr, "PID=%ld - Modify(%d): entry=\"%s\".\n", - (long) pid, maxloop, entry ); - } - - rc = ldap_sasl_bind_s( ld, manager, LDAP_SASL_SIMPLE, passwd, NULL, NULL, NULL ); - if ( rc != LDAP_SUCCESS ) { - tester_ldap_error( ld, "ldap_sasl_bind_s", NULL ); - switch ( rc ) { - case LDAP_BUSY: - case LDAP_UNAVAILABLE: - if ( do_retry > 0 ) { - do_retry--; - if ( delay > 0 ) { - sleep( delay ); - } - goto retry; - } - /* fallthru */ - default: - break; - } - exit( EXIT_FAILURE ); + (long) pid, config->loops, entry ); } - for ( ; i < maxloop; i++ ) { + for ( ; i < config->loops; i++ ) { mod.mod_op = LDAP_MOD_ADD; rc = ldap_modify_ext_s( ld, entry, mods, NULL, NULL ); if ( rc != LDAP_SUCCESS ) { diff --git a/tests/progs/slapd-modrdn.c b/tests/progs/slapd-modrdn.c index d2ec0d5be3..d5e4076c66 100644 --- a/tests/progs/slapd-modrdn.c +++ b/tests/progs/slapd-modrdn.c @@ -39,27 +39,21 @@ #define RETRIES 0 static void -do_modrdn( char *uri, char *manager, struct berval *passwd, - char *entry, int maxloop, int maxretries, int delay, - int friendly, int chaserefs ); +do_modrdn( struct tester_conn_args *config, + char *entry, int friendly ); static void -usage( char *name ) +usage( char *name, char opt ) { - fprintf( stderr, - "usage: %s " - "-H | ([-h ] -p ) " - "-D " - "-w " + if ( opt ) { + fprintf( stderr, "%s: unable to handle option \'%c\'\n\n", + name, opt ); + } + + fprintf( stderr, "usage: %s " TESTER_COMMON_HELP "-e " - "[-i ] " - "[-l ] " - "[-L ] " - "[-r ] " - "[-t ] " - "[-F] " - "[-C]\n", - name ); + "[-F]\n", + name ); exit( EXIT_FAILURE ); } @@ -67,96 +61,38 @@ int main( int argc, char **argv ) { int i; - char *uri = NULL; - char *host = "localhost"; - int port = -1; - char *manager = NULL; - struct berval passwd = { 0, NULL }; char *entry = NULL; - int loops = LOOPS; - int outerloops = 1; - int retries = RETRIES; - int delay = 0; int friendly = 0; - int chaserefs = 0; + struct tester_conn_args *config; - tester_init( "slapd-modrdn", TESTER_MODRDN ); + config = tester_init( "slapd-modrdn", TESTER_MODRDN ); - while ( ( i = getopt( argc, argv, "CD:e:FH:h:i:L:l:p:r:t:w:" ) ) != EOF ) + while ( ( i = getopt( argc, argv, TESTER_COMMON_OPTS "e:F" ) ) != EOF ) { switch ( i ) { - case 'C': - chaserefs++; - break; - case 'F': friendly++; break; - case 'H': /* the server uri */ - uri = strdup( optarg ); - break; - - case 'h': /* the servers host */ - host = strdup( optarg ); - break; - case 'i': /* ignored (!) by now */ break; - case 'p': /* the servers port */ - if ( lutil_atoi( &port, optarg ) != 0 ) { - usage( argv[0] ); - } - break; - - case 'D': /* the servers manager */ - manager = strdup( optarg ); - break; - - case 'w': /* the server managers password */ - passwd.bv_val = strdup( optarg ); - passwd.bv_len = strlen( optarg ); - memset( optarg, '*', passwd.bv_len ); - break; - case 'e': /* entry to rename */ entry = strdup( optarg ); break; - case 'l': /* the number of loops */ - if ( lutil_atoi( &loops, optarg ) != 0 ) { - usage( argv[0] ); - } - break; - - case 'L': /* the number of outerloops */ - if ( lutil_atoi( &outerloops, optarg ) != 0 ) { - usage( argv[0] ); - } - break; - - case 'r': /* the number of retries */ - if ( lutil_atoi( &retries, optarg ) != 0 ) { - usage( argv[0] ); - } - break; - - case 't': /* delay in seconds */ - if ( lutil_atoi( &delay, optarg ) != 0 ) { - usage( argv[0] ); - } - break; - default: - usage( argv[0] ); + if ( tester_config_opt( config, i, optarg ) == LDAP_SUCCESS ) { + break; + } + usage( argv[0], i ); break; } } - if (( entry == NULL ) || ( port == -1 && uri == NULL )) - usage( argv[0] ); + if ( entry == NULL ) + usage( argv[0], 0 ); if ( *entry == '\0' ) { @@ -166,11 +102,10 @@ main( int argc, char **argv ) } - uri = tester_uri( uri, host, port ); + tester_config_finish( config ); - for ( i = 0; i < outerloops; i++ ) { - do_modrdn( uri, manager, &passwd, entry, - loops, retries, delay, friendly, chaserefs ); + for ( i = 0; i < config->outerloops; i++ ) { + do_modrdn( config, entry, friendly ); } exit( EXIT_SUCCESS ); @@ -178,17 +113,15 @@ main( int argc, char **argv ) static void -do_modrdn( char *uri, char *manager, - struct berval *passwd, char *entry, int maxloop, int maxretries, - int delay, int friendly, int chaserefs ) +do_modrdn( struct tester_conn_args *config, + char *entry, int friendly ) { LDAP *ld = NULL; - int i, do_retry = maxretries; + int i, do_retry = config->retries; char *DNs[2]; char *rdns[2]; int rc = LDAP_SUCCESS; char *p1, *p2; - int version = LDAP_VERSION3; DNs[0] = entry; DNs[1] = strdup( entry ); @@ -211,42 +144,14 @@ do_modrdn( char *uri, char *manager, i = 0; retry:; - ldap_initialize( &ld, uri ); - if ( ld == NULL ) { - tester_perror( "ldap_initialize", NULL ); - exit( EXIT_FAILURE ); - } - - (void) ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version ); - (void) ldap_set_option( ld, LDAP_OPT_REFERRALS, - chaserefs ? LDAP_OPT_ON : LDAP_OPT_OFF ); + tester_init_ld( &ld, config, 0 ); - if ( do_retry == maxretries ) { + if ( do_retry == config->retries ) { fprintf( stderr, "PID=%ld - Modrdn(%d): entry=\"%s\".\n", - (long) pid, maxloop, entry ); - } - - rc = ldap_sasl_bind_s( ld, manager, LDAP_SASL_SIMPLE, passwd, NULL, NULL, NULL ); - if ( rc != LDAP_SUCCESS ) { - tester_ldap_error( ld, "ldap_sasl_bind_s", NULL ); - switch ( rc ) { - case LDAP_BUSY: - case LDAP_UNAVAILABLE: - if ( do_retry > 0 ) { - do_retry--; - if ( delay > 0) { - sleep( delay ); - } - goto retry; - } - /* fallthru */ - default: - break; - } - exit( EXIT_FAILURE ); + (long) pid, config->loops, entry ); } - for ( ; i < maxloop; i++ ) { + for ( ; i < config->loops; i++ ) { rc = ldap_rename_s( ld, DNs[0], rdns[0], NULL, 0, NULL, NULL ); if ( rc != LDAP_SUCCESS ) { tester_ldap_error( ld, "ldap_rename_s", NULL ); diff --git a/tests/progs/slapd-mtread.c b/tests/progs/slapd-mtread.c index 571487173c..5c855cdadb 100644 --- a/tests/progs/slapd-mtread.c +++ b/tests/progs/slapd-mtread.c @@ -49,26 +49,20 @@ #define RETRIES 0 #define DEFAULT_BASE "ou=people,dc=example,dc=com" -static void -do_conn( char *uri, char *manager, struct berval *passwd, - LDAP **ld, int nobind, int maxretries, int conn_num ); - static void do_read( LDAP *ld, char *entry, char **attrs, int noattrs, int nobind, int maxloop, - int maxretries, int delay, int force, int chaserefs, int idx ); + int force, int idx ); static void do_random( LDAP *ld, char *sbase, char *filter, char **attrs, int noattrs, int nobind, - int innerloop, int maxretries, int delay, int force, int chaserefs, - int idx ); + int force, int idx ); static void do_random2( LDAP *ld, char *sbase, char *filter, char **attrs, int noattrs, int nobind, - int innerloop, int maxretries, int delay, int force, int chaserefs, - int idx ); + int force, int idx ); static void * do_onethread( void *arg ); @@ -88,14 +82,10 @@ ldap_pvt_thread_t rtid[MAX_THREAD*2], *rwtid = rtid + MAX_THREAD; * Shared globals (command line args) */ LDAP *ld = NULL; +struct tester_conn_args *config; char *entry = NULL; char *filter = NULL; -int loops = LOOPS; -int outerloops = 1; -int retries = RETRIES; -int delay = 0; int force = 0; -int chaserefs = 0; char *srchattrs[] = { "1.1", NULL }; char **attrs = srchattrs; int noattrs = 0; @@ -137,28 +127,23 @@ thread_verbose(int idx, char *string) } static void -usage( char *name ) +usage( char *name, char opt ) { - fprintf( stderr, - "usage: %s " - "-H | ([-h ] -p ) " - "-D " - "-w " + if ( opt ) { + fprintf( stderr, "%s: unable to handle option \'%c\'\n\n", + name, opt ); + } + + fprintf( stderr, "usage: %s " TESTER_COMMON_HELP "-e " "[-A] " - "[-C] " "[-F] " "[-N] " "[-v] " "[-c connections] " "[-f filter] " - "[-i ] " - "[-l ] " - "[-L ] " "[-m threads] " "[-M threads] " - "[-r ] " - "[-t ] " "[-T ] " "[] " "\n", @@ -179,61 +164,28 @@ main( int argc, char **argv ) int ptpass; int testfail = 0; - - tester_init( "slapd-mtread", TESTER_READ ); + config = tester_init( "slapd-mtread", TESTER_READ ); /* by default, tolerate referrals and no such object */ tester_ignore_str2errlist( "REFERRAL,NO_SUCH_OBJECT" ); - while ( (i = getopt( argc, argv, "ACc:D:e:Ff:H:h:i:L:l:M:m:Np:r:t:T:w:v" )) != EOF ) { + while ( (i = getopt( argc, argv, TESTER_COMMON_OPTS "Ac:e:Ff:M:m:NT:v" )) != EOF ) { switch ( i ) { case 'A': noattrs++; break; - case 'C': - chaserefs++; - break; - - case 'H': /* the server uri */ - uri = strdup( optarg ); - break; - - case 'h': /* the servers host */ - host = strdup( optarg ); - break; - - case 'i': - tester_ignore_str2errlist( optarg ); - break; - case 'N': - nobind++; + nobind = TESTER_INIT_ONLY; break; case 'v': verbose++; break; - case 'p': /* the servers port */ - if ( lutil_atoi( &port, optarg ) != 0 ) { - usage( argv[0] ); - } - break; - - case 'D': /* the servers manager */ - manager = strdup( optarg ); - break; - - case 'w': /* the server managers password */ - passwd.bv_val = strdup( optarg ); - passwd.bv_len = strlen( optarg ); - memset( optarg, '*', passwd.bv_len ); - break; - case 'c': /* the number of connections */ if ( lutil_atoi( &noconns, optarg ) != 0 ) { - usage( argv[0] ); + usage( argv[0], i ); } break; @@ -249,21 +201,9 @@ main( int argc, char **argv ) force++; break; - case 'l': /* the number of loops */ - if ( lutil_atoi( &loops, optarg ) != 0 ) { - usage( argv[0] ); - } - break; - - case 'L': /* the number of outerloops */ - if ( lutil_atoi( &outerloops, optarg ) != 0 ) { - usage( argv[0] ); - } - break; - case 'M': /* the number of R/W threads */ if ( lutil_atoi( &rwthreads, optarg ) != 0 ) { - usage( argv[0] ); + usage( argv[0], i ); } if (rwthreads > MAX_THREAD) rwthreads = MAX_THREAD; @@ -271,39 +211,30 @@ main( int argc, char **argv ) case 'm': /* the number of threads */ if ( lutil_atoi( &threads, optarg ) != 0 ) { - usage( argv[0] ); + usage( argv[0], i ); } if (threads > MAX_THREAD) threads = MAX_THREAD; break; - case 'r': /* the number of retries */ - if ( lutil_atoi( &retries, optarg ) != 0 ) { - usage( argv[0] ); - } - break; - - case 't': /* delay in seconds */ - if ( lutil_atoi( &delay, optarg ) != 0 ) { - usage( argv[0] ); - } - break; - case 'T': attrs = ldap_str2charray( optarg, "," ); if ( attrs == NULL ) { - usage( argv[0] ); + usage( argv[0], i ); } break; default: - usage( argv[0] ); + if ( tester_config_opt( config, i, optarg ) == LDAP_SUCCESS ) { + break; + } + usage( argv[0], i ); break; } } - if (( entry == NULL ) || ( port == -1 && uri == NULL )) - usage( argv[0] ); + if ( entry == NULL ) + usage( argv[0], 0 ); if ( *entry == '\0' ) { fprintf( stderr, "%s: invalid EMPTY entry DN.\n", @@ -326,16 +257,13 @@ main( int argc, char **argv ) exit( EXIT_FAILURE ); } - uri = tester_uri( uri, host, port ); - /* One connection and one connection only */ - do_conn( uri, manager, &passwd, &ld, nobind, retries, 0 ); - lds[0] = ld; - for(i = 1; i < noconns; i++) { - do_conn( uri, manager, &passwd, &lds[i], nobind, retries, i ); - } - + tester_config_finish( config ); ldap_pvt_thread_initialize(); + for (i = 0; i < noconns; i++) { + tester_init_ld( &lds[i], config, nobind ); + } + snprintf(outstr, BUFSIZ, "MT Test Start: conns: %d (%s)", noconns, uri); tester_error(outstr); snprintf(outstr, BUFSIZ, "Threads: RO: %d RW: %d", threads, rwthreads); @@ -354,7 +282,7 @@ main( int argc, char **argv ) thread_verbose(-1, outstr); } - ptpass = outerloops * loops; + ptpass = config->outerloops * config->loops; /* wait for read only threads to complete */ for ( i = 0; i < threads; i++ ) @@ -413,7 +341,7 @@ do_onethread( void *arg ) exit( EXIT_FAILURE ); } - for ( j = 0; j < outerloops; j++ ) { + for ( j = 0; j < config->outerloops; j++ ) { for(i = 0; i < noconns; i++) { mlds[i] = ldap_dup(lds[i]); if (mlds[i] == NULL) { @@ -439,17 +367,14 @@ do_onethread( void *arg ) if ( filter != NULL ) { if (strchr(filter, '[')) do_random2( mlds[thisconn], entry, filter, attrs, - noattrs, nobind, loops, retries, delay, force, - chaserefs, idx ); + noattrs, nobind, force, idx ); else do_random( mlds[thisconn], entry, filter, attrs, - noattrs, nobind, loops, retries, delay, force, - chaserefs, idx ); + noattrs, nobind, force, idx ); } else { - do_read( mlds[thisconn], entry, attrs, - noattrs, nobind, loops, retries, delay, force, - chaserefs, idx ); + do_read( mlds[thisconn], entry, attrs, noattrs, + nobind, config->loops, force, idx ); } for(i = 0; i < noconns; i++) { (void) ldap_destroy(mlds[i]); @@ -504,7 +429,7 @@ do_onerwthread( void *arg ) attrs[3].mod_values = uid_vals; uid_vals[0] = &uids[0]; - for ( j = 0; j < outerloops; j++ ) { + for ( j = 0; j < config->outerloops; j++ ) { for(i = 0; i < noconns; i++) { mlds[i] = ldap_dup(lds[i]); if (mlds[i] == NULL) { @@ -537,7 +462,7 @@ do_onerwthread( void *arg ) adds = 0; dels = 0; - for (i = 0; i < loops; i++) { + for (i = 0; i < config->loops; i++) { ret = ldap_add_ext_s(ld, dn, &attrp[0], NULL, NULL); if (ret == LDAP_SUCCESS) { adds++; @@ -570,69 +495,12 @@ do_onerwthread( void *arg ) return( NULL ); } -static void -do_conn( char *uri, char *manager, struct berval *passwd, - LDAP **ldp, int nobind, int maxretries, int conn_num ) -{ - LDAP *ld = NULL; - int version = LDAP_VERSION3; - int do_retry = maxretries; - int rc = LDAP_SUCCESS; - char thrstr[BUFSIZ]; - -retry:; - ldap_initialize( &ld, uri ); - if ( ld == NULL ) { - snprintf( thrstr, BUFSIZ, "connection: %d", conn_num ); - tester_error( thrstr ); - tester_perror( "ldap_initialize", NULL ); - exit( EXIT_FAILURE ); - } - - (void) ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version ); - (void) ldap_set_option( ld, LDAP_OPT_REFERRALS, - chaserefs ? LDAP_OPT_ON : LDAP_OPT_OFF ); - - if ( do_retry == maxretries ) { - snprintf( thrstr, BUFSIZ, "do_conn #%d\n", conn_num ); - thread_verbose( -1, thrstr ); - } - - if ( nobind == 0 ) { - rc = ldap_sasl_bind_s( ld, manager, LDAP_SASL_SIMPLE, passwd, NULL, NULL, NULL ); - if ( rc != LDAP_SUCCESS ) { - snprintf( thrstr, BUFSIZ, "connection: %d", conn_num ); - tester_error( thrstr ); - tester_ldap_error( ld, "ldap_sasl_bind_s", NULL ); - switch ( rc ) { - case LDAP_BUSY: - case LDAP_UNAVAILABLE: - if ( do_retry > 0 ) { - ldap_unbind_ext( ld, NULL, NULL ); - ld = NULL; - do_retry--; - if ( delay != 0 ) { - sleep( delay ); - } - goto retry; - } - /* fallthru */ - default: - break; - } - exit( EXIT_FAILURE ); - } - } - *ldp = ld; -} - static void do_random( LDAP *ld, char *sbase, char *filter, char **srchattrs, int noattrs, int nobind, - int innerloop, int maxretries, int delay, int force, int chaserefs, - int idx ) + int force, int idx ) { - int i = 0, do_retry = maxretries; + int i = 0, do_retry = config->retries; char *attrs[ 2 ]; int rc = LDAP_SUCCESS; int nvalues = 0; @@ -645,7 +513,7 @@ do_random( LDAP *ld, snprintf( thrstr, BUFSIZ, "Read(%d): base=\"%s\", filter=\"%s\".\n", - innerloop, sbase, filter ); + config->loops, sbase, filter ); thread_verbose( idx, thrstr ); rc = ldap_search_ext_s( ld, sbase, LDAP_SCOPE_SUBTREE, @@ -671,19 +539,18 @@ do_random( LDAP *ld, ldap_msgfree( res ); - if ( do_retry == maxretries ) { + if ( do_retry == config->retries ) { snprintf( thrstr, BUFSIZ, "Read base=\"%s\" filter=\"%s\" got %d values.\n", sbase, filter, nvalues ); thread_verbose( idx, thrstr ); } - for ( i = 0; i < innerloop; i++ ) { + for ( i = 0; i < config->loops; i++ ) { int r = ((double)nvalues)*rand()/(RAND_MAX + 1.0); do_read( ld, values[ r ], - srchattrs, noattrs, nobind, 1, maxretries, - delay, force, chaserefs, idx ); + srchattrs, noattrs, nobind, 1, force, idx ); } for( i = 0; i < nvalues; i++) { if (values[i] != NULL) @@ -705,10 +572,9 @@ do_random( LDAP *ld, static void do_random2( LDAP *ld, char *sbase, char *filter, char **srchattrs, int noattrs, int nobind, - int innerloop, int maxretries, int delay, int force, int chaserefs, - int idx ) + int force, int idx ) { - int i = 0, do_retry = maxretries; + int i = 0, do_retry = config->retries; int rc = LDAP_SUCCESS; int lo, hi, range; int flen; @@ -719,7 +585,7 @@ do_random2( LDAP *ld, snprintf( thrstr, BUFSIZ, "Read(%d): base=\"%s\", filter=\"%s\".\n", - innerloop, sbase, filter ); + config->loops, sbase, filter ); thread_verbose( idx, thrstr ); ptr = strchr(filter, '['); @@ -735,7 +601,7 @@ do_random2( LDAP *ld, flen = ptr - filter; ftail++; - for ( i = 0; i < innerloop; i++ ) { + for ( i = 0; i < config->loops; i++ ) { int r = ((double)range)*rand()/(RAND_MAX + 1.0); sprintf(fbuf, "%.*s%d%s", flen, filter, r, ftail); @@ -780,21 +646,21 @@ do_random2( LDAP *ld, static void do_read( LDAP *ld, char *entry, char **attrs, int noattrs, int nobind, int maxloop, - int maxretries, int delay, int force, int chaserefs, int idx ) + int force, int idx ) { - int i = 0, do_retry = maxretries; + int i = 0, do_retry = config->retries; int rc = LDAP_SUCCESS; char thrstr[BUFSIZ]; retry:; - if ( do_retry == maxretries ) { + if ( do_retry == config->retries ) { snprintf( thrstr, BUFSIZ, "Read(%d): entry=\"%s\".\n", maxloop, entry ); thread_verbose( idx, thrstr ); } snprintf(thrstr, BUFSIZ, "LD %p cnt: %d (retried %d) (%s)", \ - (void *) ld, maxloop, (do_retry - maxretries), entry); + (void *) ld, maxloop, (do_retry - config->retries), entry); thread_verbose( idx, thrstr ); for ( ; i < maxloop; i++ ) { diff --git a/tests/progs/slapd-read.c b/tests/progs/slapd-read.c index bab8766b92..4df5d1ce69 100644 --- a/tests/progs/slapd-read.c +++ b/tests/progs/slapd-read.c @@ -41,35 +41,28 @@ #define RETRIES 0 static void -do_read( char *uri, char *manager, struct berval *passwd, - char *entry, LDAP **ld, - char **attrs, int noattrs, int nobind, int maxloop, - int maxretries, int delay, int force, int chaserefs ); +do_read( struct tester_conn_args *config, char *entry, LDAP **ld, + char **attrs, int noattrs, int nobind, int maxloop, int force ); static void -do_random( char *uri, char *manager, struct berval *passwd, - char *sbase, char *filter, char **attrs, int noattrs, int nobind, - int innerloop, int maxretries, int delay, int force, int chaserefs ); +do_random( struct tester_conn_args *config, char *sbase, + char *filter, char **attrs, int noattrs, int nobind, int force ); static void -usage( char *name ) +usage( char *name, int opt ) { - fprintf( stderr, - "usage: %s " - "-H | ([-h ] -p ) " - "-D " - "-w " + if ( opt ) { + fprintf( stderr, "%s: unable to handle option \'%c\'\n\n", + name, opt ); + } + + fprintf( stderr, "usage: %s " TESTER_COMMON_HELP "-e " "[-A] " - "[-C] " "[-F] " "[-N] " + "[-S[S[S]]] " "[-f filter] " - "[-i ] " - "[-l ] " - "[-L ] " - "[-r ] " - "[-t ] " "[-T ] " "[] " "\n", @@ -87,69 +80,28 @@ int main( int argc, char **argv ) { int i; - char *uri = NULL; - char *host = "localhost"; - int port = -1; - char *manager = NULL; - struct berval passwd = { 0, NULL }; char *entry = NULL; char *filter = NULL; - int loops = LOOPS; - int outerloops = 1; - int retries = RETRIES; - int delay = 0; int force = 0; - int chaserefs = 0; char *srchattrs[] = { "1.1", NULL }; char **attrs = srchattrs; int noattrs = 0; int nobind = 0; + struct tester_conn_args *config; - tester_init( "slapd-read", TESTER_READ ); + config = tester_init( "slapd-read", TESTER_READ ); /* by default, tolerate referrals and no such object */ tester_ignore_str2errlist( "REFERRAL,NO_SUCH_OBJECT" ); - while ( (i = getopt( argc, argv, "ACD:e:Ff:H:h:i:L:l:p:r:St:T:w:" )) != EOF ) { + while ( (i = getopt( argc, argv, TESTER_COMMON_OPTS "Ae:Ff:NST:" )) != EOF ) { switch ( i ) { case 'A': noattrs++; break; - case 'C': - chaserefs++; - break; - - case 'H': /* the server uri */ - uri = strdup( optarg ); - break; - - case 'h': /* the servers host */ - host = strdup( optarg ); - break; - - case 'i': - tester_ignore_str2errlist( optarg ); - break; - case 'N': - nobind++; - break; - - case 'p': /* the servers port */ - if ( lutil_atoi( &port, optarg ) != 0 ) { - usage( argv[0] ); - } - break; - - case 'D': /* the servers manager */ - manager = strdup( optarg ); - break; - - case 'w': /* the server managers password */ - passwd.bv_val = strdup( optarg ); - passwd.bv_len = strlen( optarg ); - memset( optarg, '*', passwd.bv_len ); + nobind = TESTER_INIT_ONLY; break; case 'e': /* DN to search for */ @@ -164,49 +116,28 @@ main( int argc, char **argv ) force++; break; - case 'l': /* the number of loops */ - if ( lutil_atoi( &loops, optarg ) != 0 ) { - usage( argv[0] ); - } - break; - - case 'L': /* the number of outerloops */ - if ( lutil_atoi( &outerloops, optarg ) != 0 ) { - usage( argv[0] ); - } - break; - - case 'r': /* the number of retries */ - if ( lutil_atoi( &retries, optarg ) != 0 ) { - usage( argv[0] ); - } - break; - case 'S': swamp++; break; - case 't': /* delay in seconds */ - if ( lutil_atoi( &delay, optarg ) != 0 ) { - usage( argv[0] ); - } - break; - case 'T': attrs = ldap_str2charray( optarg, "," ); if ( attrs == NULL ) { - usage( argv[0] ); + usage( argv[0], i ); } break; default: - usage( argv[0] ); + if ( tester_config_opt( config, i, optarg ) == LDAP_SUCCESS ) { + break; + } + usage( argv[0], i ); break; } } - if (( entry == NULL ) || ( port == -1 && uri == NULL )) - usage( argv[0] ); + if ( entry == NULL ) + usage( argv[0], 0 ); if ( *entry == '\0' ) { fprintf( stderr, "%s: invalid EMPTY entry DN.\n", @@ -218,18 +149,16 @@ main( int argc, char **argv ) attrs = &argv[optind]; } - uri = tester_uri( uri, host, port ); + tester_config_finish( config ); - for ( i = 0; i < outerloops; i++ ) { + for ( i = 0; i < config->outerloops; i++ ) { if ( filter != NULL ) { - do_random( uri, manager, &passwd, entry, filter, attrs, - noattrs, nobind, loops, retries, delay, force, - chaserefs ); + do_random( config, entry, filter, attrs, + noattrs, nobind, force ); } else { - do_read( uri, manager, &passwd, entry, NULL, attrs, - noattrs, nobind, loops, retries, delay, force, - chaserefs ); + do_read( config, entry, NULL, attrs, + noattrs, nobind, config->loops, force ); } } @@ -237,15 +166,13 @@ main( int argc, char **argv ) } static void -do_random( char *uri, char *manager, struct berval *passwd, - char *sbase, char *filter, char **srchattrs, int noattrs, int nobind, - int innerloop, int maxretries, int delay, int force, int chaserefs ) +do_random( struct tester_conn_args *config, char *sbase, char *filter, + char **srchattrs, int noattrs, int nobind, int force ) { LDAP *ld = NULL; - int i = 0, do_retry = maxretries; + int i = 0, do_retry = config->retries; char *attrs[ 2 ]; int rc = LDAP_SUCCESS; - int version = LDAP_VERSION3; int nvalues = 0; char **values = NULL; LDAPMessage *res = NULL, *e = NULL; @@ -253,34 +180,11 @@ do_random( char *uri, char *manager, struct berval *passwd, attrs[ 0 ] = LDAP_NO_ATTRS; attrs[ 1 ] = NULL; - ldap_initialize( &ld, uri ); - if ( ld == NULL ) { - tester_perror( "ldap_initialize", NULL ); - exit( EXIT_FAILURE ); - } - - (void) ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version ); - (void) ldap_set_option( ld, LDAP_OPT_REFERRALS, - chaserefs ? LDAP_OPT_ON : LDAP_OPT_OFF ); + tester_init_ld( &ld, config, nobind ); - if ( do_retry == maxretries ) { + if ( do_retry == config->retries ) { fprintf( stderr, "PID=%ld - Read(%d): base=\"%s\", filter=\"%s\".\n", - (long) pid, innerloop, sbase, filter ); - } - - if ( nobind == 0 ) { - rc = ldap_sasl_bind_s( ld, manager, LDAP_SASL_SIMPLE, passwd, NULL, NULL, NULL ); - if ( rc != LDAP_SUCCESS ) { - tester_ldap_error( ld, "ldap_sasl_bind_s", NULL ); - switch ( rc ) { - case LDAP_BUSY: - case LDAP_UNAVAILABLE: - /* fallthru */ - default: - break; - } - exit( EXIT_FAILURE ); - } + (long) pid, config->loops, sbase, filter ); } rc = ldap_search_ext_s( ld, sbase, LDAP_SCOPE_SUBTREE, @@ -306,20 +210,19 @@ do_random( char *uri, char *manager, struct berval *passwd, ldap_msgfree( res ); - if ( do_retry == maxretries ) { + if ( do_retry == config->retries ) { fprintf( stderr, " PID=%ld - Read base=\"%s\" filter=\"%s\" got %d values.\n", (long) pid, sbase, filter, nvalues ); } - for ( i = 0; i < innerloop; i++ ) { + for ( i = 0; i < config->loops; i++ ) { #if 0 /* use high-order bits for better randomness (Numerical Recipes in "C") */ int r = rand() % nvalues; #endif int r = ((double)nvalues)*rand()/(RAND_MAX + 1.0); - do_read( uri, manager, passwd, values[ r ], &ld, - srchattrs, noattrs, nobind, 1, maxretries, - delay, force, chaserefs ); + do_read( config, values[ r ], &ld, + srchattrs, noattrs, nobind, 1, force ); } free( values ); break; @@ -337,14 +240,12 @@ do_random( char *uri, char *manager, struct berval *passwd, } static void -do_read( char *uri, char *manager, struct berval *passwd, char *entry, - LDAP **ldp, char **attrs, int noattrs, int nobind, int maxloop, - int maxretries, int delay, int force, int chaserefs ) +do_read( struct tester_conn_args *config, char *entry, LDAP **ldp, + char **attrs, int noattrs, int nobind, int maxloop, int force ) { LDAP *ld = ldp ? *ldp : NULL; - int i = 0, do_retry = maxretries; + int i = 0, do_retry = config->retries; int rc = LDAP_SUCCESS; - int version = LDAP_VERSION3; int *msgids = NULL, active = 0; /* make room for msgid */ @@ -354,44 +255,12 @@ do_read( char *uri, char *manager, struct berval *passwd, char *entry, retry:; if ( ld == NULL ) { - ldap_initialize( &ld, uri ); - if ( ld == NULL ) { - tester_perror( "ldap_initialize", NULL ); - exit( EXIT_FAILURE ); - } - - (void) ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version ); - (void) ldap_set_option( ld, LDAP_OPT_REFERRALS, - chaserefs ? LDAP_OPT_ON : LDAP_OPT_OFF ); - - if ( do_retry == maxretries ) { - fprintf( stderr, "PID=%ld - Read(%d): entry=\"%s\".\n", - (long) pid, maxloop, entry ); - } + tester_init_ld( &ld, config, nobind ); + } - if ( nobind == 0 ) { - rc = ldap_sasl_bind_s( ld, manager, LDAP_SASL_SIMPLE, passwd, NULL, NULL, NULL ); - if ( rc != LDAP_SUCCESS ) { - tester_ldap_error( ld, "ldap_sasl_bind_s", NULL ); - switch ( rc ) { - case LDAP_BUSY: - case LDAP_UNAVAILABLE: - if ( do_retry > 0 ) { - ldap_unbind_ext( ld, NULL, NULL ); - ld = NULL; - do_retry--; - if ( delay != 0 ) { - sleep( delay ); - } - goto retry; - } - /* fallthru */ - default: - break; - } - exit( EXIT_FAILURE ); - } - } + if ( do_retry == config->retries ) { + fprintf( stderr, "PID=%ld - Read(%d): entry=\"%s\".\n", + (long) pid, maxloop, entry ); } if ( swamp > 1 ) { diff --git a/tests/progs/slapd-search.c b/tests/progs/slapd-search.c index c9cb532c83..c8505f05c8 100644 --- a/tests/progs/slapd-search.c +++ b/tests/progs/slapd-search.c @@ -40,46 +40,35 @@ #define RETRIES 0 static void -do_search( char *uri, char *manager, struct berval *passwd, +do_search( struct tester_conn_args *config, char *sbase, int scope, char *filter, LDAP **ldp, char **attrs, int noattrs, int nobind, - int innerloop, int maxretries, int delay, int force, int chaserefs ); + int innerloop, int force ); static void -do_random( char *uri, char *manager, struct berval *passwd, +do_random( struct tester_conn_args *config, char *sbase, int scope, char *filter, char *attr, - char **attrs, int noattrs, int nobind, - int innerloop, int maxretries, int delay, int force, int chaserefs ); + char **attrs, int noattrs, int nobind, int force ); static void -usage( char *name, char o ) +usage( char *name, char opt ) { - if ( o != '\0' ) { - fprintf( stderr, "unknown/incorrect option \"%c\"\n", o ); + if ( opt != '\0' ) { + fprintf( stderr, "unknown/incorrect option \"%c\"\n", opt ); } - fprintf( stderr, - "usage: %s " - "-H | ([-h ] -p ) " - "-D " - "-w " + fprintf( stderr, "usage: %s " TESTER_COMMON_HELP "-b " "-s " "-f " "[-a ] " "[-A] " - "[-C] " "[-F] " "[-N] " "[-S[S[S]]] " - "[-i ] " - "[-l ] " - "[-L ] " - "[-r ] " - "[-t ] " "[] " "\n", - name ); + name ); exit( EXIT_FAILURE ); } @@ -93,72 +82,31 @@ int main( int argc, char **argv ) { int i; - char *uri = NULL; - char *host = "localhost"; - int port = -1; - char *manager = NULL; - struct berval passwd = { 0, NULL }; char *sbase = NULL; int scope = LDAP_SCOPE_SUBTREE; char *filter = NULL; char *attr = NULL; char *srchattrs[] = { "cn", "sn", NULL }; char **attrs = srchattrs; - int loops = LOOPS; - int outerloops = 1; - int retries = RETRIES; - int delay = 0; int force = 0; - int chaserefs = 0; int noattrs = 0; int nobind = 0; + struct tester_conn_args *config; - tester_init( "slapd-search", TESTER_SEARCH ); + config = tester_init( "slapd-search", TESTER_SEARCH ); /* by default, tolerate referrals and no such object */ tester_ignore_str2errlist( "REFERRAL,NO_SUCH_OBJECT" ); - while ( ( i = getopt( argc, argv, "Aa:b:CD:f:FH:h:i:l:L:Np:r:Ss:t:T:w:" ) ) != EOF ) + while ( ( i = getopt( argc, argv, TESTER_COMMON_OPTS "Aa:b:f:FNSs:T:" ) ) != EOF ) { switch ( i ) { case 'A': noattrs++; break; - case 'C': - chaserefs++; - break; - - case 'H': /* the server uri */ - uri = strdup( optarg ); - break; - - case 'h': /* the servers host */ - host = strdup( optarg ); - break; - - case 'i': - tester_ignore_str2errlist( optarg ); - break; - case 'N': - nobind++; - break; - - case 'p': /* the servers port */ - if ( lutil_atoi( &port, optarg ) != 0 ) { - usage( argv[0], i ); - } - break; - - case 'D': /* the servers manager */ - manager = strdup( optarg ); - break; - - case 'w': /* the server managers password */ - passwd.bv_val = strdup( optarg ); - passwd.bv_len = strlen( optarg ); - memset( optarg, '*', passwd.bv_len ); + nobind = TESTER_INIT_ONLY; break; case 'a': @@ -177,30 +125,6 @@ main( int argc, char **argv ) force++; break; - case 'l': /* number of loops */ - if ( lutil_atoi( &loops, optarg ) != 0 ) { - usage( argv[0], i ); - } - break; - - case 'L': /* number of loops */ - if ( lutil_atoi( &outerloops, optarg ) != 0 ) { - usage( argv[0], i ); - } - break; - - case 'r': /* number of retries */ - if ( lutil_atoi( &retries, optarg ) != 0 ) { - usage( argv[0], i ); - } - break; - - case 't': /* delay in seconds */ - if ( lutil_atoi( &delay, optarg ) != 0 ) { - usage( argv[0], i ); - } - break; - case 'T': attrs = ldap_str2charray( optarg, "," ); if ( attrs == NULL ) { @@ -220,13 +144,16 @@ main( int argc, char **argv ) break; default: + if ( tester_config_opt( config, i, optarg ) == LDAP_SUCCESS ) { + break; + } usage( argv[0], i ); break; } } - if (( sbase == NULL ) || ( filter == NULL ) || ( port == -1 && uri == NULL )) - usage( argv[0], '\0' ); + if (( sbase == NULL ) || ( filter == NULL )) + usage( argv[0], 0 ); if ( *filter == '\0' ) { @@ -240,20 +167,18 @@ main( int argc, char **argv ) attrs = &argv[optind]; } - uri = tester_uri( uri, host, port ); + tester_config_finish( config ); - for ( i = 0; i < outerloops; i++ ) { + for ( i = 0; i < config->outerloops; i++ ) { if ( attr != NULL ) { - do_random( uri, manager, &passwd, + do_random( config, sbase, scope, filter, attr, - attrs, noattrs, nobind, - loops, retries, delay, force, chaserefs ); + attrs, noattrs, nobind, force ); } else { - do_search( uri, manager, &passwd, - sbase, scope, filter, NULL, - attrs, noattrs, nobind, - loops, retries, delay, force, chaserefs ); + do_search( config, sbase, scope, filter, + NULL, attrs, noattrs, config->loops, + nobind, force ); } } @@ -262,16 +187,14 @@ main( int argc, char **argv ) static void -do_random( char *uri, char *manager, struct berval *passwd, +do_random( struct tester_conn_args *config, char *sbase, int scope, char *filter, char *attr, - char **srchattrs, int noattrs, int nobind, - int innerloop, int maxretries, int delay, int force, int chaserefs ) + char **srchattrs, int noattrs, int nobind, int force ) { LDAP *ld = NULL; - int i = 0, do_retry = maxretries; + int i = 0, do_retry = config->retries; char *attrs[ 2 ]; int rc = LDAP_SUCCESS; - int version = LDAP_VERSION3; int nvalues = 0; char **values = NULL; LDAPMessage *res = NULL, *e = NULL; @@ -279,35 +202,7 @@ do_random( char *uri, char *manager, struct berval *passwd, attrs[ 0 ] = attr; attrs[ 1 ] = NULL; - ldap_initialize( &ld, uri ); - if ( ld == NULL ) { - tester_perror( "ldap_initialize", NULL ); - exit( EXIT_FAILURE ); - } - - (void) ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version ); - (void) ldap_set_option( ld, LDAP_OPT_REFERRALS, - chaserefs ? LDAP_OPT_ON : LDAP_OPT_OFF ); - - if ( do_retry == maxretries ) { - fprintf( stderr, "PID=%ld - Search(%d): base=\"%s\", filter=\"%s\" attr=\"%s\".\n", - (long) pid, innerloop, sbase, filter, attr ); - } - - if ( nobind == 0 ) { - rc = ldap_sasl_bind_s( ld, manager, LDAP_SASL_SIMPLE, passwd, NULL, NULL, NULL ); - if ( rc != LDAP_SUCCESS ) { - tester_ldap_error( ld, "ldap_sasl_bind_s", NULL ); - switch ( rc ) { - case LDAP_BUSY: - case LDAP_UNAVAILABLE: - /* fallthru */ - default: - break; - } - exit( EXIT_FAILURE ); - } - } + tester_init_ld( &ld, config, nobind ); rc = ldap_search_ext_s( ld, sbase, LDAP_SCOPE_SUBTREE, filter, attrs, 0, NULL, NULL, NULL, LDAP_NO_LIMIT, &res ); @@ -348,12 +243,12 @@ do_random( char *uri, char *manager, struct berval *passwd, exit(EXIT_FAILURE); } - if ( do_retry == maxretries ) { + if ( do_retry == config->retries ) { fprintf( stderr, " PID=%ld - Search base=\"%s\" filter=\"%s\" got %d values.\n", (long) pid, sbase, filter, nvalues ); } - for ( i = 0; i < innerloop; i++ ) { + for ( i = 0; i < config->loops; i++ ) { char buf[ BUFSIZ ]; #if 0 /* use high-order bits for better randomness (Numerical Recipes in "C") */ int r = rand() % nvalues; @@ -362,10 +257,10 @@ do_random( char *uri, char *manager, struct berval *passwd, snprintf( buf, sizeof( buf ), "(%s=%s)", attr, values[ r ] ); - do_search( uri, manager, passwd, + do_search( config, sbase, scope, buf, &ld, srchattrs, noattrs, nobind, - 1, maxretries, delay, force, chaserefs ); + 1, force ); } break; @@ -376,21 +271,27 @@ do_random( char *uri, char *manager, struct berval *passwd, fprintf( stderr, " PID=%ld - Search done (%d).\n", (long) pid, rc ); + if ( values ) { + for ( i = 0; i < nvalues; i++ ) { + free( values[i] ); + } + free( values ); + } + if ( ld != NULL ) { ldap_unbind_ext( ld, NULL, NULL ); } } static void -do_search( char *uri, char *manager, struct berval *passwd, +do_search( struct tester_conn_args *config, char *sbase, int scope, char *filter, LDAP **ldp, char **attrs, int noattrs, int nobind, - int innerloop, int maxretries, int delay, int force, int chaserefs ) + int innerloop, int force ) { LDAP *ld = ldp ? *ldp : NULL; - int i = 0, do_retry = maxretries; + int i = 0, do_retry = config->retries; int rc = LDAP_SUCCESS; - int version = LDAP_VERSION3; char buf[ BUFSIZ ]; int *msgids = NULL, active = 0; @@ -401,51 +302,15 @@ do_search( char *uri, char *manager, struct berval *passwd, retry:; if ( ld == NULL ) { - ldap_initialize( &ld, uri ); - if ( ld == NULL ) { - tester_perror( "ldap_initialize", NULL ); - exit( EXIT_FAILURE ); - } - - (void) ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version ); - (void) ldap_set_option( ld, LDAP_OPT_REFERRALS, - chaserefs ? LDAP_OPT_ON : LDAP_OPT_OFF ); - - if ( do_retry == maxretries ) { - fprintf( stderr, - "PID=%ld - Search(%d): " - "base=\"%s\" scope=%s filter=\"%s\" " - "attrs=%s%s.\n", - (long) pid, innerloop, - sbase, ldap_pvt_scope2str( scope ), filter, - attrs[0], attrs[1] ? " (more...)" : "" ); - } - - if ( nobind == 0 ) { - rc = ldap_sasl_bind_s( ld, manager, LDAP_SASL_SIMPLE, passwd, NULL, NULL, NULL ); - if ( rc != LDAP_SUCCESS ) { - snprintf( buf, sizeof( buf ), - "bindDN=\"%s\"", manager ); - tester_ldap_error( ld, "ldap_sasl_bind_s", buf ); - switch ( rc ) { - case LDAP_BUSY: - case LDAP_UNAVAILABLE: - if ( do_retry > 0 ) { - ldap_unbind_ext( ld, NULL, NULL ); - ld = NULL; - do_retry--; - if ( delay != 0 ) { - sleep( delay ); - } - goto retry; - } - /* fallthru */ - default: - break; - } - exit( EXIT_FAILURE ); - } - } + fprintf( stderr, + "PID=%ld - Search(%d): " + "base=\"%s\" scope=%s filter=\"%s\" " + "attrs=%s%s.\n", + (long) pid, innerloop, + sbase, ldap_pvt_scope2str( scope ), filter, + attrs[0], attrs[1] ? " (more...)" : "" ); + + tester_init_ld( &ld, config, nobind ); } if ( swamp > 1 ) { -- 2.39.5