From 4a10635371a794281114e0e227ed174a518792ee Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 3 Jun 2010 13:01:16 +0200 Subject: s4-smbtorture: refactor test_EnumPrintProcessors(). Guenther --- source4/torture/rpc/spoolss.c | 89 ++++++++++++++++++++++++++----------------- 1 file changed, 54 insertions(+), 35 deletions(-) diff --git a/source4/torture/rpc/spoolss.c b/source4/torture/rpc/spoolss.c index b233b21bdd..a389a495a4 100644 --- a/source4/torture/rpc/spoolss.c +++ b/source4/torture/rpc/spoolss.c @@ -787,53 +787,72 @@ static bool test_EnumMonitors(struct torture_context *tctx, return true; } +static bool test_EnumPrintProcessors_level(struct torture_context *tctx, + struct dcerpc_binding_handle *b, + const char *environment, + uint32_t level, + uint32_t *count_p, + union spoolss_PrintProcessorInfo **info_p) +{ + struct spoolss_EnumPrintProcessors r; + DATA_BLOB blob; + uint32_t needed; + uint32_t count; + union spoolss_PrintProcessorInfo *info; + + r.in.servername = ""; + r.in.environment = environment; + r.in.level = level; + r.in.buffer = NULL; + r.in.offered = 0; + r.out.needed = &needed; + r.out.count = &count; + r.out.info = &info; + + torture_comment(tctx, "Testing EnumPrintProcessors level %u\n", r.in.level); + + torture_assert_ntstatus_ok(tctx, + dcerpc_spoolss_EnumPrintProcessors_r(b, tctx, &r), + "EnumPrintProcessors failed"); + if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) { + blob = data_blob_talloc_zero(tctx, needed); + r.in.buffer = &blob; + r.in.offered = needed; + torture_assert_ntstatus_ok(tctx, + dcerpc_spoolss_EnumPrintProcessors_r(b, tctx, &r), + "EnumPrintProcessors failed"); + } + torture_assert_werr_ok(tctx, r.out.result, + "EnumPrintProcessors failed"); + + CHECK_NEEDED_SIZE_ENUM_LEVEL(spoolss_EnumPrintProcessors, info, level, count, needed, 4); + + if (count_p) { + *count_p = count; + } + if (info_p) { + *info_p = info; + } + + return true; +} + static bool test_EnumPrintProcessors(struct torture_context *tctx, struct dcerpc_binding_handle *b, struct test_spoolss_context *ctx, const char *environment) { - NTSTATUS status; - struct spoolss_EnumPrintProcessors r; uint16_t levels[] = { 1 }; int i, j; for (i=0;iprint_processor_count[level] = count; ctx->print_processors[level] = info; -- cgit