[PATCH] Remove use of talloc_autofree_context() from source4/torture/

Jeremy Allison jra at samba.org
Tue Apr 25 16:53:56 UTC 2017


This is mostly boilerplate building on
the earlier patches that are already in.

Mostly it's just adding a TALLOC_CTX *
parameter to functions that were using
talloc_autofree_context() internally,
and then passing down an appropriate
context to them.

Unlike the other patches in this series
this shouldn't break any other module
use (sorry for your eternal rebasing
Andreas).

The last patch bears looking at a little
more closely, as it was using talloc_autofree_context()
to hang onto a received packet list in
the spoolss test code until all the tests
finished. I fixed it by using the NULL
context and then adding a free() function
for the list.

Please review and push if happy. This
gets rid of the majority of talloc_autofree_context()
in our codebase, and will allow me to more
carefully remove the rest of them shortly.

Passes local full make test.

Cheers,

Jeremy.
-------------- next part --------------
From e0ed7f2e87832784d34fe136533a82b534cce9f1 Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Mon, 24 Apr 2017 14:24:15 -0700
Subject: [PATCH 01/35] s4: torture: Create a top level talloc contxt.

Use it to replace some talloc_autofree_contexts.

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 source4/torture/smbtorture.c | 38 ++++++++++++++++++++++++++++++++------
 1 file changed, 32 insertions(+), 6 deletions(-)

diff --git a/source4/torture/smbtorture.c b/source4/torture/smbtorture.c
index 1595786..b36f0ba 100644
--- a/source4/torture/smbtorture.c
+++ b/source4/torture/smbtorture.c
@@ -387,6 +387,7 @@ int main(int argc, const char *argv[])
 	enum {OPT_LOADFILE=1000,OPT_UNCLIST,OPT_TIMELIMIT,OPT_DNS, OPT_LIST,
 	      OPT_DANGEROUS,OPT_SMB_PORTS,OPT_ASYNC,OPT_NUMPROGS,
 	      OPT_EXTRA_USER,};
+	TALLOC_CTX *mem_ctx = NULL;
 
 	struct poptOption long_options[] = {
 		POPT_AUTOHELP
@@ -428,6 +429,12 @@ int main(int argc, const char *argv[])
 
 	setlinebuf(stdout);
 
+	mem_ctx = talloc_named_const(NULL, 0, "torture_ctx");
+	if (mem_ctx == NULL) {
+		printf("Unable to allocate torture_ctx\n");
+		exit(1);
+	}
+
 	printf("smbtorture %s\n", samba_version_string());
 
 	/* we are never interested in SIGPIPE */
@@ -466,9 +473,15 @@ int main(int argc, const char *argv[])
 			break;
 		case OPT_EXTRA_USER:
 			{
-				char *option = talloc_asprintf(NULL, "torture:extra_user%u",
-							       ++num_extra_users);
+				char *option = talloc_asprintf(mem_ctx,
+						"torture:extra_user%u",
+						++num_extra_users);
 				const char *value = poptGetOptArg(pc);
+				if (option == NULL) {
+					printf("talloc fail\n");
+					talloc_free(mem_ctx);
+					exit(1);
+				}
 				lpcfg_set_cmdline(cmdline_lp_ctx, option, value);
 				talloc_free(option);
 			}
@@ -476,6 +489,7 @@ int main(int argc, const char *argv[])
 		default:
 			if (opt < 0) {
 				printf("bad command line option %d\n", opt);
+				talloc_free(mem_ctx);
 				exit(1);
 			}
 		}
@@ -483,10 +497,11 @@ int main(int argc, const char *argv[])
 
 	if (load_list != NULL) {
 		char **r;
-		r = file_lines_load(load_list, &num_restricted, 0, talloc_autofree_context());
+		r = file_lines_load(load_list, &num_restricted, 0, mem_ctx);
 		restricted = discard_const_p(const char *, r);
 		if (restricted == NULL) {
 			printf("Unable to read load list file '%s'\n", load_list);
+			talloc_free(mem_ctx);
 			exit(1);
 		}
 	}
@@ -560,7 +575,7 @@ int main(int argc, const char *argv[])
 		if (fn == NULL) 
 			d_printf("Unable to load module from %s\n", poptGetOptArg(pc));
 		else {
-			status = fn(NULL);
+			status = fn(mem_ctx);
 			if (NT_STATUS_IS_ERR(status)) {
 				d_printf("Error initializing module %s: %s\n", 
 					poptGetOptArg(pc), nt_errstr(status));
@@ -572,6 +587,7 @@ int main(int argc, const char *argv[])
 
 	if (list_testsuites) {
 		print_testsuite_list();
+		talloc_free(mem_ctx);
 		return 0;
 	}
 
@@ -593,6 +609,7 @@ int main(int argc, const char *argv[])
 				print_test_list(torture_root, NULL, argv_new[i]);
 			}
 		}
+		talloc_free(mem_ctx);
 		return 0;
 	}
 
@@ -608,16 +625,18 @@ int main(int argc, const char *argv[])
 		ui_ops = &torture_subunit_ui_ops;
 	} else {
 		printf("Unknown output format '%s'\n", ui_ops_name);
+		talloc_free(mem_ctx);
 		exit(1);
 	}
 
-	results = torture_results_init(talloc_autofree_context(), ui_ops);
+	results = torture_results_init(mem_ctx, ui_ops);
 
-	torture = torture_context_init(s4_event_context_init(talloc_autofree_context()),
+	torture = torture_context_init(s4_event_context_init(mem_ctx),
 	                               results);
 	if (basedir != NULL) {
 		if (basedir[0] != '/') {
 			fprintf(stderr, "Please specify an absolute path to --basedir\n");
+			talloc_free(mem_ctx);
 			return 1;
 		}
 		outputdir = talloc_asprintf(torture, "%s/smbtortureXXXXXX", basedir);
@@ -625,17 +644,21 @@ int main(int argc, const char *argv[])
 		char *pwd = talloc_size(torture, PATH_MAX);
 		if (!getcwd(pwd, PATH_MAX)) {
 			fprintf(stderr, "Unable to determine current working directory\n");
+			talloc_free(mem_ctx);
 			return 1;
 		}
 		outputdir = talloc_asprintf(torture, "%s/smbtortureXXXXXX", pwd);
 	}
 	if (!outputdir) {
 		fprintf(stderr, "Could not allocate per-run output dir\n");
+		talloc_free(mem_ctx);
 		return 1;
 	}
 	torture->outputdir = mkdtemp(outputdir);
 	if (!torture->outputdir) {
 		perror("Failed to make temp output dir");
+		talloc_free(mem_ctx);
+		return 1;
 	}
 
 	torture->lp_ctx = cmdline_lp_ctx;
@@ -674,8 +697,11 @@ int main(int argc, const char *argv[])
 	torture_deltree_outputdir(torture);
 
 	if (torture->results->returncode && correct) {
+		talloc_free(mem_ctx);
 		return(0);
 	} else {
+		talloc_free(mem_ctx);
+		return(0);
 		return(1);
 	}
 }
-- 
2.7.4


From e165e80c04a11ee1ecdc5b616c789eb0f837fa1d Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Mon, 24 Apr 2017 16:00:17 -0700
Subject: [PATCH 02/35] s4: torture: Add a TALLOC_CTX * to
 torture_parse_target().

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 source4/torture/shell.c      |  2 +-
 source4/torture/smbtorture.c | 11 +++++++----
 source4/torture/smbtorture.h |  4 +++-
 3 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/source4/torture/shell.c b/source4/torture/shell.c
index aa85da3..cf56135 100644
--- a/source4/torture/shell.c
+++ b/source4/torture/shell.c
@@ -285,7 +285,7 @@ static void shell_target(const struct shell_command *command,
 		printf("Target share: %s\n", share ? share : "");
 		printf("Target binding: %s\n", binding ? binding : "");
 	} else if (argc == 1) {
-		torture_parse_target(tctx->lp_ctx, argv[0]);
+		torture_parse_target(tctx, tctx->lp_ctx, argv[0]);
 	} else {
 		shell_usage(command);
 	}
diff --git a/source4/torture/smbtorture.c b/source4/torture/smbtorture.c
index b36f0ba..3bd5188 100644
--- a/source4/torture/smbtorture.c
+++ b/source4/torture/smbtorture.c
@@ -150,7 +150,9 @@ bool torture_run_named_tests(struct torture_context *torture, const char *name,
 	return ret;
 }
 
-bool torture_parse_target(struct loadparm_context *lp_ctx, const char *target)
+bool torture_parse_target(TALLOC_CTX *ctx,
+				struct loadparm_context *lp_ctx,
+				const char *target)
 {
 	char *host = NULL, *share = NULL;
 	struct dcerpc_binding *binding_struct;
@@ -160,7 +162,7 @@ bool torture_parse_target(struct loadparm_context *lp_ctx, const char *target)
 	if (!smbcli_parse_unc(target, NULL, &host, &share)) {
 		const char *h;
 
-		status = dcerpc_parse_binding(talloc_autofree_context(), target, &binding_struct);
+		status = dcerpc_parse_binding(ctx, target, &binding_struct);
 		if (NT_STATUS_IS_ERR(status)) {
 			d_printf("Invalid option: %s is not a valid torture target (share or binding string)\n\n", target);
 			return false;
@@ -679,8 +681,9 @@ int main(int argc, const char *argv[])
 			printf("You must specify a test to run, or 'ALL'\n");
 			usage(pc);
 			torture->results->returncode = 1;
-		} else if (!torture_parse_target(cmdline_lp_ctx, argv_new[1])) {
-		/* Take the target name or binding. */
+		} else if (!torture_parse_target(torture,
+					cmdline_lp_ctx, argv_new[1])) {
+			/* Take the target name or binding. */
 			usage(pc);
 			torture->results->returncode = 1;
 		} else {
diff --git a/source4/torture/smbtorture.h b/source4/torture/smbtorture.h
index cbb4823..0a0647d 100644
--- a/source4/torture/smbtorture.h
+++ b/source4/torture/smbtorture.h
@@ -40,7 +40,9 @@ void torture_shell(struct torture_context *tctx);
 void torture_print_testsuites(bool structured);
 bool torture_run_named_tests(struct torture_context *torture, const char *name,
 			    const char **restricted);
-bool torture_parse_target(struct loadparm_context *lp_ctx, const char *target);
+bool torture_parse_target(TALLOC_CTX *ctx,
+			struct loadparm_context *lp_ctx,
+			const char *target);
 
 /* Server Functionality Support */
 
-- 
2.7.4


From d313aac52f26badad06c7e962dc59f50de11ad6f Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Mon, 24 Apr 2017 14:27:36 -0700
Subject: [PATCH 03/35] s4: torture: Pass the new talloc context into
 torture_init().

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 source4/torture/smbtorture.c | 2 +-
 source4/torture/smbtorture.h | 2 +-
 source4/torture/torture.c    | 8 ++++----
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/source4/torture/smbtorture.c b/source4/torture/smbtorture.c
index 3bd5188..e5e9e1d 100644
--- a/source4/torture/smbtorture.c
+++ b/source4/torture/smbtorture.c
@@ -584,7 +584,7 @@ int main(int argc, const char *argv[])
 			}
 		}
 	} else { 
-		torture_init();
+		torture_init(mem_ctx);
 	}
 
 	if (list_testsuites) {
diff --git a/source4/torture/smbtorture.h b/source4/torture/smbtorture.h
index 0a0647d..7480f24 100644
--- a/source4/torture/smbtorture.h
+++ b/source4/torture/smbtorture.h
@@ -34,7 +34,7 @@ extern int torture_failures;
 extern int torture_numasync;
 
 struct torture_test;
-int torture_init(void);
+int torture_init(TALLOC_CTX *);
 bool torture_register_suite(struct torture_suite *suite);
 void torture_shell(struct torture_context *tctx);
 void torture_print_testsuites(bool structured);
diff --git a/source4/torture/torture.c b/source4/torture/torture.c
index 0108921..3ef1f3b 100644
--- a/source4/torture/torture.c
+++ b/source4/torture/torture.c
@@ -44,15 +44,15 @@ bool torture_register_suite(struct torture_suite *suite)
 	return torture_suite_add_suite(torture_root, suite);
 }
 
-_PUBLIC_ int torture_init(void)
+_PUBLIC_ int torture_init(TALLOC_CTX *mem_ctx)
 {
 #define _MODULE_PROTO(init) extern NTSTATUS init(TALLOC_CTX *);
 	STATIC_smbtorture_MODULES_PROTO;
 	init_module_fn static_init[] = { STATIC_smbtorture_MODULES };
-	init_module_fn *shared_init = load_samba_modules(NULL, "smbtorture");
+	init_module_fn *shared_init = load_samba_modules(mem_ctx, "smbtorture");
 
-	run_init_functions(NULL, static_init);
-	run_init_functions(NULL, shared_init);
+	run_init_functions(mem_ctx, static_init);
+	run_init_functions(mem_ctx, shared_init);
 
 	talloc_free(shared_init);
 
-- 
2.7.4


From c9e21def51b2079c27442f621fd3def8efe58735 Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Mon, 24 Apr 2017 14:41:26 -0700
Subject: [PATCH 04/35] s4: torture: Change torture_register_suite() to add a
 TALLOC_CTX *.

Change callers to use the passed in TALLOC_CTX *
instead of talloc_autofree_context().

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 libcli/echo/tests/echo.c                    | 4 ++--
 source4/torture/basic/base.c                | 4 ++--
 source4/torture/dfs/domaindfs.c             | 4 ++--
 source4/torture/dns/dlz_bind9.c             | 5 ++---
 source4/torture/dns/internal_dns.c          | 5 ++---
 source4/torture/drs/drs_init.c              | 9 ++++-----
 source4/torture/krb5/kdc-heimdal.c          | 4 ++--
 source4/torture/krb5/kdc-mit.c              | 4 ++--
 source4/torture/ldap/common.c               | 4 ++--
 source4/torture/libnet/libnet.c             | 4 ++--
 source4/torture/libnetapi/libnetapi.c       | 4 ++--
 source4/torture/libsmbclient/libsmbclient.c | 4 ++--
 source4/torture/local/local.c               | 6 +++---
 source4/torture/nbench/nbench.c             | 4 ++--
 source4/torture/nbt/nbt.c                   | 4 ++--
 source4/torture/ntp/ntp_signd.c             | 4 ++--
 source4/torture/rap/rap.c                   | 4 ++--
 source4/torture/raw/raw.c                   | 4 ++--
 source4/torture/rpc/rpc.c                   | 4 ++--
 source4/torture/smb2/smb2.c                 | 4 ++--
 source4/torture/smbtorture.h                | 2 +-
 source4/torture/torture.c                   | 4 ++--
 source4/torture/unix/unix.c                 | 4 ++--
 source4/torture/vfs/vfs.c                   | 4 ++--
 source4/torture/winbind/winbind.c           | 6 +++---
 25 files changed, 53 insertions(+), 56 deletions(-)

diff --git a/libcli/echo/tests/echo.c b/libcli/echo/tests/echo.c
index 8e51504..e465b99 100644
--- a/libcli/echo/tests/echo.c
+++ b/libcli/echo/tests/echo.c
@@ -85,13 +85,13 @@ NTSTATUS torture_libcli_echo_init(TALLOC_CTX *ctx)
 {
 	struct torture_suite *suite;
 
-	suite = torture_suite_create(talloc_autofree_context(), "echo");
+	suite = torture_suite_create(ctx, "echo");
 	NT_STATUS_HAVE_NO_MEMORY(suite);
 
 	torture_suite_add_simple_test(suite, "udp", torture_echo_udp);
 
 	suite->description = talloc_strdup(suite, "libcli/echo interface tests");
-	torture_register_suite(suite);
+	torture_register_suite(ctx, suite);
 
 	return NT_STATUS_OK;
 }
diff --git a/source4/torture/basic/base.c b/source4/torture/basic/base.c
index f5ee966..6e989bf 100644
--- a/source4/torture/basic/base.c
+++ b/source4/torture/basic/base.c
@@ -1937,7 +1937,7 @@ static bool run_birthtimetest(struct torture_context *tctx,
 
 NTSTATUS torture_base_init(TALLOC_CTX *ctx)
 {
-	struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "base");
+	struct torture_suite *suite = torture_suite_create(ctx, "base");
 
 	torture_suite_add_2smb_test(suite, "fdpass", run_fdpasstest);
 	torture_suite_add_suite(suite, torture_base_locktest(suite));
@@ -1996,7 +1996,7 @@ NTSTATUS torture_base_init(TALLOC_CTX *ctx)
 	suite->description = talloc_strdup(suite, 
 					"Basic SMB tests (imported from the original smbtorture)");
 
-	torture_register_suite(suite);
+	torture_register_suite(ctx, suite);
 
 	return NT_STATUS_OK;
 }
diff --git a/source4/torture/dfs/domaindfs.c b/source4/torture/dfs/domaindfs.c
index 82e6843..4bc5192 100644
--- a/source4/torture/dfs/domaindfs.c
+++ b/source4/torture/dfs/domaindfs.c
@@ -503,7 +503,7 @@ static bool test_low_referral_level(struct torture_context *tctx,
 
 NTSTATUS torture_dfs_init(TALLOC_CTX *ctx)
 {
-	struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "dfs");
+	struct torture_suite *suite = torture_suite_create(ctx, "dfs");
 	struct torture_suite *suite_basic = torture_suite_create(suite, "domain");
 
 	torture_suite_add_suite(suite, suite_basic);
@@ -534,7 +534,7 @@ NTSTATUS torture_dfs_init(TALLOC_CTX *ctx)
 
 	suite->description = talloc_strdup(suite, "DFS referrals calls");
 
-	torture_register_suite(suite);
+	torture_register_suite(ctx, suite);
 
 	return NT_STATUS_OK;
 }
diff --git a/source4/torture/dns/dlz_bind9.c b/source4/torture/dns/dlz_bind9.c
index 7a01ec0..f16d16e 100644
--- a/source4/torture/dns/dlz_bind9.c
+++ b/source4/torture/dns/dlz_bind9.c
@@ -1084,12 +1084,11 @@ NTSTATUS torture_bind_dns_init(TALLOC_CTX *);
 NTSTATUS torture_bind_dns_init(TALLOC_CTX *ctx)
 {
 	struct torture_suite *suite;
-	TALLOC_CTX *mem_ctx = talloc_autofree_context();
 
 	/* register DNS related test cases */
-	suite = dlz_bind9_suite(mem_ctx);
+	suite = dlz_bind9_suite(ctx);
 	if (!suite) return NT_STATUS_NO_MEMORY;
-	torture_register_suite(suite);
+	torture_register_suite(ctx, suite);
 
 	return NT_STATUS_OK;
 }
diff --git a/source4/torture/dns/internal_dns.c b/source4/torture/dns/internal_dns.c
index ac234e1..2ccc7ed 100644
--- a/source4/torture/dns/internal_dns.c
+++ b/source4/torture/dns/internal_dns.c
@@ -179,12 +179,11 @@ NTSTATUS torture_internal_dns_init(TALLOC_CTX *);
 NTSTATUS torture_internal_dns_init(TALLOC_CTX *ctx)
 {
 	struct torture_suite *suite;
-	TALLOC_CTX *mem_ctx = talloc_autofree_context();
 
 	/* register internal DNS torture test cases */
-	suite = internal_dns_suite(mem_ctx);
+	suite = internal_dns_suite(ctx);
 	if (!suite) return NT_STATUS_NO_MEMORY;
-	torture_register_suite(suite);
+	torture_register_suite(ctx, suite);
 
 	return NT_STATUS_OK;
 }
diff --git a/source4/torture/drs/drs_init.c b/source4/torture/drs/drs_init.c
index 2dcb6f1..bbe246d 100644
--- a/source4/torture/drs/drs_init.c
+++ b/source4/torture/drs/drs_init.c
@@ -65,17 +65,16 @@ static struct torture_suite * torture_drs_unit_suite(TALLOC_CTX *mem_ctx,
 NTSTATUS torture_drs_init(TALLOC_CTX *ctx)
 {
 	struct torture_suite *suite;
-	TALLOC_CTX *mem_ctx = talloc_autofree_context();
 
 	/* register RPC related test cases */
-	suite = torture_drs_rpc_suite(mem_ctx, "drs.rpc");
+	suite = torture_drs_rpc_suite(ctx, "drs.rpc");
 	if (!suite) return NT_STATUS_NO_MEMORY;
-	torture_register_suite(suite);
+	torture_register_suite(ctx, suite);
 
 	/* register DRS Unit test cases */
-	suite = torture_drs_unit_suite(mem_ctx, "drs.unit");
+	suite = torture_drs_unit_suite(ctx, "drs.unit");
 	if (!suite) return NT_STATUS_NO_MEMORY;
-	torture_register_suite(suite);
+	torture_register_suite(ctx, suite);
 
 	return NT_STATUS_OK;
 }
diff --git a/source4/torture/krb5/kdc-heimdal.c b/source4/torture/krb5/kdc-heimdal.c
index b6c8117..2cf972c 100644
--- a/source4/torture/krb5/kdc-heimdal.c
+++ b/source4/torture/krb5/kdc-heimdal.c
@@ -687,7 +687,7 @@ static bool torture_krb5_as_req_aes_rc4(struct torture_context *tctx)
 
 NTSTATUS torture_krb5_init(TALLOC_CTX *ctx)
 {
-	struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "krb5");
+	struct torture_suite *suite = torture_suite_create(ctx, "krb5");
 	struct torture_suite *kdc_suite = torture_suite_create(suite, "kdc");
 	suite->description = talloc_strdup(suite, "Kerberos tests");
 	kdc_suite->description = talloc_strdup(kdc_suite, "Kerberos KDC tests");
@@ -719,6 +719,6 @@ NTSTATUS torture_krb5_init(TALLOC_CTX *ctx)
 	torture_suite_add_suite(kdc_suite, torture_krb5_canon(kdc_suite));
 	torture_suite_add_suite(suite, kdc_suite);
 
-	torture_register_suite(suite);
+	torture_register_suite(ctx, suite);
 	return NT_STATUS_OK;
 }
diff --git a/source4/torture/krb5/kdc-mit.c b/source4/torture/krb5/kdc-mit.c
index 882627e..2334609 100644
--- a/source4/torture/krb5/kdc-mit.c
+++ b/source4/torture/krb5/kdc-mit.c
@@ -41,7 +41,7 @@ static bool test_skip(struct torture_context *tctx)
 NTSTATUS torture_krb5_init(TALLOC_CTX *ctx)
 {
 	struct torture_suite *suite =
-		torture_suite_create(talloc_autofree_context(), "krb5");
+		torture_suite_create(ctx, "krb5");
 	struct torture_suite *kdc_suite = torture_suite_create(suite, "kdc");
 	suite->description = talloc_strdup(suite, "Kerberos tests");
 	kdc_suite->description = talloc_strdup(kdc_suite, "Kerberos KDC tests");
@@ -50,7 +50,7 @@ NTSTATUS torture_krb5_init(TALLOC_CTX *ctx)
 
 	torture_suite_add_suite(suite, kdc_suite);
 
-	torture_register_suite(suite);
+	torture_register_suite(ctx, suite);
 
 	return NT_STATUS_OK;
 }
diff --git a/source4/torture/ldap/common.c b/source4/torture/ldap/common.c
index 50c5e03..9d53da4 100644
--- a/source4/torture/ldap/common.c
+++ b/source4/torture/ldap/common.c
@@ -131,7 +131,7 @@ NTSTATUS torture_ldap_close(struct ldap_connection *conn)
 
 NTSTATUS torture_ldap_init(TALLOC_CTX *ctx)
 {
-	struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "ldap");
+	struct torture_suite *suite = torture_suite_create(ctx, "ldap");
 	torture_suite_add_simple_test(suite, "bench-cldap", torture_bench_cldap);
 	torture_suite_add_simple_test(suite, "basic", torture_ldap_basic);
 	torture_suite_add_simple_test(suite, "sort", torture_ldap_sort);
@@ -144,7 +144,7 @@ NTSTATUS torture_ldap_init(TALLOC_CTX *ctx)
 
 	suite->description = talloc_strdup(suite, "LDAP and CLDAP tests");
 
-	torture_register_suite(suite);
+	torture_register_suite(ctx, suite);
 
 	return NT_STATUS_OK;
 }
diff --git a/source4/torture/libnet/libnet.c b/source4/torture/libnet/libnet.c
index 7b9c31a..faf7bca 100644
--- a/source4/torture/libnet/libnet.c
+++ b/source4/torture/libnet/libnet.c
@@ -27,7 +27,7 @@
 NTSTATUS torture_net_init(TALLOC_CTX *ctx)
 {
 	struct torture_suite *suite = torture_suite_create(
-		talloc_autofree_context(), "net");
+		ctx, "net");
 
 	torture_suite_add_simple_test(suite, "userinfo", torture_userinfo);
 	torture_suite_add_simple_test(suite, "useradd", torture_useradd);
@@ -64,7 +64,7 @@ NTSTATUS torture_net_init(TALLOC_CTX *ctx)
 
 	suite->description = talloc_strdup(suite, "libnet convenience interface tests");
 
-	torture_register_suite(suite);
+	torture_register_suite(ctx, suite);
 
 	return NT_STATUS_OK;
 }
diff --git a/source4/torture/libnetapi/libnetapi.c b/source4/torture/libnetapi/libnetapi.c
index 856b2c8..9d3973a 100644
--- a/source4/torture/libnetapi/libnetapi.c
+++ b/source4/torture/libnetapi/libnetapi.c
@@ -84,7 +84,7 @@ NTSTATUS torture_libnetapi_init(TALLOC_CTX *ctx)
 {
 	struct torture_suite *suite;
 
-	suite = torture_suite_create(talloc_autofree_context(), "netapi");
+	suite = torture_suite_create(ctx, "netapi");
 
 	torture_suite_add_simple_test(suite, "server", torture_libnetapi_server);
 	torture_suite_add_simple_test(suite, "group", torture_libnetapi_group);
@@ -93,7 +93,7 @@ NTSTATUS torture_libnetapi_init(TALLOC_CTX *ctx)
 
 	suite->description = talloc_strdup(suite, "libnetapi convenience interface tests");
 
-	torture_register_suite(suite);
+	torture_register_suite(ctx, suite);
 
 	return NT_STATUS_OK;
 }
diff --git a/source4/torture/libsmbclient/libsmbclient.c b/source4/torture/libsmbclient/libsmbclient.c
index c714a97..b93fda0 100644
--- a/source4/torture/libsmbclient/libsmbclient.c
+++ b/source4/torture/libsmbclient/libsmbclient.c
@@ -205,7 +205,7 @@ NTSTATUS torture_libsmbclient_init(TALLOC_CTX *ctx)
 {
 	struct torture_suite *suite;
 
-	suite = torture_suite_create(talloc_autofree_context(), "libsmbclient");
+	suite = torture_suite_create(ctx, "libsmbclient");
 
 	torture_suite_add_simple_test(suite, "version", torture_libsmbclient_version);
 	torture_suite_add_simple_test(suite, "initialize", torture_libsmbclient_initialize);
@@ -215,7 +215,7 @@ NTSTATUS torture_libsmbclient_init(TALLOC_CTX *ctx)
 
 	suite->description = talloc_strdup(suite, "libsmbclient interface tests");
 
-	torture_register_suite(suite);
+	torture_register_suite(ctx, suite);
 
 	return NT_STATUS_OK;
 }
diff --git a/source4/torture/local/local.c b/source4/torture/local/local.c
index e723152..d1c523b 100644
--- a/source4/torture/local/local.c
+++ b/source4/torture/local/local.c
@@ -83,7 +83,7 @@ NTSTATUS torture_local_init(TALLOC_CTX *ctx)
 {
 	int i;
 	struct torture_suite *suite = torture_suite_create(
-		talloc_autofree_context(), "local");
+		ctx, "local");
 	
 	torture_suite_add_simple_test(suite, "talloc", torture_local_talloc);
 	torture_suite_add_simple_test(suite, "replace", torture_local_replace);
@@ -103,12 +103,12 @@ NTSTATUS torture_local_init(TALLOC_CTX *ctx)
 
 	for (i = 0; suite_generators[i]; i++)
 		torture_suite_add_suite(suite,
-					suite_generators[i](talloc_autofree_context()));
+					suite_generators[i](ctx));
 	
 	suite->description = talloc_strdup(suite, 
 					   "Local, Samba-specific tests");
 
-	torture_register_suite(suite);
+	torture_register_suite(ctx, suite);
 
 	return NT_STATUS_OK;
 }
diff --git a/source4/torture/nbench/nbench.c b/source4/torture/nbench/nbench.c
index 979f16e..8e4a984 100644
--- a/source4/torture/nbench/nbench.c
+++ b/source4/torture/nbench/nbench.c
@@ -287,12 +287,12 @@ bool torture_nbench(struct torture_context *torture)
 NTSTATUS torture_nbench_init(TALLOC_CTX *ctx)
 {
 	struct torture_suite *suite = torture_suite_create(
-						   talloc_autofree_context(), "bench");
+						   ctx, "bench");
 
 	torture_suite_add_simple_test(suite, "nbench", torture_nbench);
 
 	suite->description = talloc_strdup(suite, "Benchmarks");
 
-	torture_register_suite(suite);
+	torture_register_suite(ctx, suite);
 	return NT_STATUS_OK;
 }
diff --git a/source4/torture/nbt/nbt.c b/source4/torture/nbt/nbt.c
index ac53c91..f350885 100644
--- a/source4/torture/nbt/nbt.c
+++ b/source4/torture/nbt/nbt.c
@@ -51,7 +51,7 @@ bool torture_nbt_get_name(struct torture_context *tctx,
 NTSTATUS torture_nbt_init(TALLOC_CTX *ctx)
 {
 	struct torture_suite *suite = torture_suite_create(
-		talloc_autofree_context(), "nbt");
+		ctx, "nbt");
 	/* nbt tests */
 	torture_suite_add_suite(suite, torture_nbt_register(suite));
 	torture_suite_add_suite(suite, torture_nbt_wins(suite));
@@ -63,7 +63,7 @@ NTSTATUS torture_nbt_init(TALLOC_CTX *ctx)
 	suite->description = talloc_strdup(suite, 
 					 "NetBIOS over TCP/IP and WINS tests");
 
-	torture_register_suite(suite);
+	torture_register_suite(ctx, suite);
 
 	return NT_STATUS_OK;
 }
diff --git a/source4/torture/ntp/ntp_signd.c b/source4/torture/ntp/ntp_signd.c
index 1963e57..d2a4181 100644
--- a/source4/torture/ntp/ntp_signd.c
+++ b/source4/torture/ntp/ntp_signd.c
@@ -286,7 +286,7 @@ static bool test_ntp_signd(struct torture_context *tctx,
 
 NTSTATUS torture_ntp_init(TALLOC_CTX *ctx)
 {
-	struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "ntp");
+	struct torture_suite *suite = torture_suite_create(ctx, "ntp");
 	struct torture_rpc_tcase *tcase;
 
 	tcase = torture_suite_add_machine_workstation_rpc_iface_tcase(suite,
@@ -296,7 +296,7 @@ NTSTATUS torture_ntp_init(TALLOC_CTX *ctx)
 
 	suite->description = talloc_strdup(suite, "NTP tests");
 
-	torture_register_suite(suite);
+	torture_register_suite(ctx, suite);
 
 	return NT_STATUS_OK;
 }
diff --git a/source4/torture/rap/rap.c b/source4/torture/rap/rap.c
index 043154b..054e011 100644
--- a/source4/torture/rap/rap.c
+++ b/source4/torture/rap/rap.c
@@ -243,7 +243,7 @@ bool torture_rap_scan(struct torture_context *torture, struct smbcli_state *cli)
 
 NTSTATUS torture_rap_init(TALLOC_CTX *ctx)
 {
-	struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "rap");
+	struct torture_suite *suite = torture_suite_create(ctx, "rap");
 	struct torture_suite *suite_basic = torture_suite_create(suite, "basic");
 
 	torture_suite_add_suite(suite, suite_basic);
@@ -269,7 +269,7 @@ NTSTATUS torture_rap_init(TALLOC_CTX *ctx)
 	suite->description = talloc_strdup(suite, 
 						"Remote Administration Protocol tests");
 
-	torture_register_suite(suite);
+	torture_register_suite(ctx, suite);
 
 	return NT_STATUS_OK;
 }
diff --git a/source4/torture/raw/raw.c b/source4/torture/raw/raw.c
index 5b237d3..a225efe 100644
--- a/source4/torture/raw/raw.c
+++ b/source4/torture/raw/raw.c
@@ -26,7 +26,7 @@
 NTSTATUS torture_raw_init(TALLOC_CTX *ctx)
 {
 	struct torture_suite *suite = torture_suite_create(
-		talloc_autofree_context(), "raw");
+		ctx, "raw");
 	/* RAW smb tests */
 	torture_suite_add_simple_test(suite, "bench-oplock", torture_bench_oplock);
 	torture_suite_add_simple_test(suite, "ping-pong", torture_ping_pong);
@@ -79,7 +79,7 @@ NTSTATUS torture_raw_init(TALLOC_CTX *ctx)
 
 	suite->description = talloc_strdup(suite, "Tests for the raw SMB interface");
 
-	torture_register_suite(suite);
+	torture_register_suite(ctx, suite);
 
 	return NT_STATUS_OK;
 }
diff --git a/source4/torture/rpc/rpc.c b/source4/torture/rpc/rpc.c
index 12dcced..36148cc 100644
--- a/source4/torture/rpc/rpc.c
+++ b/source4/torture/rpc/rpc.c
@@ -484,7 +484,7 @@ _PUBLIC_ struct torture_test *torture_rpc_tcase_add_test_ex(
 
 NTSTATUS torture_rpc_init(TALLOC_CTX *ctx)
 {
-	struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "rpc");
+	struct torture_suite *suite = torture_suite_create(ctx, "rpc");
 
 	ndr_table_init();
 
@@ -570,7 +570,7 @@ NTSTATUS torture_rpc_init(TALLOC_CTX *ctx)
 
 	suite->description = talloc_strdup(suite, "DCE/RPC protocol and interface tests");
 
-	torture_register_suite(suite);
+	torture_register_suite(ctx, suite);
 
 	return NT_STATUS_OK;
 }
diff --git a/source4/torture/smb2/smb2.c b/source4/torture/smb2/smb2.c
index 3c3c22a..043372f 100644
--- a/source4/torture/smb2/smb2.c
+++ b/source4/torture/smb2/smb2.c
@@ -145,7 +145,7 @@ struct torture_test *torture_suite_add_2smb2_test(struct torture_suite *suite,
 
 NTSTATUS torture_smb2_init(TALLOC_CTX *ctx)
 {
-	struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "smb2");
+	struct torture_suite *suite = torture_suite_create(ctx, "smb2");
 	torture_suite_add_simple_test(suite, "connect", torture_smb2_connect);
 	torture_suite_add_suite(suite, torture_smb2_scan_init());
 	torture_suite_add_suite(suite, torture_smb2_getinfo_init());
@@ -180,7 +180,7 @@ NTSTATUS torture_smb2_init(TALLOC_CTX *ctx)
 
 	suite->description = talloc_strdup(suite, "SMB2-specific tests");
 
-	torture_register_suite(suite);
+	torture_register_suite(ctx, suite);
 
 	return NT_STATUS_OK;
 }
diff --git a/source4/torture/smbtorture.h b/source4/torture/smbtorture.h
index 7480f24..5a75f06 100644
--- a/source4/torture/smbtorture.h
+++ b/source4/torture/smbtorture.h
@@ -35,7 +35,7 @@ extern int torture_numasync;
 
 struct torture_test;
 int torture_init(TALLOC_CTX *);
-bool torture_register_suite(struct torture_suite *suite);
+bool torture_register_suite(TALLOC_CTX *, struct torture_suite *suite);
 void torture_shell(struct torture_context *tctx);
 void torture_print_testsuites(bool structured);
 bool torture_run_named_tests(struct torture_context *torture, const char *name,
diff --git a/source4/torture/torture.c b/source4/torture/torture.c
index 3ef1f3b..cc29ffa 100644
--- a/source4/torture/torture.c
+++ b/source4/torture/torture.c
@@ -33,13 +33,13 @@ _PUBLIC_ int torture_numasync=100;
 
 struct torture_suite *torture_root = NULL;
 
-bool torture_register_suite(struct torture_suite *suite)
+bool torture_register_suite(TALLOC_CTX *mem_ctx, struct torture_suite *suite)
 {
 	if (!suite)
 		return true;
 
 	if (torture_root == NULL)
-		torture_root = talloc_zero(talloc_autofree_context(), struct torture_suite);
+		torture_root = talloc_zero(mem_ctx, struct torture_suite);
 
 	return torture_suite_add_suite(torture_root, suite);
 }
diff --git a/source4/torture/unix/unix.c b/source4/torture/unix/unix.c
index 0ea1b51..8ee3d8d 100644
--- a/source4/torture/unix/unix.c
+++ b/source4/torture/unix/unix.c
@@ -24,7 +24,7 @@
 NTSTATUS torture_unix_init(TALLOC_CTX *ctx)
 {
         struct torture_suite *suite =
-                torture_suite_create(talloc_autofree_context(), "unix");
+                torture_suite_create(ctx, "unix");
 
         suite->description =
                 talloc_strdup(suite, "CIFS UNIX extensions tests");
@@ -34,7 +34,7 @@ NTSTATUS torture_unix_init(TALLOC_CTX *ctx)
 	torture_suite_add_simple_test(suite,
 			"info2", unix_torture_unix_info2);
 
-        return (torture_register_suite(suite)) ? NT_STATUS_OK
+        return (torture_register_suite(ctx, suite)) ? NT_STATUS_OK
                                         : NT_STATUS_UNSUCCESSFUL;
 
 }
diff --git a/source4/torture/vfs/vfs.c b/source4/torture/vfs/vfs.c
index 8c1f1ff6..e167576 100644
--- a/source4/torture/vfs/vfs.c
+++ b/source4/torture/vfs/vfs.c
@@ -104,7 +104,7 @@ struct torture_test *torture_suite_add_2ns_smb2_test(struct torture_suite *suite
 NTSTATUS torture_vfs_init(TALLOC_CTX *ctx)
 {
 	struct torture_suite *suite = torture_suite_create(
-		talloc_autofree_context(), "vfs");
+		ctx, "vfs");
 
 	suite->description = talloc_strdup(suite, "VFS modules tests");
 
@@ -113,7 +113,7 @@ NTSTATUS torture_vfs_init(TALLOC_CTX *ctx)
 	torture_suite_add_suite(suite, torture_acl_xattr());
 	torture_suite_add_suite(suite, torture_vfs_fruit_file_id());
 
-	torture_register_suite(suite);
+	torture_register_suite(ctx, suite);
 
 	return NT_STATUS_OK;
 }
diff --git a/source4/torture/winbind/winbind.c b/source4/torture/winbind/winbind.c
index 74de381..d05918a 100644
--- a/source4/torture/winbind/winbind.c
+++ b/source4/torture/winbind/winbind.c
@@ -292,12 +292,12 @@ static bool torture_winbind_pac_krb5(struct torture_context *tctx)
 
 NTSTATUS torture_winbind_init(TALLOC_CTX *ctx)
 {
-	struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "winbind");
+	struct torture_suite *suite = torture_suite_create(ctx, "winbind");
 	struct torture_suite *pac_suite;
 	torture_suite_add_suite(suite, torture_winbind_struct_init());
 	torture_suite_add_suite(suite, torture_wbclient());
 
-	pac_suite = torture_suite_create(talloc_autofree_context(), "pac");
+	pac_suite = torture_suite_create(ctx, "pac");
 	torture_suite_add_simple_test(pac_suite,
 				      "GSSAPI", torture_winbind_pac_gssapi);
 	torture_suite_add_simple_test(pac_suite,
@@ -311,7 +311,7 @@ NTSTATUS torture_winbind_init(TALLOC_CTX *ctx)
 
 	suite->description = talloc_strdup(suite, "WINBIND tests");
 
-	torture_register_suite(suite);
+	torture_register_suite(ctx, suite);
 
 	return NT_STATUS_OK;
 }
-- 
2.7.4


From 947dbb6b99dbf4ac1cf63fdb17669211555ae73c Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Mon, 24 Apr 2017 15:07:49 -0700
Subject: [PATCH 05/35] s4: torture: Pass TALLOC_CTX * to
 torture_delay_write().

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 source4/torture/basic/base.c       | 2 +-
 source4/torture/basic/delaywrite.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/source4/torture/basic/base.c b/source4/torture/basic/base.c
index 6e989bf..d6f0a7b 100644
--- a/source4/torture/basic/base.c
+++ b/source4/torture/basic/base.c
@@ -1972,7 +1972,7 @@ NTSTATUS torture_base_init(TALLOC_CTX *ctx)
 	torture_suite_add_1smb_test(suite, "chkpath",  torture_chkpath_test);
 	torture_suite_add_1smb_test(suite, "secleak",  torture_sec_leak);
 	torture_suite_add_simple_test(suite, "disconnect",  torture_disconnect);
-	torture_suite_add_suite(suite, torture_delay_write());
+	torture_suite_add_suite(suite, torture_delay_write(suite));
 	torture_suite_add_simple_test(suite, "samba3error", torture_samba3_errorpaths);
 	torture_suite_add_1smb_test(suite, "casetable", torture_casetable);
 	torture_suite_add_1smb_test(suite, "utable", torture_utable);
diff --git a/source4/torture/basic/delaywrite.c b/source4/torture/basic/delaywrite.c
index 67788f4..45a5f4e 100644
--- a/source4/torture/basic/delaywrite.c
+++ b/source4/torture/basic/delaywrite.c
@@ -3068,9 +3068,9 @@ static bool test_directory_update8(struct torture_context *tctx, struct smbcli_s
 /*
    testing of delayed update of write_time
 */
-struct torture_suite *torture_delay_write(void)
+struct torture_suite *torture_delay_write(TALLOC_CTX *ctx)
 {
-	struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "delaywrite");
+	struct torture_suite *suite = torture_suite_create(ctx, "delaywrite");
 
 	torture_suite_add_2smb_test(suite, "finfo update on close", test_finfo_after_write);
 	torture_suite_add_1smb_test(suite, "delayed update of write time", test_delayed_write_update);
-- 
2.7.4


From a1d53ed0bbcac1fbe9c6e4ea0c312c58fc1d4f6b Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Mon, 24 Apr 2017 15:09:36 -0700
Subject: [PATCH 06/35] s4: torture: Add TALLOC_CTX * to
 torture_winbind_init().

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 nsswitch/libwbclient/tests/wbclient.c | 4 ++--
 source4/torture/winbind/winbind.c     | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/nsswitch/libwbclient/tests/wbclient.c b/nsswitch/libwbclient/tests/wbclient.c
index b3c93a1..c5428af 100644
--- a/nsswitch/libwbclient/tests/wbclient.c
+++ b/nsswitch/libwbclient/tests/wbclient.c
@@ -925,9 +925,9 @@ static bool test_wbc_getgroups(struct torture_context *tctx)
 	return true;
 }
 
-struct torture_suite *torture_wbclient(void)
+struct torture_suite *torture_wbclient(TALLOC_CTX *ctx)
 {
-	struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "wbclient");
+	struct torture_suite *suite = torture_suite_create(ctx, "wbclient");
 
 	torture_suite_add_simple_test(suite, "wbcPing", test_wbc_ping);
 	torture_suite_add_simple_test(suite, "wbcPingDc", test_wbc_pingdc);
diff --git a/source4/torture/winbind/winbind.c b/source4/torture/winbind/winbind.c
index d05918a..fec95e8 100644
--- a/source4/torture/winbind/winbind.c
+++ b/source4/torture/winbind/winbind.c
@@ -295,7 +295,7 @@ NTSTATUS torture_winbind_init(TALLOC_CTX *ctx)
 	struct torture_suite *suite = torture_suite_create(ctx, "winbind");
 	struct torture_suite *pac_suite;
 	torture_suite_add_suite(suite, torture_winbind_struct_init());
-	torture_suite_add_suite(suite, torture_wbclient());
+	torture_suite_add_suite(suite, torture_wbclient(suite));
 
 	pac_suite = torture_suite_create(ctx, "pac");
 	torture_suite_add_simple_test(pac_suite,
-- 
2.7.4


From fd2dc361640cbf947c764cba5c9f0212026f2f25 Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Mon, 24 Apr 2017 15:11:19 -0700
Subject: [PATCH 07/35] s4: torture: Add TALLOC_CTX * to
 torture_smb2_acls_init().

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 source4/torture/smb2/acls.c | 4 ++--
 source4/torture/smb2/smb2.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/source4/torture/smb2/acls.c b/source4/torture/smb2/acls.c
index beb5abf..9dee159 100644
--- a/source4/torture/smb2/acls.c
+++ b/source4/torture/smb2/acls.c
@@ -2090,9 +2090,9 @@ done:
 /*
    basic testing of SMB2 ACLs
 */
-struct torture_suite *torture_smb2_acls_init(void)
+struct torture_suite *torture_smb2_acls_init(TALLOC_CTX *ctx)
 {
-	struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "acls");
+	struct torture_suite *suite = torture_suite_create(ctx, "acls");
 
 	torture_suite_add_1smb2_test(suite, "CREATOR", test_creator_sid);
 	torture_suite_add_1smb2_test(suite, "GENERIC", test_generic_bits);
diff --git a/source4/torture/smb2/smb2.c b/source4/torture/smb2/smb2.c
index 043372f..14fd339 100644
--- a/source4/torture/smb2/smb2.c
+++ b/source4/torture/smb2/smb2.c
@@ -153,7 +153,7 @@ NTSTATUS torture_smb2_init(TALLOC_CTX *ctx)
 	torture_suite_add_suite(suite, torture_smb2_lock_init());
 	torture_suite_add_suite(suite, torture_smb2_read_init());
 	torture_suite_add_suite(suite, torture_smb2_create_init());
-	torture_suite_add_suite(suite, torture_smb2_acls_init());
+	torture_suite_add_suite(suite, torture_smb2_acls_init(suite));
 	torture_suite_add_suite(suite, torture_smb2_notify_init());
 	torture_suite_add_suite(suite, torture_smb2_notify_disabled_init());
 	torture_suite_add_suite(suite, torture_smb2_durable_open_init());
-- 
2.7.4


From 017b1e070246d3959ddcce25e1988d1059b14bf5 Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Mon, 24 Apr 2017 15:13:10 -0700
Subject: [PATCH 08/35] s4: torture: Add TALLOC_CTX * to
 torture_smb2_compound_find_init() and torture_smb2_compound_init().

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 source4/torture/smb2/compound.c | 8 ++++----
 source4/torture/smb2/smb2.c     | 4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/source4/torture/smb2/compound.c b/source4/torture/smb2/compound.c
index 1480576..e501870 100644
--- a/source4/torture/smb2/compound.c
+++ b/source4/torture/smb2/compound.c
@@ -1214,9 +1214,9 @@ done:
 	return ret;
 }
 
-struct torture_suite *torture_smb2_compound_init(void)
+struct torture_suite *torture_smb2_compound_init(TALLOC_CTX *ctx)
 {
-	struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "compound");
+	struct torture_suite *suite = torture_suite_create(ctx, "compound");
 
 	torture_suite_add_1smb2_test(suite, "related1", test_compound_related1);
 	torture_suite_add_1smb2_test(suite, "related2", test_compound_related2);
@@ -1236,9 +1236,9 @@ struct torture_suite *torture_smb2_compound_init(void)
 	return suite;
 }
 
-struct torture_suite *torture_smb2_compound_find_init(void)
+struct torture_suite *torture_smb2_compound_find_init(TALLOC_CTX *ctx)
 {
-	struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "compound_find");
+	struct torture_suite *suite = torture_suite_create(ctx, "compound_find");
 
 	torture_suite_add_1smb2_test(suite, "compound_find_related", test_compound_find_related);
 	torture_suite_add_1smb2_test(suite, "compound_find_unrelated", test_compound_find_unrelated);
diff --git a/source4/torture/smb2/smb2.c b/source4/torture/smb2/smb2.c
index 14fd339..cb1eb76 100644
--- a/source4/torture/smb2/smb2.c
+++ b/source4/torture/smb2/smb2.c
@@ -161,8 +161,8 @@ NTSTATUS torture_smb2_init(TALLOC_CTX *ctx)
 	torture_suite_add_suite(suite, torture_smb2_durable_v2_open_init());
 	torture_suite_add_suite(suite, torture_smb2_dir_init());
 	torture_suite_add_suite(suite, torture_smb2_lease_init());
-	torture_suite_add_suite(suite, torture_smb2_compound_init());
-	torture_suite_add_suite(suite, torture_smb2_compound_find_init());
+	torture_suite_add_suite(suite, torture_smb2_compound_init(suite));
+	torture_suite_add_suite(suite, torture_smb2_compound_find_init(suite));
 	torture_suite_add_suite(suite, torture_smb2_oplocks_init());
 	torture_suite_add_suite(suite, torture_smb2_kernel_oplocks_init());
 	torture_suite_add_suite(suite, torture_smb2_streams_init());
-- 
2.7.4


From 191af09acd9517e942401da8ff205449881d3b64 Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Mon, 24 Apr 2017 15:17:45 -0700
Subject: [PATCH 09/35] s4: torture: Add a TALLOC_CTX * to
 torture_smb2_create_init().

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 source4/torture/smb2/create.c | 4 ++--
 source4/torture/smb2/smb2.c   | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/source4/torture/smb2/create.c b/source4/torture/smb2/create.c
index 09a17be..397c075 100644
--- a/source4/torture/smb2/create.c
+++ b/source4/torture/smb2/create.c
@@ -1736,9 +1736,9 @@ done:
 /*
    basic testing of SMB2 read
 */
-struct torture_suite *torture_smb2_create_init(void)
+struct torture_suite *torture_smb2_create_init(TALLOC_CTX *ctx)
 {
-	struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "create");
+	struct torture_suite *suite = torture_suite_create(ctx, "create");
 
 	torture_suite_add_1smb2_test(suite, "gentest", test_create_gentest);
 	torture_suite_add_1smb2_test(suite, "blob", test_create_blob);
diff --git a/source4/torture/smb2/smb2.c b/source4/torture/smb2/smb2.c
index cb1eb76..dd3ad0f 100644
--- a/source4/torture/smb2/smb2.c
+++ b/source4/torture/smb2/smb2.c
@@ -152,7 +152,7 @@ NTSTATUS torture_smb2_init(TALLOC_CTX *ctx)
 	torture_suite_add_simple_test(suite, "setinfo", torture_smb2_setinfo);
 	torture_suite_add_suite(suite, torture_smb2_lock_init());
 	torture_suite_add_suite(suite, torture_smb2_read_init());
-	torture_suite_add_suite(suite, torture_smb2_create_init());
+	torture_suite_add_suite(suite, torture_smb2_create_init(suite));
 	torture_suite_add_suite(suite, torture_smb2_acls_init(suite));
 	torture_suite_add_suite(suite, torture_smb2_notify_init());
 	torture_suite_add_suite(suite, torture_smb2_notify_disabled_init());
-- 
2.7.4


From 5afeeca179ac006ff4d8f09a657d74e65ebd52fc Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Mon, 24 Apr 2017 15:19:12 -0700
Subject: [PATCH 10/35] s4: torture: Add a TALLOC_CTX * to
 torture_smb2_crediting_init().

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 source4/torture/smb2/credits.c | 4 ++--
 source4/torture/smb2/smb2.c    | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/source4/torture/smb2/credits.c b/source4/torture/smb2/credits.c
index 43550c3..b06bae7 100644
--- a/source4/torture/smb2/credits.c
+++ b/source4/torture/smb2/credits.c
@@ -254,9 +254,9 @@ done:
 	return ret;
 }
 
-struct torture_suite *torture_smb2_crediting_init(void)
+struct torture_suite *torture_smb2_crediting_init(TALLOC_CTX *ctx)
 {
-	struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "credits");
+	struct torture_suite *suite = torture_suite_create(ctx, "credits");
 
 	torture_suite_add_1smb2_test(suite, "session_setup_credits_granted", test_session_setup_credits_granted);
 	torture_suite_add_1smb2_test(suite, "single_req_credits_granted", test_single_req_credits_granted);
diff --git a/source4/torture/smb2/smb2.c b/source4/torture/smb2/smb2.c
index dd3ad0f..b9997dd 100644
--- a/source4/torture/smb2/smb2.c
+++ b/source4/torture/smb2/smb2.c
@@ -174,7 +174,7 @@ NTSTATUS torture_smb2_init(TALLOC_CTX *ctx)
 	torture_suite_add_suite(suite, torture_smb2_replay_init());
 	torture_suite_add_simple_test(suite, "dosmode", torture_smb2_dosmode);
 	torture_suite_add_simple_test(suite, "maxfid", torture_smb2_maxfid);
-	torture_suite_add_suite(suite, torture_smb2_crediting_init());
+	torture_suite_add_suite(suite, torture_smb2_crediting_init(suite));
 
 	torture_suite_add_suite(suite, torture_smb2_doc_init());
 
-- 
2.7.4


From c9117dbb137f3de1d44599a9a4ab02266846c8b2 Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Mon, 24 Apr 2017 15:20:58 -0700
Subject: [PATCH 11/35] s4: torture: Add a TALLOC_CTX * to
 torture_smb2_doc_init().

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 source4/torture/smb2/delete-on-close.c | 4 ++--
 source4/torture/smb2/smb2.c            | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/source4/torture/smb2/delete-on-close.c b/source4/torture/smb2/delete-on-close.c
index a12c2ab..44ef33e 100644
--- a/source4/torture/smb2/delete-on-close.c
+++ b/source4/torture/smb2/delete-on-close.c
@@ -519,9 +519,9 @@ static bool test_doc_create_if_exist(struct torture_context *tctx, struct smb2_t
 /*
  *  Extreme testing of Delete On Close and permissions
  */
-struct torture_suite *torture_smb2_doc_init(void)
+struct torture_suite *torture_smb2_doc_init(TALLOC_CTX *ctx)
 {
-	struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "delete-on-close-perms");
+	struct torture_suite *suite = torture_suite_create(ctx, "delete-on-close-perms");
 
 	torture_suite_add_1smb2_test(suite, "OVERWRITE_IF", test_doc_overwrite_if);
 	torture_suite_add_1smb2_test(suite, "OVERWRITE_IF Existing", test_doc_overwrite_if_exist);
diff --git a/source4/torture/smb2/smb2.c b/source4/torture/smb2/smb2.c
index b9997dd..2997744 100644
--- a/source4/torture/smb2/smb2.c
+++ b/source4/torture/smb2/smb2.c
@@ -176,7 +176,7 @@ NTSTATUS torture_smb2_init(TALLOC_CTX *ctx)
 	torture_suite_add_simple_test(suite, "maxfid", torture_smb2_maxfid);
 	torture_suite_add_suite(suite, torture_smb2_crediting_init(suite));
 
-	torture_suite_add_suite(suite, torture_smb2_doc_init());
+	torture_suite_add_suite(suite, torture_smb2_doc_init(suite));
 
 	suite->description = talloc_strdup(suite, "SMB2-specific tests");
 
-- 
2.7.4


From b2b305d1b7a51d13ec9e43c2e07392404e208c7f Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Mon, 24 Apr 2017 15:22:37 -0700
Subject: [PATCH 12/35] s4: torture: Add a TALLOC_CTX * to
 torture_smb2_dir_init().

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 source4/torture/smb2/dir.c  | 4 ++--
 source4/torture/smb2/smb2.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/source4/torture/smb2/dir.c b/source4/torture/smb2/dir.c
index db906db..7da104b 100644
--- a/source4/torture/smb2/dir.c
+++ b/source4/torture/smb2/dir.c
@@ -1380,10 +1380,10 @@ done:
 	return ret;
 }
 
-struct torture_suite *torture_smb2_dir_init(void)
+struct torture_suite *torture_smb2_dir_init(TALLOC_CTX *ctx)
 {
 	struct torture_suite *suite =
-	    torture_suite_create(talloc_autofree_context(), "dir");
+	    torture_suite_create(ctx, "dir");
 
 	torture_suite_add_1smb2_test(suite, "find", test_find);
 	torture_suite_add_1smb2_test(suite, "fixed", test_fixed);
diff --git a/source4/torture/smb2/smb2.c b/source4/torture/smb2/smb2.c
index 2997744..5175f34 100644
--- a/source4/torture/smb2/smb2.c
+++ b/source4/torture/smb2/smb2.c
@@ -159,7 +159,7 @@ NTSTATUS torture_smb2_init(TALLOC_CTX *ctx)
 	torture_suite_add_suite(suite, torture_smb2_durable_open_init());
 	torture_suite_add_suite(suite, torture_smb2_durable_open_disconnect_init());
 	torture_suite_add_suite(suite, torture_smb2_durable_v2_open_init());
-	torture_suite_add_suite(suite, torture_smb2_dir_init());
+	torture_suite_add_suite(suite, torture_smb2_dir_init(suite));
 	torture_suite_add_suite(suite, torture_smb2_lease_init());
 	torture_suite_add_suite(suite, torture_smb2_compound_init(suite));
 	torture_suite_add_suite(suite, torture_smb2_compound_find_init(suite));
-- 
2.7.4


From 305707bde1e4ac2192e1ecd990c2322ce0cff7e6 Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Mon, 24 Apr 2017 15:25:38 -0700
Subject: [PATCH 13/35] s4: torture: Add TALLOC_CTX * to
 torture_smb2_durable_open_disconnect_init(), torture_smb2_durable_open_init()

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 source4/torture/smb2/durable_open.c | 8 ++++----
 source4/torture/smb2/smb2.c         | 5 +++--
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/source4/torture/smb2/durable_open.c b/source4/torture/smb2/durable_open.c
index 2e68170..17b3b21 100644
--- a/source4/torture/smb2/durable_open.c
+++ b/source4/torture/smb2/durable_open.c
@@ -2753,10 +2753,10 @@ done:
 }
 
 
-struct torture_suite *torture_smb2_durable_open_init(void)
+struct torture_suite *torture_smb2_durable_open_init(TALLOC_CTX *ctx)
 {
 	struct torture_suite *suite =
-	    torture_suite_create(talloc_autofree_context(), "durable-open");
+	    torture_suite_create(ctx, "durable-open");
 
 	torture_suite_add_1smb2_test(suite, "open-oplock", test_durable_open_open_oplock);
 	torture_suite_add_1smb2_test(suite, "open-lease", test_durable_open_open_lease);
@@ -2793,10 +2793,10 @@ struct torture_suite *torture_smb2_durable_open_init(void)
 	return suite;
 }
 
-struct torture_suite *torture_smb2_durable_open_disconnect_init(void)
+struct torture_suite *torture_smb2_durable_open_disconnect_init(TALLOC_CTX *ctx)
 {
 	struct torture_suite *suite =
-	    torture_suite_create(talloc_autofree_context(),
+	    torture_suite_create(ctx,
 				 "durable-open-disconnect");
 
 	torture_suite_add_1smb2_test(suite, "open-oplock-disconnect",
diff --git a/source4/torture/smb2/smb2.c b/source4/torture/smb2/smb2.c
index 5175f34..e801631 100644
--- a/source4/torture/smb2/smb2.c
+++ b/source4/torture/smb2/smb2.c
@@ -156,8 +156,9 @@ NTSTATUS torture_smb2_init(TALLOC_CTX *ctx)
 	torture_suite_add_suite(suite, torture_smb2_acls_init(suite));
 	torture_suite_add_suite(suite, torture_smb2_notify_init());
 	torture_suite_add_suite(suite, torture_smb2_notify_disabled_init());
-	torture_suite_add_suite(suite, torture_smb2_durable_open_init());
-	torture_suite_add_suite(suite, torture_smb2_durable_open_disconnect_init());
+	torture_suite_add_suite(suite, torture_smb2_durable_open_init(suite));
+	torture_suite_add_suite(suite,
+		torture_smb2_durable_open_disconnect_init(suite));
 	torture_suite_add_suite(suite, torture_smb2_durable_v2_open_init());
 	torture_suite_add_suite(suite, torture_smb2_dir_init(suite));
 	torture_suite_add_suite(suite, torture_smb2_lease_init());
-- 
2.7.4


From a99d448dacc0330fb7cbc18898a88ec83b1b12e5 Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Mon, 24 Apr 2017 15:27:01 -0700
Subject: [PATCH 14/35] s4: torture: Add TALLOC_CTX * to
 torture_smb2_durable_v2_open_init().

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 source4/torture/smb2/durable_v2_open.c | 4 ++--
 source4/torture/smb2/smb2.c            | 3 ++-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/source4/torture/smb2/durable_v2_open.c b/source4/torture/smb2/durable_v2_open.c
index b7d8920..3a0e070 100644
--- a/source4/torture/smb2/durable_v2_open.c
+++ b/source4/torture/smb2/durable_v2_open.c
@@ -2004,10 +2004,10 @@ bool test_persistent_open_lease(struct torture_context *tctx,
 	return ret;
 }
 
-struct torture_suite *torture_smb2_durable_v2_open_init(void)
+struct torture_suite *torture_smb2_durable_v2_open_init(TALLOC_CTX *ctx)
 {
 	struct torture_suite *suite =
-	    torture_suite_create(talloc_autofree_context(), "durable-v2-open");
+	    torture_suite_create(ctx, "durable-v2-open");
 
 	torture_suite_add_1smb2_test(suite, "create-blob", test_durable_v2_open_create_blob);
 	torture_suite_add_1smb2_test(suite, "open-oplock", test_durable_v2_open_oplock);
diff --git a/source4/torture/smb2/smb2.c b/source4/torture/smb2/smb2.c
index e801631..2822267 100644
--- a/source4/torture/smb2/smb2.c
+++ b/source4/torture/smb2/smb2.c
@@ -159,7 +159,8 @@ NTSTATUS torture_smb2_init(TALLOC_CTX *ctx)
 	torture_suite_add_suite(suite, torture_smb2_durable_open_init(suite));
 	torture_suite_add_suite(suite,
 		torture_smb2_durable_open_disconnect_init(suite));
-	torture_suite_add_suite(suite, torture_smb2_durable_v2_open_init());
+	torture_suite_add_suite(suite,
+		torture_smb2_durable_v2_open_init(suite));
 	torture_suite_add_suite(suite, torture_smb2_dir_init(suite));
 	torture_suite_add_suite(suite, torture_smb2_lease_init());
 	torture_suite_add_suite(suite, torture_smb2_compound_init(suite));
-- 
2.7.4


From 835c0c31d4ac8beb6510766c155eb9999616d64a Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Mon, 24 Apr 2017 15:30:14 -0700
Subject: [PATCH 15/35] s4: tortute: Add a TALLOC_CTX * to
 torture_smb2_ioctl_init().

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 source4/torture/smb2/ioctl.c | 4 ++--
 source4/torture/smb2/smb2.c  | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/source4/torture/smb2/ioctl.c b/source4/torture/smb2/ioctl.c
index 54a36a8..53476fa 100644
--- a/source4/torture/smb2/ioctl.c
+++ b/source4/torture/smb2/ioctl.c
@@ -6188,9 +6188,9 @@ static bool test_ioctl_dup_extents_dest_lck(struct torture_context *tctx,
 /*
  * testing of SMB2 ioctls
  */
-struct torture_suite *torture_smb2_ioctl_init(void)
+struct torture_suite *torture_smb2_ioctl_init(TALLOC_CTX *ctx)
 {
-	struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "ioctl");
+	struct torture_suite *suite = torture_suite_create(ctx, "ioctl");
 
 	torture_suite_add_1smb2_test(suite, "shadow_copy",
 				     test_ioctl_get_shadow_copy);
diff --git a/source4/torture/smb2/smb2.c b/source4/torture/smb2/smb2.c
index 2822267..23a6df0 100644
--- a/source4/torture/smb2/smb2.c
+++ b/source4/torture/smb2/smb2.c
@@ -168,7 +168,7 @@ NTSTATUS torture_smb2_init(TALLOC_CTX *ctx)
 	torture_suite_add_suite(suite, torture_smb2_oplocks_init());
 	torture_suite_add_suite(suite, torture_smb2_kernel_oplocks_init());
 	torture_suite_add_suite(suite, torture_smb2_streams_init());
-	torture_suite_add_suite(suite, torture_smb2_ioctl_init());
+	torture_suite_add_suite(suite, torture_smb2_ioctl_init(suite));
 	torture_suite_add_suite(suite, torture_smb2_rename_init());
 	torture_suite_add_1smb2_test(suite, "bench-oplock", test_smb2_bench_oplock);
 	torture_suite_add_1smb2_test(suite, "hold-oplock", test_smb2_hold_oplock);
-- 
2.7.4


From 2cd11abc6b6678dcec563dfd47e4847090402fc2 Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Mon, 24 Apr 2017 15:31:25 -0700
Subject: [PATCH 16/35] s4: torture: Add a TALLOC_CTX * to
 torture_smb2_lease_init().

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 source4/torture/smb2/lease.c | 4 ++--
 source4/torture/smb2/smb2.c  | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/source4/torture/smb2/lease.c b/source4/torture/smb2/lease.c
index 3ee915c..b72d76c 100644
--- a/source4/torture/smb2/lease.c
+++ b/source4/torture/smb2/lease.c
@@ -3909,10 +3909,10 @@ static bool test_lease_dynamic_share(struct torture_context *tctx,
 	return ret;
 }
 
-struct torture_suite *torture_smb2_lease_init(void)
+struct torture_suite *torture_smb2_lease_init(TALLOC_CTX *ctx)
 {
 	struct torture_suite *suite =
-	    torture_suite_create(talloc_autofree_context(), "lease");
+	    torture_suite_create(ctx, "lease");
 
 	torture_suite_add_1smb2_test(suite, "request", test_lease_request);
 	torture_suite_add_1smb2_test(suite, "break_twice",
diff --git a/source4/torture/smb2/smb2.c b/source4/torture/smb2/smb2.c
index 23a6df0..70a6b78 100644
--- a/source4/torture/smb2/smb2.c
+++ b/source4/torture/smb2/smb2.c
@@ -162,7 +162,7 @@ NTSTATUS torture_smb2_init(TALLOC_CTX *ctx)
 	torture_suite_add_suite(suite,
 		torture_smb2_durable_v2_open_init(suite));
 	torture_suite_add_suite(suite, torture_smb2_dir_init(suite));
-	torture_suite_add_suite(suite, torture_smb2_lease_init());
+	torture_suite_add_suite(suite, torture_smb2_lease_init(suite));
 	torture_suite_add_suite(suite, torture_smb2_compound_init(suite));
 	torture_suite_add_suite(suite, torture_smb2_compound_find_init(suite));
 	torture_suite_add_suite(suite, torture_smb2_oplocks_init());
-- 
2.7.4


From 04875681d340b977f8afe642973f20a6aae38dfd Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Mon, 24 Apr 2017 15:32:26 -0700
Subject: [PATCH 17/35] s4: torture: Add a TALLOC_CTX * to
 torture_smb2_lock_init().

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 source4/torture/smb2/lock.c | 4 ++--
 source4/torture/smb2/smb2.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/source4/torture/smb2/lock.c b/source4/torture/smb2/lock.c
index ff42211..bf090ad 100644
--- a/source4/torture/smb2/lock.c
+++ b/source4/torture/smb2/lock.c
@@ -3114,10 +3114,10 @@ done:
 
 /* basic testing of SMB2 locking
 */
-struct torture_suite *torture_smb2_lock_init(void)
+struct torture_suite *torture_smb2_lock_init(TALLOC_CTX *ctx)
 {
 	struct torture_suite *suite =
-	    torture_suite_create(talloc_autofree_context(), "lock");
+	    torture_suite_create(ctx, "lock");
 	torture_suite_add_1smb2_test(suite, "valid-request",
 	    test_valid_request);
 	torture_suite_add_1smb2_test(suite, "rw-none", test_lock_rw_none);
diff --git a/source4/torture/smb2/smb2.c b/source4/torture/smb2/smb2.c
index 70a6b78..cf785b8 100644
--- a/source4/torture/smb2/smb2.c
+++ b/source4/torture/smb2/smb2.c
@@ -150,7 +150,7 @@ NTSTATUS torture_smb2_init(TALLOC_CTX *ctx)
 	torture_suite_add_suite(suite, torture_smb2_scan_init());
 	torture_suite_add_suite(suite, torture_smb2_getinfo_init());
 	torture_suite_add_simple_test(suite, "setinfo", torture_smb2_setinfo);
-	torture_suite_add_suite(suite, torture_smb2_lock_init());
+	torture_suite_add_suite(suite, torture_smb2_lock_init(suite));
 	torture_suite_add_suite(suite, torture_smb2_read_init());
 	torture_suite_add_suite(suite, torture_smb2_create_init(suite));
 	torture_suite_add_suite(suite, torture_smb2_acls_init(suite));
-- 
2.7.4


From 2bbc58cdb8de80d065da21c27d9b1584e48dcef9 Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Mon, 24 Apr 2017 15:33:53 -0700
Subject: [PATCH 18/35] s4: torture: Add a TALLOC_CTX * to
 torture_smb2_notify_init().

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 source4/torture/smb2/notify.c | 4 ++--
 source4/torture/smb2/smb2.c   | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/source4/torture/smb2/notify.c b/source4/torture/smb2/notify.c
index 90f5ad9..9fc856c 100644
--- a/source4/torture/smb2/notify.c
+++ b/source4/torture/smb2/notify.c
@@ -2357,9 +2357,9 @@ static bool torture_smb2_notify_rmdir4(struct torture_context *torture,
 /*
    basic testing of SMB2 change notify
 */
-struct torture_suite *torture_smb2_notify_init(void)
+struct torture_suite *torture_smb2_notify_init(TALLOC_CTX *ctx)
 {
-	struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "notify");
+	struct torture_suite *suite = torture_suite_create(ctx, "notify");
 
 	torture_suite_add_1smb2_test(suite, "valid-req", test_valid_request);
 	torture_suite_add_1smb2_test(suite, "tcon", torture_smb2_notify_tcon);
diff --git a/source4/torture/smb2/smb2.c b/source4/torture/smb2/smb2.c
index cf785b8..c493811 100644
--- a/source4/torture/smb2/smb2.c
+++ b/source4/torture/smb2/smb2.c
@@ -154,7 +154,7 @@ NTSTATUS torture_smb2_init(TALLOC_CTX *ctx)
 	torture_suite_add_suite(suite, torture_smb2_read_init());
 	torture_suite_add_suite(suite, torture_smb2_create_init(suite));
 	torture_suite_add_suite(suite, torture_smb2_acls_init(suite));
-	torture_suite_add_suite(suite, torture_smb2_notify_init());
+	torture_suite_add_suite(suite, torture_smb2_notify_init(suite));
 	torture_suite_add_suite(suite, torture_smb2_notify_disabled_init());
 	torture_suite_add_suite(suite, torture_smb2_durable_open_init(suite));
 	torture_suite_add_suite(suite,
-- 
2.7.4


From 1c7236cf1d74d95261949a3da0d1ce6557db086f Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Mon, 24 Apr 2017 15:35:18 -0700
Subject: [PATCH 19/35] s4: torture: Add a TALLOC_CTX * to
 torture_smb2_notify_disabled_init().

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 source4/torture/smb2/notify_disabled.c | 5 +++--
 source4/torture/smb2/smb2.c            | 3 ++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/source4/torture/smb2/notify_disabled.c b/source4/torture/smb2/notify_disabled.c
index 0faeb51..a7bbebd 100644
--- a/source4/torture/smb2/notify_disabled.c
+++ b/source4/torture/smb2/notify_disabled.c
@@ -108,9 +108,10 @@ done:
 /*
    basic testing of SMB2 change notify
 */
-struct torture_suite *torture_smb2_notify_disabled_init(void)
+struct torture_suite *torture_smb2_notify_disabled_init(TALLOC_CTX *ctx)
 {
-	struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "change_notify_disabled");
+	struct torture_suite *suite = torture_suite_create(ctx,
+		"change_notify_disabled");
 
 	torture_suite_add_1smb2_test(suite, "notfiy_disabled", torture_smb2_notify_disabled);
 	suite->description = talloc_strdup(suite, "SMB2-CHANGE-NOTIFY-DISABLED tests");
diff --git a/source4/torture/smb2/smb2.c b/source4/torture/smb2/smb2.c
index c493811..50391a5 100644
--- a/source4/torture/smb2/smb2.c
+++ b/source4/torture/smb2/smb2.c
@@ -155,7 +155,8 @@ NTSTATUS torture_smb2_init(TALLOC_CTX *ctx)
 	torture_suite_add_suite(suite, torture_smb2_create_init(suite));
 	torture_suite_add_suite(suite, torture_smb2_acls_init(suite));
 	torture_suite_add_suite(suite, torture_smb2_notify_init(suite));
-	torture_suite_add_suite(suite, torture_smb2_notify_disabled_init());
+	torture_suite_add_suite(suite,
+		torture_smb2_notify_disabled_init(suite));
 	torture_suite_add_suite(suite, torture_smb2_durable_open_init(suite));
 	torture_suite_add_suite(suite,
 		torture_smb2_durable_open_disconnect_init(suite));
-- 
2.7.4


From 594bbcee3a71d8eff30241aa1ae425f7cdba5afe Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Mon, 24 Apr 2017 15:37:12 -0700
Subject: [PATCH 20/35] s4: torture: Add a TALLOC_CTX * to
 torture_smb2_oplocks_init(), torture_smb2_kernel_oplocks_init().

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 source4/torture/smb2/oplock.c | 8 ++++----
 source4/torture/smb2/smb2.c   | 4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/source4/torture/smb2/oplock.c b/source4/torture/smb2/oplock.c
index 53a6c18..83197a4 100644
--- a/source4/torture/smb2/oplock.c
+++ b/source4/torture/smb2/oplock.c
@@ -3947,10 +3947,10 @@ static void levelII501_timeout_cb(struct tevent_context *ev,
 	state->done = true;
 }
 
-struct torture_suite *torture_smb2_oplocks_init(void)
+struct torture_suite *torture_smb2_oplocks_init(TALLOC_CTX *ctx)
 {
 	struct torture_suite *suite =
-	    torture_suite_create(talloc_autofree_context(), "oplock");
+	    torture_suite_create(ctx, "oplock");
 
 	torture_suite_add_2smb2_test(suite, "exclusive1", test_smb2_oplock_exclusive1);
 	torture_suite_add_2smb2_test(suite, "exclusive2", test_smb2_oplock_exclusive2);
@@ -4332,10 +4332,10 @@ done:
 	return ret;
 }
 
-struct torture_suite *torture_smb2_kernel_oplocks_init(void)
+struct torture_suite *torture_smb2_kernel_oplocks_init(TALLOC_CTX *ctx)
 {
 	struct torture_suite *suite =
-	    torture_suite_create(talloc_autofree_context(), "kernel-oplocks");
+	    torture_suite_create(ctx, "kernel-oplocks");
 
 	torture_suite_add_1smb2_test(suite, "kernel_oplocks1", test_smb2_kernel_oplocks1);
 	torture_suite_add_1smb2_test(suite, "kernel_oplocks2", test_smb2_kernel_oplocks2);
diff --git a/source4/torture/smb2/smb2.c b/source4/torture/smb2/smb2.c
index 50391a5..55716a3 100644
--- a/source4/torture/smb2/smb2.c
+++ b/source4/torture/smb2/smb2.c
@@ -166,8 +166,8 @@ NTSTATUS torture_smb2_init(TALLOC_CTX *ctx)
 	torture_suite_add_suite(suite, torture_smb2_lease_init(suite));
 	torture_suite_add_suite(suite, torture_smb2_compound_init(suite));
 	torture_suite_add_suite(suite, torture_smb2_compound_find_init(suite));
-	torture_suite_add_suite(suite, torture_smb2_oplocks_init());
-	torture_suite_add_suite(suite, torture_smb2_kernel_oplocks_init());
+	torture_suite_add_suite(suite, torture_smb2_oplocks_init(suite));
+	torture_suite_add_suite(suite, torture_smb2_kernel_oplocks_init(suite));
 	torture_suite_add_suite(suite, torture_smb2_streams_init());
 	torture_suite_add_suite(suite, torture_smb2_ioctl_init(suite));
 	torture_suite_add_suite(suite, torture_smb2_rename_init());
-- 
2.7.4


From 0976353391278aa886f67dbe2c13e9086e2e1d31 Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Mon, 24 Apr 2017 15:38:38 -0700
Subject: [PATCH 21/35] s4: torture: Add a TALLOC_CTX * to
 torture_smb2_read_init().

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 source4/torture/smb2/read.c | 4 ++--
 source4/torture/smb2/smb2.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/source4/torture/smb2/read.c b/source4/torture/smb2/read.c
index c4469df..4bf3bb7 100644
--- a/source4/torture/smb2/read.c
+++ b/source4/torture/smb2/read.c
@@ -303,9 +303,9 @@ done:
 /* 
    basic testing of SMB2 read
 */
-struct torture_suite *torture_smb2_read_init(void)
+struct torture_suite *torture_smb2_read_init(TALLOC_CTX *ctx)
 {
-	struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "read");
+	struct torture_suite *suite = torture_suite_create(ctx, "read");
 
 	torture_suite_add_1smb2_test(suite, "eof", test_read_eof);
 	torture_suite_add_1smb2_test(suite, "position", test_read_position);
diff --git a/source4/torture/smb2/smb2.c b/source4/torture/smb2/smb2.c
index 55716a3..9b96ad8 100644
--- a/source4/torture/smb2/smb2.c
+++ b/source4/torture/smb2/smb2.c
@@ -151,7 +151,7 @@ NTSTATUS torture_smb2_init(TALLOC_CTX *ctx)
 	torture_suite_add_suite(suite, torture_smb2_getinfo_init());
 	torture_suite_add_simple_test(suite, "setinfo", torture_smb2_setinfo);
 	torture_suite_add_suite(suite, torture_smb2_lock_init(suite));
-	torture_suite_add_suite(suite, torture_smb2_read_init());
+	torture_suite_add_suite(suite, torture_smb2_read_init(suite));
 	torture_suite_add_suite(suite, torture_smb2_create_init(suite));
 	torture_suite_add_suite(suite, torture_smb2_acls_init(suite));
 	torture_suite_add_suite(suite, torture_smb2_notify_init(suite));
-- 
2.7.4


From e9530e12382f0b6c6da57cedff4bdcd997afe261 Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Mon, 24 Apr 2017 15:40:16 -0700
Subject: [PATCH 22/35] s4: torture: Add a TALLOC_CTX * to
 torture_smb2_rename_init().

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 source4/torture/smb2/rename.c | 4 ++--
 source4/torture/smb2/smb2.c   | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/source4/torture/smb2/rename.c b/source4/torture/smb2/rename.c
index 9652643..4c41c8b 100644
--- a/source4/torture/smb2/rename.c
+++ b/source4/torture/smb2/rename.c
@@ -1419,10 +1419,10 @@ static bool torture_smb2_rename_dir_bench(struct torture_context *tctx,
 /*
    basic testing of SMB2 rename
  */
-struct torture_suite *torture_smb2_rename_init(void)
+struct torture_suite *torture_smb2_rename_init(TALLOC_CTX *ctx)
 {
 	struct torture_suite *suite =
-		torture_suite_create(talloc_autofree_context(), "rename");
+		torture_suite_create(ctx, "rename");
 
 	torture_suite_add_1smb2_test(suite, "simple",
 		torture_smb2_rename_simple);
diff --git a/source4/torture/smb2/smb2.c b/source4/torture/smb2/smb2.c
index 9b96ad8..caa7685 100644
--- a/source4/torture/smb2/smb2.c
+++ b/source4/torture/smb2/smb2.c
@@ -170,7 +170,7 @@ NTSTATUS torture_smb2_init(TALLOC_CTX *ctx)
 	torture_suite_add_suite(suite, torture_smb2_kernel_oplocks_init(suite));
 	torture_suite_add_suite(suite, torture_smb2_streams_init());
 	torture_suite_add_suite(suite, torture_smb2_ioctl_init(suite));
-	torture_suite_add_suite(suite, torture_smb2_rename_init());
+	torture_suite_add_suite(suite, torture_smb2_rename_init(suite));
 	torture_suite_add_1smb2_test(suite, "bench-oplock", test_smb2_bench_oplock);
 	torture_suite_add_1smb2_test(suite, "hold-oplock", test_smb2_hold_oplock);
 	torture_suite_add_suite(suite, torture_smb2_session_init());
-- 
2.7.4


From b0bdfe42325fef45b221389879db033c3777bdbb Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Mon, 24 Apr 2017 15:41:18 -0700
Subject: [PATCH 23/35] s4: torture: Add a TALLOC_CTX * to
 torture_smb2_replay_init().

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 source4/torture/smb2/replay.c | 4 ++--
 source4/torture/smb2/smb2.c   | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/source4/torture/smb2/replay.c b/source4/torture/smb2/replay.c
index 26b5583..19cda2f 100644
--- a/source4/torture/smb2/replay.c
+++ b/source4/torture/smb2/replay.c
@@ -2427,10 +2427,10 @@ done:
 	return ret;
 }
 
-struct torture_suite *torture_smb2_replay_init(void)
+struct torture_suite *torture_smb2_replay_init(TALLOC_CTX *ctx)
 {
 	struct torture_suite *suite =
-		torture_suite_create(talloc_autofree_context(), "replay");
+		torture_suite_create(ctx, "replay");
 
 	torture_suite_add_1smb2_test(suite, "replay-commands", test_replay_commands);
 	torture_suite_add_1smb2_test(suite, "replay-regular", test_replay_regular);
diff --git a/source4/torture/smb2/smb2.c b/source4/torture/smb2/smb2.c
index caa7685..b5f5353 100644
--- a/source4/torture/smb2/smb2.c
+++ b/source4/torture/smb2/smb2.c
@@ -174,7 +174,7 @@ NTSTATUS torture_smb2_init(TALLOC_CTX *ctx)
 	torture_suite_add_1smb2_test(suite, "bench-oplock", test_smb2_bench_oplock);
 	torture_suite_add_1smb2_test(suite, "hold-oplock", test_smb2_hold_oplock);
 	torture_suite_add_suite(suite, torture_smb2_session_init());
-	torture_suite_add_suite(suite, torture_smb2_replay_init());
+	torture_suite_add_suite(suite, torture_smb2_replay_init(suite));
 	torture_suite_add_simple_test(suite, "dosmode", torture_smb2_dosmode);
 	torture_suite_add_simple_test(suite, "maxfid", torture_smb2_maxfid);
 	torture_suite_add_suite(suite, torture_smb2_crediting_init(suite));
-- 
2.7.4


From f18fa0664158bdd2dcdc19340859e296a7a7bc48 Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Mon, 24 Apr 2017 15:42:20 -0700
Subject: [PATCH 24/35] s4: torture: Add a TALLOC_CTX * to
 torture_smb2_scan_init().

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 source4/torture/smb2/scan.c | 4 ++--
 source4/torture/smb2/smb2.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/source4/torture/smb2/scan.c b/source4/torture/smb2/scan.c
index f1527d6..f750dcc 100644
--- a/source4/torture/smb2/scan.c
+++ b/source4/torture/smb2/scan.c
@@ -249,9 +249,9 @@ static bool torture_smb2_scan(struct torture_context *tctx)
 	return true;
 }
 
-struct torture_suite *torture_smb2_scan_init(void)
+struct torture_suite *torture_smb2_scan_init(TALLOC_CTX *ctx)
 {
-	struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "scan");
+	struct torture_suite *suite = torture_suite_create(ctx, "scan");
 
 	torture_suite_add_simple_test(suite, "scan", torture_smb2_scan);
 	torture_suite_add_simple_test(suite, "getinfo", torture_smb2_getinfo_scan);
diff --git a/source4/torture/smb2/smb2.c b/source4/torture/smb2/smb2.c
index b5f5353..2badc04 100644
--- a/source4/torture/smb2/smb2.c
+++ b/source4/torture/smb2/smb2.c
@@ -147,7 +147,7 @@ NTSTATUS torture_smb2_init(TALLOC_CTX *ctx)
 {
 	struct torture_suite *suite = torture_suite_create(ctx, "smb2");
 	torture_suite_add_simple_test(suite, "connect", torture_smb2_connect);
-	torture_suite_add_suite(suite, torture_smb2_scan_init());
+	torture_suite_add_suite(suite, torture_smb2_scan_init(suite));
 	torture_suite_add_suite(suite, torture_smb2_getinfo_init());
 	torture_suite_add_simple_test(suite, "setinfo", torture_smb2_setinfo);
 	torture_suite_add_suite(suite, torture_smb2_lock_init(suite));
-- 
2.7.4


From e3c087ba19ce065eaa326c87ae3e08cfa3486092 Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Mon, 24 Apr 2017 15:43:27 -0700
Subject: [PATCH 25/35] s4: torture: Add a TALLOC_CTX * to
 torture_smb2_session_init().

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 source4/torture/smb2/session.c | 4 ++--
 source4/torture/smb2/smb2.c    | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/source4/torture/smb2/session.c b/source4/torture/smb2/session.c
index e35ec85..92ed2c5 100644
--- a/source4/torture/smb2/session.c
+++ b/source4/torture/smb2/session.c
@@ -1306,10 +1306,10 @@ done:
 	return ret;
 }
 
-struct torture_suite *torture_smb2_session_init(void)
+struct torture_suite *torture_smb2_session_init(TALLOC_CTX *ctx)
 {
 	struct torture_suite *suite =
-	    torture_suite_create(talloc_autofree_context(), "session");
+	    torture_suite_create(ctx, "session");
 
 	torture_suite_add_1smb2_test(suite, "reconnect1", test_session_reconnect1);
 	torture_suite_add_1smb2_test(suite, "reconnect2", test_session_reconnect2);
diff --git a/source4/torture/smb2/smb2.c b/source4/torture/smb2/smb2.c
index 2badc04..1f72ec8 100644
--- a/source4/torture/smb2/smb2.c
+++ b/source4/torture/smb2/smb2.c
@@ -173,7 +173,7 @@ NTSTATUS torture_smb2_init(TALLOC_CTX *ctx)
 	torture_suite_add_suite(suite, torture_smb2_rename_init(suite));
 	torture_suite_add_1smb2_test(suite, "bench-oplock", test_smb2_bench_oplock);
 	torture_suite_add_1smb2_test(suite, "hold-oplock", test_smb2_hold_oplock);
-	torture_suite_add_suite(suite, torture_smb2_session_init());
+	torture_suite_add_suite(suite, torture_smb2_session_init(suite));
 	torture_suite_add_suite(suite, torture_smb2_replay_init(suite));
 	torture_suite_add_simple_test(suite, "dosmode", torture_smb2_dosmode);
 	torture_suite_add_simple_test(suite, "maxfid", torture_smb2_maxfid);
-- 
2.7.4


From cae1c97db5c1560562d9410ebf1888e9ebf2cd39 Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Mon, 24 Apr 2017 15:45:02 -0700
Subject: [PATCH 26/35] s4: torture: Add a TALLOC_CTX * to
 torture_smb2_streams_init().

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 source4/torture/smb2/smb2.c    | 2 +-
 source4/torture/smb2/streams.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/source4/torture/smb2/smb2.c b/source4/torture/smb2/smb2.c
index 1f72ec8..436c960 100644
--- a/source4/torture/smb2/smb2.c
+++ b/source4/torture/smb2/smb2.c
@@ -168,7 +168,7 @@ NTSTATUS torture_smb2_init(TALLOC_CTX *ctx)
 	torture_suite_add_suite(suite, torture_smb2_compound_find_init(suite));
 	torture_suite_add_suite(suite, torture_smb2_oplocks_init(suite));
 	torture_suite_add_suite(suite, torture_smb2_kernel_oplocks_init(suite));
-	torture_suite_add_suite(suite, torture_smb2_streams_init());
+	torture_suite_add_suite(suite, torture_smb2_streams_init(suite));
 	torture_suite_add_suite(suite, torture_smb2_ioctl_init(suite));
 	torture_suite_add_suite(suite, torture_smb2_rename_init(suite));
 	torture_suite_add_1smb2_test(suite, "bench-oplock", test_smb2_bench_oplock);
diff --git a/source4/torture/smb2/streams.c b/source4/torture/smb2/streams.c
index e48a217..d302bf9 100644
--- a/source4/torture/smb2/streams.c
+++ b/source4/torture/smb2/streams.c
@@ -1834,10 +1834,10 @@ done:
 /*
    basic testing of streams calls SMB2
 */
-struct torture_suite *torture_smb2_streams_init(void)
+struct torture_suite *torture_smb2_streams_init(TALLOC_CTX *ctx)
 {
 	struct torture_suite *suite =
-		torture_suite_create(talloc_autofree_context(), "streams");
+		torture_suite_create(ctx, "streams");
 
 	torture_suite_add_1smb2_test(suite, "dir", test_stream_dir);
 	torture_suite_add_1smb2_test(suite, "io", test_stream_io);
-- 
2.7.4


From 25f7eea5df18394fa285c7695b0098c7b194f16b Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Mon, 24 Apr 2017 15:46:47 -0700
Subject: [PATCH 27/35] s4: torture: Add a TALLOC_CTX * to torture_acl_xattr().

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 source4/torture/vfs/acl_xattr.c | 4 ++--
 source4/torture/vfs/vfs.c       | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/source4/torture/vfs/acl_xattr.c b/source4/torture/vfs/acl_xattr.c
index 676d012..d1285d4 100644
--- a/source4/torture/vfs/acl_xattr.c
+++ b/source4/torture/vfs/acl_xattr.c
@@ -303,9 +303,9 @@ done:
 /*
    basic testing of vfs_acl_xattr
 */
-struct torture_suite *torture_acl_xattr(void)
+struct torture_suite *torture_acl_xattr(TALLOC_CTX *ctx)
 {
-	struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "acl_xattr");
+	struct torture_suite *suite = torture_suite_create(ctx, "acl_xattr");
 
 	torture_suite_add_1smb2_test(suite, "default-acl-style-posix", test_default_acl_posix);
 	torture_suite_add_1smb2_test(suite, "default-acl-style-windows", test_default_acl_win);
diff --git a/source4/torture/vfs/vfs.c b/source4/torture/vfs/vfs.c
index e167576..fef7491 100644
--- a/source4/torture/vfs/vfs.c
+++ b/source4/torture/vfs/vfs.c
@@ -110,7 +110,7 @@ NTSTATUS torture_vfs_init(TALLOC_CTX *ctx)
 
 	torture_suite_add_suite(suite, torture_vfs_fruit());
 	torture_suite_add_suite(suite, torture_vfs_fruit_netatalk());
-	torture_suite_add_suite(suite, torture_acl_xattr());
+	torture_suite_add_suite(suite, torture_acl_xattr(suite));
 	torture_suite_add_suite(suite, torture_vfs_fruit_file_id());
 
 	torture_register_suite(ctx, suite);
-- 
2.7.4


From 30e57f568a18b8f46badaf44950da459423a1d3b Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Mon, 24 Apr 2017 15:48:42 -0700
Subject: [PATCH 28/35] s4: torture: Add a TALLOC_CTX * to torture_vfs_fruit(),
 torture_vfs_fruit_netatalk(), torture_vfs_fruit_file_id()

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 source4/torture/vfs/fruit.c | 12 ++++++------
 source4/torture/vfs/vfs.c   |  6 +++---
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/source4/torture/vfs/fruit.c b/source4/torture/vfs/fruit.c
index bb8f36e..96edec2 100644
--- a/source4/torture/vfs/fruit.c
+++ b/source4/torture/vfs/fruit.c
@@ -4050,10 +4050,10 @@ done:
  *
  * When running against an OS X SMB server add "--option=torture:osx=true"
  */
-struct torture_suite *torture_vfs_fruit(void)
+struct torture_suite *torture_vfs_fruit(TALLOC_CTX *ctx)
 {
 	struct torture_suite *suite = torture_suite_create(
-		talloc_autofree_context(), "fruit");
+		ctx, "fruit");
 
 	suite->description = talloc_strdup(suite, "vfs_fruit tests");
 
@@ -4084,10 +4084,10 @@ struct torture_suite *torture_vfs_fruit(void)
 	return suite;
 }
 
-struct torture_suite *torture_vfs_fruit_netatalk(void)
+struct torture_suite *torture_vfs_fruit_netatalk(TALLOC_CTX *ctx)
 {
 	struct torture_suite *suite = torture_suite_create(
-		talloc_autofree_context(), "fruit_netatalk");
+		ctx, "fruit_netatalk");
 
 	suite->description = talloc_strdup(suite, "vfs_fruit tests for Netatalk interop that require fruit:metadata=netatalk");
 
@@ -4097,10 +4097,10 @@ struct torture_suite *torture_vfs_fruit_netatalk(void)
 	return suite;
 }
 
-struct torture_suite *torture_vfs_fruit_file_id(void)
+struct torture_suite *torture_vfs_fruit_file_id(TALLOC_CTX *ctx)
 {
 	struct torture_suite *suite =
-	    torture_suite_create(talloc_autofree_context(), "fruit_file_id");
+	    torture_suite_create(ctx, "fruit_file_id");
 
 	suite->description =
 	    talloc_strdup(suite, "vfs_fruit tests for on-disk file ID that "
diff --git a/source4/torture/vfs/vfs.c b/source4/torture/vfs/vfs.c
index fef7491..eef1f89 100644
--- a/source4/torture/vfs/vfs.c
+++ b/source4/torture/vfs/vfs.c
@@ -108,10 +108,10 @@ NTSTATUS torture_vfs_init(TALLOC_CTX *ctx)
 
 	suite->description = talloc_strdup(suite, "VFS modules tests");
 
-	torture_suite_add_suite(suite, torture_vfs_fruit());
-	torture_suite_add_suite(suite, torture_vfs_fruit_netatalk());
+	torture_suite_add_suite(suite, torture_vfs_fruit(suite));
+	torture_suite_add_suite(suite, torture_vfs_fruit_netatalk(suite));
 	torture_suite_add_suite(suite, torture_acl_xattr(suite));
-	torture_suite_add_suite(suite, torture_vfs_fruit_file_id());
+	torture_suite_add_suite(suite, torture_vfs_fruit_file_id(suite));
 
 	torture_register_suite(ctx, suite);
 
-- 
2.7.4


From 6df067c07de5d5a394a49ac6e9c29a0e34e0874f Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Mon, 24 Apr 2017 15:50:37 -0700
Subject: [PATCH 29/35] s4: torture: Add a TALLOC_CTX * to
 torture_winbind_struct_init().

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 source4/torture/winbind/struct_based.c | 4 ++--
 source4/torture/winbind/winbind.c      | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/source4/torture/winbind/struct_based.c b/source4/torture/winbind/struct_based.c
index 1a84a7a..9cf0102 100644
--- a/source4/torture/winbind/struct_based.c
+++ b/source4/torture/winbind/struct_based.c
@@ -1074,9 +1074,9 @@ static bool torture_winbind_struct_lookup_name_sid(struct torture_context *tortu
 	return true;
 }
 
-struct torture_suite *torture_winbind_struct_init(void)
+struct torture_suite *torture_winbind_struct_init(TALLOC_CTX *ctx)
 {
-	struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "struct");
+	struct torture_suite *suite = torture_suite_create(ctx, "struct");
 
 	torture_suite_add_simple_test(suite, "interface_version", torture_winbind_struct_interface_version);
 	torture_suite_add_simple_test(suite, "ping", torture_winbind_struct_ping);
diff --git a/source4/torture/winbind/winbind.c b/source4/torture/winbind/winbind.c
index fec95e8..82c817c 100644
--- a/source4/torture/winbind/winbind.c
+++ b/source4/torture/winbind/winbind.c
@@ -294,7 +294,7 @@ NTSTATUS torture_winbind_init(TALLOC_CTX *ctx)
 {
 	struct torture_suite *suite = torture_suite_create(ctx, "winbind");
 	struct torture_suite *pac_suite;
-	torture_suite_add_suite(suite, torture_winbind_struct_init());
+	torture_suite_add_suite(suite, torture_winbind_struct_init(suite));
 	torture_suite_add_suite(suite, torture_wbclient(suite));
 
 	pac_suite = torture_suite_create(ctx, "pac");
-- 
2.7.4


From c097b53e98f620e54a301963dc5757a8cd77d643 Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Mon, 24 Apr 2017 16:02:46 -0700
Subject: [PATCH 30/35] s4: torture: Add a TALLOC_CTX * to
 torture_test_delete().

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 source4/torture/basic/base.c   | 2 +-
 source4/torture/basic/delete.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/source4/torture/basic/base.c b/source4/torture/basic/base.c
index d6f0a7b..8e7ae49 100644
--- a/source4/torture/basic/base.c
+++ b/source4/torture/basic/base.c
@@ -1963,7 +1963,7 @@ NTSTATUS torture_base_init(TALLOC_CTX *ctx)
 	torture_suite_add_1smb_test(suite, "xcopy", run_xcopy);
 	torture_suite_add_1smb_test(suite, "iometer", run_iometer);
 	torture_suite_add_1smb_test(suite, "rename", torture_test_rename);
-	torture_suite_add_suite(suite, torture_test_delete());
+	torture_suite_add_suite(suite, torture_test_delete(suite));
 	torture_suite_add_1smb_test(suite, "properties", torture_test_properties);
 	torture_suite_add_1smb_test(suite, "mangle", torture_mangle);
 	torture_suite_add_1smb_test(suite, "openattr", torture_openattrtest);
diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c
index 76a83df..21af05c 100644
--- a/source4/torture/basic/delete.c
+++ b/source4/torture/basic/delete.c
@@ -2204,10 +2204,10 @@ static bool deltest23(struct torture_context *tctx,
 /*
   Test delete on close semantics.
  */
-struct torture_suite *torture_test_delete(void)
+struct torture_suite *torture_test_delete(TALLOC_CTX *ctx)
 {
 	struct torture_suite *suite = torture_suite_create(
-		talloc_autofree_context(), "delete");
+		ctx, "delete");
 
 	torture_suite_add_2smb_test(suite, "deltest1", deltest1);
 	torture_suite_add_2smb_test(suite, "deltest2", deltest2);
-- 
2.7.4


From 7fbf646db89744550a479fa090d55b44e449d0b9 Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Mon, 24 Apr 2017 16:04:10 -0700
Subject: [PATCH 31/35] s4: torture: Add a TALLOC_CTX * to
 torture_smb2_getinfo_init().

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 source4/torture/smb2/getinfo.c | 4 ++--
 source4/torture/smb2/smb2.c    | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/source4/torture/smb2/getinfo.c b/source4/torture/smb2/getinfo.c
index 78f62e7..f6ef0a5 100644
--- a/source4/torture/smb2/getinfo.c
+++ b/source4/torture/smb2/getinfo.c
@@ -474,10 +474,10 @@ static bool torture_smb2_getinfo(struct torture_context *tctx)
 	return ret;
 }
 
-struct torture_suite *torture_smb2_getinfo_init(void)
+struct torture_suite *torture_smb2_getinfo_init(TALLOC_CTX *ctx)
 {
 	struct torture_suite *suite = torture_suite_create(
-		talloc_autofree_context(), "getinfo");
+		ctx, "getinfo");
 
 	torture_suite_add_simple_test(suite, "complex", torture_smb2_getinfo);
 	torture_suite_add_simple_test(suite, "fsinfo",  torture_smb2_fsinfo);
diff --git a/source4/torture/smb2/smb2.c b/source4/torture/smb2/smb2.c
index 436c960..e766005 100644
--- a/source4/torture/smb2/smb2.c
+++ b/source4/torture/smb2/smb2.c
@@ -148,7 +148,7 @@ NTSTATUS torture_smb2_init(TALLOC_CTX *ctx)
 	struct torture_suite *suite = torture_suite_create(ctx, "smb2");
 	torture_suite_add_simple_test(suite, "connect", torture_smb2_connect);
 	torture_suite_add_suite(suite, torture_smb2_scan_init(suite));
-	torture_suite_add_suite(suite, torture_smb2_getinfo_init());
+	torture_suite_add_suite(suite, torture_smb2_getinfo_init(suite));
 	torture_suite_add_simple_test(suite, "setinfo", torture_smb2_setinfo);
 	torture_suite_add_suite(suite, torture_smb2_lock_init(suite));
 	torture_suite_add_suite(suite, torture_smb2_read_init(suite));
-- 
2.7.4


From ea6390b1ea30f88ef9ff078dbf8bd87cdfc030f7 Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Mon, 24 Apr 2017 16:11:22 -0700
Subject: [PATCH 32/35] s4: torture: Use a named TALLOC_CTX in masktest instead
 of talloc_autofree_context().

Move all talloc_free()'s back to main from the function call.

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 source4/torture/masktest.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/source4/torture/masktest.c b/source4/torture/masktest.c
index 2097de4..7f1be86 100644
--- a/source4/torture/masktest.c
+++ b/source4/torture/masktest.c
@@ -268,7 +268,6 @@ static void test_mask(int argc, char *argv[],
 
  finished:
 	smbcli_rmdir(cli->tree, "\\masktest");
-	talloc_free(mem_ctx);
 }
 
 
@@ -300,7 +299,7 @@ int main(int argc, const char *argv[])
 	poptContext pc;
 	int argc_new, i;
 	char **argv_new;
-	TALLOC_CTX *mem_ctx;
+	TALLOC_CTX *mem_ctx = NULL;
 	enum {OPT_UNCLIST=1000};
 	struct poptOption long_options[] = {
 		POPT_AUTOHELP
@@ -322,6 +321,11 @@ int main(int argc, const char *argv[])
 	setlinebuf(stdout);
 	seed = time(NULL);
 
+	mem_ctx = talloc_named_const(NULL, 0, "masktest_ctx");
+	if (mem_ctx == NULL) {
+		exit(1);
+	}
+
 	pc = poptGetContext("locktest", argc, argv, long_options,
 			    POPT_CONTEXT_KEEP_FIRST);
 
@@ -346,6 +350,7 @@ int main(int argc, const char *argv[])
 
 	if (!(argc_new >= 2)) {
 		usage(pc);
+		talloc_free(mem_ctx);
 		exit(1);
 	}
 
@@ -357,8 +362,6 @@ int main(int argc, const char *argv[])
 
 	lp_ctx = cmdline_lp_ctx;
 
-	mem_ctx = talloc_autofree_context();
-
 	ev = s4_event_context_init(mem_ctx);
 
 	gensec_init();
@@ -372,6 +375,7 @@ int main(int argc, const char *argv[])
 			  lpcfg_gensec_settings(mem_ctx, lp_ctx));
 	if (!cli) {
 		DEBUG(0,("Failed to connect to %s\n", share));
+		talloc_free(mem_ctx);
 		exit(1);
 	}
 
@@ -381,5 +385,6 @@ int main(int argc, const char *argv[])
 
 	test_mask(argc_new-1, argv_new+1, mem_ctx, cli);
 
+	talloc_free(mem_ctx);
 	return(0);
 }
-- 
2.7.4


From 966d0db36dbb47912ce6080092469c237c38105d Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Mon, 24 Apr 2017 16:18:16 -0700
Subject: [PATCH 33/35] s4: torture: Remove talloc_autofree_context() from
 locktest.

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 source4/torture/locktest.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/source4/torture/locktest.c b/source4/torture/locktest.c
index ac8d854..7047554 100644
--- a/source4/torture/locktest.c
+++ b/source4/torture/locktest.c
@@ -580,18 +580,26 @@ int main(int argc, const char *argv[])
 		POPT_COMMON_VERSION
 		{ NULL }
 	};
+	TALLOC_CTX *mem_ctx = NULL;
+	int ret = -1;
 
 	setlinebuf(stdout);
 	seed = time(NULL);
 
+	mem_ctx = talloc_named_const(NULL, 0, "locktest_ctx");
+	if (mem_ctx == NULL) {
+		printf("Unable to allocate locktest_ctx\n");
+		exit(1);
+	}
+
 	pc = poptGetContext("locktest", argc, argv, long_options,
 			    POPT_CONTEXT_KEEP_FIRST);
 
 	poptSetOtherOptionHelp(pc, "<unc1> <unc2>");
 
 	lp_ctx = cmdline_lp_ctx;
-	servers[0] = cli_credentials_init(talloc_autofree_context());
-	servers[1] = cli_credentials_init(talloc_autofree_context());
+	servers[0] = cli_credentials_init(mem_ctx);
+	servers[1] = cli_credentials_init(mem_ctx);
 	cli_credentials_guess(servers[0], lp_ctx);
 	cli_credentials_guess(servers[1], lp_ctx);
 
@@ -603,6 +611,7 @@ int main(int argc, const char *argv[])
 		case 'U':
 			if (username_count == 2) {
 				usage(pc);
+				talloc_free(mem_ctx);
 				exit(1);
 			}
 			cli_credentials_parse_string(servers[username_count], poptGetOptArg(pc), CRED_SPECIFIED);
@@ -642,7 +651,7 @@ int main(int argc, const char *argv[])
 		servers[1] = servers[0];
 	}
 
-	ev = s4_event_context_init(talloc_autofree_context());
+	ev = s4_event_context_init(mem_ctx);
 
 	gensec_init();
 
@@ -650,6 +659,8 @@ int main(int argc, const char *argv[])
 		 seed, lock_base, lock_range, min_length));
 	srandom(seed);
 
-	return test_locks(ev, lp_ctx, NULL, share);
+	ret = test_locks(ev, lp_ctx, NULL, share);
+	talloc_free(mem_ctx);
+	return ret;
 }
 
-- 
2.7.4


From 065bfac1c84596ab7aff69f9e62830b7b4f1d75a Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Mon, 24 Apr 2017 16:20:28 -0700
Subject: [PATCH 34/35] s4: torture: Remove talloc_autofree_context() from
 gentest.

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 source4/torture/gentest.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/source4/torture/gentest.c b/source4/torture/gentest.c
index 4cd2258..33de6cc 100644
--- a/source4/torture/gentest.c
+++ b/source4/torture/gentest.c
@@ -3199,6 +3199,7 @@ int main(int argc, const char *argv[])
 		POPT_COMMON_VERSION
 		{ NULL }
 	};
+	TALLOC_CTX *mem_ctx = NULL;
 
 	memset(&bad_smb2_handle, 0xFF, sizeof(bad_smb2_handle));
 
@@ -3208,14 +3209,20 @@ int main(int argc, const char *argv[])
 	options.max_open_handles = 20;
 	options.seeds_file = "gentest_seeds.dat";
 
+	mem_ctx = talloc_named_const(NULL, 0, "gentest_ctx");
+	if (mem_ctx == NULL) {
+		printf("Unable to allocate gentest_ctx\n");
+		exit(1);
+	}
+
 	pc = poptGetContext("gentest", argc, argv, long_options,
 			    POPT_CONTEXT_KEEP_FIRST);
 
 	poptSetOtherOptionHelp(pc, "<unc1> <unc2>");
 
 	lp_ctx = cmdline_lp_ctx;
-	servers[0].credentials = cli_credentials_init(talloc_autofree_context());
-	servers[1].credentials = cli_credentials_init(talloc_autofree_context());
+	servers[0].credentials = cli_credentials_init(mem_ctx);
+	servers[1].credentials = cli_credentials_init(mem_ctx);
 	cli_credentials_guess(servers[0].credentials, lp_ctx);
 	cli_credentials_guess(servers[1].credentials, lp_ctx);
 
@@ -3227,6 +3234,7 @@ int main(int argc, const char *argv[])
 		case 'U':
 			if (username_count == 2) {
 				usage(pc);
+				talloc_free(mem_ctx);
 				exit(1);
 			}
 			cli_credentials_parse_string(servers[username_count].credentials, poptGetOptArg(pc), CRED_SPECIFIED);
@@ -3250,6 +3258,7 @@ int main(int argc, const char *argv[])
 
 	if (!(argc_new >= 3)) {
 		usage(pc);
+		talloc_free(mem_ctx);
 		exit(1);
 	}
 
@@ -3259,6 +3268,7 @@ int main(int argc, const char *argv[])
 
 	if (argc < 3 || argv[1][0] == '-') {
 		usage(pc);
+		talloc_free(mem_ctx);
 		exit(1);
 	}
 
@@ -3268,12 +3278,14 @@ int main(int argc, const char *argv[])
 		const char *share = argv[1+i];
 		if (!split_unc_name(share, &servers[i].server_name, &servers[i].share_name)) {
 			printf("Invalid share name '%s'\n", share);
+			talloc_free(mem_ctx);
 			return -1;
 		}
 	}
 
 	if (username_count == 0) {
 		usage(pc);
+		talloc_free(mem_ctx);
 		return -1;
 	}
 	if (username_count == 1) {
@@ -3282,7 +3294,7 @@ int main(int argc, const char *argv[])
 
 	printf("seed=%u\n", options.seed);
 
-	ev = s4_event_context_init(talloc_autofree_context());
+	ev = s4_event_context_init(mem_ctx);
 
 	gensec_init();
 
@@ -3294,5 +3306,6 @@ int main(int argc, const char *argv[])
 		printf("gentest failed\n");
 	}
 
+	talloc_free(mem_ctx);
 	return ret?0:-1;
 }
-- 
2.7.4


From 331e340567efc235790282eea5e0ec90b98b5074 Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Mon, 24 Apr 2017 16:40:37 -0700
Subject: [PATCH 35/35] s4: torture: Remove the last talloc_autofree_context()
 from source4/torture/*.c

Allocate the saved packets off the NULL context instead, and
use a new function free_received_packets() to clear out the
received_packets list.

Signed-off-by: Jeremy Allison <jra at samba.org>
---
 source4/torture/rpc/spoolss_notify.c | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/source4/torture/rpc/spoolss_notify.c b/source4/torture/rpc/spoolss_notify.c
index 928b619..bcae5f8 100644
--- a/source4/torture/rpc/spoolss_notify.c
+++ b/source4/torture/rpc/spoolss_notify.c
@@ -72,7 +72,7 @@ static NTSTATUS spoolss__op_ndr_pull(struct dcesrv_call_state *dce_call, TALLOC_
 	return NT_STATUS_OK;
 }
 
-/* Note that received_packets are allocated in talloc_autofree_context(),
+/* Note that received_packets are allocated on the NULL context
  * because no other context appears to stay around long enough. */
 static struct received_packet {
 	uint16_t opnum;
@@ -80,6 +80,20 @@ static struct received_packet {
 	struct received_packet *prev, *next;
 } *received_packets = NULL;
 
+static void free_received_packets(void)
+{
+	struct received_packet *rp;
+	struct received_packet *rp_next;
+
+	for (rp = received_packets; rp; rp = rp_next) {
+		rp_next = rp->next;
+		DLIST_REMOVE(received_packets, rp);
+		talloc_unlink(rp, rp->r);
+		talloc_free(rp);
+	}
+	received_packets = NULL;
+}
+
 static WERROR _spoolss_ReplyOpenPrinter(struct dcesrv_call_state *dce_call,
 					TALLOC_CTX *mem_ctx,
 					struct spoolss_ReplyOpenPrinter *r)
@@ -136,7 +150,7 @@ static NTSTATUS spoolss__op_dispatch(struct dcesrv_call_state *dce_call, TALLOC_
 	uint16_t opnum = dce_call->pkt.u.request.opnum;
 	struct received_packet *rp;
 
-	rp = talloc_zero(talloc_autofree_context(), struct received_packet);
+	rp = talloc_zero(NULL, struct received_packet);
 	rp->opnum = opnum;
 	rp->r = talloc_reference(rp, r);
 
@@ -502,7 +516,7 @@ static bool test_RFFPCNEx(struct torture_context *tctx,
 	const char *printername = NULL;
 	struct spoolss_NotifyInfo *info = NULL;
 
-	received_packets = NULL;
+	free_received_packets();
 
 	/* Start DCE/RPC server */
 	torture_assert(tctx, test_start_dcerpc_server(tctx, tctx->ev, &dce_ctx, &address), "");
@@ -541,6 +555,7 @@ static bool test_RFFPCNEx(struct torture_context *tctx,
 #endif
 	/* Shut down DCE/RPC server */
 	talloc_free(dce_ctx);
+	free_received_packets();
 
 	return true;
 }
-- 
2.7.4



More information about the samba-technical mailing list