s4-smbtorture: use torture_context for debugging output everywhere in libnet torture...
authorGünther Deschner <gd@samba.org>
Tue, 23 Mar 2010 14:31:27 +0000 (15:31 +0100)
committerGünther Deschner <gd@samba.org>
Tue, 23 Mar 2010 15:13:54 +0000 (16:13 +0100)
Mimir, please check.

Guenther

12 files changed:
source4/torture/libnet/groupinfo.c
source4/torture/libnet/groupman.c
source4/torture/libnet/libnet_domain.c
source4/torture/libnet/libnet_group.c
source4/torture/libnet/libnet_lookup.c
source4/torture/libnet/libnet_rpc.c
source4/torture/libnet/libnet_share.c
source4/torture/libnet/libnet_user.c
source4/torture/libnet/userinfo.c
source4/torture/libnet/userman.c
source4/torture/libnet/utils.c
source4/torture/libnet/utils.h

index 055f1563516c7cf5ab68150df19eda8db924c740..6b58ddf0f542c3c130b9270078843c84deb2315e 100644 (file)
@@ -29,7 +29,8 @@
 #define TEST_GROUPNAME  "libnetgroupinfotest"
 
 
-static bool test_groupinfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_groupinfo(struct torture_context *tctx,
+                          struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
                           struct policy_handle *domain_handle,
                           struct dom_sid2 *domain_sid, const char* group_name,
                           uint32_t *rid)
@@ -45,10 +46,10 @@ static bool test_groupinfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
        group.in.sid           = dom_sid_string(mem_ctx, group_sid);
        group.in.level         = level;       /* this should be extended */
 
-       printf("Testing sync libnet_rpc_groupinfo (SID argument)\n");
+       torture_comment(tctx, "Testing sync libnet_rpc_groupinfo (SID argument)\n");
        status = libnet_rpc_groupinfo(p, mem_ctx, &group);
        if (!NT_STATUS_IS_OK(status)) {
-               printf("Failed to call sync libnet_rpc_userinfo - %s\n", nt_errstr(status));
+               torture_comment(tctx, "Failed to call sync libnet_rpc_userinfo - %s\n", nt_errstr(status));
                return false;
        }
 
@@ -62,7 +63,7 @@ static bool test_groupinfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
        printf("Testing sync libnet_rpc_groupinfo (groupname argument)\n");
        status = libnet_rpc_groupinfo(p, mem_ctx, &group);
        if (!NT_STATUS_IS_OK(status)) {
-               printf("Failed to call sync libnet_rpc_groupinfo - %s\n", nt_errstr(status));
+               torture_comment(tctx, "Failed to call sync libnet_rpc_groupinfo - %s\n", nt_errstr(status));
                return false;
        }
 
@@ -103,17 +104,17 @@ bool torture_groupinfo(struct torture_context *torture)
                goto done;
        }
 
-       if (!test_group_create(b, mem_ctx, &h, TEST_GROUPNAME, &rid)) {
+       if (!test_group_create(torture, b, mem_ctx, &h, TEST_GROUPNAME, &rid)) {
                ret = false;
                goto done;
        }
 
-       if (!test_groupinfo(p, mem_ctx, &h, &sid, TEST_GROUPNAME, &rid)) {
+       if (!test_groupinfo(torture, p, mem_ctx, &h, &sid, TEST_GROUPNAME, &rid)) {
                ret = false;
                goto done;
        }
 
-       if (!test_group_cleanup(b, mem_ctx, &h, TEST_GROUPNAME)) {
+       if (!test_group_cleanup(torture, b, mem_ctx, &h, TEST_GROUPNAME)) {
                ret = false;
                goto done;
        }
index ada17b480951d0d707f402fb931135873dd92db9..e2b565735a6594bd58cd0886bd00b4ee4d39cc2b 100644 (file)
@@ -82,7 +82,7 @@ bool torture_groupadd(struct torture_context *torture)
                goto done;
        }
 
-       if (!test_group_cleanup(b, mem_ctx, &h, name)) {
+       if (!test_group_cleanup(torture, b, mem_ctx, &h, name)) {
                ret = false;
                goto done;
        }
index d6b389fede3e3a768c6ec8365a02a04f91493d1e..bd0e1fa2236d1b6b174a4a72754738ddfd927bc5 100644 (file)
@@ -28,7 +28,8 @@
 #include "param/param.h"
 
 
-static bool test_opendomain_samr(struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx,
+static bool test_opendomain_samr(struct torture_context *tctx,
+                                struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx,
                                 struct policy_handle *handle, struct lsa_String *domname,
                                 uint32_t *access_mask, struct dom_sid **sid_p)
 {
@@ -39,7 +40,7 @@ static bool test_opendomain_samr(struct dcerpc_binding_handle *b, TALLOC_CTX *me
        struct dom_sid2 *sid = NULL;
        struct samr_OpenDomain r3;
 
-       printf("connecting\n");
+       torture_comment(tctx, "connecting\n");
 
        *access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
 
@@ -49,7 +50,7 @@ static bool test_opendomain_samr(struct dcerpc_binding_handle *b, TALLOC_CTX *me
 
        status = dcerpc_samr_Connect_r(b, mem_ctx, &r1);
        if (!NT_STATUS_IS_OK(status)) {
-               printf("Connect failed - %s\n", nt_errstr(status));
+               torture_comment(tctx, "Connect failed - %s\n", nt_errstr(status));
                return false;
        }
 
@@ -57,11 +58,11 @@ static bool test_opendomain_samr(struct dcerpc_binding_handle *b, TALLOC_CTX *me
        r2.in.domain_name = domname;
        r2.out.sid = &sid;
 
-       printf("domain lookup on %s\n", domname->string);
+       torture_comment(tctx, "domain lookup on %s\n", domname->string);
 
        status = dcerpc_samr_LookupDomain_r(b, mem_ctx, &r2);
        if (!NT_STATUS_IS_OK(status)) {
-               printf("LookupDomain failed - %s\n", nt_errstr(status));
+               torture_comment(tctx, "LookupDomain failed - %s\n", nt_errstr(status));
                return false;
        }
 
@@ -70,11 +71,11 @@ static bool test_opendomain_samr(struct dcerpc_binding_handle *b, TALLOC_CTX *me
        r3.in.sid = *sid_p = *r2.out.sid;
        r3.out.domain_handle = &domain_handle;
 
-       printf("opening domain\n");
+       torture_comment(tctx, "opening domain\n");
 
        status = dcerpc_samr_OpenDomain_r(b, mem_ctx, &r3);
        if (!NT_STATUS_IS_OK(status)) {
-               printf("OpenDomain failed - %s\n", nt_errstr(status));
+               torture_comment(tctx, "OpenDomain failed - %s\n", nt_errstr(status));
                return false;
        } else {
                *handle = domain_handle;
@@ -135,7 +136,7 @@ bool torture_domain_open_lsa(struct torture_context *torture)
 
        ctx = libnet_context_init(torture->ev, torture->lp_ctx);
        if (ctx == NULL) {
-               d_printf("failed to create libnet context\n");
+               torture_comment(torture, "failed to create libnet context\n");
                return false;
        }
 
@@ -148,7 +149,7 @@ bool torture_domain_open_lsa(struct torture_context *torture)
 
        status = libnet_DomainOpen(ctx, torture, &r);
        if (!NT_STATUS_IS_OK(status)) {
-               d_printf("failed to open domain on lsa service: %s\n", nt_errstr(status));
+               torture_comment(torture, "failed to open domain on lsa service: %s\n", nt_errstr(status));
                ret = false;
                goto done;
        }
@@ -159,7 +160,7 @@ bool torture_domain_open_lsa(struct torture_context *torture)
 
        status = dcerpc_lsa_Close_r(ctx->lsa.pipe->binding_handle, ctx, &lsa_close);
        if (!NT_STATUS_IS_OK(status)) {
-               d_printf("failed to close domain on lsa service: %s\n", nt_errstr(status));
+               torture_comment(torture, "failed to close domain on lsa service: %s\n", nt_errstr(status));
                ret = false;
        }
 
@@ -189,7 +190,7 @@ bool torture_domain_close_lsa(struct torture_context *torture)
 
        ctx = libnet_context_init(torture->ev, torture->lp_ctx);
        if (ctx == NULL) {
-               d_printf("failed to create libnet context\n");
+               torture_comment(torture, "failed to create libnet context\n");
                ret = false;
                goto done;
        }
@@ -200,7 +201,7 @@ bool torture_domain_close_lsa(struct torture_context *torture)
        status = dcerpc_pipe_connect_b(mem_ctx, &p, binding, &ndr_table_lsarpc,
                                     cmdline_credentials, torture->ev, torture->lp_ctx);
        if (!NT_STATUS_IS_OK(status)) {
-               d_printf("failed to connect to server: %s\n", nt_errstr(status));
+               torture_comment(torture, "failed to connect to server: %s\n", nt_errstr(status));
                ret = false;
                goto done;
        }
@@ -208,7 +209,7 @@ bool torture_domain_close_lsa(struct torture_context *torture)
        domain_name.string = lp_workgroup(torture->lp_ctx);
 
        if (!test_opendomain_lsa(p->binding_handle, torture, &h, &domain_name, &access_mask)) {
-               d_printf("failed to open domain on lsa service\n");
+               torture_comment(torture, "failed to open domain on lsa service\n");
                ret = false;
                goto done;
        }
@@ -262,7 +263,7 @@ bool torture_domain_open_samr(struct torture_context *torture)
        /*
         * Testing synchronous version
         */
-       printf("opening domain\n");
+       torture_comment(torture, "opening domain\n");
 
        io.in.type         = DOMAIN_SAMR;
        io.in.domain_name  = domain_name;
@@ -270,7 +271,7 @@ bool torture_domain_open_samr(struct torture_context *torture)
 
        status = libnet_DomainOpen(ctx, mem_ctx, &io);
        if (!NT_STATUS_IS_OK(status)) {
-               printf("Composite domain open failed - %s\n", nt_errstr(status));
+               torture_comment(torture, "Composite domain open failed - %s\n", nt_errstr(status));
                ret = false;
                goto done;
        }
@@ -280,11 +281,11 @@ bool torture_domain_open_samr(struct torture_context *torture)
        r.in.handle   = &domain_handle;
        r.out.handle  = &handle;
 
-       printf("closing domain handle\n");
+       torture_comment(torture, "closing domain handle\n");
 
        status = dcerpc_samr_Close_r(ctx->samr.pipe->binding_handle, mem_ctx, &r);
        if (!NT_STATUS_IS_OK(status)) {
-               printf("Close failed - %s\n", nt_errstr(status));
+               torture_comment(torture, "Close failed - %s\n", nt_errstr(status));
                ret = false;
                goto done;
        }
@@ -318,7 +319,7 @@ bool torture_domain_close_samr(struct torture_context *torture)
 
        ctx = libnet_context_init(torture->ev, torture->lp_ctx);
        if (ctx == NULL) {
-               d_printf("failed to create libnet context\n");
+               torture_comment(torture, "failed to create libnet context\n");
                ret = false;
                goto done;
        }
@@ -329,15 +330,15 @@ bool torture_domain_close_samr(struct torture_context *torture)
        status = dcerpc_pipe_connect_b(mem_ctx, &p, binding, &ndr_table_samr,
                                     ctx->cred, torture->ev, torture->lp_ctx);
        if (!NT_STATUS_IS_OK(status)) {
-               d_printf("failed to connect to server: %s\n", nt_errstr(status));
+               torture_comment(torture, "failed to connect to server: %s\n", nt_errstr(status));
                ret = false;
                goto done;
        }
 
        domain_name.string = talloc_strdup(mem_ctx, lp_workgroup(torture->lp_ctx));
 
-       if (!test_opendomain_samr(p->binding_handle, torture, &h, &domain_name, &access_mask, &sid)) {
-               d_printf("failed to open domain on samr service\n");
+       if (!test_opendomain_samr(torture, p->binding_handle, torture, &h, &domain_name, &access_mask, &sid)) {
+               torture_comment(torture, "failed to open domain on samr service\n");
                ret = false;
                goto done;
        }
@@ -386,7 +387,7 @@ bool torture_domain_list(struct torture_context *torture)
 
        ctx = libnet_context_init(torture->ev, torture->lp_ctx);
        if (ctx == NULL) {
-               d_printf("failed to create libnet context\n");
+               torture_comment(torture, "failed to create libnet context\n");
                ret = false;
                goto done;
        }
@@ -408,10 +409,10 @@ bool torture_domain_list(struct torture_context *torture)
                goto done;
        }
 
-       d_printf("Received list or domains (everything in one piece):\n");
+       torture_comment(torture, "Received list or domains (everything in one piece):\n");
 
        for (i = 0; i < r.out.count; i++) {
-               d_printf("Name[%d]: %s\n", i, r.out.domains[i].name);
+               torture_comment(torture, "Name[%d]: %s\n", i, r.out.domains[i].name);
        }
 
        /*
@@ -429,14 +430,14 @@ bool torture_domain_list(struct torture_context *torture)
                goto done;
        }
 
-       d_printf("Received list or domains (collected in more than one round):\n");
+       torture_comment(torture, "Received list or domains (collected in more than one round):\n");
 
        for (i = 0; i < r.out.count; i++) {
-               d_printf("Name[%d]: %s\n", i, r.out.domains[i].name);
+               torture_comment(torture, "Name[%d]: %s\n", i, r.out.domains[i].name);
        }
 
 done:
-       d_printf("\nStatus: %s\n", nt_errstr(status));
+       torture_comment(torture, "\nStatus: %s\n", nt_errstr(status));
 
        talloc_free(mem_ctx);
        talloc_free(ctx);
index 531820564cd24769419dc316d627d3a4aba0282d..db711916df6e978ebdefc7fe980815a62eae6c9c 100644 (file)
@@ -31,7 +31,8 @@
 #define TEST_GROUPNAME  "libnetgrouptest"
 
 
-static bool test_cleanup(struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx,
+static bool test_cleanup(struct torture_context *tctx,
+                        struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx,
                         struct policy_handle *domain_handle, const char *groupname)
 {
        NTSTATUS status;
@@ -51,11 +52,11 @@ static bool test_cleanup(struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx,
        r1.out.rids          = &rids;
        r1.out.types         = &types;
 
-       printf("group account lookup '%s'\n", groupname);
+       torture_comment(tctx, "group account lookup '%s'\n", groupname);
 
        status = dcerpc_samr_LookupNames_r(b, mem_ctx, &r1);
        if (!NT_STATUS_IS_OK(status)) {
-               printf("LookupNames failed - %s\n", nt_errstr(status));
+               torture_comment(tctx, "LookupNames failed - %s\n", nt_errstr(status));
                return false;
        }
 
@@ -66,22 +67,22 @@ static bool test_cleanup(struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx,
        r2.in.rid            = rid;
        r2.out.group_handle  = &group_handle;
 
-       printf("opening group account\n");
+       torture_comment(tctx, "opening group account\n");
 
        status = dcerpc_samr_OpenGroup_r(b, mem_ctx, &r2);
        if (!NT_STATUS_IS_OK(status)) {
-               printf("OpenGroup failed - %s\n", nt_errstr(status));
+               torture_comment(tctx, "OpenGroup failed - %s\n", nt_errstr(status));
                return false;
        }
 
        r3.in.group_handle  = &group_handle;
        r3.out.group_handle = &group_handle;
 
-       printf("deleting group account\n");
+       torture_comment(tctx, "deleting group account\n");
 
        status = dcerpc_samr_DeleteDomainGroup_r(b, mem_ctx, &r3);
        if (!NT_STATUS_IS_OK(status)) {
-               printf("DeleteGroup failed - %s\n", nt_errstr(status));
+               torture_comment(tctx, "DeleteGroup failed - %s\n", nt_errstr(status));
                return false;
        }
 
@@ -89,7 +90,8 @@ static bool test_cleanup(struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx,
 }
 
 
-static bool test_creategroup(struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx,
+static bool test_creategroup(struct torture_context *tctx,
+                            struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx,
                             struct policy_handle *handle, const char *name)
 {
        NTSTATUS status;
@@ -106,23 +108,23 @@ static bool test_creategroup(struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ct
        r.out.group_handle  = &group_handle;
        r.out.rid           = &group_rid;
 
-       printf("creating group account %s\n", name);
+       torture_comment(tctx, "creating group account %s\n", name);
 
        status = dcerpc_samr_CreateDomainGroup_r(b, mem_ctx, &r);
        if (!NT_STATUS_IS_OK(status)) {
-               printf("CreateGroup failed - %s\n", nt_errstr(status));
+               torture_comment(tctx, "CreateGroup failed - %s\n", nt_errstr(status));
 
                if (NT_STATUS_EQUAL(status, NT_STATUS_GROUP_EXISTS)) {
-                       printf("Group (%s) already exists - attempting to delete and recreate group again\n", name);
-                       if (!test_cleanup(b, mem_ctx, handle, TEST_GROUPNAME)) {
+                       torture_comment(tctx, "Group (%s) already exists - attempting to delete and recreate group again\n", name);
+                       if (!test_cleanup(tctx, b, mem_ctx, handle, TEST_GROUPNAME)) {
                                return false;
                        }
 
-                       printf("creating group account\n");
+                       torture_comment(tctx, "creating group account\n");
 
                        status = dcerpc_samr_CreateDomainGroup_r(b, mem_ctx, &r);
                        if (!NT_STATUS_IS_OK(status)) {
-                               printf("CreateGroup failed - %s\n", nt_errstr(status));
+                               torture_comment(tctx, "CreateGroup failed - %s\n", nt_errstr(status));
                                return false;
                        }
                        return true;
@@ -134,7 +136,8 @@ static bool test_creategroup(struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ct
 }
 
 
-static bool test_opendomain(struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx,
+static bool test_opendomain(struct torture_context *tctx,
+                           struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx,
                            struct policy_handle *handle, struct lsa_String *domname)
 {
        NTSTATUS status;
@@ -144,7 +147,7 @@ static bool test_opendomain(struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx
        struct dom_sid2 *sid = NULL;
        struct samr_OpenDomain r3;
 
-       printf("connecting\n");
+       torture_comment(tctx, "connecting\n");
 
        r1.in.system_name = 0;
        r1.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
@@ -152,7 +155,7 @@ static bool test_opendomain(struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx
 
        status = dcerpc_samr_Connect_r(b, mem_ctx, &r1);
        if (!NT_STATUS_IS_OK(status)) {
-               printf("Connect failed - %s\n", nt_errstr(status));
+               torture_comment(tctx, "Connect failed - %s\n", nt_errstr(status));
                return false;
        }
 
@@ -160,11 +163,11 @@ static bool test_opendomain(struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx
        r2.in.domain_name = domname;
        r2.out.sid = &sid;
 
-       printf("domain lookup on %s\n", domname->string);
+       torture_comment(tctx, "domain lookup on %s\n", domname->string);
 
        status = dcerpc_samr_LookupDomain_r(b, mem_ctx, &r2);
        if (!NT_STATUS_IS_OK(status)) {
-               printf("LookupDomain failed - %s\n", nt_errstr(status));
+               torture_comment(tctx, "LookupDomain failed - %s\n", nt_errstr(status));
                return false;
        }
 
@@ -173,11 +176,11 @@ static bool test_opendomain(struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx
        r3.in.sid = *r2.out.sid;
        r3.out.domain_handle = &domain_handle;
 
-       printf("opening domain\n");
+       torture_comment(tctx, "opening domain\n");
 
        status = dcerpc_samr_OpenDomain_r(b, mem_ctx, &r3);
        if (!NT_STATUS_IS_OK(status)) {
-               printf("OpenDomain failed - %s\n", nt_errstr(status));
+               torture_comment(tctx, "OpenDomain failed - %s\n", nt_errstr(status));
                return false;
        } else {
                *handle = domain_handle;
@@ -187,7 +190,8 @@ static bool test_opendomain(struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx
 }
 
 
-static bool test_samr_close(struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx,
+static bool test_samr_close(struct torture_context *tctx,
+                           struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx,
                            struct policy_handle *domain_handle)
 {
        NTSTATUS status;
@@ -198,7 +202,7 @@ static bool test_samr_close(struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx
 
        status = dcerpc_samr_Close_r(b, mem_ctx, &r);
        if (!NT_STATUS_IS_OK(status)) {
-               printf("Close samr domain failed - %s\n", nt_errstr(status));
+               torture_comment(tctx, "Close samr domain failed - %s\n", nt_errstr(status));
                return false;
        }
 
@@ -206,7 +210,8 @@ static bool test_samr_close(struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx
 }
 
 
-static bool test_lsa_close(struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx,
+static bool test_lsa_close(struct torture_context *tctx,
+                          struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx,
                           struct policy_handle *domain_handle)
 {
        NTSTATUS status;
@@ -217,7 +222,7 @@ static bool test_lsa_close(struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx,
 
        status = dcerpc_lsa_Close_r(b, mem_ctx, &r);
        if (!NT_STATUS_IS_OK(status)) {
-               printf("Close lsa domain failed - %s\n", nt_errstr(status));
+               torture_comment(tctx, "Close lsa domain failed - %s\n", nt_errstr(status));
                return false;
        }
 
@@ -250,12 +255,12 @@ bool torture_groupinfo_api(struct torture_context *torture)
        }
 
        domain_name.string = lp_workgroup(torture->lp_ctx);
-       if (!test_opendomain(p->binding_handle, prep_mem_ctx, &h, &domain_name)) {
+       if (!test_opendomain(torture, p->binding_handle, prep_mem_ctx, &h, &domain_name)) {
                ret = false;
                goto done;
        }
 
-       if (!test_creategroup(p->binding_handle, prep_mem_ctx, &h, name)) {
+       if (!test_creategroup(torture, p->binding_handle, prep_mem_ctx, &h, name)) {
                ret = false;
                goto done;
        }
@@ -270,19 +275,19 @@ bool torture_groupinfo_api(struct torture_context *torture)
 
        status = libnet_GroupInfo(ctx, mem_ctx, &req);
        if (!NT_STATUS_IS_OK(status)) {
-               printf("libnet_GroupInfo call failed: %s\n", nt_errstr(status));
+               torture_comment(torture, "libnet_GroupInfo call failed: %s\n", nt_errstr(status));
                ret = false;
                goto done;
        }
 
-       if (!test_cleanup(ctx->samr.pipe->binding_handle, mem_ctx, &ctx->samr.handle, TEST_GROUPNAME)) {
-               printf("cleanup failed\n");
+       if (!test_cleanup(torture, ctx->samr.pipe->binding_handle, mem_ctx, &ctx->samr.handle, TEST_GROUPNAME)) {
+               torture_comment(torture, "cleanup failed\n");
                ret = false;
                goto done;
        }
 
-       if (!test_samr_close(ctx->samr.pipe->binding_handle, mem_ctx, &ctx->samr.handle)) {
-               printf("domain close failed\n");
+       if (!test_samr_close(torture, ctx->samr.pipe->binding_handle, mem_ctx, &ctx->samr.handle)) {
+               torture_comment(torture, "domain close failed\n");
                ret = false;
        }
 
@@ -312,7 +317,7 @@ bool torture_grouplist(struct torture_context *torture)
 
        ZERO_STRUCT(req);
 
-       printf("listing group accounts:\n");
+       torture_comment(torture, "listing group accounts:\n");
 
        do {
                req.in.domain_name  = domain_name.string;
@@ -324,7 +329,7 @@ bool torture_grouplist(struct torture_context *torture)
                    !NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES)) break;
 
                for (i = 0; i < req.out.count; i++) {
-                       printf("\tgroup: %s, sid=%s\n",
+                       torture_comment(torture, "\tgroup: %s, sid=%s\n",
                               req.out.groups[i].groupname, req.out.groups[i].sid);
                }
 
@@ -332,18 +337,18 @@ bool torture_grouplist(struct torture_context *torture)
 
        if (!(NT_STATUS_IS_OK(status) ||
              NT_STATUS_EQUAL(status, NT_STATUS_NO_MORE_ENTRIES))) {
-               printf("libnet_GroupList call failed: %s\n", nt_errstr(status));
+               torture_comment(torture, "libnet_GroupList call failed: %s\n", nt_errstr(status));
                ret = false;
                goto done;
        }
 
-       if (!test_samr_close(ctx->samr.pipe->binding_handle, mem_ctx, &ctx->samr.handle)) {
-               printf("domain close failed\n");
+       if (!test_samr_close(torture, ctx->samr.pipe->binding_handle, mem_ctx, &ctx->samr.handle)) {
+               torture_comment(torture, "domain close failed\n");
                ret = false;
        }
 
-       if (!test_lsa_close(ctx->lsa.pipe->binding_handle, mem_ctx, &ctx->lsa.handle)) {
-               printf("lsa domain close failed\n");
+       if (!test_lsa_close(torture, ctx->lsa.pipe->binding_handle, mem_ctx, &ctx->lsa.handle)) {
+               torture_comment(torture, "lsa domain close failed\n");
                ret = false;
        }
 
@@ -374,19 +379,19 @@ bool torture_creategroup(struct torture_context *torture)
 
        status = libnet_CreateGroup(ctx, mem_ctx, &req);
        if (!NT_STATUS_IS_OK(status)) {
-               printf("libnet_CreateGroup call failed: %s\n", nt_errstr(status));
+               torture_comment(torture, "libnet_CreateGroup call failed: %s\n", nt_errstr(status));
                ret = false;
                goto done;
        }
 
-       if (!test_cleanup(ctx->samr.pipe->binding_handle, mem_ctx, &ctx->samr.handle, TEST_GROUPNAME)) {
-               printf("cleanup failed\n");
+       if (!test_cleanup(torture, ctx->samr.pipe->binding_handle, mem_ctx, &ctx->samr.handle, TEST_GROUPNAME)) {
+               torture_comment(torture, "cleanup failed\n");
                ret = false;
                goto done;
        }
 
-       if (!test_samr_close(ctx->samr.pipe->binding_handle, mem_ctx, &ctx->samr.handle)) {
-               printf("domain close failed\n");
+       if (!test_samr_close(torture, ctx->samr.pipe->binding_handle, mem_ctx, &ctx->samr.handle)) {
+               torture_comment(torture, "domain close failed\n");
                ret = false;
        }
 
index 6cf615b3a85e3da8dfb3410a921942d5147c9293..832a7e5f848c5ad7be74986678d2e4b5c849f878 100644 (file)
@@ -55,14 +55,14 @@ bool torture_lookup(struct torture_context *torture)
        status = libnet_Lookup(ctx, mem_ctx, &lookup);
 
        if (!NT_STATUS_IS_OK(status)) {
-               printf("Couldn't lookup name %s: %s\n", lookup.in.hostname, nt_errstr(status));
+               torture_comment(torture, "Couldn't lookup name %s: %s\n", lookup.in.hostname, nt_errstr(status));
                ret = false;
                goto done;
        }
 
        ret = true;
 
-       printf("Name [%s] found at address: %s.\n", lookup.in.hostname, *lookup.out.address);
+       torture_comment(torture, "Name [%s] found at address: %s.\n", lookup.in.hostname, *lookup.out.address);
 
 done:
        talloc_free(mem_ctx);
@@ -98,14 +98,14 @@ bool torture_lookup_host(struct torture_context *torture)
        status = libnet_LookupHost(ctx, mem_ctx, &lookup);
 
        if (!NT_STATUS_IS_OK(status)) {
-               printf("Couldn't lookup host %s: %s\n", lookup.in.hostname, nt_errstr(status));
+               torture_comment(torture, "Couldn't lookup host %s: %s\n", lookup.in.hostname, nt_errstr(status));
                ret = false;
                goto done;
        }
 
        ret = true;
 
-       printf("Host [%s] found at address: %s.\n", lookup.in.hostname, *lookup.out.address);
+       torture_comment(torture, "Host [%s] found at address: %s.\n", lookup.in.hostname, *lookup.out.address);
 
 done:
        talloc_free(mem_ctx);
@@ -141,7 +141,7 @@ bool torture_lookup_pdc(struct torture_context *torture)
        status = libnet_LookupDCs(ctx, mem_ctx, lookup);
 
        if (!NT_STATUS_IS_OK(status)) {
-               printf("Couldn't lookup pdc %s: %s\n", lookup->in.domain_name,
+               torture_comment(torture, "Couldn't lookup pdc %s: %s\n", lookup->in.domain_name,
                       nt_errstr(status));
                ret = false;
                goto done;
@@ -149,9 +149,9 @@ bool torture_lookup_pdc(struct torture_context *torture)
 
        ret = true;
 
-       printf("DCs of domain [%s] found.\n", lookup->in.domain_name);
+       torture_comment(torture, "DCs of domain [%s] found.\n", lookup->in.domain_name);
        for (i = 0; i < lookup->out.num_dcs; i++) {
-               printf("\tDC[%d]: name=%s, address=%s\n", i, lookup->out.dcs[i].name,
+               torture_comment(torture, "\tDC[%d]: name=%s, address=%s\n", i, lookup->out.dcs[i].name,
                       lookup->out.dcs[i].address);
        }
 
index d30053d79ce511254dab870f6b4ba0f100cfe828..d4a87a8f267364674a97407d34a76dcf75f89fa0 100644 (file)
@@ -29,7 +29,8 @@
 #include "param/param.h"
 
 
-static bool test_connect_service(struct libnet_context *ctx,
+static bool test_connect_service(struct torture_context *tctx,
+                                struct libnet_context *ctx,
                                 const struct ndr_interface_table *iface,
                                 const char *binding_string,
                                 const char *hostname,
@@ -55,7 +56,7 @@ static bool test_connect_service(struct libnet_context *ctx,
        status = libnet_RpcConnect(ctx, ctx, &connect_r);
 
        if (!NT_STATUS_EQUAL(status, expected_status)) {
-               d_printf("Connecting to rpc service %s on %s.\n\tFAILED. Expected: %s."
+               torture_comment(tctx, "Connecting to rpc service %s on %s.\n\tFAILED. Expected: %s."
                       "Received: %s\n",
                       connect_r.in.dcerpc_iface->name, connect_r.in.binding, nt_errstr(expected_status),
                       nt_errstr(status));
@@ -63,18 +64,18 @@ static bool test_connect_service(struct libnet_context *ctx,
                return false;
        }
 
-       d_printf("PASSED. Expected: %s, received: %s\n", nt_errstr(expected_status),
+       torture_comment(tctx, "PASSED. Expected: %s, received: %s\n", nt_errstr(expected_status),
               nt_errstr(status));
 
        if (connect_r.level == LIBNET_RPC_CONNECT_DC_INFO && NT_STATUS_IS_OK(status)) {
-               d_printf("Domain Controller Info:\n");
-               d_printf("\tDomain Name:\t %s\n", connect_r.out.domain_name);
-               d_printf("\tDomain SID:\t %s\n", dom_sid_string(ctx, connect_r.out.domain_sid));
-               d_printf("\tRealm:\t\t %s\n", connect_r.out.realm);
-               d_printf("\tGUID:\t\t %s\n", GUID_string(ctx, connect_r.out.guid));
+               torture_comment(tctx, "Domain Controller Info:\n");
+               torture_comment(tctx, "\tDomain Name:\t %s\n", connect_r.out.domain_name);
+               torture_comment(tctx, "\tDomain SID:\t %s\n", dom_sid_string(ctx, connect_r.out.domain_sid));
+               torture_comment(tctx, "\tRealm:\t\t %s\n", connect_r.out.realm);
+               torture_comment(tctx, "\tGUID:\t\t %s\n", GUID_string(ctx, connect_r.out.guid));
 
        } else if (!NT_STATUS_IS_OK(status)) {
-               d_printf("Error string: %s\n", connect_r.out.error_string);
+               torture_comment(tctx, "Error string: %s\n", connect_r.out.error_string);
        }
 
        return true;
@@ -90,38 +91,39 @@ static bool torture_rpc_connect(struct torture_context *torture,
        ctx = libnet_context_init(torture->ev, torture->lp_ctx);
        ctx->cred = cmdline_credentials;
 
-       d_printf("Testing connection to LSA interface\n");
-       if (!test_connect_service(ctx, &ndr_table_lsarpc, bindstr,
+       torture_comment(torture, "Testing connection to LSA interface\n");
+
+       if (!test_connect_service(torture, ctx, &ndr_table_lsarpc, bindstr,
                                  hostname, level, false, NT_STATUS_OK)) {
-               d_printf("failed to connect LSA interface\n");
+               torture_comment(torture, "failed to connect LSA interface\n");
                return false;
        }
 
-       d_printf("Testing connection to SAMR interface\n");
-       if (!test_connect_service(ctx, &ndr_table_samr, bindstr,
+       torture_comment(torture, "Testing connection to SAMR interface\n");
+       if (!test_connect_service(torture, ctx, &ndr_table_samr, bindstr,
                                  hostname, level, false, NT_STATUS_OK)) {
-               d_printf("failed to connect SAMR interface\n");
+               torture_comment(torture, "failed to connect SAMR interface\n");
                return false;
        }
 
-       d_printf("Testing connection to SRVSVC interface\n");
-       if (!test_connect_service(ctx, &ndr_table_srvsvc, bindstr,
+       torture_comment(torture, "Testing connection to SRVSVC interface\n");
+       if (!test_connect_service(torture, ctx, &ndr_table_srvsvc, bindstr,
                                  hostname, level, false, NT_STATUS_OK)) {
-               d_printf("failed to connect SRVSVC interface\n");
+               torture_comment(torture, "failed to connect SRVSVC interface\n");
                return false;
        }
 
-       d_printf("Testing connection to LSA interface with wrong credentials\n");
-       if (!test_connect_service(ctx, &ndr_table_lsarpc, bindstr,
+       torture_comment(torture, "Testing connection to LSA interface with wrong credentials\n");
+       if (!test_connect_service(torture, ctx, &ndr_table_lsarpc, bindstr,
                                  hostname, level, true, NT_STATUS_LOGON_FAILURE)) {
-               d_printf("failed to test wrong credentials on LSA interface\n");
+               torture_comment(torture, "failed to test wrong credentials on LSA interface\n");
                return false;
        }
 
-       d_printf("Testing connection to SAMR interface with wrong credentials\n");
-       if (!test_connect_service(ctx, &ndr_table_samr, bindstr,
+       torture_comment(torture, "Testing connection to SAMR interface with wrong credentials\n");
+       if (!test_connect_service(torture, ctx, &ndr_table_samr, bindstr,
                                  hostname, level, true, NT_STATUS_LOGON_FAILURE)) {
-               d_printf("failed to test wrong credentials on SAMR interface\n");
+               torture_comment(torture, "failed to test wrong credentials on SAMR interface\n");
                return false;
        }
 
index 1d64f558ada11406ac0ce7c44481a17335d77c83..966c21d33e57e805c4e6c81cf4ad6ec38549b876 100644 (file)
@@ -29,7 +29,8 @@
 #define TEST_SHARENAME "libnetsharetest"
 
 
-static void test_displayshares(struct libnet_ListShares s)
+static void test_displayshares(struct torture_context *tctx,
+                              struct libnet_ListShares s)
 {
        int i, j;
 
@@ -55,7 +56,7 @@ static void test_displayshares(struct libnet_ListShares s)
        case 0:
                for (i = 0; i < s.out.ctr.ctr0->count; i++) {
                        struct srvsvc_NetShareInfo0 *info = &s.out.ctr.ctr0->array[i];
-                       d_printf("\t[%d] %s\n", i, info->name);
+                       torture_comment(tctx, "\t[%d] %s\n", i, info->name);
                }
                break;
 
@@ -65,7 +66,7 @@ static void test_displayshares(struct libnet_ListShares s)
                        for (j = 0; j < ARRAY_SIZE(share_types); j++) {
                                if (share_types[j].type == info->type) break;
                        }
-                       d_printf("\t[%d] %s (%s)\t%s\n", i, info->name,
+                       torture_comment(tctx, "\t[%d] %s (%s)\t%s\n", i, info->name,
                               info->comment, share_types[j].desc);
                }
                break;
@@ -76,7 +77,7 @@ static void test_displayshares(struct libnet_ListShares s)
                        for (j = 0; j < ARRAY_SIZE(share_types); j++) {
                                if (share_types[j].type == info->type) break;
                        }
-                       d_printf("\t[%d] %s\t%s\n\t    %s\n\t    [perms=0x%08x, max_usr=%d, cur_usr=%d, path=%s, pass=%s]\n",
+                       torture_comment(tctx, "\t[%d] %s\t%s\n\t    %s\n\t    [perms=0x%08x, max_usr=%d, cur_usr=%d, path=%s, pass=%s]\n",
                                 i, info->name, share_types[j].desc, info->comment,
                                 info->permissions, info->max_users,
                                 info->current_users, info->path,
@@ -90,7 +91,7 @@ static void test_displayshares(struct libnet_ListShares s)
                        for (j = 0; j < ARRAY_SIZE(share_types); j++) {
                                if (share_types[j].type == info->type) break;
                        }
-                       d_printf("\t[%d] %s\t%s [csc_policy=0x%08x]\n\t    %s\n", i, info->name,
+                       torture_comment(tctx, "\t[%d] %s\t%s [csc_policy=0x%08x]\n\t    %s\n", i, info->name,
                                 share_types[j].desc, info->csc_policy,
                                 info->comment);
                }
@@ -102,7 +103,7 @@ static void test_displayshares(struct libnet_ListShares s)
                        for (j = 0; j < ARRAY_SIZE(share_types); j++) {
                                if (share_types[j].type == info->type) break;
                        }
-                       d_printf("\t[%d] %s\t%s\n\t    %s\n\t    [perms=0x%08x, max_usr=%d, cur_usr=%d, path=%s, pass=%s]\n",
+                       torture_comment(tctx, "\t[%d] %s\t%s\n\t    %s\n\t    [perms=0x%08x, max_usr=%d, cur_usr=%d, path=%s, pass=%s]\n",
                                 i, info->name, share_types[j].desc, info->comment,
                                 info->permissions, info->max_users,
                                 info->current_users, info->path,
@@ -133,30 +134,30 @@ bool torture_listshares(struct torture_context *torture)
 
        libnetctx = libnet_context_init(torture->ev, torture->lp_ctx);
        if (!libnetctx) {
-               printf("Couldn't allocate libnet context\n");
+               torture_comment(torture, "Couldn't allocate libnet context\n");
                ret = false;
                goto done;
        }
 
        libnetctx->cred = cmdline_credentials;
 
-       printf("Testing libnet_ListShare\n");
+       torture_comment(torture, "Testing libnet_ListShare\n");
 
        share.in.server_name = talloc_asprintf(mem_ctx, "%s", binding->host);
 
        for (i = 0; i < ARRAY_SIZE(levels); i++) {
                share.in.level = levels[i];
-               printf("testing libnet_ListShare level %u\n", share.in.level);
+               torture_comment(torture, "testing libnet_ListShare level %u\n", share.in.level);
 
                status = libnet_ListShares(libnetctx, mem_ctx, &share);
                if (!NT_STATUS_IS_OK(status)) {
-                       printf("libnet_ListShare level %u failed - %s\n", share.in.level, share.out.error_string);
+                       torture_comment(torture, "libnet_ListShare level %u failed - %s\n", share.in.level, share.out.error_string);
                        ret = false;
                        goto done;
                }
 
-               printf("listing shares:\n");
-               test_displayshares(share);
+               torture_comment(torture, "listing shares:\n");
+               test_displayshares(torture, share);
        }
 
 done:
@@ -165,7 +166,8 @@ done:
 }
 
 
-static bool test_addshare(struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx, const char *host,
+static bool test_addshare(struct torture_context *tctx,
+                         struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx, const char *host,
                          const char* share)
 {
        NTSTATUS status;
@@ -190,11 +192,11 @@ static bool test_addshare(struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx,
 
        status = dcerpc_srvsvc_NetShareAdd_r(b, mem_ctx, &add);
        if (!NT_STATUS_IS_OK(status)) {
-               printf("Failed to add a new share\n");
+               torture_comment(tctx, "Failed to add a new share\n");
                return false;
        }
 
-       printf("share added\n");
+       torture_comment(tctx, "share added\n");
        return true;
 }
 
@@ -222,7 +224,7 @@ bool torture_delshare(struct torture_context *torture)
 
        torture_assert_ntstatus_ok(torture, status, "Failed to get rpc connection");
 
-       if (!test_addshare(p->binding_handle, torture, host, TEST_SHARENAME)) {
+       if (!test_addshare(torture, p->binding_handle, torture, host, TEST_SHARENAME)) {
                return false;
        }
 
index 873a701ca9ffd8aef57bdccddccdc6b3181140df..3f7ea5494f5a13eb455e798d8fa509041c2e35da 100644 (file)
@@ -29,7 +29,8 @@
 #include "param/param.h"
 
 
-static bool test_cleanup(struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx,
+static bool test_cleanup(struct torture_context *tctx,
+                        struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx,
                         struct policy_handle *domain_handle, const char *username)
 {
        NTSTATUS status;
@@ -49,11 +50,11 @@ static bool test_cleanup(struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx,
        r1.out.rids          = &rids;
        r1.out.types         = &types;
 
-       printf("user account lookup '%s'\n", username);
+       torture_comment(tctx, "user account lookup '%s'\n", username);
 
        status = dcerpc_samr_LookupNames_r(b, mem_ctx, &r1);
        if (!NT_STATUS_IS_OK(status)) {
-               printf("LookupNames failed - %s\n", nt_errstr(status));
+               torture_comment(tctx, "LookupNames failed - %s\n", nt_errstr(status));
                return false;
        }
 
@@ -64,22 +65,22 @@ static bool test_cleanup(struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx,
        r2.in.rid            = rid;
        r2.out.user_handle   = &user_handle;
 
-       printf("opening user account\n");
+       torture_comment(tctx, "opening user account\n");
 
        status = dcerpc_samr_OpenUser_r(b, mem_ctx, &r2);
        if (!NT_STATUS_IS_OK(status)) {
-               printf("OpenUser failed - %s\n", nt_errstr(status));
+               torture_comment(tctx, "OpenUser failed - %s\n", nt_errstr(status));
                return false;
        }
 
        r3.in.user_handle  = &user_handle;
        r3.out.user_handle = &user_handle;
 
-       printf("deleting user account\n");
+       torture_comment(tctx, "deleting user account\n");
 
        status = dcerpc_samr_DeleteUser_r(b, mem_ctx, &r3);
        if (!NT_STATUS_IS_OK(status)) {
-               printf("DeleteUser failed - %s\n", nt_errstr(status));
+               torture_comment(tctx, "DeleteUser failed - %s\n", nt_errstr(status));
                return false;
        }
 
@@ -87,7 +88,8 @@ static bool test_cleanup(struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx,
 }
 
 
-static bool test_opendomain(struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx,
+static bool test_opendomain(struct torture_context *tctx,
+                           struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx,
                            struct policy_handle *handle, struct lsa_String *domname)
 {
        NTSTATUS status;
@@ -97,7 +99,7 @@ static bool test_opendomain(struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx
        struct dom_sid2 *sid = NULL;
        struct samr_OpenDomain r3;
 
-       printf("connecting\n");
+       torture_comment(tctx, "connecting\n");
 
        r1.in.system_name = 0;
        r1.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
@@ -105,7 +107,7 @@ static bool test_opendomain(struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx
 
        status = dcerpc_samr_Connect_r(b, mem_ctx, &r1);
        if (!NT_STATUS_IS_OK(status)) {
-               printf("Connect failed - %s\n", nt_errstr(status));
+               torture_comment(tctx, "Connect failed - %s\n", nt_errstr(status));
                return false;
        }
 
@@ -113,11 +115,11 @@ static bool test_opendomain(struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx
        r2.in.domain_name = domname;
        r2.out.sid = &sid;
 
-       printf("domain lookup on %s\n", domname->string);
+       torture_comment(tctx, "domain lookup on %s\n", domname->string);
 
        status = dcerpc_samr_LookupDomain_r(b, mem_ctx, &r2);
        if (!NT_STATUS_IS_OK(status)) {
-               printf("LookupDomain failed - %s\n", nt_errstr(status));
+               torture_comment(tctx, "LookupDomain failed - %s\n", nt_errstr(status));
                return false;
        }
 
@@ -126,11 +128,11 @@ static bool test_opendomain(struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx
        r3.in.sid = *r2.out.sid;
        r3.out.domain_handle = &domain_handle;
 
-       printf("opening domain\n");
+       torture_comment(tctx, "opening domain\n");
 
        status = dcerpc_samr_OpenDomain_r(b, mem_ctx, &r3);
        if (!NT_STATUS_IS_OK(status)) {
-               printf("OpenDomain failed - %s\n", nt_errstr(status));
+               torture_comment(tctx, "OpenDomain failed - %s\n", nt_errstr(status));
                return false;
        } else {
                *handle = domain_handle;
@@ -140,7 +142,8 @@ static bool test_opendomain(struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx
 }
 
 
-static bool test_samr_close(struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx,
+static bool test_samr_close(struct torture_context *tctx,
+                           struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx,
                            struct policy_handle *domain_handle)
 {
        NTSTATUS status;
@@ -151,7 +154,7 @@ static bool test_samr_close(struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx
 
        status = dcerpc_samr_Close_r(b, mem_ctx, &r);
        if (!NT_STATUS_IS_OK(status)) {
-               printf("Close samr domain failed - %s\n", nt_errstr(status));
+               torture_comment(tctx, "Close samr domain failed - %s\n", nt_errstr(status));
                return false;
        }
 
@@ -159,7 +162,8 @@ static bool test_samr_close(struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx
 }
 
 
-static bool test_lsa_close(struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx,
+static bool test_lsa_close(struct torture_context *tctx,
+                          struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx,
                           struct policy_handle *domain_handle)
 {
        NTSTATUS status;
@@ -170,7 +174,7 @@ static bool test_lsa_close(struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx,
 
        status = dcerpc_lsa_Close_r(b, mem_ctx, &r);
        if (!NT_STATUS_IS_OK(status)) {
-               printf("Close lsa domain failed - %s\n", nt_errstr(status));
+               torture_comment(tctx, "Close lsa domain failed - %s\n", nt_errstr(status));
                return false;
        }
 
@@ -178,7 +182,8 @@ static bool test_lsa_close(struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx,
 }
 
 
-static bool test_createuser(struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx,
+static bool test_createuser(struct torture_context *tctx,
+                           struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx,
                            struct policy_handle *handle, const char* user)
 {
        NTSTATUS status;
@@ -196,23 +201,23 @@ static bool test_createuser(struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx
        r1.out.user_handle = &user_handle;
        r1.out.rid = &user_rid;
 
-       printf("creating user '%s'\n", username.string);
+       torture_comment(tctx, "creating user '%s'\n", username.string);
 
        status = dcerpc_samr_CreateUser_r(b, mem_ctx, &r1);
        if (!NT_STATUS_IS_OK(status)) {
-               printf("CreateUser failed - %s\n", nt_errstr(status));
+               torture_comment(tctx, "CreateUser failed - %s\n", nt_errstr(status));
 
                if (NT_STATUS_EQUAL(status, NT_STATUS_USER_EXISTS)) {
-                       printf("User (%s) already exists - attempting to delete and recreate account again\n", user);
-                       if (!test_cleanup(b, mem_ctx, handle, TEST_USERNAME)) {
+                       torture_comment(tctx, "User (%s) already exists - attempting to delete and recreate account again\n", user);
+                       if (!test_cleanup(tctx, b, mem_ctx, handle, TEST_USERNAME)) {
                                return false;
                        }
 
-                       printf("creating user account\n");
+                       torture_comment(tctx, "creating user account\n");
 
                        status = dcerpc_samr_CreateUser_r(b, mem_ctx, &r1);
                        if (!NT_STATUS_IS_OK(status)) {
-                               printf("CreateUser failed - %s\n", nt_errstr(status));
+                               torture_comment(tctx, "CreateUser failed - %s\n", nt_errstr(status));
                                return false;
                        }
                        return true;
@@ -223,11 +228,11 @@ static bool test_createuser(struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx
        r2.in.handle = &user_handle;
        r2.out.handle = &user_handle;
 
-       printf("closing user '%s'\n", username.string);
+       torture_comment(tctx, "closing user '%s'\n", username.string);
 
        status = dcerpc_samr_Close_r(b, mem_ctx, &r2);
        if (!NT_STATUS_IS_OK(status)) {
-               printf("Close failed - %s\n", nt_errstr(status));
+               torture_comment(tctx, "Close failed - %s\n", nt_errstr(status));
                return false;
        }
 
@@ -254,19 +259,19 @@ bool torture_createuser(struct torture_context *torture)
 
        status = libnet_CreateUser(ctx, mem_ctx, &req);
        if (!NT_STATUS_IS_OK(status)) {
-               printf("libnet_CreateUser call failed: %s\n", nt_errstr(status));
+               torture_comment(torture, "libnet_CreateUser call failed: %s\n", nt_errstr(status));
                ret = false;
                goto done;
        }
 
-       if (!test_cleanup(ctx->samr.pipe->binding_handle, mem_ctx, &ctx->samr.handle, TEST_USERNAME)) {
-               printf("cleanup failed\n");
+       if (!test_cleanup(torture, ctx->samr.pipe->binding_handle, mem_ctx, &ctx->samr.handle, TEST_USERNAME)) {
+               torture_comment(torture, "cleanup failed\n");
                ret = false;
                goto done;
        }
 
-       if (!test_samr_close(ctx->samr.pipe->binding_handle, mem_ctx, &ctx->samr.handle)) {
-               printf("domain close failed\n");
+       if (!test_samr_close(torture, ctx->samr.pipe->binding_handle, mem_ctx, &ctx->samr.handle)) {
+               torture_comment(torture, "domain close failed\n");
                ret = false;
        }
 
@@ -306,12 +311,12 @@ bool torture_deleteuser(struct torture_context *torture)
        }
 
        domain_name.string = lp_workgroup(torture->lp_ctx);
-       if (!test_opendomain(p->binding_handle, prep_mem_ctx, &h, &domain_name)) {
+       if (!test_opendomain(torture, p->binding_handle, prep_mem_ctx, &h, &domain_name)) {
                ret = false;
                goto done;
        }
 
-       if (!test_createuser(p->binding_handle, prep_mem_ctx, &h, name)) {
+       if (!test_createuser(torture, p->binding_handle, prep_mem_ctx, &h, name)) {
                ret = false;
                goto done;
        }
@@ -320,7 +325,7 @@ bool torture_deleteuser(struct torture_context *torture)
 
        status = libnet_DeleteUser(ctx, mem_ctx, &req);
        if (!NT_STATUS_IS_OK(status)) {
-               printf("libnet_DeleteUser call failed: %s\n", nt_errstr(status));
+               torture_comment(torture, "libnet_DeleteUser call failed: %s\n", nt_errstr(status));
                ret = false;
        }
 
@@ -337,7 +342,8 @@ done:
   Generate testing set of random changes
 */
 
-static void set_test_changes(TALLOC_CTX *mem_ctx, struct libnet_ModifyUser *r,
+static void set_test_changes(struct torture_context *tctx,
+                            TALLOC_CTX *mem_ctx, struct libnet_ModifyUser *r,
                             int num_changes, char **user_name, enum test_fields req_change)
 {
        const char* logon_scripts[] = { "start_login.cmd", "login.bat", "start.cmd" };
@@ -350,7 +356,7 @@ static void set_test_changes(TALLOC_CTX *mem_ctx, struct libnet_ModifyUser *r,
        struct timeval now;
        int i, testfld;
 
-       printf("Fields to change: [");
+       torture_comment(tctx, "Fields to change: [");
 
        for (i = 0; i < num_changes && i < FIELDS_NUM; i++) {
                const char *fldname;
@@ -437,33 +443,33 @@ static void set_test_changes(TALLOC_CTX *mem_ctx, struct libnet_ModifyUser *r,
                        fldname = "unknown_field";
                }
 
-               printf(((i < num_changes - 1) ? "%s," : "%s"), fldname);
+               torture_comment(tctx, ((i < num_changes - 1) ? "%s," : "%s"), fldname);
 
                /* disable requested field (it's supposed to be the only one used) */
                if (req_change != none) req_change = none;
        }
 
-       printf("]\n");
+       torture_comment(tctx, "]\n");
 }
 
 
 #define TEST_STR_FLD(fld) \
        if (!strequal(req.in.fld, user_req.out.fld)) { \
-               printf("failed to change '%s'\n", #fld); \
+               torture_comment(torture, "failed to change '%s'\n", #fld); \
                ret = false; \
                goto cleanup; \
        }
 
 #define TEST_TIME_FLD(fld) \
        if (timeval_compare(req.in.fld, user_req.out.fld)) { \
-               printf("failed to change '%s'\n", #fld); \
+               torture_comment(torture, "failed to change '%s'\n", #fld); \
                ret = false; \
                goto cleanup; \
        }
 
 #define TEST_NUM_FLD(fld) \
        if (req.in.fld != user_req.out.fld) { \
-               printf("failed to change '%s'\n", #fld); \
+               torture_comment(torture, "failed to change '%s'\n", #fld); \
                ret = false; \
                goto cleanup; \
        }
@@ -502,12 +508,12 @@ bool torture_modifyuser(struct torture_context *torture)
        name = talloc_strdup(prep_mem_ctx, TEST_USERNAME);
 
        domain_name.string = lp_workgroup(torture->lp_ctx);
-       if (!test_opendomain(b, prep_mem_ctx, &h, &domain_name)) {
+       if (!test_opendomain(torture, b, prep_mem_ctx, &h, &domain_name)) {
                ret = false;
                goto done;
        }
 
-       if (!test_createuser(b, prep_mem_ctx, &h, name)) {
+       if (!test_createuser(torture, b, prep_mem_ctx, &h, name)) {
                ret = false;
                goto done;
        }
@@ -518,18 +524,18 @@ bool torture_modifyuser(struct torture_context *torture)
                goto done;
        }
 
-       printf("Testing change of all fields - each single one in turn\n");
+       torture_comment(torture, "Testing change of all fields - each single one in turn\n");
 
        for (fld = 1; fld < FIELDS_NUM - 1; fld++) {
                ZERO_STRUCT(req);
                req.in.domain_name = lp_workgroup(torture->lp_ctx);
                req.in.user_name = name;
 
-               set_test_changes(torture, &req, 1, &name, fld);
+               set_test_changes(torture, torture, &req, 1, &name, fld);
 
                status = libnet_ModifyUser(ctx, torture, &req);
                if (!NT_STATUS_IS_OK(status)) {
-                       printf("libnet_ModifyUser call failed: %s\n", nt_errstr(status));
+                       torture_comment(torture, "libnet_ModifyUser call failed: %s\n", nt_errstr(status));
                        ret = false;
                        continue;
                }
@@ -541,7 +547,7 @@ bool torture_modifyuser(struct torture_context *torture)
 
                status = libnet_UserInfo(ctx, torture, &user_req);
                if (!NT_STATUS_IS_OK(status)) {
-                       printf("libnet_UserInfo call failed: %s\n", nt_errstr(status));
+                       torture_comment(torture, "libnet_UserInfo call failed: %s\n", nt_errstr(status));
                        ret = false;
                        continue;
                }
@@ -581,7 +587,7 @@ bool torture_modifyuser(struct torture_context *torture)
 
                        status = libnet_ModifyUser(ctx, torture, &req);
                        if (!NT_STATUS_IS_OK(status)) {
-                               printf("libnet_ModifyUser call failed: %s\n", nt_errstr(status));
+                               torture_comment(torture, "libnet_ModifyUser call failed: %s\n", nt_errstr(status));
                                ret = false;
                                goto done;
                        }
@@ -591,14 +597,14 @@ bool torture_modifyuser(struct torture_context *torture)
        }
 
 cleanup:
-       if (!test_cleanup(ctx->samr.pipe->binding_handle, torture, &ctx->samr.handle, name)) {
-               printf("cleanup failed\n");
+       if (!test_cleanup(torture, ctx->samr.pipe->binding_handle, torture, &ctx->samr.handle, name)) {
+               torture_comment(torture, "cleanup failed\n");
                ret = false;
                goto done;
        }
 
-       if (!test_samr_close(ctx->samr.pipe->binding_handle, torture, &ctx->samr.handle)) {
-               printf("domain close failed\n");
+       if (!test_samr_close(torture, ctx->samr.pipe->binding_handle, torture, &ctx->samr.handle)) {
+               torture_comment(torture, "domain close failed\n");
                ret = false;
        }
 
@@ -636,12 +642,12 @@ bool torture_userinfo_api(struct torture_context *torture)
        b = p->binding_handle;
 
        domain_name.string = lp_workgroup(torture->lp_ctx);
-       if (!test_opendomain(b, prep_mem_ctx, &h, &domain_name)) {
+       if (!test_opendomain(torture, b, prep_mem_ctx, &h, &domain_name)) {
                ret = false;
                goto done;
        }
 
-       if (!test_createuser(b, prep_mem_ctx, &h, name)) {
+       if (!test_createuser(torture, b, prep_mem_ctx, &h, name)) {
                ret = false;
                goto done;
        }
@@ -656,19 +662,19 @@ bool torture_userinfo_api(struct torture_context *torture)
 
        status = libnet_UserInfo(ctx, mem_ctx, &req);
        if (!NT_STATUS_IS_OK(status)) {
-               printf("libnet_UserInfo call failed: %s\n", nt_errstr(status));
+               torture_comment(torture, "libnet_UserInfo call failed: %s\n", nt_errstr(status));
                ret = false;
                goto done;
        }
 
-       if (!test_cleanup(ctx->samr.pipe->binding_handle, mem_ctx, &ctx->samr.handle, TEST_USERNAME)) {
-               printf("cleanup failed\n");
+       if (!test_cleanup(torture, ctx->samr.pipe->binding_handle, mem_ctx, &ctx->samr.handle, TEST_USERNAME)) {
+               torture_comment(torture, "cleanup failed\n");
                ret = false;
                goto done;
        }
 
-       if (!test_samr_close(ctx->samr.pipe->binding_handle, mem_ctx, &ctx->samr.handle)) {
-               printf("domain close failed\n");
+       if (!test_samr_close(torture, ctx->samr.pipe->binding_handle, mem_ctx, &ctx->samr.handle)) {
+               torture_comment(torture, "domain close failed\n");
                ret = false;
        }
 
@@ -698,7 +704,7 @@ bool torture_userlist(struct torture_context *torture)
 
        ZERO_STRUCT(req);
 
-       printf("listing user accounts:\n");
+       torture_comment(torture, "listing user accounts:\n");
 
        do {
 
@@ -711,7 +717,7 @@ bool torture_userlist(struct torture_context *torture)
                    !NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES)) break;
 
                for (i = 0; i < req.out.count; i++) {
-                       printf("\tuser: %s, sid=%s\n",
+                       torture_comment(torture, "\tuser: %s, sid=%s\n",
                               req.out.users[i].username, req.out.users[i].sid);
                }
 
@@ -719,19 +725,19 @@ bool torture_userlist(struct torture_context *torture)
 
        if (!(NT_STATUS_IS_OK(status) ||
              NT_STATUS_EQUAL(status, NT_STATUS_NO_MORE_ENTRIES))) {
-               printf("libnet_UserList call failed: %s\n", nt_errstr(status));
+               torture_comment(torture, "libnet_UserList call failed: %s\n", nt_errstr(status));
                ret = false;
                goto done;
        }
 
-       if (!test_samr_close(ctx->samr.pipe->binding_handle, mem_ctx, &ctx->samr.handle)) {
-               printf("samr domain close failed\n");
+       if (!test_samr_close(torture, ctx->samr.pipe->binding_handle, mem_ctx, &ctx->samr.handle)) {
+               torture_comment(torture, "samr domain close failed\n");
                ret = false;
                goto done;
        }
 
-       if (!test_lsa_close(ctx->lsa.pipe->binding_handle, mem_ctx, &ctx->lsa.handle)) {
-               printf("lsa domain close failed\n");
+       if (!test_lsa_close(torture, ctx->lsa.pipe->binding_handle, mem_ctx, &ctx->lsa.handle)) {
+               torture_comment(torture, "lsa domain close failed\n");
                ret = false;
        }
 
index 50e994f3bf5ef66e73d0c2d5e29db2384762eac4..7db04e4d3826b9b6d43bdb5e44c1744fb90dc4e1 100644 (file)
@@ -29,7 +29,8 @@
 
 #define TEST_USERNAME  "libnetuserinfotest"
 
-static bool test_userinfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_userinfo(struct torture_context *tctx,
+                         struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
                          struct policy_handle *domain_handle,
                          struct dom_sid2 *domain_sid, const char* user_name,
                          uint32_t *rid)
@@ -45,10 +46,10 @@ static bool test_userinfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
        user.in.sid           = dom_sid_string(mem_ctx, user_sid);
        user.in.level         = level;       /* this should be extended */
 
-       printf("Testing sync libnet_rpc_userinfo (SID argument)\n");
+       torture_comment(tctx, "Testing sync libnet_rpc_userinfo (SID argument)\n");
        status = libnet_rpc_userinfo(p, mem_ctx, &user);
        if (!NT_STATUS_IS_OK(status)) {
-               printf("Failed to call sync libnet_rpc_userinfo - %s\n", nt_errstr(status));
+               torture_comment(tctx, "Failed to call sync libnet_rpc_userinfo - %s\n", nt_errstr(status));
                return false;
        }
 
@@ -59,10 +60,10 @@ static bool test_userinfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
        user.in.username      = TEST_USERNAME;
        user.in.level         = level;
 
-       printf("Testing sync libnet_rpc_userinfo (username argument)\n");
+       torture_comment(tctx, "Testing sync libnet_rpc_userinfo (username argument)\n");
        status = libnet_rpc_userinfo(p, mem_ctx, &user);
        if (!NT_STATUS_IS_OK(status)) {
-               printf("Failed to call sync libnet_rpc_userinfo - %s\n", nt_errstr(status));
+               torture_comment(tctx, "Failed to call sync libnet_rpc_userinfo - %s\n", nt_errstr(status));
                return false;
        }
 
@@ -70,7 +71,8 @@ static bool test_userinfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
 }
 
 
-static bool test_userinfo_async(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_userinfo_async(struct torture_context *tctx,
+                               struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
                                struct policy_handle *domain_handle,
                                struct dom_sid2 *domain_sid, const char* user_name,
                                uint32_t *rid)
@@ -87,17 +89,17 @@ static bool test_userinfo_async(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
        user.in.sid           = dom_sid_string(mem_ctx, user_sid);
        user.in.level         = level;       /* this should be extended */
 
-       printf("Testing async libnet_rpc_userinfo (SID argument)\n");
+       torture_comment(tctx, "Testing async libnet_rpc_userinfo (SID argument)\n");
 
        c = libnet_rpc_userinfo_send(p, &user, msg_handler);
        if (!c) {
-               printf("Failed to call sync libnet_rpc_userinfo_send\n");
+               torture_comment(tctx, "Failed to call sync libnet_rpc_userinfo_send\n");
                return false;
        }
 
        status = libnet_rpc_userinfo_recv(c, mem_ctx, &user);
        if (!NT_STATUS_IS_OK(status)) {
-               printf("Calling async libnet_rpc_userinfo failed - %s\n", nt_errstr(status));
+               torture_comment(tctx, "Calling async libnet_rpc_userinfo failed - %s\n", nt_errstr(status));
                return false;
        }
 
@@ -108,17 +110,17 @@ static bool test_userinfo_async(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
        user.in.username      = TEST_USERNAME;
        user.in.level         = level;
 
-       printf("Testing async libnet_rpc_userinfo (username argument)\n");
+       torture_comment(tctx, "Testing async libnet_rpc_userinfo (username argument)\n");
 
        c = libnet_rpc_userinfo_send(p, &user, msg_handler);
        if (!c) {
-               printf("Failed to call sync libnet_rpc_userinfo_send\n");
+               torture_comment(tctx, "Failed to call sync libnet_rpc_userinfo_send\n");
                return false;
        }
 
        status = libnet_rpc_userinfo_recv(c, mem_ctx, &user);
        if (!NT_STATUS_IS_OK(status)) {
-               printf("Calling async libnet_rpc_userinfo failed - %s\n", nt_errstr(status));
+               torture_comment(tctx, "Calling async libnet_rpc_userinfo failed - %s\n", nt_errstr(status));
                return false;
        }
 
@@ -164,7 +166,7 @@ bool torture_userinfo(struct torture_context *torture)
                goto done;
        }
 
-       if (!test_userinfo(p, mem_ctx, &h, &sid, TEST_USERNAME, &rid)) {
+       if (!test_userinfo(torture, p, mem_ctx, &h, &sid, TEST_USERNAME, &rid)) {
                ret = false;
                goto done;
        }
@@ -187,7 +189,7 @@ bool torture_userinfo(struct torture_context *torture)
                goto done;
        }
 
-       if (!test_userinfo_async(p, mem_ctx, &h, &sid, TEST_USERNAME, &rid)) {
+       if (!test_userinfo_async(torture, p, mem_ctx, &h, &sid, TEST_USERNAME, &rid)) {
                ret = false;
                goto done;
        }
index e38c4693f78d367cba99d9818cdd042c9933e9b2..b16a09cbe88f2be3891a9c93198c0b59f25be489 100644 (file)
@@ -28,7 +28,8 @@
 #include "torture/libnet/utils.h"
 
 
-static bool test_useradd(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_useradd(struct torture_context *tctx,
+                        struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
                         struct policy_handle *domain_handle,
                         const char *name)
 {
@@ -39,11 +40,11 @@ static bool test_useradd(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
        user.in.domain_handle = *domain_handle;
        user.in.username      = name;
 
-       printf("Testing libnet_rpc_useradd\n");
+       torture_comment(tctx, "Testing libnet_rpc_useradd\n");
 
        status = libnet_rpc_useradd(p, mem_ctx, &user);
        if (!NT_STATUS_IS_OK(status)) {
-               printf("Failed to call libnet_rpc_useradd - %s\n", nt_errstr(status));
+               torture_comment(tctx, "Failed to call libnet_rpc_useradd - %s\n", nt_errstr(status));
                return false;
        }
 
@@ -51,7 +52,8 @@ static bool test_useradd(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
 }
 
 
-static bool test_useradd_async(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_useradd_async(struct torture_context *tctx,
+                              struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
                               struct policy_handle *handle, const char* username)
 {
        NTSTATUS status;
@@ -61,17 +63,17 @@ static bool test_useradd_async(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
        user.in.domain_handle = *handle;
        user.in.username      = username;
 
-       printf("Testing async libnet_rpc_useradd\n");
+       torture_comment(tctx, "Testing async libnet_rpc_useradd\n");
 
        c = libnet_rpc_useradd_send(p, &user, msg_handler);
        if (!c) {
-               printf("Failed to call async libnet_rpc_useradd\n");
+               torture_comment(tctx, "Failed to call async libnet_rpc_useradd\n");
                return false;
        }
 
        status = libnet_rpc_useradd_recv(c, mem_ctx, &user);
        if (!NT_STATUS_IS_OK(status)) {
-               printf("Calling async libnet_rpc_useradd failed - %s\n", nt_errstr(status));
+               torture_comment(tctx, "Calling async libnet_rpc_useradd failed - %s\n", nt_errstr(status));
                return false;
        }
 
@@ -212,7 +214,8 @@ static bool test_usermod(struct torture_context *tctx, struct dcerpc_pipe *p,
 }
 
 
-static bool test_userdel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_userdel(struct torture_context *tctx,
+                        struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
                         struct policy_handle *handle, const char *username)
 {
        NTSTATUS status;
@@ -223,7 +226,7 @@ static bool test_userdel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
 
        status = libnet_rpc_userdel(p, mem_ctx, &user);
        if (!NT_STATUS_IS_OK(status)) {
-               printf("Failed to call sync libnet_rpc_userdel - %s\n", nt_errstr(status));
+               torture_comment(tctx, "Failed to call sync libnet_rpc_userdel - %s\n", nt_errstr(status));
                return false;
        }
 
@@ -234,9 +237,9 @@ static bool test_userdel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
 #define CMP_LSA_STRING_FLD(fld, flags) \
        if ((mod->in.change.fields & flags) && \
            !strequal(i->fld.string, mod->in.change.fld)) { \
-               printf("'%s' field does not match\n", #fld); \
-               printf("received: '%s'\n", i->fld.string); \
-               printf("expected: '%s'\n", mod->in.change.fld); \
+               torture_comment(tctx, "'%s' field does not match\n", #fld); \
+               torture_comment(tctx, "received: '%s'\n", i->fld.string); \
+               torture_comment(tctx, "expected: '%s'\n", mod->in.change.fld); \
                return false; \
        }
 
@@ -245,10 +248,10 @@ static bool test_userdel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
        if (mod->in.change.fields & flags) { \
                nttime_to_timeval(&t, i->fld); \
                if (timeval_compare(&t, mod->in.change.fld)) { \
-                       printf("'%s' field does not match\n", #fld); \
-                       printf("received: '%s (+%ld us)'\n", \
+                       torture_comment(tctx, "'%s' field does not match\n", #fld); \
+                       torture_comment(tctx, "received: '%s (+%ld us)'\n", \
                               timestring(mem_ctx, t.tv_sec), t.tv_usec); \
-                       printf("expected: '%s (+%ld us)'\n", \
+                       torture_comment(tctx, "expected: '%s (+%ld us)'\n", \
                               timestring(mem_ctx, mod->in.change.fld->tv_sec), \
                               mod->in.change.fld->tv_usec); \
                        return false; \
@@ -258,9 +261,9 @@ static bool test_userdel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
 #define CMP_NUM_FLD(fld, flags) \
        if ((mod->in.change.fields & flags) && \
            (i->fld != mod->in.change.fld)) { \
-               printf("'%s' field does not match\n", #fld); \
-               printf("received: '%04x'\n", i->fld); \
-               printf("expected: '%04x'\n", mod->in.change.fld); \
+               torture_comment(tctx, "'%s' field does not match\n", #fld); \
+               torture_comment(tctx, "received: '%04x'\n", i->fld); \
+               torture_comment(tctx, "expected: '%04x'\n", mod->in.change.fld); \
                return false; \
        }
 
@@ -328,7 +331,7 @@ bool torture_useradd(struct torture_context *torture)
                goto done;
        }
 
-       if (!test_useradd(p, mem_ctx, &h, name)) {
+       if (!test_useradd(torture, p, mem_ctx, &h, name)) {
                ret = false;
                goto done;
        }
@@ -343,7 +346,7 @@ bool torture_useradd(struct torture_context *torture)
                goto done;
        }
 
-       if (!test_useradd_async(p, mem_ctx, &h, name)) {
+       if (!test_useradd_async(torture, p, mem_ctx, &h, name)) {
                ret = false;
                goto done;
        }
@@ -394,7 +397,7 @@ bool torture_userdel(struct torture_context *torture)
                goto done;
        }
 
-               if (!test_userdel(p, mem_ctx, &h, name)) {
+       if (!test_userdel(torture, p, mem_ctx, &h, name)) {
                ret = false;
                goto done;
        }
index 46e152c2c44515a320235335879d84e582cee594..6c1638bb589ce47e9254bbdf6befc044caffb800 100644 (file)
@@ -148,7 +148,7 @@ bool test_user_create(struct torture_context *tctx,
 
        status = dcerpc_samr_CreateUser_r(b, mem_ctx, &r);
        if (!NT_STATUS_IS_OK(status)) {
-               printf("CreateUser failed - %s\n", nt_errstr(status));
+               torture_comment(tctx, "CreateUser failed - %s\n", nt_errstr(status));
 
                if (NT_STATUS_EQUAL(status, NT_STATUS_USER_EXISTS)) {
                        torture_comment(tctx, "User (%s) already exists - attempting to delete and recreate account again\n", name);
@@ -169,7 +169,8 @@ bool test_user_create(struct torture_context *tctx,
 }
 
 
-bool test_group_cleanup(struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx,
+bool test_group_cleanup(struct torture_context *tctx,
+                       struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx,
                        struct policy_handle *domain_handle,
                        const char *name)
 {
@@ -190,11 +191,11 @@ bool test_group_cleanup(struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx,
        r1.out.rids          = &rids;
        r1.out.types         = &types;
 
-       printf("group account lookup '%s'\n", name);
+       torture_comment(tctx, "group account lookup '%s'\n", name);
 
        status = dcerpc_samr_LookupNames_r(b, mem_ctx, &r1);
        if (!NT_STATUS_IS_OK(status)) {
-               printf("LookupNames failed - %s\n", nt_errstr(status));
+               torture_comment(tctx, "LookupNames failed - %s\n", nt_errstr(status));
                return false;
        }
 
@@ -205,22 +206,22 @@ bool test_group_cleanup(struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx,
        r2.in.rid            = rid;
        r2.out.group_handle  = &group_handle;
 
-       printf("opening group account\n");
+       torture_comment(tctx, "opening group account\n");
 
        status = dcerpc_samr_OpenGroup_r(b, mem_ctx, &r2);
        if (!NT_STATUS_IS_OK(status)) {
-               printf("OpenGroup failed - %s\n", nt_errstr(status));
+               torture_comment(tctx, "OpenGroup failed - %s\n", nt_errstr(status));
                return false;
        }
 
        r3.in.group_handle  = &group_handle;
        r3.out.group_handle = &group_handle;
 
-       printf("deleting group account\n");
+       torture_comment(tctx, "deleting group account\n");
 
        status = dcerpc_samr_DeleteDomainGroup_r(b, mem_ctx, &r3);
        if (!NT_STATUS_IS_OK(status)) {
-               printf("DeleteGroup failed - %s\n", nt_errstr(status));
+               torture_comment(tctx, "DeleteGroup failed - %s\n", nt_errstr(status));
                return false;
        }
 
@@ -228,7 +229,8 @@ bool test_group_cleanup(struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx,
 }
 
 
-bool test_group_create(struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx,
+bool test_group_create(struct torture_context *tctx,
+                      struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx,
                       struct policy_handle *handle, const char *name,
                       uint32_t *rid)
 {
@@ -245,23 +247,23 @@ bool test_group_create(struct dcerpc_binding_handle *b, TALLOC_CTX *mem_ctx,
        r.out.group_handle  = &group_handle;
        r.out.rid           = rid;
 
-       printf("creating group account %s\n", name);
+       torture_comment(tctx, "creating group account %s\n", name);
 
        status = dcerpc_samr_CreateDomainGroup_r(b, mem_ctx, &r);
        if (!NT_STATUS_IS_OK(status)) {
-               printf("CreateGroup failed - %s\n", nt_errstr(status));
+               torture_comment(tctx, "CreateGroup failed - %s\n", nt_errstr(status));
 
                if (NT_STATUS_EQUAL(status, NT_STATUS_USER_EXISTS)) {
-                       printf("Group (%s) already exists - attempting to delete and recreate account again\n", name);
-                       if (!test_group_cleanup(b, mem_ctx, handle, name)) {
+                       torture_comment(tctx, "Group (%s) already exists - attempting to delete and recreate account again\n", name);
+                       if (!test_group_cleanup(tctx, b, mem_ctx, handle, name)) {
                                return false;
                        }
 
-                       printf("creating group account\n");
+                       torture_comment(tctx, "creating group account\n");
 
                        status = dcerpc_samr_CreateDomainGroup_r(b, mem_ctx, &r);
                        if (!NT_STATUS_IS_OK(status)) {
-                               printf("CreateGroup failed - %s\n", nt_errstr(status));
+                               torture_comment(tctx, "CreateGroup failed - %s\n", nt_errstr(status));
                                return false;
                        }
                        return true;
index 94a971dd9791f090a764bcd991232b10b08c812c..7a16d8f174cc91884c43cf639e6e5e64bf53eeda 100644 (file)
@@ -37,12 +37,14 @@ bool test_user_cleanup(struct torture_context *tctx,
                       struct policy_handle *domain_handle,
                       const char *name);
 
-bool test_group_create(struct dcerpc_binding_handle *b,
+bool test_group_create(struct torture_context *tctx,
+                      struct dcerpc_binding_handle *b,
                       TALLOC_CTX *mem_ctx,
                       struct policy_handle *handle, const char *name,
                       uint32_t *rid);
 
-bool test_group_cleanup(struct dcerpc_binding_handle *b,
+bool test_group_cleanup(struct torture_context *tctx,
+                       struct dcerpc_binding_handle *b,
                        TALLOC_CTX *mem_ctx,
                        struct policy_handle *domain_handle,
                        const char *name);