From 97a974e5b7b4645544b10ff48459125c5580580d Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 23 Mar 2010 15:31:27 +0100 Subject: s4-smbtorture: use torture_context for debugging output everywhere in libnet torture tests. Mimir, please check. Guenther --- source4/torture/libnet/libnet_share.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'source4/torture/libnet/libnet_share.c') diff --git a/source4/torture/libnet/libnet_share.c b/source4/torture/libnet/libnet_share.c index 1d64f558ad..966c21d33e 100644 --- a/source4/torture/libnet/libnet_share.c +++ b/source4/torture/libnet/libnet_share.c @@ -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; } -- cgit