From 93d7230d25427af2955a9209335f657b8a901860 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 28 Sep 2010 00:10:31 +0200 Subject: s4-smbtorture: rework spoolss_EnumPrintProcDataTypes test. Guenther --- source4/torture/rpc/spoolss.c | 113 +++++++++++++++++++++++++++++------------- 1 file changed, 79 insertions(+), 34 deletions(-) (limited to 'source4/torture') diff --git a/source4/torture/rpc/spoolss.c b/source4/torture/rpc/spoolss.c index 53a6397488..b577815622 100644 --- a/source4/torture/rpc/spoolss.c +++ b/source4/torture/rpc/spoolss.c @@ -896,63 +896,108 @@ static bool test_EnumPrintProcessors(struct torture_context *tctx, return true; } +static bool test_EnumPrintProcDataTypes_level(struct torture_context *tctx, + struct dcerpc_binding_handle *b, + const char *print_processor_name, + uint32_t level, + uint32_t *count_p, + union spoolss_PrintProcDataTypesInfo **info_p, + WERROR expected_result) +{ + struct spoolss_EnumPrintProcDataTypes r; + DATA_BLOB blob; + uint32_t needed; + uint32_t count; + union spoolss_PrintProcDataTypesInfo *info; + + r.in.servername = ""; + r.in.print_processor_name = print_processor_name; + 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 EnumPrintProcDataTypes(%s) level %u\n", + r.in.print_processor_name, r.in.level); + + torture_assert_ntstatus_ok(tctx, + dcerpc_spoolss_EnumPrintProcDataTypes_r(b, tctx, &r), + "EnumPrintProcDataTypes 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_EnumPrintProcDataTypes_r(b, tctx, &r), + "EnumPrintProcDataTypes failed"); + } + torture_assert_werr_equal(tctx, r.out.result, expected_result, + "EnumPrintProcDataTypes failed"); + + CHECK_NEEDED_SIZE_ENUM_LEVEL(spoolss_EnumPrintProcDataTypes, info, level, count, needed, 4); + + if (count_p) { + *count_p = count; + } + if (info_p) { + *info_p = info; + } + + return true; +} + static bool test_EnumPrintProcDataTypes(struct torture_context *tctx, void *private_data) { struct test_spoolss_context *ctx = talloc_get_type_abort(private_data, struct test_spoolss_context); - NTSTATUS status; - struct spoolss_EnumPrintProcDataTypes r; - uint16_t levels[] = { 1 }; + uint16_t levels[] = {0, 1, 2, 3, 32, 256 }; + uint16_t ok[] = {0, 1, 0, 0, 0, 0 }; int i; struct dcerpc_pipe *p = ctx->spoolss_pipe; struct dcerpc_binding_handle *b = p->binding_handle; + torture_assert(tctx, + test_EnumPrintProcDataTypes_level(tctx, b, NULL, 1, NULL, NULL, WERR_UNKNOWN_PRINTPROCESSOR), + "test_EnumPrintProcDataTypes_level failed"); + + torture_assert(tctx, + test_EnumPrintProcDataTypes_level(tctx, b, "nonexisting", 1, NULL, NULL, WERR_UNKNOWN_PRINTPROCESSOR), + "test_EnumPrintProcDataTypes_level failed"); + for (i=0;ienvironment, 1, &count, &info, WERR_OK), + "test_EnumPrintProcessors_level failed"); + for (i=0; i < count; i++) { + torture_assert(tctx, + test_EnumPrintProcDataTypes_level(tctx, b, info[i].info1.print_processor_name, 1, NULL, NULL, WERR_OK), + "test_EnumPrintProcDataTypes_level failed"); + } } + return true; } - static bool test_EnumPrinters(struct torture_context *tctx, void *private_data) { -- cgit