From cfa9178822575a2c234d9b75d44ec437f32b3af7 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Fri, 3 Mar 2006 16:02:34 +0000 Subject: [PATCH] split operations in inner/outer loops --- tests/progs/slapd-addel.c | 16 ++++++++--- tests/progs/slapd-bind.c | 33 ++++++++++++++++++----- tests/progs/slapd-modify.c | 17 +++++++++--- tests/progs/slapd-modrdn.c | 17 +++++++++--- tests/progs/slapd-read.c | 17 +++++++++--- tests/progs/slapd-search.c | 26 +++++++++++++----- tests/progs/slapd-tester.c | 54 +++++++++++++++++++++++++++++++------- 7 files changed, 144 insertions(+), 36 deletions(-) diff --git a/tests/progs/slapd-addel.c b/tests/progs/slapd-addel.c index dc94d83a05..5c437634ff 100644 --- a/tests/progs/slapd-addel.c +++ b/tests/progs/slapd-addel.c @@ -56,6 +56,7 @@ usage( char *name ) "-w " "-f " "[-l ] " + "[-L ] " "[-r ] " "[-t ] " "[-F]\n", @@ -75,6 +76,7 @@ main( int argc, char **argv ) char *filename = NULL; char *entry = NULL; int loops = LOOPS; + int outerloops = 1; int retries = RETRIES; int delay = 0; int friendly = 0; @@ -82,7 +84,7 @@ main( int argc, char **argv ) tester_init( "slapd-modify" ); - while ( (i = getopt( argc, argv, "FH:h:p:D:w:f:l:r:t:" )) != EOF ) { + while ( (i = getopt( argc, argv, "FH:h:p:D:w:f:l:L:r:t:" )) != EOF ) { switch( i ) { case 'F': friendly++; @@ -121,6 +123,12 @@ main( int argc, char **argv ) } 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] ); @@ -162,8 +170,10 @@ main( int argc, char **argv ) uri = tester_uri( uri, host, port ); - do_addel( uri, manager, &passwd, entry, attrs, - loops, retries, delay, friendly ); + for ( i = 0; i < outerloops; i++ ) { + do_addel( uri, manager, &passwd, entry, attrs, + loops, retries, delay, friendly ); + } exit( EXIT_SUCCESS ); } diff --git a/tests/progs/slapd-bind.c b/tests/progs/slapd-bind.c index 45ebd51dda..c538e4ff7a 100644 --- a/tests/progs/slapd-bind.c +++ b/tests/progs/slapd-bind.c @@ -55,8 +55,17 @@ do_base( char *uri, struct berval *base, struct berval *pass, int maxloop, int f static void usage( char *name ) { - fprintf( stderr, "usage: %s [-h ] -p port (-D |-b [-f ]) -w [-l ] [-F] [-I] [-t delay]\n", - name ); + fprintf( stderr, "usage: %s " + "[-h ] " + "-p port " + "(-D |-b [-f ]) " + "-w " + "[-l ] " + "[-L ] " + "[-F] " + "[-I] " + "[-t delay]\n", + name ); exit( EXIT_FAILURE ); } @@ -73,13 +82,14 @@ main( int argc, char **argv ) struct berval pass = { 0, NULL }; int port = -1; int loops = LOOPS; + int outerloops = 1; int force = 0; int noinit = 0; int delay = 0; tester_init( "slapd-bind" ); - while ( (i = getopt( argc, argv, "b:H:h:p:D:w:l:f:FIt:" )) != EOF ) { + while ( (i = getopt( argc, argv, "b:H:h:p:D:w:l:L:f:FIt:" )) != EOF ) { switch( i ) { case 'b': /* base DN of a tree of user DNs */ ber_str2bv( optarg, 0, 0, &base ); @@ -114,6 +124,12 @@ main( int argc, char **argv ) } break; + case 'L': /* the number of outerloops */ + if ( lutil_atoi( &outerloops, optarg ) != 0 ) { + usage( argv[0] ); + } + break; + case 'f': filter = optarg; break; @@ -146,11 +162,14 @@ main( int argc, char **argv ) uri = tester_uri( uri, host, port ); - if ( base.bv_val != NULL ) { - do_base( uri, &base, &pass, ( 20 * loops ), force, noinit, delay ); - } else { - do_bind( uri, dn, &pass, ( 20 * loops ), force, noinit, NULL ); + for ( i = 0; i < outerloops; i++ ) { + if ( base.bv_val != NULL ) { + do_base( uri, &base, &pass, loops, force, noinit, delay ); + } else { + do_bind( uri, dn, &pass, loops, force, noinit, NULL ); + } } + exit( EXIT_SUCCESS ); } diff --git a/tests/progs/slapd-modify.c b/tests/progs/slapd-modify.c index 510571c914..4be8a5d97d 100644 --- a/tests/progs/slapd-modify.c +++ b/tests/progs/slapd-modify.c @@ -50,6 +50,7 @@ usage( char *name ) "-w " "-e " "[-l ] " + "[-L ] " "[-r ] " "[-t ] " "[-F]\n", @@ -70,13 +71,14 @@ main( int argc, char **argv ) char *ava = NULL; char *value = NULL; int loops = LOOPS; + int outerloops = 1; int retries = RETRIES; int delay = 0; int friendly = 0; tester_init( "slapd-modify" ); - while ( (i = getopt( argc, argv, "FH:h:p:D:w:e:a:l:r:t:" )) != EOF ) { + while ( (i = getopt( argc, argv, "FH:h:p:D:w:e:a:l:L:r:t:" )) != EOF ) { switch( i ) { case 'F': friendly++; @@ -119,6 +121,12 @@ main( int argc, char **argv ) } 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] ); @@ -164,8 +172,11 @@ main( int argc, char **argv ) uri = tester_uri( uri, host, port ); - do_modify( uri, manager, &passwd, entry, ava, value, - loops, retries, delay, friendly ); + for ( i = 0; i < outerloops; i++ ) { + do_modify( uri, manager, &passwd, entry, ava, value, + loops, retries, delay, friendly ); + } + exit( EXIT_SUCCESS ); } diff --git a/tests/progs/slapd-modrdn.c b/tests/progs/slapd-modrdn.c index 8695e172a4..b28ae28484 100644 --- a/tests/progs/slapd-modrdn.c +++ b/tests/progs/slapd-modrdn.c @@ -53,6 +53,7 @@ usage( char *name ) "-w " "-e " "[-l ] " + "[-L ] " "[-r ] " "[-t ] " "[-F]\n", @@ -71,13 +72,14 @@ main( int argc, char **argv ) struct berval passwd = { 0, NULL }; char *entry = NULL; int loops = LOOPS; + int outerloops = 1; int retries = RETRIES; int delay = 0; int friendly = 0; tester_init( "slapd-modrdn" ); - while ( (i = getopt( argc, argv, "FH:h:p:D:w:e:l:r:t:" )) != EOF ) { + while ( (i = getopt( argc, argv, "FH:h:p:D:w:e:l:L:r:t:" )) != EOF ) { switch( i ) { case 'F': friendly++; @@ -116,6 +118,12 @@ main( int argc, char **argv ) } 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] ); @@ -147,8 +155,11 @@ main( int argc, char **argv ) uri = tester_uri( uri, host, port ); - do_modrdn( uri, manager, &passwd, entry, - loops, retries, delay, friendly ); + for ( i = 0; i < outerloops; i++ ) { + do_modrdn( uri, manager, &passwd, entry, + loops, retries, delay, friendly ); + } + exit( EXIT_SUCCESS ); } diff --git a/tests/progs/slapd-read.c b/tests/progs/slapd-read.c index 6d5858d4e5..493b4b74b2 100644 --- a/tests/progs/slapd-read.c +++ b/tests/progs/slapd-read.c @@ -50,9 +50,10 @@ usage( char *name ) "-H | ([-h ] -p ) " "-e " "[-l ] " + "[-L ] " "[-r ] " "[-t ]\n", - name ); + name ); exit( EXIT_FAILURE ); } @@ -65,12 +66,13 @@ main( int argc, char **argv ) int port = -1; char *entry = NULL; int loops = LOOPS; + int outerloops = 1; int retries = RETRIES; int delay = 0; tester_init( "slapd-read" ); - while ( (i = getopt( argc, argv, "H:h:p:e:l:r:t:" )) != EOF ) { + while ( (i = getopt( argc, argv, "H:h:p:e:l:L:r:t:" )) != EOF ) { switch( i ) { case 'H': /* the server uri */ uri = strdup( optarg ); @@ -96,6 +98,12 @@ main( int argc, char **argv ) } 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] ); @@ -125,7 +133,10 @@ main( int argc, char **argv ) uri = tester_uri( uri, host, port ); - do_read( uri, entry, ( 20 * loops ), retries, delay ); + for ( i = 0; i < outerloops; i++ ) { + do_read( uri, entry, loops, retries, delay ); + } + exit( EXIT_SUCCESS ); } diff --git a/tests/progs/slapd-search.c b/tests/progs/slapd-search.c index 9d66783ef4..80a6c3f1d2 100644 --- a/tests/progs/slapd-search.c +++ b/tests/progs/slapd-search.c @@ -40,7 +40,8 @@ static void do_search( char *uri, char *manager, struct berval *passwd, - char *sbase, char *filter, int maxloop, int maxretries, int delay ); + char *sbase, char *filter, int innerloop, + int maxretries, int delay ); static void usage( char *name ) @@ -53,6 +54,7 @@ usage( char *name ) "-b " "-f " "[-l ] " + "[-L ] " "[-r ] " "[-t ]\n", name ); @@ -71,12 +73,13 @@ main( int argc, char **argv ) char *sbase = NULL; char *filter = NULL; int loops = LOOPS; + int outerloops = 1; int retries = RETRIES; int delay = 0; tester_init( "slapd-search" ); - while ( (i = getopt( argc, argv, "b:D:f:H:h:l:p:w:r:t:" )) != EOF ) { + while ( (i = getopt( argc, argv, "b:D:f:H:h:l:L:p:w:r:t:" )) != EOF ) { switch( i ) { case 'H': /* the server uri */ uri = strdup( optarg ); @@ -115,6 +118,12 @@ main( int argc, char **argv ) } break; + case 'L': /* number of loops */ + if ( lutil_atoi( &outerloops, optarg ) != 0 ) { + usage( argv[0] ); + } + break; + case 'r': /* number of retries */ if ( lutil_atoi( &retries, optarg ) != 0 ) { usage( argv[0] ); @@ -146,15 +155,18 @@ main( int argc, char **argv ) uri = tester_uri( uri, host, port ); - do_search( uri, manager, &passwd, sbase, filter, - ( 10 * loops ), retries, delay ); + for ( i = 0; i < outerloops; i++ ) { + do_search( uri, manager, &passwd, sbase, filter, + loops, retries, delay ); + } + exit( EXIT_SUCCESS ); } static void do_search( char *uri, char *manager, struct berval *passwd, - char *sbase, char *filter, int maxloop, int maxretries, int delay ) + char *sbase, char *filter, int innerloop, int maxretries, int delay ) { LDAP *ld = NULL; int i = 0, do_retry = maxretries; @@ -174,7 +186,7 @@ retry:; if ( do_retry == maxretries ) { fprintf( stderr, "PID=%ld - Search(%d): base=\"%s\", filter=\"%s\".\n", - (long) pid, maxloop, sbase, filter ); + (long) pid, innerloop, sbase, filter ); } rc = ldap_sasl_bind_s( ld, manager, LDAP_SASL_SIMPLE, passwd, NULL, NULL, NULL ); @@ -198,7 +210,7 @@ retry:; exit( EXIT_FAILURE ); } - for ( ; i < maxloop; i++ ) { + for ( ; i < innerloop; i++ ) { LDAPMessage *res; rc = ldap_search_ext_s( ld, sbase, LDAP_SCOPE_SUBTREE, diff --git a/tests/progs/slapd-tester.c b/tests/progs/slapd-tester.c index 19c18bf0b3..8b818da555 100644 --- a/tests/progs/slapd-tester.c +++ b/tests/progs/slapd-tester.c @@ -46,7 +46,8 @@ #define BINDCMD "slapd-bind" #define MAXARGS 100 #define MAXREQS 5000 -#define LOOPS "100" +#define LOOPS 100 +#define OUTERLOOPS "1" #define RETRIES "0" #define TSEARCHFILE "do_search.0" @@ -84,6 +85,7 @@ usage( char *name ) "-d " "[-j ] " "[-l ] " + "[-L ] " "-P " "[-r ] " "[-t ] " @@ -103,7 +105,8 @@ main( int argc, char **argv ) char *passwd = NULL; char *dirname = NULL; char *progdir = NULL; - char *loops = LOOPS; + int loops = LOOPS; + char *outerloops = OUTERLOOPS; char *retries = RETRIES; char *delay = "0"; DIR *datadir; @@ -117,6 +120,7 @@ main( int argc, char **argv ) char *sargs[MAXARGS]; int sanum; char scmd[MAXPATHLEN]; + char sloops[] = "18446744073709551615UL"; /* read */ char *rfile = NULL; char *rreqs[MAXREQS]; @@ -124,12 +128,14 @@ main( int argc, char **argv ) char *rargs[MAXARGS]; int ranum; char rcmd[MAXPATHLEN]; + char rloops[] = "18446744073709551615UL"; /* addel */ char *afiles[MAXREQS]; int anum = 0; char *aargs[MAXARGS]; int aanum; char acmd[MAXPATHLEN]; + char aloops[] = "18446744073709551615UL"; /* modrdn */ char *mfile = NULL; char *mreqs[MAXREQS]; @@ -137,6 +143,7 @@ main( int argc, char **argv ) char *margs[MAXARGS]; int manum; char mcmd[MAXPATHLEN]; + char mloops[] = "18446744073709551615UL"; /* modify */ char *modfile = NULL; char *modreqs[MAXREQS]; @@ -145,6 +152,7 @@ main( int argc, char **argv ) char *modargs[MAXARGS]; int modanum; char modcmd[MAXPATHLEN]; + char modloops[] = "18446744073709551615UL"; /* bind */ char *bfile = NULL; char *breqs[MAXREQS]; @@ -153,12 +161,13 @@ main( int argc, char **argv ) char *bargs[MAXARGS]; int banum; char bcmd[MAXPATHLEN]; + char bloops[] = "18446744073709551615UL"; char *friendlyOpt = NULL; tester_init( "slapd-tester" ); - while ( (i = getopt( argc, argv, "D:d:FH:h:j:l:P:p:r:t:w:" )) != EOF ) { + while ( (i = getopt( argc, argv, "D:d:FH:h:j:l:L:P:p:r:t:w:" )) != EOF ) { switch( i ) { case 'D': /* slapd manager */ manager = ArgDup( optarg ); @@ -187,7 +196,13 @@ main( int argc, char **argv ) break; case 'l': /* the number of loops per client */ - loops = strdup( optarg ); + if ( lutil_atoi( &loops, optarg ) != 0 ) { + usage( argv[0] ); + } + break; + + case 'L': /* the number of outerloops per client */ + outerloops = strdup( optarg ); break; case 'P': /* prog directory */ @@ -301,6 +316,13 @@ main( int argc, char **argv ) break; } + snprintf( sloops, sizeof( sloops ), "%d", 10 * loops ); + snprintf( rloops, sizeof( rloops ), "%d", 20 * loops ); + snprintf( aloops, sizeof( aloops ), "%d", loops ); + snprintf( mloops, sizeof( mloops ), "%d", loops ); + snprintf( modloops, sizeof( modloops ), "%d", loops ); + snprintf( bloops, sizeof( bloops ), "%d", 20 * loops ); + /* * generate the search clients */ @@ -323,7 +345,9 @@ main( int argc, char **argv ) sargs[sanum++] = "-w"; sargs[sanum++] = passwd; sargs[sanum++] = "-l"; - sargs[sanum++] = loops; + sargs[sanum++] = sloops; + sargs[sanum++] = "-L"; + sargs[sanum++] = outerloops; sargs[sanum++] = "-r"; sargs[sanum++] = retries; sargs[sanum++] = "-t"; @@ -352,7 +376,9 @@ main( int argc, char **argv ) rargs[ranum++] = port; } rargs[ranum++] = "-l"; - rargs[ranum++] = loops; + rargs[ranum++] = rloops; + rargs[ranum++] = "-L"; + rargs[ranum++] = outerloops; rargs[ranum++] = "-r"; rargs[ranum++] = retries; rargs[ranum++] = "-t"; @@ -383,7 +409,9 @@ main( int argc, char **argv ) margs[manum++] = "-w"; margs[manum++] = passwd; margs[manum++] = "-l"; - margs[manum++] = loops; + margs[manum++] = mloops; + margs[manum++] = "-L"; + margs[manum++] = outerloops; margs[manum++] = "-r"; margs[manum++] = retries; margs[manum++] = "-t"; @@ -417,7 +445,9 @@ main( int argc, char **argv ) modargs[modanum++] = "-w"; modargs[modanum++] = passwd; modargs[modanum++] = "-l"; - modargs[modanum++] = loops; + modargs[modanum++] = modloops; + modargs[modanum++] = "-L"; + modargs[modanum++] = outerloops; modargs[modanum++] = "-r"; modargs[modanum++] = retries; modargs[modanum++] = "-t"; @@ -453,7 +483,9 @@ main( int argc, char **argv ) aargs[aanum++] = "-w"; aargs[aanum++] = passwd; aargs[aanum++] = "-l"; - aargs[aanum++] = loops; + aargs[aanum++] = aloops; + aargs[aanum++] = "-L"; + aargs[aanum++] = outerloops; aargs[aanum++] = "-r"; aargs[aanum++] = retries; aargs[aanum++] = "-t"; @@ -483,7 +515,9 @@ main( int argc, char **argv ) bargs[banum++] = port; } bargs[banum++] = "-l"; - bargs[banum++] = loops; + bargs[banum++] = bloops; + bargs[banum++] = "-L"; + bargs[banum++] = outerloops; #if 0 bargs[banum++] = "-r"; bargs[banum++] = retries; -- 2.39.5