svn commit: samba r26240 - in branches/SAMBA_4_0: . source/torture source/torture/libnet source/torture/rpc

jelmer at samba.org jelmer at samba.org
Mon Dec 3 02:58:13 GMT 2007


Author: jelmer
Date: 2007-12-03 02:58:12 +0000 (Mon, 03 Dec 2007)
New Revision: 26240

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

Log:
We now actually use torture_context pointers for more than just allocation.
Fix a few places where we were passing talloc contexts that were not 
torture contexts.

Modified:
   branches/SAMBA_4_0/
   branches/SAMBA_4_0/source/torture/libnet/libnet_user.c
   branches/SAMBA_4_0/source/torture/rpc/autoidl.c
   branches/SAMBA_4_0/source/torture/rpc/countcalls.c
   branches/SAMBA_4_0/source/torture/smbtorture.c
   branches/SAMBA_4_0/source/torture/ui.c


Changeset:

Property changes on: branches/SAMBA_4_0
___________________________________________________________________
Name: bzr:revision-info
...skipped...
Name: bzr:revision-id:v3-trunk0
...skipped...

Modified: branches/SAMBA_4_0/source/torture/libnet/libnet_user.c
===================================================================
--- branches/SAMBA_4_0/source/torture/libnet/libnet_user.c	2007-12-03 00:28:44 UTC (rev 26239)
+++ branches/SAMBA_4_0/source/torture/libnet/libnet_user.c	2007-12-03 02:58:12 UTC (rev 26240)
@@ -463,7 +463,7 @@
 	NTSTATUS status;
 	struct dcerpc_binding *bind;
 	struct dcerpc_pipe *p;
-	TALLOC_CTX *prep_mem_ctx, *mem_ctx;
+	TALLOC_CTX *prep_mem_ctx;
 	struct policy_handle h;
 	struct lsa_String domain_name;
 	char *name;
@@ -499,9 +499,7 @@
 		goto done;
 	}
 
-	mem_ctx = talloc_init("test_modifyuser");
-
-	status = torture_rpc_binding(mem_ctx, &bind);
+	status = torture_rpc_binding(torture, &bind);
 	if (!NT_STATUS_IS_OK(status)) {
 		ret = false;
 		goto done;
@@ -514,9 +512,9 @@
 		req.in.domain_name = lp_workgroup(torture->lp_ctx);
 		req.in.user_name = name;
 
-		set_test_changes(mem_ctx, &req, 1, &name, fld);
+		set_test_changes(torture, &req, 1, &name, fld);
 
-		status = libnet_ModifyUser(ctx, mem_ctx, &req);
+		status = libnet_ModifyUser(ctx, torture, &req);
 		if (!NT_STATUS_IS_OK(status)) {
 			printf("libnet_ModifyUser call failed: %s\n", nt_errstr(status));
 			ret = false;
@@ -527,7 +525,7 @@
 		user_req.in.domain_name = lp_workgroup(torture->lp_ctx);
 		user_req.in.user_name = name;
 
-		status = libnet_UserInfo(ctx, mem_ctx, &user_req);
+		status = libnet_UserInfo(ctx, torture, &user_req);
 		if (!NT_STATUS_IS_OK(status)) {
 			printf("libnet_UserInfo call failed: %s\n", nt_errstr(status));
 			ret = false;
@@ -567,32 +565,29 @@
 			req.in.user_name = name;
 			req.in.account_name = TEST_USERNAME;
 			
-			status = libnet_ModifyUser(ctx, mem_ctx, &req);
+			status = libnet_ModifyUser(ctx, torture, &req);
 			if (!NT_STATUS_IS_OK(status)) {
 				printf("libnet_ModifyUser call failed: %s\n", nt_errstr(status));
-				talloc_free(mem_ctx);
 				ret = false;
 				goto done;
 			}
 			
-			name = talloc_strdup(mem_ctx, TEST_USERNAME);
+			name = talloc_strdup(torture, TEST_USERNAME);
 		}
 	}
 
 cleanup:
-	if (!test_cleanup(ctx->samr.pipe, mem_ctx, &ctx->samr.handle, name)) {
+	if (!test_cleanup(ctx->samr.pipe, torture, &ctx->samr.handle, name)) {
 		printf("cleanup failed\n");
 		ret = false;
 		goto done;
 	}
 
-	if (!test_samr_close(ctx->samr.pipe, mem_ctx, &ctx->samr.handle)) {
+	if (!test_samr_close(ctx->samr.pipe, torture, &ctx->samr.handle)) {
 		printf("domain close failed\n");
 		ret = false;
 	}
 
-	talloc_free(mem_ctx);
-
 done:
 	talloc_free(ctx);
 	talloc_free(prep_mem_ctx);

Modified: branches/SAMBA_4_0/source/torture/rpc/autoidl.c
===================================================================
--- branches/SAMBA_4_0/source/torture/rpc/autoidl.c	2007-12-03 00:28:44 UTC (rev 26239)
+++ branches/SAMBA_4_0/source/torture/rpc/autoidl.c	2007-12-03 02:58:12 UTC (rev 26240)
@@ -87,7 +87,7 @@
 	memcpy(blob->data, b2.data, 20);
 }
 
-static void reopen(TALLOC_CTX *mem_ctx, 
+static void reopen(struct torture_context *tctx, 
 		   struct dcerpc_pipe **p, 
 		   const struct ndr_interface_table *iface)
 {
@@ -95,7 +95,7 @@
 
 	talloc_free(*p);
 
-	status = torture_rpc_connection(mem_ctx, p, iface);
+	status = torture_rpc_connection(tctx, p, iface);
 	if (!NT_STATUS_IS_OK(status)) {
 		printf("Failed to reopen '%s' - %s\n", iface->name, nt_errstr(status));
 		exit(1);
@@ -110,10 +110,10 @@
 	}
 }
 
-static void test_ptr_scan(TALLOC_CTX *mem_ctx, const struct ndr_interface_table *iface, 
+static void test_ptr_scan(struct torture_context *tctx, const struct ndr_interface_table *iface, 
 			  int opnum, DATA_BLOB *base_in, int min_ofs, int max_ofs, int depth);
 
-static void try_expand(TALLOC_CTX *mem_ctx, const struct ndr_interface_table *iface, 
+static void try_expand(struct torture_context *tctx, const struct ndr_interface_table *iface, 
 		       int opnum, DATA_BLOB *base_in, int insert_ofs, int depth)
 {
 	DATA_BLOB stub_in, stub_out;
@@ -121,7 +121,7 @@
 	NTSTATUS status;
 	struct dcerpc_pipe *p = NULL;
 
-	reopen(mem_ctx, &p, iface);
+	reopen(tctx, &p, iface);
 
 	/* work out how much to expand to get a non fault */
 	for (n=0;n<2000;n++) {
@@ -130,24 +130,24 @@
 		memcpy(stub_in.data, base_in->data, insert_ofs);
 		memcpy(stub_in.data+insert_ofs+n, base_in->data+insert_ofs, base_in->length-insert_ofs);
 
-		status = dcerpc_request(p, NULL, opnum, false, mem_ctx, &stub_in, &stub_out);
+		status = dcerpc_request(p, NULL, opnum, false, tctx, &stub_in, &stub_out);
 
 		if (!NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
 			print_depth(depth);
 			printf("expand by %d gives %s\n", n, nt_errstr(status));
 			if (n >= 4) {
-				test_ptr_scan(mem_ctx, iface, opnum, &stub_in, 
+				test_ptr_scan(tctx, iface, opnum, &stub_in, 
 					      insert_ofs, insert_ofs+n, depth+1);
 			}
 			return;
 		} else {
 #if 0
 			print_depth(depth);
-			printf("expand by %d gives fault %s\n", n, dcerpc_errstr(mem_ctx, p->last_fault_code));
+			printf("expand by %d gives fault %s\n", n, dcerpc_errstr(tctx, p->last_fault_code));
 #endif
 		}
 		if (p->last_fault_code == 5) {
-			reopen(mem_ctx, &p, iface);
+			reopen(tctx, &p, iface);
 		}
 	}
 
@@ -155,7 +155,7 @@
 }
 
 
-static void test_ptr_scan(TALLOC_CTX *mem_ctx, const struct ndr_interface_table *iface, 
+static void test_ptr_scan(struct torture_context *tctx, const struct ndr_interface_table *iface, 
 			  int opnum, DATA_BLOB *base_in, int min_ofs, int max_ofs, int depth)
 {
 	DATA_BLOB stub_in, stub_out;
@@ -163,7 +163,7 @@
 	NTSTATUS status;
 	struct dcerpc_pipe *p = NULL;
 
-	reopen(mem_ctx, &p, iface);
+	reopen(tctx, &p, iface);
 
 	stub_in = data_blob(NULL, base_in->length);
 	memcpy(stub_in.data, base_in->data, base_in->length);
@@ -171,19 +171,19 @@
 	/* work out which elements are pointers */
 	for (ofs=min_ofs;ofs<=max_ofs-4;ofs+=4) {
 		SIVAL(stub_in.data, ofs, 1);
-		status = dcerpc_request(p, NULL, opnum, false, mem_ctx, &stub_in, &stub_out);
+		status = dcerpc_request(p, NULL, opnum, false, tctx, &stub_in, &stub_out);
 
 		if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
 			print_depth(depth);
 			printf("possible ptr at ofs %d - fault %s\n", 
-			       ofs-min_ofs, dcerpc_errstr(mem_ctx, p->last_fault_code));
+			       ofs-min_ofs, dcerpc_errstr(tctx, p->last_fault_code));
 			if (p->last_fault_code == 5) {
-				reopen(mem_ctx, &p, iface);
+				reopen(tctx, &p, iface);
 			}
 			if (depth == 0) {
-				try_expand(mem_ctx, iface, opnum, &stub_in, ofs+4, depth+1);
+				try_expand(tctx, iface, opnum, &stub_in, ofs+4, depth+1);
 			} else {
-				try_expand(mem_ctx, iface, opnum, &stub_in, max_ofs, depth+1);
+				try_expand(tctx, iface, opnum, &stub_in, max_ofs, depth+1);
 			}
 			SIVAL(stub_in.data, ofs, 0);
 			continue;
@@ -195,7 +195,7 @@
 }
 	
 
-static void test_scan_call(TALLOC_CTX *mem_ctx, const struct ndr_interface_table *iface, int opnum)
+static void test_scan_call(struct torture_context *tctx, const struct ndr_interface_table *iface, int opnum)
 {
 	DATA_BLOB stub_in, stub_out;
 	int i;
@@ -203,9 +203,9 @@
 	struct dcerpc_pipe *p = NULL;
 	struct policy_handle handle;
 
-	reopen(mem_ctx, &p, iface);
+	reopen(tctx, &p, iface);
 
-	get_policy_handle(p, mem_ctx, &handle);
+	get_policy_handle(p, tctx, &handle);
 
 	/* work out the minimum amount of input data */
 	for (i=0;i<2000;i++) {
@@ -213,34 +213,34 @@
 		data_blob_clear(&stub_in);
 
 
-		status = dcerpc_request(p, NULL, opnum, false, mem_ctx, &stub_in, &stub_out);
+		status = dcerpc_request(p, NULL, opnum, false, tctx, &stub_in, &stub_out);
 
 		if (NT_STATUS_IS_OK(status)) {
 			printf("opnum %d   min_input %d - output %d\n", 
 			       opnum, (int)stub_in.length, (int)stub_out.length);
 			dump_data(0, stub_out.data, stub_out.length);
 			talloc_free(p);
-			test_ptr_scan(mem_ctx, iface, opnum, &stub_in, 0, stub_in.length, 0);
+			test_ptr_scan(tctx, iface, opnum, &stub_in, 0, stub_in.length, 0);
 			return;
 		}
 
-		fill_blob_handle(&stub_in, mem_ctx, &handle);
+		fill_blob_handle(&stub_in, tctx, &handle);
 
-		status = dcerpc_request(p, NULL, opnum, false, mem_ctx, &stub_in, &stub_out);
+		status = dcerpc_request(p, NULL, opnum, false, tctx, &stub_in, &stub_out);
 
 		if (NT_STATUS_IS_OK(status)) {
 			printf("opnum %d   min_input %d - output %d (with handle)\n", 
 			       opnum, (int)stub_in.length, (int)stub_out.length);
 			dump_data(0, stub_out.data, stub_out.length);
 			talloc_free(p);
-			test_ptr_scan(mem_ctx, iface, opnum, &stub_in, 0, stub_in.length, 0);
+			test_ptr_scan(tctx, iface, opnum, &stub_in, 0, stub_in.length, 0);
 			return;
 		}
 
 		if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
-			printf("opnum %d  size %d fault %s\n", opnum, i, dcerpc_errstr(mem_ctx, p->last_fault_code));
+			printf("opnum %d  size %d fault %s\n", opnum, i, dcerpc_errstr(tctx, p->last_fault_code));
 			if (p->last_fault_code == 5) {
-				reopen(mem_ctx, &p, iface);
+				reopen(tctx, &p, iface);
 			}
 			continue;
 		}
@@ -253,14 +253,13 @@
 }
 
 
-static void test_auto_scan(TALLOC_CTX *mem_ctx, const struct ndr_interface_table *iface)
+static void test_auto_scan(struct torture_context *tctx, const struct ndr_interface_table *iface)
 {
-	test_scan_call(mem_ctx, iface, 2);
+	test_scan_call(tctx, iface, 2);
 }
 
 bool torture_rpc_autoidl(struct torture_context *torture)
 {
-	TALLOC_CTX *mem_ctx;
 	const struct ndr_interface_table *iface;
 		
 	iface = ndr_table_by_name("drsuapi");
@@ -269,12 +268,9 @@
 		return false;
 	}
 
-	mem_ctx = talloc_init("torture_rpc_autoidl");
-
 	printf("\nProbing pipe '%s'\n", iface->name);
 
-	test_auto_scan(mem_ctx, iface);
+	test_auto_scan(torture, iface);
 
-	talloc_free(mem_ctx);
 	return true;
 }

Modified: branches/SAMBA_4_0/source/torture/rpc/countcalls.c
===================================================================
--- branches/SAMBA_4_0/source/torture/rpc/countcalls.c	2007-12-03 00:28:44 UTC (rev 26239)
+++ branches/SAMBA_4_0/source/torture/rpc/countcalls.c	2007-12-03 02:58:12 UTC (rev 26240)
@@ -29,14 +29,15 @@
 
 
 	
-bool count_calls(TALLOC_CTX *mem_ctx,
+bool count_calls(struct torture_context *tctx,
+		 TALLOC_CTX *mem_ctx,
 		 const struct ndr_interface_table *iface,
 	bool all) 
 {
 	struct dcerpc_pipe *p;
 	DATA_BLOB stub_in, stub_out;
 	int i;
-	NTSTATUS status = torture_rpc_connection(mem_ctx, &p, iface);
+	NTSTATUS status = torture_rpc_connection(tctx, &p, iface);
 	if (NT_STATUS_EQUAL(NT_STATUS_OBJECT_NAME_NOT_FOUND, status)
 	    || NT_STATUS_EQUAL(NT_STATUS_NET_WRITE_FAULT, status)
 	    || NT_STATUS_EQUAL(NT_STATUS_PORT_UNREACHABLE, status)
@@ -107,10 +108,6 @@
 	const char *iface_name;
 	bool ret = true;
 	const struct ndr_interface_list *l;
-	TALLOC_CTX *mem_ctx = talloc_named(torture, 0, "torture_rpc_countcalls context");
-	if (!mem_ctx) {
-		return false;
-	}
 	iface_name = lp_parm_string(torture->lp_ctx, NULL, "countcalls", "interface");
 	if (iface_name != NULL) {
 		iface = ndr_table_by_name(iface_name);
@@ -118,13 +115,13 @@
 			printf("Unknown interface '%s'\n", iface_name);
 			return false;
 		}
-		return count_calls(mem_ctx, iface, false);
+		return count_calls(torture, torture, iface, false);
 	}
 
 	for (l=ndr_table_list();l;l=l->next) {		
 		TALLOC_CTX *loop_ctx;
-		loop_ctx = talloc_named(mem_ctx, 0, "torture_rpc_councalls loop context");
-		ret &= count_calls(loop_ctx, l->table, true);
+		loop_ctx = talloc_named(torture, 0, "torture_rpc_councalls loop context");
+		ret &= count_calls(torture, loop_ctx, l->table, true);
 		talloc_free(loop_ctx);
 	}
 	return ret;

Modified: branches/SAMBA_4_0/source/torture/smbtorture.c
===================================================================
--- branches/SAMBA_4_0/source/torture/smbtorture.c	2007-12-03 00:28:44 UTC (rev 26239)
+++ branches/SAMBA_4_0/source/torture/smbtorture.c	2007-12-03 02:58:12 UTC (rev 26240)
@@ -484,7 +484,7 @@
 				fprintf(stderr, "Usage: set <variable> <value>\n");
 			} else {
 				char *name = talloc_asprintf(NULL, "torture:%s", argv[1]);
-				lp_set_cmdline(global_loadparm, name, argv[2]);
+				lp_set_cmdline(tctx->lp_ctx, name, argv[2]);
 				talloc_free(name);
 			}
 		} else if (!strcmp(argv[0], "help")) {

Modified: branches/SAMBA_4_0/source/torture/ui.c
===================================================================
--- branches/SAMBA_4_0/source/torture/ui.c	2007-12-03 00:28:44 UTC (rev 26239)
+++ branches/SAMBA_4_0/source/torture/ui.c	2007-12-03 02:58:12 UTC (rev 26240)
@@ -387,8 +387,13 @@
 				   const char *name, 
 				   const char *default_value)
 {
-	const char *ret = lp_parm_string(test->lp_ctx, NULL, "torture", name);
+	const char *ret;
 
+	SMB_ASSERT(test != NULL);
+	SMB_ASSERT(test->lp_ctx != NULL);
+	
+	ret = lp_parm_string(test->lp_ctx, NULL, "torture", name);
+
 	if (ret == NULL)
 		return default_value;
 



More information about the samba-cvs mailing list