From 17e41720d9167ad12f807d61049a2246ee5041cc Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 16 Apr 2008 15:16:56 +0200 Subject: torture/smb2: add torture_suite_add_2smb2_test() helper function metze (This used to be commit d70afbb0673184ed067e5f1c7608536025a3cca7) --- source4/torture/smb2/smb2.c | 55 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'source4') diff --git a/source4/torture/smb2/smb2.c b/source4/torture/smb2/smb2.c index 2d5b709d12..b5befce1b2 100644 --- a/source4/torture/smb2/smb2.c +++ b/source4/torture/smb2/smb2.c @@ -69,6 +69,61 @@ struct torture_test *torture_suite_add_1smb2_test(struct torture_suite *suite, return test; } + +static bool wrap_simple_2smb2_test(struct torture_context *torture_ctx, + struct torture_tcase *tcase, + struct torture_test *test) +{ + bool (*fn) (struct torture_context *, struct smb2_tree *, struct smb2_tree *); + bool ret; + + struct smb2_tree *tree1; + struct smb2_tree *tree2; + TALLOC_CTX *mem_ctx = talloc_new(torture_ctx); + + if (!torture_smb2_connection(torture_ctx, &tree1) || + !torture_smb2_connection(torture_ctx, &tree2)) { + return false; + } + + talloc_steal(mem_ctx, tree1); + talloc_steal(mem_ctx, tree2); + + fn = test->fn; + + ret = fn(torture_ctx, tree1, tree2); + + /* the test may already closed some of the connections */ + talloc_free(mem_ctx); + + return ret; +} + + +_PUBLIC_ struct torture_test *torture_suite_add_2smb2_test(struct torture_suite *suite, + const char *name, + bool (*run)(struct torture_context *, + struct smb2_tree *, + struct smb2_tree *)) +{ + struct torture_test *test; + struct torture_tcase *tcase; + + tcase = torture_suite_add_tcase(suite, name); + + test = talloc(tcase, struct torture_test); + + test->name = talloc_strdup(test, name); + test->description = NULL; + test->run = wrap_simple_2smb2_test; + test->fn = run; + test->dangerous = false; + + DLIST_ADD_END(tcase->tests, test, struct torture_test *); + + return test; +} + NTSTATUS torture_smb2_init(void) { struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "SMB2"); -- cgit