summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2010-04-20 16:25:27 +0200
committerGünther Deschner <gd@samba.org>2010-04-20 17:01:48 +0200
commite647b8c61f9b65e4c4d07eae7f1a4c2be711b8de (patch)
tree202ca10db025a2677b6c81285c26cdea3738f1eb /source4
parent7e9e5291de3e3a44491a482754515d2e76a99a83 (diff)
downloadsamba-e647b8c61f9b65e4c4d07eae7f1a4c2be711b8de.tar.gz
samba-e647b8c61f9b65e4c4d07eae7f1a4c2be711b8de.tar.bz2
samba-e647b8c61f9b65e4c4d07eae7f1a4c2be711b8de.zip
s4-smbtorture: refactor test_GetPrinterDriver2().
Guenther
Diffstat (limited to 'source4')
-rw-r--r--source4/torture/rpc/spoolss.c100
1 files changed, 64 insertions, 36 deletions
diff --git a/source4/torture/rpc/spoolss.c b/source4/torture/rpc/spoolss.c
index 55af920f4d..d5940bc5c1 100644
--- a/source4/torture/rpc/spoolss.c
+++ b/source4/torture/rpc/spoolss.c
@@ -5158,60 +5158,88 @@ static bool test_GetPrinterDriver(struct torture_context *tctx,
return true;
}
-static bool test_GetPrinterDriver2(struct torture_context *tctx,
- struct dcerpc_binding_handle *b,
- struct policy_handle *handle,
- const char *driver_name,
- const char *architecture)
+static bool test_GetPrinterDriver2_level(struct torture_context *tctx,
+ struct dcerpc_binding_handle *b,
+ struct policy_handle *handle,
+ const char *driver_name,
+ const char *architecture,
+ uint32_t level,
+ uint32_t client_major_version,
+ uint32_t client_minor_version,
+ union spoolss_DriverInfo *info_p)
+
{
struct spoolss_GetPrinterDriver2 r;
- uint16_t levels[] = {1, 2, 3, 4, 5, 6, 8, 101 };
uint32_t needed;
uint32_t server_major_version;
uint32_t server_minor_version;
- int i;
r.in.handle = handle;
r.in.architecture = architecture;
- r.in.client_major_version = 3;
- r.in.client_minor_version = 0;
+ r.in.client_major_version = client_major_version;
+ r.in.client_minor_version = client_minor_version;
+ r.in.buffer = NULL;
+ r.in.offered = 0;
+ r.in.level = level;
r.out.needed = &needed;
r.out.server_major_version = &server_major_version;
r.out.server_minor_version = &server_minor_version;
- for (i=0;i<ARRAY_SIZE(levels);i++) {
+ torture_comment(tctx, "Testing GetPrinterDriver2(%s) level %d\n",
+ driver_name, r.in.level);
- r.in.buffer = NULL;
- r.in.offered = 0;
- r.in.level = levels[i];
-
- torture_comment(tctx, "Testing GetPrinterDriver2(%s) level %d\n",
- driver_name, r.in.level);
-
- torture_assert_ntstatus_ok(tctx, dcerpc_spoolss_GetPrinterDriver2_r(b, tctx, &r),
+ torture_assert_ntstatus_ok(tctx,
+ dcerpc_spoolss_GetPrinterDriver2_r(b, tctx, &r),
+ "failed to call GetPrinterDriver2");
+ if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) {
+ DATA_BLOB blob = data_blob_talloc_zero(tctx, needed);
+ r.in.buffer = &blob;
+ r.in.offered = needed;
+ torture_assert_ntstatus_ok(tctx,
+ dcerpc_spoolss_GetPrinterDriver2_r(b, tctx, &r),
"failed to call GetPrinterDriver2");
- if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) {
- DATA_BLOB blob = data_blob_talloc_zero(tctx, needed);
- r.in.buffer = &blob;
- r.in.offered = needed;
- torture_assert_ntstatus_ok(tctx, dcerpc_spoolss_GetPrinterDriver2_r(b, tctx, &r),
- "failed to call GetPrinterDriver2");
- }
+ }
- if (W_ERROR_EQUAL(r.out.result, WERR_INVALID_LEVEL)) {
- switch (r.in.level) {
- case 101:
- case 8:
- continue;
- default:
- break;
- }
+ if (W_ERROR_EQUAL(r.out.result, WERR_INVALID_LEVEL)) {
+ switch (r.in.level) {
+ case 101:
+ case 8:
+ torture_comment(tctx,
+ "level %d not implemented, not considering as an error\n",
+ r.in.level);
+ return true;
+ default:
+ break;
}
+ }
+
+ torture_assert_werr_ok(tctx, r.out.result,
+ "failed to call GetPrinterDriver2");
+
+ CHECK_NEEDED_SIZE_LEVEL(spoolss_DriverInfo, r.out.info, r.in.level, lp_iconv_convenience(tctx->lp_ctx), needed, 4);
+
+ if (info_p) {
+ *info_p = *r.out.info;
+ }
+
+ return true;
+}
+
+static bool test_GetPrinterDriver2(struct torture_context *tctx,
+ struct dcerpc_binding_handle *b,
+ struct policy_handle *handle,
+ const char *driver_name,
+ const char *architecture)
+{
+ uint16_t levels[] = {1, 2, 3, 4, 5, 6, 8, 101 };
+ int i;
- torture_assert_werr_ok(tctx, r.out.result,
- "failed to call GetPrinterDriver2");
- CHECK_NEEDED_SIZE_LEVEL(spoolss_DriverInfo, r.out.info, r.in.level, lp_iconv_convenience(tctx->lp_ctx), needed, 4);
+ for (i=0;i<ARRAY_SIZE(levels);i++) {
+
+ torture_assert(tctx,
+ test_GetPrinterDriver2_level(tctx, b, handle, driver_name, architecture, levels[i], 3, 0, NULL),
+ "");
}
return true;