From b9e262c51261af275db4d0e7e6e2c7318a41bed0 Mon Sep 17 00:00:00 2001 From: Kamen Mazdrashki Date: Mon, 16 Nov 2009 03:28:01 +0200 Subject: s4/drs(tort): Convert DSSYNC test to a test case fixture Now it should be much more clear why and where a test in DSSYNC test case has failed. Signed-off-by: Andrew Bartlett --- source4/torture/rpc/dssync.c | 90 +++++++++++++++++++++++++++++++++----------- source4/torture/rpc/rpc.c | 2 +- 2 files changed, 68 insertions(+), 24 deletions(-) (limited to 'source4') diff --git a/source4/torture/rpc/dssync.c b/source4/torture/rpc/dssync.c index 67993bd863..f64ecea21f 100644 --- a/source4/torture/rpc/dssync.c +++ b/source4/torture/rpc/dssync.c @@ -1016,30 +1016,74 @@ static bool test_FetchNT4Data(struct torture_context *tctx, return true; } -bool torture_rpc_dssync(struct torture_context *torture) +/** + * DSSYNC test case setup + */ +static bool torture_dssync_tcase_setup(struct torture_context *tctx, void **data) { - bool ret = true; - TALLOC_CTX *mem_ctx; + bool bret; struct DsSyncTest *ctx; - - mem_ctx = talloc_init("torture_rpc_dssync"); - ctx = test_create_context(torture); - - ret &= _test_DsBind(torture, ctx, ctx->admin.credentials, &ctx->admin.drsuapi); - if (!ret) { - return ret; - } - ret &= test_LDAPBind(torture, ctx, ctx->admin.credentials, &ctx->admin.ldap); - if (!ret) { - return ret; - } - ret &= test_GetInfo(torture, ctx); - ret &= _test_DsBind(torture, ctx, ctx->new_dc.credentials, &ctx->new_dc.drsuapi); - if (!ret) { - return ret; - } - ret &= test_FetchData(torture, ctx); - ret &= test_FetchNT4Data(torture, ctx); - return ret; + *data = ctx = test_create_context(tctx); + torture_assert(tctx, ctx, "test_create_context() failed"); + + bret = _test_DsBind(tctx, ctx, ctx->admin.credentials, &ctx->admin.drsuapi); + torture_assert(tctx, bret, "_test_DsBind() failed"); + + bret = test_LDAPBind(tctx, ctx, ctx->admin.credentials, &ctx->admin.ldap); + torture_assert(tctx, bret, "test_LDAPBind() failed"); + + bret = test_GetInfo(tctx, ctx); + torture_assert(tctx, bret, "test_GetInfo() failed"); + + bret = _test_DsBind(tctx, ctx, ctx->new_dc.credentials, &ctx->new_dc.drsuapi); + torture_assert(tctx, bret, "_test_DsBind() failed"); + + return true; } + +/** + * DSSYNC test case cleanup + */ +static bool torture_dssync_tcase_teardown(struct torture_context *tctx, void *data) +{ + struct DsSyncTest *ctx; + struct drsuapi_DsUnbind r; + struct policy_handle bind_handle; + + ctx = talloc_get_type(data, struct DsSyncTest); + + ZERO_STRUCT(r); + r.out.bind_handle = &bind_handle; + + /* Unbing admin handle */ + r.in.bind_handle = &ctx->admin.drsuapi.bind_handle; + dcerpc_drsuapi_DsUnbind(ctx->admin.drsuapi.drs_pipe, ctx, &r); + + /* Unbing new_dc handle */ + r.in.bind_handle = &ctx->new_dc.drsuapi.bind_handle; + dcerpc_drsuapi_DsUnbind(ctx->new_dc.drsuapi.drs_pipe, ctx, &r); + + talloc_free(ctx); + + return true; +} + +/** + * DSSYNC test case implementation + */ +void torture_drs_rpc_dssync_tcase(struct torture_suite *suite) +{ + typedef bool (*run_func) (struct torture_context *test, void *tcase_data); + + struct torture_test *test; + struct torture_tcase *tcase = torture_suite_add_tcase(suite, "DSSYNC"); + + torture_tcase_set_fixture(tcase, + torture_dssync_tcase_setup, + torture_dssync_tcase_teardown); + + test = torture_tcase_add_simple_test(tcase, "DC_FetchData", (run_func)test_FetchData); + test = torture_tcase_add_simple_test(tcase, "FetchNT4Data", (run_func)test_FetchNT4Data); +} + diff --git a/source4/torture/rpc/rpc.c b/source4/torture/rpc/rpc.c index 71043f0282..141a39e258 100644 --- a/source4/torture/rpc/rpc.c +++ b/source4/torture/rpc/rpc.c @@ -495,7 +495,7 @@ NTSTATUS torture_rpc_init(void) torture_suite_add_simple_test(suite, "SAMBA3-REGCONFIG", torture_samba3_regconfig); torture_suite_add_simple_test(suite, "ALTERCONTEXT", torture_rpc_alter_context); torture_suite_add_simple_test(suite, "JOIN", torture_rpc_join); - torture_suite_add_simple_test(suite, "DSSYNC", torture_rpc_dssync); + torture_drs_rpc_dssync_tcase(suite); torture_suite_add_simple_test(suite, "BENCH-RPC", torture_bench_rpc); torture_suite_add_simple_test(suite, "ASYNCBIND", torture_async_bind); torture_suite_add_suite(suite, torture_rpc_ntsvcs(suite)); -- cgit