svn commit: samba r14942 - in branches/SAMBA_4_0/source/torture/raw: .

tridge at samba.org tridge at samba.org
Thu Apr 6 10:06:29 GMT 2006


Author: tridge
Date: 2006-04-06 10:06:28 +0000 (Thu, 06 Apr 2006)
New Revision: 14942

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=14942

Log:

make the RAW-NOTIFY test check the strange file rename semantics. Also
be more forgiving of matching on extra bits (inotify cannot match on
minimal bits for all events).

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-04-06 10:05:19 UTC (rev 14941)
+++ branches/SAMBA_4_0/source/torture/raw/notify.c	2006-04-06 10:06:28 UTC (rev 14942)
@@ -288,7 +288,7 @@
 	/* ask for a change notify, on file or directory name
 	   changes. Setup both with and without recursion */
 	notify.in.buffer_size = 1000;
-	notify.in.completion_filter = FILE_NOTIFY_CHANGE_NAME;
+	notify.in.completion_filter = FILE_NOTIFY_CHANGE_NAME | FILE_NOTIFY_CHANGE_ATTRIBUTES | FILE_NOTIFY_CHANGE_CREATION;
 	notify.in.file.fnum = fnum;
 
 	notify.in.recursive = True;
@@ -308,7 +308,8 @@
 
 	smbcli_mkdir(cli->tree, BASEDIR "\\subdir-name");
 	smbcli_mkdir(cli->tree, BASEDIR "\\subdir-name\\subname1");
-	smbcli_mkdir(cli->tree, BASEDIR "\\subdir-name\\subname2");
+	smbcli_close(cli->tree, 
+		     smbcli_open(cli->tree, BASEDIR "\\subdir-name\\subname2", O_CREAT, 0));
 	smbcli_rename(cli->tree, BASEDIR "\\subdir-name\\subname1", BASEDIR "\\subdir-name\\subname1-r");
 	smbcli_rename(cli->tree, BASEDIR "\\subdir-name\\subname2", BASEDIR "\\subname2-r");
 	smbcli_rename(cli->tree, BASEDIR "\\subname2-r", BASEDIR "\\subname3-r");
@@ -320,7 +321,7 @@
 
 	smbcli_rmdir(cli->tree, BASEDIR "\\subdir-name\\subname1-r");
 	smbcli_rmdir(cli->tree, BASEDIR "\\subdir-name");
-	smbcli_rmdir(cli->tree, BASEDIR "\\subname3-r");
+	smbcli_unlink(cli->tree, BASEDIR "\\subname3-r");
 
 	notify.in.recursive = False;
 	req2 = smb_raw_changenotify_send(cli->tree, &notify);
@@ -328,7 +329,7 @@
 	status = smb_raw_changenotify_recv(req1, mem_ctx, &notify);
 	CHECK_STATUS(status, NT_STATUS_OK);
 
-	CHECK_VAL(notify.out.num_changes, 9);
+	CHECK_VAL(notify.out.num_changes, 11);
 	CHECK_VAL(notify.out.changes[0].action, NOTIFY_ACTION_ADDED);
 	CHECK_WSTR(notify.out.changes[0].name, "subdir-name", STR_UNICODE);
 	CHECK_VAL(notify.out.changes[1].action, NOTIFY_ACTION_ADDED);
@@ -340,16 +341,29 @@
 	CHECK_VAL(notify.out.changes[4].action, NOTIFY_ACTION_NEW_NAME);
 	CHECK_WSTR(notify.out.changes[4].name, "subdir-name\\subname1-r", STR_UNICODE);
 
-	CHECK_VAL(notify.out.changes[5].action, NOTIFY_ACTION_REMOVED);
-	CHECK_WSTR(notify.out.changes[5].name, "subdir-name\\subname2", STR_UNICODE);
-	CHECK_VAL(notify.out.changes[6].action, NOTIFY_ACTION_ADDED);
-	CHECK_WSTR(notify.out.changes[6].name, "subname2-r", STR_UNICODE);
+	/* the remove/add between directories is acceptable in either order */
+	if (notify.out.changes[5].action == NOTIFY_ACTION_ADDED) {
+		CHECK_VAL(notify.out.changes[6].action, NOTIFY_ACTION_REMOVED);
+		CHECK_WSTR(notify.out.changes[6].name, "subdir-name\\subname2", STR_UNICODE);
+		CHECK_VAL(notify.out.changes[5].action, NOTIFY_ACTION_ADDED);
+		CHECK_WSTR(notify.out.changes[5].name, "subname2-r", STR_UNICODE);
+	} else {
+		CHECK_VAL(notify.out.changes[5].action, NOTIFY_ACTION_REMOVED);
+		CHECK_WSTR(notify.out.changes[5].name, "subdir-name\\subname2", STR_UNICODE);
+		CHECK_VAL(notify.out.changes[6].action, NOTIFY_ACTION_ADDED);
+		CHECK_WSTR(notify.out.changes[6].name, "subname2-r", STR_UNICODE);
+	}
 
-	CHECK_VAL(notify.out.changes[7].action, NOTIFY_ACTION_OLD_NAME);
+	CHECK_VAL(notify.out.changes[7].action, NOTIFY_ACTION_MODIFIED);
 	CHECK_WSTR(notify.out.changes[7].name, "subname2-r", STR_UNICODE);
-	CHECK_VAL(notify.out.changes[8].action, NOTIFY_ACTION_NEW_NAME);
-	CHECK_WSTR(notify.out.changes[8].name, "subname3-r", STR_UNICODE);
 
+	CHECK_VAL(notify.out.changes[8].action, NOTIFY_ACTION_OLD_NAME);
+	CHECK_WSTR(notify.out.changes[8].name, "subname2-r", STR_UNICODE);
+	CHECK_VAL(notify.out.changes[9].action, NOTIFY_ACTION_NEW_NAME);
+	CHECK_WSTR(notify.out.changes[9].name, "subname3-r", STR_UNICODE);
+	CHECK_VAL(notify.out.changes[10].action, NOTIFY_ACTION_MODIFIED);
+	CHECK_WSTR(notify.out.changes[10].name, "subname3-r", STR_UNICODE);
+
 	status = smb_raw_changenotify_recv(req2, mem_ctx, &notify);
 	CHECK_STATUS(status, NT_STATUS_OK);
 
@@ -380,8 +394,13 @@
 	uint32_t mask;
 	int i;
 	char c = 1;
+	struct timeval tv;
+	NTTIME t;
 
 	printf("TESTING CHANGE NOTIFY COMPLETION FILTERS\n");
+
+	tv = timeval_current_ofs(1000, 0);
+	t = timeval_to_nttime(&tv);
 		
 	/*
 	  get a handle on the directory
@@ -416,21 +435,36 @@
 		msleep(10); smb_raw_ntcancel(req); \
 		status = smb_raw_changenotify_recv(req, mem_ctx, &notify); \
 		cleanup \
+		smbcli_close(cli->tree, fnum); \
 		if (NT_STATUS_EQUAL(status, NT_STATUS_CANCELLED)) continue; \
 		CHECK_STATUS(status, NT_STATUS_OK); \
-		if (nchanges != notify.out.num_changes || \
+		/* special case to cope with file rename behaviour */ \
+		if (nchanges == 2 && notify.out.num_changes == 1 && \
+		    notify.out.changes[0].action == NOTIFY_ACTION_MODIFIED && \
+		    ((expected) & FILE_NOTIFY_CHANGE_ATTRIBUTES) && \
+		    Action == NOTIFY_ACTION_OLD_NAME) { \
+			printf("(rename file special handling OK)\n"); \
+		} else if (nchanges != notify.out.num_changes || \
 		    notify.out.changes[0].action != Action || \
 		    strcmp(notify.out.changes[0].name.s, "tname1") != 0) { \
-			printf("nchanges=%d action=%d filter=0x%08x\n", \
+			printf("ERROR: nchanges=%d action=%d filter=0x%08x\n", \
 			       notify.out.num_changes, \
 			       notify.out.changes[0].action, \
 			       notify.in.completion_filter); \
 			ret = False; \
 		} \
 		mask |= (1<<i); \
-		smbcli_close(cli->tree, fnum); \
 	} \
-	CHECK_VAL(mask, expected); \
+	if ((expected) != mask) { \
+		if (((expected) & ~mask) != 0) { \
+			printf("ERROR: trigger on too few bits. mask=0x%08x expected=0x%08x\n", \
+			       mask, expected); \
+			ret = False; \
+		} else { \
+			printf("WARNING: trigger on too many bits. mask=0x%08x expected=0x%08x\n", \
+			       mask, expected); \
+		} \
+	} \
 	} while (0)
 
 	printf("testing mkdir\n");
@@ -506,7 +540,7 @@
 	printf("testing set file create time\n");
 	NOTIFY_MASK_TEST(
 		fnum2 = create_complex_file(cli, mem_ctx, BASEDIR "\\tname1");,
-		smbcli_fsetatr(cli->tree, fnum2, 0, 1000*1000, 0, 0, 0);,
+		smbcli_fsetatr(cli->tree, fnum2, 0, t, 0, 0, 0);,
 		(smbcli_close(cli->tree, fnum2), smbcli_unlink(cli->tree, BASEDIR "\\tname1"));,
 		NOTIFY_ACTION_MODIFIED,
 		FILE_NOTIFY_CHANGE_CREATION, 1);
@@ -514,7 +548,7 @@
 	printf("testing set file access time\n");
 	NOTIFY_MASK_TEST(
 		fnum2 = create_complex_file(cli, mem_ctx, BASEDIR "\\tname1");,
-		smbcli_fsetatr(cli->tree, fnum2, 0, 0, 1000*1000, 0, 0);,
+		smbcli_fsetatr(cli->tree, fnum2, 0, 0, t, 0, 0);,
 		(smbcli_close(cli->tree, fnum2), smbcli_unlink(cli->tree, BASEDIR "\\tname1"));,
 		NOTIFY_ACTION_MODIFIED,
 		FILE_NOTIFY_CHANGE_LAST_ACCESS, 1);
@@ -522,7 +556,7 @@
 	printf("testing set file write time\n");
 	NOTIFY_MASK_TEST(
 		fnum2 = create_complex_file(cli, mem_ctx, BASEDIR "\\tname1");,
-		smbcli_fsetatr(cli->tree, fnum2, 0, 0, 0, 1000*1000, 0);,
+		smbcli_fsetatr(cli->tree, fnum2, 0, 0, 0, t, 0);,
 		(smbcli_close(cli->tree, fnum2), smbcli_unlink(cli->tree, BASEDIR "\\tname1"));,
 		NOTIFY_ACTION_MODIFIED,
 		FILE_NOTIFY_CHANGE_LAST_WRITE, 1);
@@ -530,7 +564,7 @@
 	printf("testing set file change time\n");
 	NOTIFY_MASK_TEST(
 		fnum2 = create_complex_file(cli, mem_ctx, BASEDIR "\\tname1");,
-		smbcli_fsetatr(cli->tree, fnum2, 0, 0, 0, 0, 1000*1000);,
+		smbcli_fsetatr(cli->tree, fnum2, 0, 0, 0, 0, t);,
 		(smbcli_close(cli->tree, fnum2), smbcli_unlink(cli->tree, BASEDIR "\\tname1"));,
 		NOTIFY_ACTION_MODIFIED,
 		0, 1);



More information about the samba-cvs mailing list