Author: metze Date: 2006-03-23 15:03:52 +0000 (Thu, 23 Mar 2006) New Revision: 14680
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=14680 Log: add some tests which demonstrate that closing the dir handle triggers an empty notify reply with NT_STATUS_OK metze Modified: branches/SAMBA_4_0/source/torture/raw/notify.c Changeset: Modified: branches/SAMBA_4_0/source/torture/raw/notify.c =================================================================== --- branches/SAMBA_4_0/source/torture/raw/notify.c 2006-03-23 14:55:59 UTC (rev 14679) +++ branches/SAMBA_4_0/source/torture/raw/notify.c 2006-03-23 15:03:52 UTC (rev 14680) @@ -61,6 +61,7 @@ NTSTATUS status; struct smb_notify notify; union smb_open io; + union smb_close cl; int i, count, fnum, fnum2; struct smbcli_request *req, *req2; extern int torture_numops; @@ -229,6 +230,21 @@ CHECK_VAL(notify.out.changes[i].action, NOTIFY_ACTION_REMOVED); } + printf("testing if a close() on the dir handle triggers the notify reply\n"); + + notify.in.file.fnum = fnum; + req = smb_raw_changenotify_send(cli->tree, ¬ify); + + cl.close.level = RAW_CLOSE_CLOSE; + cl.close.in.file.fnum = fnum; + cl.close.in.write_time = 0; + status = smb_raw_close(cli->tree, &cl); + CHECK_STATUS(status, NT_STATUS_OK); + + status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify); + CHECK_STATUS(status, NT_STATUS_OK); + CHECK_VAL(notify.out.num_changes, 0); + done: smb_raw_exit(cli->session); return ret; @@ -293,6 +309,186 @@ return ret; } +/* + basic testing of change notifies followed by a tdis +*/ +static BOOL test_notify_tdis(TALLOC_CTX *mem_ctx) +{ + BOOL ret = True; + NTSTATUS status; + struct smb_notify notify; + union smb_open io; + int fnum; + struct smbcli_request *req; + struct smbcli_state *cli = NULL; + + printf("TESTING CHANGE NOTIFY FOLLOWED BY TDIS\n"); + + if (!torture_open_connection(&cli)) { + return False; + } + + /* + get a handle on the directory + */ + io.generic.level = RAW_OPEN_NTCREATEX; + io.ntcreatex.in.root_fid = 0; + io.ntcreatex.in.flags = 0; + io.ntcreatex.in.access_mask = SEC_FILE_ALL; + io.ntcreatex.in.create_options = NTCREATEX_OPTIONS_DIRECTORY; + io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; + io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE; + io.ntcreatex.in.alloc_size = 0; + io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN; + io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; + io.ntcreatex.in.security_flags = 0; + io.ntcreatex.in.fname = BASEDIR; + + status = smb_raw_open(cli->tree, mem_ctx, &io); + CHECK_STATUS(status, NT_STATUS_OK); + fnum = io.ntcreatex.out.file.fnum; + + /* ask for a change notify, + on file or directory name changes */ + notify.in.buffer_size = 1000; + notify.in.completion_filter = FILE_NOTIFY_CHANGE_NAME; + notify.in.file.fnum = fnum; + notify.in.recursive = True; + + req = smb_raw_changenotify_send(cli->tree, ¬ify); + + status = smbcli_tdis(cli); + CHECK_STATUS(status, NT_STATUS_OK); + + status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify); + CHECK_STATUS(status, NT_STATUS_OK); + CHECK_VAL(notify.out.num_changes, 0); + +done: + torture_close_connection(cli); + return ret; +} + +/* + basic testing of change notifies followed by a exit +*/ +static BOOL test_notify_exit(TALLOC_CTX *mem_ctx) +{ + BOOL ret = True; + NTSTATUS status; + struct smb_notify notify; + union smb_open io; + int fnum; + struct smbcli_request *req; + struct smbcli_state *cli = NULL; + + printf("TESTING CHANGE NOTIFY FOLLOWED BY EXIT\n"); + + if (!torture_open_connection(&cli)) { + return False; + } + + /* + get a handle on the directory + */ + io.generic.level = RAW_OPEN_NTCREATEX; + io.ntcreatex.in.root_fid = 0; + io.ntcreatex.in.flags = 0; + io.ntcreatex.in.access_mask = SEC_FILE_ALL; + io.ntcreatex.in.create_options = NTCREATEX_OPTIONS_DIRECTORY; + io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; + io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE; + io.ntcreatex.in.alloc_size = 0; + io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN; + io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; + io.ntcreatex.in.security_flags = 0; + io.ntcreatex.in.fname = BASEDIR; + + status = smb_raw_open(cli->tree, mem_ctx, &io); + CHECK_STATUS(status, NT_STATUS_OK); + fnum = io.ntcreatex.out.file.fnum; + + /* ask for a change notify, + on file or directory name changes */ + notify.in.buffer_size = 1000; + notify.in.completion_filter = FILE_NOTIFY_CHANGE_NAME; + notify.in.file.fnum = fnum; + notify.in.recursive = True; + + req = smb_raw_changenotify_send(cli->tree, ¬ify); + + status = smb_raw_exit(cli->session); + CHECK_STATUS(status, NT_STATUS_OK); + + status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify); + CHECK_STATUS(status, NT_STATUS_OK); + CHECK_VAL(notify.out.num_changes, 0); + +done: + torture_close_connection(cli); + return ret; +} + +/* + basic testing of change notifies followed by a ulogoff +*/ +static BOOL test_notify_ulogoff(TALLOC_CTX *mem_ctx) +{ + BOOL ret = True; + NTSTATUS status; + struct smb_notify notify; + union smb_open io; + int fnum; + struct smbcli_request *req; + struct smbcli_state *cli = NULL; + + printf("TESTING CHANGE NOTIFY FOLLOWED BY ULOGOFF\n"); + + if (!torture_open_connection(&cli)) { + return False; + } + + /* + get a handle on the directory + */ + io.generic.level = RAW_OPEN_NTCREATEX; + io.ntcreatex.in.root_fid = 0; + io.ntcreatex.in.flags = 0; + io.ntcreatex.in.access_mask = SEC_FILE_ALL; + io.ntcreatex.in.create_options = NTCREATEX_OPTIONS_DIRECTORY; + io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; + io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE; + io.ntcreatex.in.alloc_size = 0; + io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN; + io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; + io.ntcreatex.in.security_flags = 0; + io.ntcreatex.in.fname = BASEDIR; + + status = smb_raw_open(cli->tree, mem_ctx, &io); + CHECK_STATUS(status, NT_STATUS_OK); + fnum = io.ntcreatex.out.file.fnum; + + /* ask for a change notify, + on file or directory name changes */ + notify.in.buffer_size = 1000; + notify.in.completion_filter = FILE_NOTIFY_CHANGE_NAME; + notify.in.file.fnum = fnum; + notify.in.recursive = True; + + req = smb_raw_changenotify_send(cli->tree, ¬ify); + + status = smb_raw_ulogoff(cli->session); + CHECK_STATUS(status, NT_STATUS_OK); + + status = smb_raw_changenotify_recv(req, mem_ctx, ¬ify); + CHECK_STATUS(status, NT_STATUS_OK); + CHECK_VAL(notify.out.num_changes, 0); + +done: + torture_close_connection(cli); + return ret; +} + /* basic testing of change notify */ @@ -314,6 +510,9 @@ ret &= test_notify_dir(cli, mem_ctx); ret &= test_notify_file(cli, mem_ctx); + ret &= test_notify_tdis(mem_ctx); + ret &= test_notify_exit(mem_ctx); + ret &= test_notify_ulogoff(mem_ctx); smb_raw_exit(cli->session); smbcli_deltree(cli->tree, BASEDIR);
