[SCM] Samba Shared Repository - branch master updated

Michael Adam obnox at samba.org
Wed Sep 10 05:16:04 MDT 2014


The branch, master has been updated
       via  868e8f4 s4:torture: fix multi_smb_test child status tracking.
       via  5893448 s4:torture:base: add torture_comments to the loop of the deferopen test.
       via  485cf56 s4:torture:base: move i++ down in loop in run_deferopen()
      from  5629cfc ctdb-util: Make tdb_wrap self-sufficient - it doesn't need includes.h

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 868e8f42a08f9cb75cb9ab728169faf368a3e7f5
Author: Michael Adam <obnox at samba.org>
Date:   Thu Aug 21 10:32:00 2014 +0200

    s4:torture: fix multi_smb_test child status tracking.
    
    The original code in torture_start_procs() lost status of
    child status. So the affected test caseses
    (defer_open, ntdeny1, bench-torture, and also direct
     torture_start_proxy-user bench-nbench) were not always
    able to correctly detect and treat errors in the worker children.
    
    With this patch, torture_create_procs() correctly puts
    child result and reason into top level torture_result(),
    thereby in particular fixing remaining unexpected errors
    in the flapping deferopen test.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    
    Autobuild-User(master): Michael Adam <obnox at samba.org>
    Autobuild-Date(master): Wed Sep 10 13:15:17 CEST 2014 on sn-devel-104

commit 589344802df9916bbfcd12317e703d3b6cbbba8e
Author: Michael Adam <obnox at samba.org>
Date:   Wed Aug 20 15:42:27 2014 +0200

    s4:torture:base: add torture_comments to the loop of the deferopen test.
    
    This is to be able to better tell what went wrong if something
    went wrong. This is currently one of the main flapping tests.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 485cf5654d33d540bb57c3c481295ac90d06dadc
Author: Michael Adam <obnox at samba.org>
Date:   Wed Aug 20 23:46:32 2014 +0200

    s4:torture:base: move i++ down in loop in run_deferopen()
    
    This is where it belongs, and it prepares
    subsequent patches.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 source4/torture/basic/base.c |   39 +++++++++++++++++-
 source4/torture/util_smb.c   |   87 ++++++++++++++++++++++++++++++------------
 2 files changed, 98 insertions(+), 28 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source4/torture/basic/base.c b/source4/torture/basic/base.c
index 3789081..bd9a304 100644
--- a/source4/torture/basic/base.c
+++ b/source4/torture/basic/base.c
@@ -665,27 +665,55 @@ static bool run_deferopen(struct torture_context *tctx, struct smbcli_state *cli
 
 	while (i < 4) {
 		int fnum = -1;
+		int j = 1;
 
 		do {
 			struct timeval tv;
 			tv = timeval_current();
+
+			torture_comment(tctx,
+					"pid %u: create[%d,%d]...\n",
+					(unsigned)getpid(), i, j);
+
 			fnum = smbcli_nt_create_full(cli->tree, fname, 0, 
 						     SEC_RIGHTS_FILE_ALL,
 						     FILE_ATTRIBUTE_NORMAL, 
 						     NTCREATEX_SHARE_ACCESS_NONE,
 						     NTCREATEX_DISP_OPEN_IF, 0, 0);
+			status = smbcli_nt_error(cli->tree);
+
+			torture_comment(tctx,
+					"pid %u: create[%d,%d] gave fnum %d, status %s\n",
+					(unsigned)getpid(), i, j, fnum,
+					nt_errstr(status));
+
 			if (fnum != -1) {
 				break;
 			}
-			if (NT_STATUS_EQUAL(smbcli_nt_error(cli->tree),NT_STATUS_SHARING_VIOLATION)) {
+
+			if (NT_STATUS_EQUAL(status, NT_STATUS_SHARING_VIOLATION)) {
 				double e = timeval_elapsed(&tv);
+
+				torture_comment(tctx, "pid %u: create[%d,%d] "
+						"time elapsed: %.2f (1 sec = %.2f)\n",
+						(unsigned)getpid(), i, j, e, sec);
 				if (e < (0.5 * sec) || e > ((1.5 * sec) + 1)) {
+					torture_comment(tctx, "pid %u: create[%d,%d] "
+							"timing incorrect\n",
+							(unsigned)getpid(), i, j);
 					torture_result(tctx, TORTURE_FAIL, "Timing incorrect %.2f violation 1 sec == %.2f\n",
 						e, sec);
 					return false;
 				}
 			}
-		} while (NT_STATUS_EQUAL(smbcli_nt_error(cli->tree),NT_STATUS_SHARING_VIOLATION));
+
+			j++;
+
+		} while (NT_STATUS_EQUAL(status, NT_STATUS_SHARING_VIOLATION));
+
+		torture_comment(tctx,
+				"pid %u: create loop %d done: fnum %d, status %s\n",
+				(unsigned)getpid(), i, fnum, nt_errstr(status));
 
 		torture_assert(tctx, fnum != -1,
 			       talloc_asprintf(tctx,
@@ -696,9 +724,12 @@ static bool run_deferopen(struct torture_context *tctx, struct smbcli_state *cli
 		torture_comment(tctx, "pid %u: open %d\n", (unsigned)getpid(), i);
 
 		smb_msleep(10 * msec);
-		i++;
 
 		status = smbcli_close(cli->tree, fnum);
+
+		torture_comment(tctx, "pid %u: open %d closed, status %s\n",
+				(unsigned)getpid(), i, nt_errstr(status));
+
 		torture_assert(tctx, !NT_STATUS_IS_ERR(status),
 			       talloc_asprintf(tctx,
 					       "pid %u: Failed to close %s, "
@@ -707,6 +738,8 @@ static bool run_deferopen(struct torture_context *tctx, struct smbcli_state *cli
 					       smbcli_errstr(cli->tree)));
 
 		smb_msleep(2 * msec);
+
+		i++;
 	}
 
 	if (NT_STATUS_IS_ERR(smbcli_unlink(cli->tree, fname))) {
diff --git a/source4/torture/util_smb.c b/source4/torture/util_smb.c
index 588ac05..0520f27 100644
--- a/source4/torture/util_smb.c
+++ b/source4/torture/util_smb.c
@@ -582,12 +582,19 @@ static void sigcont(int sig)
 {
 }
 
-double torture_create_procs(struct torture_context *tctx, 
-							bool (*fn)(struct torture_context *, struct smbcli_state *, int), bool *result)
+struct child_status {
+	pid_t pid;
+	bool start;
+	enum torture_result result;
+	char reason[1024];
+};
+
+double torture_create_procs(struct torture_context *tctx,
+	bool (*fn)(struct torture_context *, struct smbcli_state *, int),
+	bool *result)
 {
 	int i, status;
-	volatile pid_t *child_status;
-	volatile bool *child_status_out;
+	struct child_status *child_status;
 	int synccount;
 	int tries = 8;
 	int torture_nprocs = torture_setting_int(tctx, "nprocs", 4);
@@ -600,21 +607,15 @@ double torture_create_procs(struct torture_context *tctx,
 
 	signal(SIGCONT, sigcont);
 
-	child_status = (volatile pid_t *)anonymous_shared_allocate(sizeof(pid_t)*torture_nprocs);
-	if (!child_status) {
+	child_status = (struct child_status *)anonymous_shared_allocate(
+				sizeof(struct child_status)*torture_nprocs);
+	if (child_status == NULL) {
 		printf("Failed to setup shared memory\n");
 		return -1;
 	}
 
-	child_status_out = (volatile bool *)anonymous_shared_allocate(sizeof(bool)*torture_nprocs);
-	if (!child_status_out) {
-		printf("Failed to setup result status shared memory\n");
-		return -1;
-	}
-
 	for (i = 0; i < torture_nprocs; i++) {
-		child_status[i] = 0;
-		child_status_out[i] = true;
+		ZERO_STRUCT(child_status[i]);
 	}
 
 	tv = timeval_current();
@@ -623,6 +624,7 @@ double torture_create_procs(struct torture_context *tctx,
 		procnum = i;
 		if (fork() == 0) {
 			char *myname;
+			bool ok;
 
 			pid_t mypid = getpid();
 			srandom(((int)mypid) ^ ((int)time(NULL)));
@@ -646,17 +648,45 @@ double torture_create_procs(struct torture_context *tctx,
 				smb_msleep(100);	
 			}
 
-			child_status[i] = getpid();
+			child_status[i].pid = getpid();
 
 			pause();
 
-			if (child_status[i]) {
+			if (!child_status[i].start) {
+				child_status[i].result = TORTURE_ERROR;
 				printf("Child %d failed to start!\n", i);
-				child_status_out[i] = 1;
 				_exit(1);
 			}
 
-			child_status_out[i] = fn(tctx, current_cli, i);
+			ok = fn(tctx, current_cli, i);
+			if (!ok) {
+				if (tctx->last_result == TORTURE_OK) {
+					torture_result(tctx, TORTURE_ERROR,
+						"unknown error: missing "
+						"torture_result call?\n");
+				}
+
+				child_status[i].result = tctx->last_result;
+
+				if (strlen(tctx->last_reason) > 1023) {
+					/* note: reason already contains \n */
+					torture_comment(tctx,
+						"child %d (pid %u) failed: %s",
+						i,
+						(unsigned)child_status[i].pid,
+						tctx->last_reason);
+				}
+
+				snprintf(child_status[i].reason,
+					 1024, "child %d (pid %u) failed: %s",
+					 i, (unsigned)child_status[i].pid,
+					 tctx->last_reason);
+				/* ensure proper "\n\0" termination: */
+				if (child_status[i].reason[1022] != '\0') {
+					child_status[i].reason[1022] = '\n';
+					child_status[i].reason[1023] = '\0';
+				}
+			}
 			_exit(0);
 		}
 	}
@@ -664,9 +694,13 @@ double torture_create_procs(struct torture_context *tctx,
 	do {
 		synccount = 0;
 		for (i=0;i<torture_nprocs;i++) {
-			if (child_status[i]) synccount++;
+			if (child_status[i].pid != 0) {
+				synccount++;
+			}
+		}
+		if (synccount == torture_nprocs) {
+			break;
 		}
-		if (synccount == torture_nprocs) break;
 		smb_msleep(100);
 	} while (timeval_elapsed(&tv) < start_time_limit);
 
@@ -675,8 +709,8 @@ double torture_create_procs(struct torture_context *tctx,
 
 		/* cleanup child processes */
 		for (i = 0; i < torture_nprocs; i++) {
-			if (child_status[i]) {
-				kill(child_status[i], SIGTERM);
+			if (child_status[i].pid != 0) {
+				kill(child_status[i].pid, SIGTERM);
 			}
 		}
 
@@ -689,7 +723,7 @@ double torture_create_procs(struct torture_context *tctx,
 	/* start the client load */
 	tv = timeval_current();
 	for (i=0;i<torture_nprocs;i++) {
-		child_status[i] = 0;
+		child_status[i].start = true;
 	}
 
 	printf("%d clients started\n", torture_nprocs);
@@ -705,12 +739,15 @@ double torture_create_procs(struct torture_context *tctx,
 	}
 
 	printf("\n");
-	
+
 	for (i=0;i<torture_nprocs;i++) {
-		if (!child_status_out[i]) {
+		if (child_status[i].result != TORTURE_OK) {
 			*result = false;
+			torture_result(tctx, child_status[i].result,
+				       "%s", child_status[i].reason);
 		}
 	}
+
 	return timeval_elapsed(&tv);
 }
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list