summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2010-04-20 14:15:24 +0200
committerGünther Deschner <gd@samba.org>2010-04-20 14:34:55 +0200
commit4f5298cbb4c044b6bde0cda04d182651f826ee53 (patch)
treeb457d5471ba262b5a9adbe3fce8d0b680261f9c2
parentac11b616dd67847be4f54f6fc08b64bacc0802f4 (diff)
downloadsamba-4f5298cbb4c044b6bde0cda04d182651f826ee53.tar.gz
samba-4f5298cbb4c044b6bde0cda04d182651f826ee53.tar.bz2
samba-4f5298cbb4c044b6bde0cda04d182651f826ee53.zip
s4-smbtorture: add test for csetprinter field behaviour in printer info level 0.
Suprisingly, that value is always 0 (at least on w2k8r2). Guenther
-rw-r--r--source4/torture/rpc/spoolss.c71
1 files changed, 71 insertions, 0 deletions
diff --git a/source4/torture/rpc/spoolss.c b/source4/torture/rpc/spoolss.c
index ec4cc78810..55af920f4d 100644
--- a/source4/torture/rpc/spoolss.c
+++ b/source4/torture/rpc/spoolss.c
@@ -5847,6 +5847,69 @@ static bool test_one_printer(struct torture_context *tctx,
return ret;
}
+static bool test_csetprinter(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
+ struct policy_handle *handle,
+ const char *printername,
+ const char *drivername,
+ const char *portname)
+{
+ union spoolss_PrinterInfo info;
+ struct policy_handle new_handle, new_handle2;
+ struct dcerpc_binding_handle *b = p->binding_handle;
+
+ torture_comment(tctx, "Testing c_setprinter\n");
+
+ torture_assert(tctx,
+ test_GetPrinter_level(tctx, b, handle, 0, &info),
+ "failed to get level 0 printer info");
+ torture_comment(tctx, "csetprinter on initial printer handle: %d\n",
+ info.info0.c_setprinter);
+
+ /* check if c_setprinter on 1st handle increases after a printer has
+ * been added */
+
+ torture_assert(tctx,
+ test_AddPrinter(tctx, p, &new_handle, printername, drivername, portname),
+ "failed to add new printer");
+ torture_assert(tctx,
+ test_GetPrinter_level(tctx, b, handle, 0, &info),
+ "failed to get level 0 printer info");
+ torture_comment(tctx, "csetprinter on initial printer handle (after add): %d\n",
+ info.info0.c_setprinter);
+
+ /* check if c_setprinter on new handle increases after a printer has
+ * been added */
+
+ torture_assert(tctx,
+ test_GetPrinter_level(tctx, b, &new_handle, 0, &info),
+ "failed to get level 0 printer info");
+ torture_comment(tctx, "csetprinter on created handle: %d\n",
+ info.info0.c_setprinter);
+
+ /* open the new printer and check if c_setprinter increases */
+
+ torture_assert(tctx,
+ call_OpenPrinterEx(tctx, p, printername, NULL, &new_handle2),
+ "failed to open created printer");
+ torture_assert(tctx,
+ test_GetPrinter_level(tctx, b, &new_handle2, 0, &info),
+ "failed to get level 0 printer info");
+ torture_comment(tctx, "csetprinter on new handle (after openprinter): %d\n",
+ info.info0.c_setprinter);
+
+ /* cleanup */
+
+ torture_assert(tctx,
+ test_ClosePrinter(tctx, b, &new_handle2),
+ "failed to close printer");
+ torture_assert(tctx,
+ test_DeletePrinter(tctx, b, &new_handle),
+ "failed to delete new printer");
+
+ return true;
+}
+
static bool test_printer(struct torture_context *tctx,
struct dcerpc_pipe *p)
{
@@ -5863,6 +5926,10 @@ static bool test_printer(struct torture_context *tctx,
return false;
}
+ if (!test_csetprinter(tctx, p, &handle[0], TORTURE_PRINTER "2", drivername, portname)) {
+ ret = false;
+ }
+
if (!test_one_printer(tctx, p, &handle[0], TORTURE_PRINTER)) {
ret = false;
}
@@ -5884,6 +5951,10 @@ static bool test_printer(struct torture_context *tctx,
return false;
}
+ if (!test_csetprinter(tctx, p, &handle[1], TORTURE_PRINTER_EX "2", drivername, portname)) {
+ ret = false;
+ }
+
if (!test_one_printer(tctx, p, &handle[1], TORTURE_PRINTER_EX)) {
ret = false;
}