"-D <manager> "
"-w <passwd> "
"-f <addfile> "
+ "[-i <ignore>] "
"[-l <loops>] "
"[-L <outerloops>] "
"[-r <maxretries>] "
int chaserefs = 0;
LDAPMod **attrs = NULL;
- tester_init( "slapd-modify" );
+ tester_init( "slapd-addel", TESTER_ADDEL );
while ( (i = getopt( argc, argv, "CFH:h:p:D:w:f:l:L:r:t:" )) != EOF ) {
switch( i ) {
host = strdup( optarg );
break;
+ case 'i':
+ /* ignored (!) by now */
+ break;
+
case 'p': /* the servers port */
if ( lutil_atoi( &port, optarg ) != 0 ) {
usage( argv[0] );
"[-F] "
"[-C] "
"[-I] "
+ "[-i <ignore>] "
"[-t delay]\n",
name );
exit( EXIT_FAILURE );
int noinit = 0;
int delay = 0;
- tester_init( "slapd-bind" );
+ tester_init( "slapd-bind", TESTER_BIND );
- while ( (i = getopt( argc, argv, "a:b:H:h:p:D:w:l:L:f:FIt:" )) != EOF ) {
+ /* by default, tolerate invalid credentials */
+ tester_ignore_str2errlist( "INVALID_CREDENTIALS" );
+
+ while ( (i = getopt( argc, argv, "a:b:H:h:i:p:D:w:l:L:f:FIt:" )) != EOF ) {
switch( i ) {
case 'a':
pwattr = optarg;
host = optarg;
break;
+ case 'i':
+ tester_ignore_str2errlist( optarg );
+ break;
+
case 'p': /* the servers port */
if ( lutil_atoi( &port, optarg ) != 0 ) {
usage( argv[0] );
int force, int chaserefs, int noinit, LDAP **ldp )
{
LDAP *ld = ldp ? *ldp : NULL;
- int i, first = 1, rc = -1;
+ int i, rc = -1;
pid_t pid = getpid();
if ( maxloop > 1 )
}
rc = ldap_sasl_bind_s( ld, dn, LDAP_SASL_SIMPLE, pass, NULL, NULL, NULL );
- switch ( rc ) {
- case LDAP_SUCCESS:
- break;
-
- case LDAP_INVALID_CREDENTIALS:
- /* don't log: it's intended */
- if ( force >= 2 ) {
- if ( !first ) {
- break;
+ if ( rc ) {
+ unsigned first = tester_ignore_err( rc );
+
+ /* if ignore.. */
+ if ( first ) {
+ /* only log if first occurrence */
+ if ( force < 2 || first == 1 ) {
+ tester_ldap_error( ld, "ldap_sasl_bind_s", NULL );
}
- first = 0;
- }
- /* fallthru */
+ rc = LDAP_SUCCESS;
- default:
- tester_ldap_error( ld, "ldap_sasl_bind_s", NULL );
+ } else {
+ tester_ldap_error( ld, "ldap_sasl_bind_s", NULL );
+ }
}
-
+
if ( !noinit ) {
ldap_unbind_ext( ld, NULL, NULL );
ld = NULL;
}
- if ( rc != LDAP_SUCCESS && !force ) {
+
+ if ( rc != LDAP_SUCCESS ) {
break;
}
}
#include <ldap.h>
+#include "ldap_pvt.h"
+#include "slapd-common.h"
+
static char progname[ BUFSIZ ];
+tester_t progtype;
+
+#define TESTER_SERVER_LAST (LDAP_OTHER + 1)
+#define TESTER_CLIENT_LAST (- LDAP_REFERRAL_LIMIT_EXCEEDED + 1)
+static unsigned ignore_server[ TESTER_SERVER_LAST ];
+static unsigned ignore_client[ TESTER_CLIENT_LAST ];
+
+static struct {
+ char *name;
+ int err;
+} ignore_str2err[] = {
+ { "OPERATIONS_ERROR", LDAP_OPERATIONS_ERROR },
+ { "PROTOCOL_ERROR", LDAP_PROTOCOL_ERROR },
+ { "TIMELIMIT_EXCEEDED", LDAP_TIMELIMIT_EXCEEDED },
+ { "SIZELIMIT_EXCEEDED", LDAP_SIZELIMIT_EXCEEDED },
+ { "COMPARE_FALSE", LDAP_COMPARE_FALSE },
+ { "COMPARE_TRUE", LDAP_COMPARE_TRUE },
+ { "AUTH_METHOD_NOT_SUPPORTED", LDAP_AUTH_METHOD_NOT_SUPPORTED },
+ { "STRONG_AUTH_NOT_SUPPORTED", LDAP_STRONG_AUTH_NOT_SUPPORTED },
+ { "STRONG_AUTH_REQUIRED", LDAP_STRONG_AUTH_REQUIRED },
+ { "STRONGER_AUTH_REQUIRED", LDAP_STRONGER_AUTH_REQUIRED },
+ { "PARTIAL_RESULTS", LDAP_PARTIAL_RESULTS },
+
+ { "REFERRAL", LDAP_REFERRAL },
+ { "ADMINLIMIT_EXCEEDED", LDAP_ADMINLIMIT_EXCEEDED },
+ { "UNAVAILABLE_CRITICAL_EXTENSION", LDAP_UNAVAILABLE_CRITICAL_EXTENSION },
+ { "CONFIDENTIALITY_REQUIRED", LDAP_CONFIDENTIALITY_REQUIRED },
+ { "SASL_BIND_IN_PROGRESS", LDAP_SASL_BIND_IN_PROGRESS },
+
+ { "NO_SUCH_ATTRIBUTE", LDAP_NO_SUCH_ATTRIBUTE },
+ { "UNDEFINED_TYPE", LDAP_UNDEFINED_TYPE },
+ { "INAPPROPRIATE_MATCHING", LDAP_INAPPROPRIATE_MATCHING },
+ { "CONSTRAINT_VIOLATION", LDAP_CONSTRAINT_VIOLATION },
+ { "TYPE_OR_VALUE_EXISTS", LDAP_TYPE_OR_VALUE_EXISTS },
+ { "INVALID_SYNTAX", LDAP_INVALID_SYNTAX },
+
+ { "NO_SUCH_OBJECT", LDAP_NO_SUCH_OBJECT },
+ { "ALIAS_PROBLEM", LDAP_ALIAS_PROBLEM },
+ { "INVALID_DN_SYNTAX", LDAP_INVALID_DN_SYNTAX },
+ { "IS_LEAF", LDAP_IS_LEAF },
+ { "ALIAS_DEREF_PROBLEM", LDAP_ALIAS_DEREF_PROBLEM },
+
+ { "PROXY_AUTHZ_FAILURE", LDAP_PROXY_AUTHZ_FAILURE },
+ { "INAPPROPRIATE_AUTH", LDAP_INAPPROPRIATE_AUTH },
+ { "INVALID_CREDENTIALS", LDAP_INVALID_CREDENTIALS },
+ { "INSUFFICIENT_ACCESS", LDAP_INSUFFICIENT_ACCESS },
+
+ { "BUSY", LDAP_BUSY },
+ { "UNAVAILABLE", LDAP_UNAVAILABLE },
+ { "UNWILLING_TO_PERFORM", LDAP_UNWILLING_TO_PERFORM },
+ { "LOOP_DETECT", LDAP_LOOP_DETECT },
+
+ { "NAMING_VIOLATION", LDAP_NAMING_VIOLATION },
+ { "OBJECT_CLASS_VIOLATION", LDAP_OBJECT_CLASS_VIOLATION },
+ { "NOT_ALLOWED_ON_NONLEAF", LDAP_NOT_ALLOWED_ON_NONLEAF },
+ { "NOT_ALLOWED_ON_RDN", LDAP_NOT_ALLOWED_ON_RDN },
+ { "ALREADY_EXISTS", LDAP_ALREADY_EXISTS },
+ { "NO_OBJECT_CLASS_MODS", LDAP_NO_OBJECT_CLASS_MODS },
+ { "RESULTS_TOO_LARGE", LDAP_RESULTS_TOO_LARGE },
+ { "AFFECTS_MULTIPLE_DSAS", LDAP_AFFECTS_MULTIPLE_DSAS },
+
+ { "OTHER", LDAP_OTHER },
+
+ { "SERVER_DOWN", LDAP_SERVER_DOWN },
+ { "LOCAL_ERROR", LDAP_LOCAL_ERROR },
+ { "ENCODING_ERROR", LDAP_ENCODING_ERROR },
+ { "DECODING_ERROR", LDAP_DECODING_ERROR },
+ { "TIMEOUT", LDAP_TIMEOUT },
+ { "AUTH_UNKNOWN", LDAP_AUTH_UNKNOWN },
+ { "FILTER_ERROR", LDAP_FILTER_ERROR },
+ { "USER_CANCELLED", LDAP_USER_CANCELLED },
+ { "PARAM_ERROR", LDAP_PARAM_ERROR },
+ { "NO_MEMORY", LDAP_NO_MEMORY },
+ { "CONNECT_ERROR", LDAP_CONNECT_ERROR },
+ { "NOT_SUPPORTED", LDAP_NOT_SUPPORTED },
+ { "CONTROL_NOT_FOUND", LDAP_CONTROL_NOT_FOUND },
+ { "NO_RESULTS_RETURNED", LDAP_NO_RESULTS_RETURNED },
+ { "MORE_RESULTS_TO_RETURN", LDAP_MORE_RESULTS_TO_RETURN },
+ { "CLIENT_LOOP", LDAP_CLIENT_LOOP },
+ { "REFERRAL_LIMIT_EXCEEDED", LDAP_REFERRAL_LIMIT_EXCEEDED },
+
+ { NULL }
+};
+
+#define UNKNOWN_ERR (1234567890)
+
+static int
+tester_ignore_str2err( const char *err )
+{
+ int i;
+ unsigned ignore = 1;
+
+ if ( strcmp( err, "ALL" ) == 0 ) {
+ for ( i = 0; ignore_str2err[ i ].name != NULL; i++ ) {
+ int err = ignore_str2err[ i ].err;
+
+ if ( err > 0 ) {
+ ignore_server[ err ] = 1;
+
+ } else if ( err < 0 ) {
+ ignore_client[ -err ] = 1;
+ }
+ }
+
+ return 0;
+ }
+
+ if ( err[ 0 ] == '!' ) {
+ ignore = 0;
+ err++;
+ }
+
+ for ( i = 0; ignore_str2err[ i ].name != NULL; i++ ) {
+ if ( strcmp( err, ignore_str2err[ i ].name ) == 0 ) {
+ int err = ignore_str2err[ i ].err;
+
+ if ( err > 0 ) {
+ ignore_server[ err ] = ignore;
+
+ } else if ( err < 0 ) {
+ ignore_client[ -err ] = ignore;
+ }
+
+ return err;
+ }
+ }
+
+ return UNKNOWN_ERR;
+}
+
+int
+tester_ignore_str2errlist( const char *err )
+{
+ int i;
+ char **errs = ldap_str2charray( err, "," );
+
+ for ( i = 0; errs[ i ] != NULL; i++ ) {
+ /* TODO: allow <err>:<prog> to ignore <err> only when <prog> */
+ (void)tester_ignore_str2err( errs[ i ] );
+ }
+
+ ldap_charray_free( errs );
+
+ return 0;
+}
+
+unsigned
+tester_ignore_err( int err )
+{
+ unsigned rc = 1;
+
+ if ( err > 0 ) {
+ if ( err < TESTER_SERVER_LAST ) {
+ rc = ignore_server[ err ];
+ if ( rc ) {
+ ignore_server[ err ]++;
+ }
+ }
+
+ } else if ( err < 0 ) {
+ if ( -err < TESTER_CLIENT_LAST ) {
+ rc = ignore_client[ -err ];
+ if ( rc ) {
+ ignore_client[ -err ]++;
+ }
+ }
+ }
+
+ /* SUCCESS is always "ignored" */
+ return rc;
+}
void
-tester_init( const char *pname )
+tester_init( const char *pname, tester_t ptype )
{
snprintf( progname, sizeof( progname ), "%s PID=%d", pname, getpid() );
+ progtype = ptype;
}
char *
#ifndef SLAPD_COMMON_H
#define SLAPD_COMMON_H
-extern void tester_init( const char *pname );
+typedef enum {
+ TESTER_TESTER,
+ TESTER_ADDEL,
+ TESTER_BIND,
+ TESTER_MODIFY,
+ TESTER_MODRDN,
+ TESTER_READ,
+ TESTER_SEARCH
+} tester_t;
+
+extern void 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 );
extern void tester_ldap_error( LDAP *ld, const char *fname, const char *msg );
+extern int tester_ignore_str2errlist( const char *err );
+extern unsigned tester_ignore_err( int err );
#endif /* SLAPD_COMMON_H */
"-D <manager> "
"-w <passwd> "
"-e <entry> "
+ "[-i <ignore>] "
"[-l <loops>] "
"[-L <outerloops>] "
"[-r <maxretries>] "
int friendly = 0;
int chaserefs = 0;
- tester_init( "slapd-modify" );
+ tester_init( "slapd-modify", TESTER_MODIFY );
- while ( (i = getopt( argc, argv, "CFH:h:p:D:w:e:a:l:L:r:t:" )) != EOF ) {
+ while ( (i = getopt( argc, argv, "CFH:h:i:p:D:w:e:a:l:L:r:t:" )) != EOF ) {
switch ( i ) {
case 'C':
chaserefs++;
host = strdup( optarg );
break;
+ case 'i':
+ /* ignored (!) by now */
+ break;
+
case 'p': /* the servers port */
if ( lutil_atoi( &port, optarg ) != 0 ) {
usage( argv[0] );
"-D <manager> "
"-w <passwd> "
"-e <entry> "
+ "[-i <ignore>] "
"[-l <loops>] "
"[-L <outerloops>] "
"[-r <maxretries>] "
int friendly = 0;
int chaserefs = 0;
- tester_init( "slapd-modrdn" );
+ tester_init( "slapd-modrdn", TESTER_MODRDN );
- while ( (i = getopt( argc, argv, "CFH:h:p:D:w:e:l:L:r:t:" )) != EOF ) {
+ while ( (i = getopt( argc, argv, "CFH:h:i:p:D:w:e:l:L:r:t:" )) != EOF ) {
switch( i ) {
case 'C':
chaserefs++;
host = strdup( optarg );
break;
+ case 'i':
+ /* ignored (!) by now */
+ break;
+
case 'p': /* the servers port */
if ( lutil_atoi( &port, optarg ) != 0 ) {
usage( argv[0] );
"[-C] "
"[-F] "
"[-f filter] "
+ "[-i <ignore>] "
"[-l <loops>] "
"[-L <outerloops>] "
"[-r <maxretries>] "
int chaserefs = 0;
int noattrs = 0;
- tester_init( "slapd-read" );
+ tester_init( "slapd-read", TESTER_READ );
- while ( (i = getopt( argc, argv, "ACD:H:h:p:e:Ff:l:L:r:t:w:" )) != EOF ) {
+ /* by default, tolerate referrals and no such object */
+ tester_ignore_str2errlist( "REFERRAL,NO_SUCH_OBJECT" );
+
+ while ( (i = getopt( argc, argv, "ACD:H:h:i:p:e:Ff:l:L:r:t:w:" )) != EOF ) {
switch( i ) {
case 'A':
noattrs++;
host = strdup( optarg );
break;
+ case 'i':
+ tester_ignore_str2errlist( optarg );
+ break;
+
case 'p': /* the servers port */
if ( lutil_atoi( &port, optarg ) != 0 ) {
usage( argv[0] );
pid_t pid = getpid();
int rc = LDAP_SUCCESS;
int version = LDAP_VERSION3;
- int first = 1;
retry:;
if ( ld == NULL ) {
rc = ldap_search_ext_s( ld, entry, LDAP_SCOPE_BASE,
NULL, attrs, noattrs, NULL, NULL, NULL,
LDAP_NO_LIMIT, &res );
- switch ( rc ) {
- case LDAP_REFERRAL:
- /* don't log: it's intended */
- if ( force >= 2 ) {
- if ( !first ) {
- break;
+ if ( res != NULL ) {
+ ldap_msgfree( res );
+ }
+
+ if ( rc ) {
+ unsigned first = tester_ignore_err( rc );
+ /* if ignore.. */
+ if ( first ) {
+ /* only log if first occurrence */
+ if ( force < 2 || first == 1 ) {
+ tester_ldap_error( ld, "ldap_search_ext_s", NULL );
}
- first = 0;
+ continue;
}
- tester_ldap_error( ld, "ldap_search_ext_s", NULL );
- /* fallthru */
-
- case LDAP_SUCCESS:
- break;
- default:
+ /* busy needs special handling */
tester_ldap_error( ld, "ldap_search_ext_s", NULL );
if ( rc == LDAP_BUSY && do_retry > 0 ) {
+ ldap_unbind_ext( ld, NULL, NULL );
+ ld = NULL;
do_retry--;
goto retry;
}
- if ( rc != LDAP_NO_SUCH_OBJECT ) {
- goto done;
- }
break;
}
-
- if ( res != NULL ) {
- ldap_msgfree( res );
- }
}
-done:;
if ( ldp != NULL ) {
*ldp = ld;
"[-A] "
"[-C] "
"[-F] "
+ "[-i <ignore>] "
"[-l <loops>] "
"[-L <outerloops>] "
"[-r <maxretries>] "
int chaserefs = 0;
int noattrs = 0;
- tester_init( "slapd-search" );
+ tester_init( "slapd-search", TESTER_SEARCH );
- while ( (i = getopt( argc, argv, "Aa:b:CD:f:FH:h:l:L:p:w:r:t:" )) != EOF ) {
+ /* 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:p:w:r:t:" )) != EOF ) {
switch( i ) {
case 'A':
noattrs++;
host = strdup( optarg );
break;
+ case 'i':
+ tester_ignore_str2errlist( optarg );
+ break;
+
case 'p': /* the servers port */
if ( lutil_atoi( &port, optarg ) != 0 ) {
usage( argv[0] );
pid_t pid = getpid();
int rc = LDAP_SUCCESS;
int version = LDAP_VERSION3;
- int first = 1;
char buf[ BUFSIZ ];
ldap_msgfree( res );
}
- switch ( rc ) {
- case LDAP_REFERRAL:
- /* don't log: it's intended */
- if ( force >= 2 ) {
- if ( !first ) {
- break;
+ if ( rc ) {
+ unsigned first = tester_ignore_err( rc );
+ /* if ignore.. */
+ if ( first ) {
+ /* only log if first occurrence */
+ if ( force < 2 || first == 1 ) {
+ tester_ldap_error( ld, "ldap_search_ext_s", NULL );
}
- first = 0;
+ continue;
}
- tester_ldap_error( ld, "ldap_search_ext_s", NULL );
- /* fallthru */
- case LDAP_SUCCESS:
- break;
-
- default:
+ /* busy needs special handling */
snprintf( buf, sizeof( buf ),
"base=\"%s\" filter=\"%s\"\n",
sbase, filter );
tester_ldap_error( ld, "ldap_search_ext_s", buf );
if ( rc == LDAP_BUSY && do_retry > 0 ) {
ldap_unbind_ext( ld, NULL, NULL );
+ ld = NULL;
do_retry--;
goto retry;
}
- if ( rc != LDAP_NO_SUCH_OBJECT ) {
- goto done;
- }
break;
}
}
-done:;
if ( ldp != NULL ) {
*ldp = ld;
"-D <manager> "
"-w <passwd> "
"-d <datadir> "
+ "[-i <ignore>] "
"[-j <maxchild>] "
"[-l <loops>] "
"[-L <outerloops>] "
int friendly = 0;
int chaserefs = 0;
int noattrs = 0;
+ char *ignore = NULL;
/* search */
char *sfile = NULL;
char *sreqs[MAXREQS];
char *friendlyOpt = NULL;
- tester_init( "slapd-tester" );
+ tester_init( "slapd-tester", TESTER_TESTER );
- while ( (i = getopt( argc, argv, "ACD:d:FH:h:j:l:L:P:p:r:t:w:" )) != EOF ) {
+ while ( (i = getopt( argc, argv, "ACD:d:FH:h:i:j:l:L:P:p:r:t:w:" )) != EOF ) {
switch( i ) {
case 'A':
noattrs++;
host = strdup( optarg );
break;
+ case 'i':
+ ignore = optarg;
+ break;
+
case 'j': /* the number of parallel clients */
if ( lutil_atoi( &maxkids, optarg ) != 0 ) {
usage( argv[0] );
if ( noattrs ) {
sargs[sanum++] = "-A";
}
+ if ( ignore ) {
+ sargs[sanum++] = "-i";
+ sargs[sanum++] = ignore;
+ }
sargs[sanum++] = "-b";
sargs[sanum++] = NULL; /* will hold the search base */
sargs[sanum++] = "-f";
if ( noattrs ) {
rargs[ranum++] = "-A";
}
+ if ( ignore ) {
+ rargs[ranum++] = "-i";
+ rargs[ranum++] = ignore;
+ }
rargs[ranum++] = "-e";
rargs[ranum++] = NULL; /* will hold the read entry */
if ( chaserefs ) {
margs[manum++] = "-C";
}
+ if ( ignore ) {
+ margs[manum++] = "-i";
+ margs[manum++] = ignore;
+ }
margs[manum++] = "-e";
margs[manum++] = NULL; /* will hold the modrdn entry */
margs[manum++] = NULL;
if ( chaserefs ) {
modargs[modanum++] = "-C";
}
+ if ( ignore ) {
+ modargs[modanum++] = "-i";
+ modargs[modanum++] = ignore;
+ }
modargs[modanum++] = "-e";
modargs[modanum++] = NULL; /* will hold the modify entry */
modargs[modanum++] = "-a";;
if ( chaserefs ) {
aargs[aanum++] = "-C";
}
+ if ( ignore ) {
+ aargs[aanum++] = "-i";
+ aargs[aanum++] = ignore;
+ }
aargs[aanum++] = "-f";
aargs[aanum++] = NULL; /* will hold the add data file */
aargs[aanum++] = NULL;
if ( chaserefs ) {
bargs[banum++] = "-C";
}
+ if ( ignore ) {
+ bargs[banum++] = "-i";
+ bargs[banum++] = ignore;
+ }
bargs[banum++] = "-D";
bargs[banum++] = NULL;
bargs[banum++] = "-w";
bargs[banum - 1] = "-a";
bargs[banum] = battrs[jj];
}
+
fork_child( bcmd, bargs );
bargs[banum - 5] = "-D";
}