[SCM] Samba Shared Repository - branch master updated
Günther Deschner
gd at samba.org
Wed Apr 28 09:06:38 MDT 2010
The branch, master has been updated
via 37e9019... s4-smbtorture: when comparing PrinterData from DsSpooler and PrinterInfo also query some existing values.
via 6cb2180... s4-smbtorture: add a test that adds a printer incl. devicemode.
from d5cc067... s3:smbd: make fsp->fake_file_handle a talloc child of fsp
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 37e9019119326aca374d55c6379b13b5cd0f564a
Author: Günther Deschner <gd at samba.org>
Date: Wed Apr 28 17:03:30 2010 +0200
s4-smbtorture: when comparing PrinterData from DsSpooler and PrinterInfo also
query some existing values.
Guenther
commit 6cb21806e8f6c811e4b0255851deaa655455469a
Author: Günther Deschner <gd at samba.org>
Date: Wed Apr 28 17:00:53 2010 +0200
s4-smbtorture: add a test that adds a printer incl. devicemode.
Guenther
-----------------------------------------------------------------------
Summary of changes:
source4/torture/rpc/spoolss.c | 116 ++++++++++++++++++++++++++++++++++++++--
1 files changed, 110 insertions(+), 6 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source4/torture/rpc/spoolss.c b/source4/torture/rpc/spoolss.c
index 4aa52e9..bb114b6 100644
--- a/source4/torture/rpc/spoolss.c
+++ b/source4/torture/rpc/spoolss.c
@@ -97,6 +97,7 @@ struct torture_printer_context {
bool wellknown;
bool added_driver;
bool have_driver;
+ struct spoolss_DeviceMode *devmode;
};
static bool upload_printer_driver(struct torture_context *tctx,
@@ -2274,7 +2275,8 @@ static bool test_PrinterInfo_DevModes(struct torture_context *tctx,
static bool test_PrinterInfo_DevMode(struct torture_context *tctx,
struct dcerpc_pipe *p,
struct policy_handle *handle,
- const char *name)
+ const char *name,
+ struct spoolss_DeviceMode *addprinter_devmode)
{
union spoolss_PrinterInfo info;
struct spoolss_DeviceMode *devmode;
@@ -2290,6 +2292,12 @@ static bool test_PrinterInfo_DevMode(struct torture_context *tctx,
devmode = info.info8.devmode;
+ if (addprinter_devmode) {
+ if (!test_devicemode_equal(tctx, devmode, addprinter_devmode)) {
+ torture_warning(tctx, "current global DM is != DM provided in addprinter");
+ }
+ }
+
/* run tests */
ret = test_PrinterInfo_DevModes(tctx, p, handle, name);
@@ -4982,6 +4990,25 @@ static bool test_PrinterData_DsSpooler(struct torture_context *tctx,
info_ctr.level = 2;
info_ctr.info = sinfo;
+#define TEST_SZ(wname, iname) \
+do {\
+ enum winreg_Type type;\
+ uint8_t *data;\
+ uint32_t needed;\
+ DATA_BLOB blob;\
+ const char *str;\
+ torture_assert(tctx,\
+ test_GetPrinterDataEx(tctx, p, handle, "DsSpooler", wname, &type, &data, &needed),\
+ "failed to query");\
+ torture_assert_int_equal(tctx, type, REG_SZ, "unexpected type");\
+ blob = data_blob_const(data, needed);\
+ torture_assert(tctx,\
+ pull_reg_sz(tctx, lp_iconv_convenience(tctx->lp_ctx), &blob, &str),\
+ "failed to pull REG_SZ");\
+ torture_assert_str_equal(tctx, str, iname, "unexpected result");\
+} while(0);
+
+
#define TEST_SET_SZ(wname, iname, val) \
do {\
enum winreg_Type type;\
@@ -5027,8 +5054,20 @@ do {\
TEST_SET_SZ("location", location, "newval");
/* TEST_SET_DWORD("priority", priority, 25); */
+ torture_assert(tctx,
+ test_GetPrinter_level(tctx, b, handle, 2, &info),
+ "failed to query Printer level 2");
+
+ TEST_SZ("description", info.info2.comment);
+ TEST_SZ("driverName", info.info2.drivername);
+ TEST_SZ("location", info.info2.location);
+ TEST_SZ("printerName", info.info2.printername);
+ /* TEST_SZ("printSeparatorFile", info.info2.sepfile); */
+ /* TEST_SZ("printShareName", info.info2.sharename); */
+
/* FIXME gd: complete the list */
+#undef TEST_SZ
#undef TEST_SET_SZ
#undef TEST_DWORD
@@ -6009,6 +6048,7 @@ static bool test_AddPrinter_normal(struct torture_context *tctx,
const char *printername,
const char *drivername,
const char *portname,
+ struct spoolss_DeviceMode *devmode,
bool ex)
{
WERROR result;
@@ -6030,6 +6070,8 @@ static bool test_AddPrinter_normal(struct torture_context *tctx,
torture_comment(tctx, "Testing AddPrinter%s level 2\n", ex ? "Ex":"");
+ devmode_ctr.devmode = devmode;
+
userlevel_ctr.level = 1;
rex.in.server = NULL;
@@ -6283,7 +6325,8 @@ static bool test_one_printer(struct torture_context *tctx,
const char *name,
const char *drivername,
const char *environment,
- bool have_driver)
+ bool have_driver,
+ struct spoolss_DeviceMode *devmode)
{
bool ret = true;
struct dcerpc_binding_handle *b = p->binding_handle;
@@ -6308,7 +6351,7 @@ static bool test_one_printer(struct torture_context *tctx,
ret = false;
}
- if (!test_PrinterInfo_DevMode(tctx, p, handle, name)) {
+ if (!test_PrinterInfo_DevMode(tctx, p, handle, name, devmode)) {
ret = false;
}
@@ -6376,7 +6419,7 @@ static bool test_csetprinter(struct torture_context *tctx,
* been added */
torture_assert(tctx,
- test_AddPrinter_normal(tctx, p, &new_handle, printername, drivername, portname, false),
+ test_AddPrinter_normal(tctx, p, &new_handle, printername, drivername, portname, NULL, false),
"failed to add new printer");
torture_assert(tctx,
test_GetPrinter_level(tctx, b, handle, 0, &info),
@@ -6435,7 +6478,7 @@ static bool test_add_printer_args_with_driver(struct torture_context *tctx,
"failed to add wellknown printer");
} else {
torture_assert(tctx,
- test_AddPrinter_normal(tctx, p, &handle, printer_name, driver_name, port_name, t->ex),
+ test_AddPrinter_normal(tctx, p, &handle, printer_name, driver_name, port_name, t->devmode, t->ex),
"failed to add printer");
}
@@ -6443,7 +6486,7 @@ static bool test_add_printer_args_with_driver(struct torture_context *tctx,
ret = false;
}
- if (!test_one_printer(tctx, p, &handle, printer_name, driver_name, t->driver.remote.environment, t->have_driver)) {
+ if (!test_one_printer(tctx, p, &handle, printer_name, driver_name, t->driver.remote.environment, t->have_driver, t->devmode)) {
ret = false;
}
@@ -6575,6 +6618,7 @@ static bool test_add_printer_wellknown(struct torture_context *tctx,
t->ex = false;
t->wellknown = true;
t->info2.printername = TORTURE_WELLKNOWN_PRINTER;
+ t->devmode = NULL;
return test_add_printer_args(tctx, p, t);
}
@@ -6589,6 +6633,7 @@ static bool test_add_printer_ex(struct torture_context *tctx,
t->ex = true;
t->wellknown = false;
t->info2.printername = TORTURE_PRINTER_EX;
+ t->devmode = NULL;
return test_add_printer_args(tctx, p, t);
}
@@ -6603,6 +6648,63 @@ static bool test_add_printer_ex_wellknown(struct torture_context *tctx,
t->ex = true;
t->wellknown = true;
t->info2.printername = TORTURE_WELLKNOWN_PRINTER_EX;
+ t->devmode = NULL;
+
+ return test_add_printer_args(tctx, p, t);
+}
+
+static struct spoolss_DeviceMode *torture_devicemode(TALLOC_CTX *mem_ctx,
+ const char *devicename)
+{
+ struct spoolss_DeviceMode *r;
+
+ r = talloc_zero(mem_ctx, struct spoolss_DeviceMode);
+ if (r == NULL) {
+ return NULL;
+ }
+
+ r->devicename = talloc_strdup(r, devicename);
+ r->specversion = DMSPEC_NT4_AND_ABOVE;
+ r->driverversion = 0x0600;
+ r->size = 0x00dc;
+ r->__driverextra_length = 0;
+ r->fields = DEVMODE_FORMNAME |
+ DEVMODE_TTOPTION |
+ DEVMODE_PRINTQUALITY |
+ DEVMODE_DEFAULTSOURCE |
+ DEVMODE_COPIES |
+ DEVMODE_SCALE |
+ DEVMODE_PAPERSIZE |
+ DEVMODE_ORIENTATION;
+ r->orientation = DMORIENT_PORTRAIT;
+ r->papersize = DMPAPER_LETTER;
+ r->paperlength = 0;
+ r->paperwidth = 0;
+ r->scale = 100;
+ r->copies = 55;
+ r->defaultsource = DMBIN_FORMSOURCE;
+ r->printquality = DMRES_HIGH;
+ r->color = DMRES_MONOCHROME;
+ r->duplex = DMDUP_SIMPLEX;
+ r->yresolution = 0;
+ r->ttoption = DMTT_SUBDEV;
+ r->collate = DMCOLLATE_FALSE;
+ r->formname = talloc_strdup(r, "Letter");
+
+ return r;
+}
+
+static bool test_add_printer_with_devmode(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
+ void *private_data)
+{
+ struct torture_printer_context *t =
+ (struct torture_printer_context *)talloc_get_type_abort(private_data, struct torture_printer_context);
+
+ t->ex = true;
+ t->wellknown = false;
+ t->info2.printername = TORTURE_PRINTER_EX;
+ t->devmode = torture_devicemode(t, TORTURE_PRINTER_EX);
return test_add_printer_args(tctx, p, t);
}
@@ -6760,6 +6862,8 @@ struct torture_suite *torture_rpc_spoolss_printer(TALLOC_CTX *mem_ctx)
torture_rpc_tcase_add_test_ex(tcase, "add_printer_ex", test_add_printer_ex, t);
torture_rpc_tcase_add_test_ex(tcase, "add_printer_ex_wellknown", test_add_printer_ex_wellknown, t);
+ torture_rpc_tcase_add_test_ex(tcase, "add_printer_with_devmode", test_add_printer_with_devmode, t);
+
return suite;
}
--
Samba Shared Repository
More information about the samba-cvs
mailing list