summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2008-04-16 15:16:56 +0200
committerStefan Metzmacher <metze@samba.org>2008-04-17 02:39:30 +0200
commit17e41720d9167ad12f807d61049a2246ee5041cc (patch)
tree04d77dba683148b673d54189d0accefc8218215d /source4
parent1fe057f2e8ea89c636fb48cd6f68f7d3d6d3c8e5 (diff)
downloadsamba-17e41720d9167ad12f807d61049a2246ee5041cc.tar.gz
samba-17e41720d9167ad12f807d61049a2246ee5041cc.tar.bz2
samba-17e41720d9167ad12f807d61049a2246ee5041cc.zip
torture/smb2: add torture_suite_add_2smb2_test() helper function
metze (This used to be commit d70afbb0673184ed067e5f1c7608536025a3cca7)
Diffstat (limited to 'source4')
-rw-r--r--source4/torture/smb2/smb2.c55
1 files changed, 55 insertions, 0 deletions
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");