From e450ba6639accd00b112e1ce9089ef4b487d8b1c Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 10 Mar 2002 23:17:47 +0000 Subject: [PATCH] added -E and -Z options, and allow for the 2 servers to have different usernames/passwords (This used to be commit 0ae4ba18e578d35206628fa29203c8becbbdc5cd) --- source3/torture/locktest.c | 96 +++++++++++++++++++++++++------------- 1 file changed, 63 insertions(+), 33 deletions(-) diff --git a/source3/torture/locktest.c b/source3/torture/locktest.c index 47be83e97fe..08a9e742695 100644 --- a/source3/torture/locktest.c +++ b/source3/torture/locktest.c @@ -22,8 +22,8 @@ #include "includes.h" -static fstring password; -static fstring username; +static fstring password[2]; +static fstring username[2]; static int got_pass; static BOOL use_kerberos; static int numops = 1000; @@ -34,11 +34,11 @@ static BOOL use_oplocks; static unsigned lock_range = 100; static unsigned lock_base = 0; static unsigned min_length = 0; +static BOOL exact_error_codes; +static BOOL zero_zero; #define FILENAME "\\locktest.dat" -#define ZERO_ZERO 0 - #define READ_PCT 50 #define LOCK_PCT 45 #define UNLOCK_PCT 70 @@ -136,7 +136,7 @@ static void show_locks(void) /***************************************************** return a connection to a server *******************************************************/ -struct cli_state *connect_one(char *share) +struct cli_state *connect_one(char *share, int snum) { struct cli_state *c; struct nmb_name called, calling; @@ -193,13 +193,19 @@ struct cli_state *connect_one(char *share) if (!got_pass) { char *pass = getpass("Password: "); if (pass) { - pstrcpy(password, pass); + pstrcpy(password[0], pass); + pstrcpy(password[1], pass); } } - if (!cli_session_setup(c, username, - password, strlen(password), - password, strlen(password), + if (got_pass == 1) { + pstrcpy(password[1], password[0]); + pstrcpy(username[1], username[0]); + } + + if (!cli_session_setup(c, username[snum], + password[snum], strlen(password[snum]), + password[snum], strlen(password[snum]), lp_workgroup())) { DEBUG(0,("session setup failed: %s\n", cli_errstr(c))); return NULL; @@ -220,7 +226,7 @@ struct cli_state *connect_one(char *share) DEBUG(4,(" session setup ok\n")); if (!cli_send_tconX(c, share, "?????", - password, strlen(password)+1)) { + password[snum], strlen(password[snum])+1)) { DEBUG(0,("tree connect failed: %s\n", cli_errstr(c))); cli_shutdown(c); return NULL; @@ -243,12 +249,15 @@ static void reconnect(struct cli_state *cli[NSERVERS][NCONNECTIONS], int fnum[NS for (conn=0;connlock_type; int server; BOOL ret[NSERVERS]; + NTSTATUS status[NSERVERS]; switch (rec->lock_op) { case OP_LOCK: @@ -277,16 +287,22 @@ static BOOL test_one(struct cli_state *cli[NSERVERS][NCONNECTIONS], ret[server] = cli_lock64(cli[server][conn], fnum[server][conn][f], start, len, LOCK_TIMEOUT, op); + status[server] = cli_nt_error(cli[server][conn]); + if (!exact_error_codes && + NT_STATUS_EQUAL(status[server], + NT_STATUS_FILE_LOCK_CONFLICT)) { + status[server] = NT_STATUS_LOCK_NOT_GRANTED; + } } - if (showall || ret[0] != ret[1]) { - printf("lock conn=%u f=%u range=%.0f(%.0f) op=%s -> %u:%u\n", + if (showall || !NT_STATUS_EQUAL(status[0],status[1])) { + printf("lock conn=%u f=%u range=%.0f(%.0f) op=%s -> %s:%s\n", conn, f, (double)start, (double)len, op==READ_LOCK?"READ_LOCK":"WRITE_LOCK", - ret[0], ret[1]); + get_nt_error_msg(status[0]), get_nt_error_msg(status[1])); } - if (showall || ret[0] != ret[1]) show_locks(); - if (ret[0] != ret[1]) return False; + if (showall || !NT_STATUS_EQUAL(status[0],status[1])) show_locks(); + if (!NT_STATUS_EQUAL(status[0],status[1])) return False; break; case OP_UNLOCK: @@ -295,21 +311,25 @@ static BOOL test_one(struct cli_state *cli[NSERVERS][NCONNECTIONS], ret[server] = cli_unlock64(cli[server][conn], fnum[server][conn][f], start, len); + status[server] = cli_nt_error(cli[server][conn]); } - if (showall || (!hide_unlock_fails && (ret[0] != ret[1]))) { - printf("unlock conn=%u f=%u range=%.0f(%.0f) -> %u:%u\n", + if (showall || + (!hide_unlock_fails && !NT_STATUS_EQUAL(status[0],status[1]))) { + printf("unlock conn=%u f=%u range=%.0f(%.0f) -> %s:%s\n", conn, f, (double)start, (double)len, - ret[0], ret[1]); + get_nt_error_msg(status[0]), get_nt_error_msg(status[1])); } - if (showall || ret[0] != ret[1]) show_locks(); - if (!hide_unlock_fails && ret[0] != ret[1]) return False; + if (showall || !NT_STATUS_EQUAL(status[0],status[1])) show_locks(); + if (!hide_unlock_fails && !NT_STATUS_EQUAL(status[0],status[1])) + return False; break; case OP_REOPEN: /* reopen the file */ for (server=0;server