From 5f475b80ee038085449647164069e8e70d37cf5d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 4 May 2007 12:41:28 +0000 Subject: r22670: changed the RAW-NOTIFY test to support clustered testing (two nodes) (This used to be commit 12ce85aea16379b9946851806c1782272ee1c48f) --- source4/torture/raw/notify.c | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/source4/torture/raw/notify.c b/source4/torture/raw/notify.c index e59c97c263..c75dbf0931 100644 --- a/source4/torture/raw/notify.c +++ b/source4/torture/raw/notify.c @@ -55,7 +55,8 @@ /* basic testing of change notify on directories */ -static BOOL test_notify_dir(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static BOOL test_notify_dir(struct smbcli_state *cli, struct smbcli_state *cli2, + TALLOC_CTX *mem_ctx) { BOOL ret = True; NTSTATUS status; @@ -110,7 +111,7 @@ static BOOL test_notify_dir(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) printf("testing notify mkdir\n"); req = smb_raw_changenotify_send(cli->tree, ¬ify); - smbcli_mkdir(cli->tree, BASEDIR "\\subdir-name"); + smbcli_mkdir(cli2->tree, BASEDIR "\\subdir-name"); status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify); CHECK_STATUS(status, NT_STATUS_OK); @@ -122,7 +123,7 @@ static BOOL test_notify_dir(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) printf("testing notify rmdir\n"); req = smb_raw_changenotify_send(cli->tree, ¬ify); - smbcli_rmdir(cli->tree, BASEDIR "\\subdir-name"); + smbcli_rmdir(cli2->tree, BASEDIR "\\subdir-name"); status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify); CHECK_STATUS(status, NT_STATUS_OK); @@ -132,10 +133,10 @@ static BOOL test_notify_dir(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) printf("testing notify mkdir - rmdir - mkdir - rmdir\n"); - smbcli_mkdir(cli->tree, BASEDIR "\\subdir-name"); - smbcli_rmdir(cli->tree, BASEDIR "\\subdir-name"); - smbcli_mkdir(cli->tree, BASEDIR "\\subdir-name"); - smbcli_rmdir(cli->tree, BASEDIR "\\subdir-name"); + smbcli_mkdir(cli2->tree, BASEDIR "\\subdir-name"); + smbcli_rmdir(cli2->tree, BASEDIR "\\subdir-name"); + smbcli_mkdir(cli2->tree, BASEDIR "\\subdir-name"); + smbcli_rmdir(cli2->tree, BASEDIR "\\subdir-name"); req = smb_raw_changenotify_send(cli->tree, ¬ify); status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify); CHECK_STATUS(status, NT_STATUS_OK); @@ -174,11 +175,14 @@ static BOOL test_notify_dir(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) notify.nttrans.in.file.fnum = fnum; req = smb_raw_changenotify_send(cli->tree, ¬ify); + status = smbcli_unlink(cli->tree, BASEDIR "\\nonexistant.txt"); + CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); + /* (1st unlink) as the 2nd notify directly returns, this unlink is only seen by the 1st notify and the 3rd notify (later) */ printf("testing notify on unlink for the first file\n"); - status = smbcli_unlink(cli->tree, BASEDIR "\\test0.txt"); + status = smbcli_unlink(cli2->tree, BASEDIR "\\test0.txt"); CHECK_STATUS(status, NT_STATUS_OK); /* receive the reply from the 2nd notify */ @@ -186,24 +190,27 @@ static BOOL test_notify_dir(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) CHECK_STATUS(status, NT_STATUS_OK); CHECK_VAL(notify.nttrans.out.num_changes, count); - for (i=1;itree, ¬ify); + status = smbcli_unlink(cli->tree, BASEDIR "\\nonexistant.txt"); + CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); + printf("testing notify on wildcard unlink for %d files\n", count-1); /* (2nd unlink) do a wildcard unlink */ - status = smbcli_unlink(cli->tree, BASEDIR "\\test*.txt"); + status = smbcli_unlink(cli2->tree, BASEDIR "\\test*.txt"); CHECK_STATUS(status, NT_STATUS_OK); /* receive the 3rd notify */ @@ -1149,13 +1156,16 @@ done: */ BOOL torture_raw_notify(struct torture_context *torture) { - struct smbcli_state *cli; + struct smbcli_state *cli, *cli2; BOOL ret = True; TALLOC_CTX *mem_ctx; if (!torture_open_connection(&cli, 0)) { return False; } + if (!torture_open_connection(&cli2, 0)) { + return False; + } mem_ctx = talloc_init("torture_raw_notify"); @@ -1163,7 +1173,7 @@ BOOL torture_raw_notify(struct torture_context *torture) return False; } - ret &= test_notify_dir(cli, mem_ctx); + ret &= test_notify_dir(cli, cli2, mem_ctx); ret &= test_notify_mask(cli, mem_ctx); ret &= test_notify_recursive(cli, mem_ctx); ret &= test_notify_file(cli, mem_ctx); @@ -1177,6 +1187,7 @@ BOOL torture_raw_notify(struct torture_context *torture) smb_raw_exit(cli->session); smbcli_deltree(cli->tree, BASEDIR); torture_close_connection(cli); + torture_close_connection(cli2); talloc_free(mem_ctx); return ret; } -- cgit