From d20bdda38a7d23c79545ba77df032d7a2a92e0f5 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Tue, 8 Aug 2017 11:25:48 +0200 Subject: [PATCH 1/3] s4:torture: Use a different driver name for add_driver tests BUG: https://bugzilla.samba.org/show_bug.cgi?id=12984 Signed-off-by: Andreas Schneider Reviewed-by: Guenther Deschner (cherry picked from commit 731fe596ac0999d54aae03ce4175356c56b3c94b) --- source4/torture/rpc/spoolss.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source4/torture/rpc/spoolss.c b/source4/torture/rpc/spoolss.c index 14a43b97f6d..4992856a9ba 100644 --- a/source4/torture/rpc/spoolss.c +++ b/source4/torture/rpc/spoolss.c @@ -47,6 +47,7 @@ #define TORTURE_WELLKNOWN_PRINTER_EX "torture_wkn_printer_ex" #define TORTURE_PRINTER_EX "torture_printer_ex" #define TORTURE_DRIVER "torture_driver" +#define TORTURE_DRIVER_ADD "torture_driver_add" #define TORTURE_DRIVER_EX "torture_driver_ex" #define TORTURE_DRIVER_ADOBE "torture_driver_adobe" #define TORTURE_DRIVER_EX_ADOBE "torture_driver_ex_adobe" @@ -10931,7 +10932,7 @@ static bool test_add_driver_64(struct torture_context *tctx, d->local.driver_directory = talloc_strdup(d, "/usr/share/cups/drivers/x64"); d->info8.version = SPOOLSS_DRIVER_VERSION_200X; - d->info8.driver_name = TORTURE_DRIVER; + d->info8.driver_name = TORTURE_DRIVER_ADD; d->info8.architecture = d->local.environment; d->info8.driver_path = talloc_strdup(d, "pscript5.dll"); d->info8.data_file = talloc_strdup(d, "cups6.ppd"); @@ -10952,7 +10953,7 @@ static bool test_add_driver_32(struct torture_context *tctx, d->local.driver_directory = talloc_strdup(d, "/usr/share/cups/drivers/i386"); d->info8.version = SPOOLSS_DRIVER_VERSION_200X; - d->info8.driver_name = TORTURE_DRIVER; + d->info8.driver_name = TORTURE_DRIVER_ADD; d->info8.architecture = d->local.environment; d->info8.driver_path = talloc_strdup(d, "pscript5.dll"); d->info8.data_file = talloc_strdup(d, "cups6.ppd"); -- 2.14.1 From ef437f9ebbb71cf3ae1a1573cb13609cb52c892b Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Tue, 8 Aug 2017 10:40:19 +0200 Subject: [PATCH 2/3] s4:torture: Delete printer before we remove the driver BUG: https://bugzilla.samba.org/show_bug.cgi?id=12984 Signed-off-by: Andreas Schneider Reviewed-by: Guenther Deschner (cherry picked from commit bd44e435fa6a93d47a470f8ee95763a95eba4b5d) --- source4/torture/rpc/spoolss.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/source4/torture/rpc/spoolss.c b/source4/torture/rpc/spoolss.c index 4992856a9ba..b35a1a59560 100644 --- a/source4/torture/rpc/spoolss.c +++ b/source4/torture/rpc/spoolss.c @@ -8583,6 +8583,22 @@ static bool torture_rpc_spoolss_printer_teardown_common(struct torture_context * server_name_slash = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p)); + if (!t->wellknown) { + const char *printer_name = t->info2.printername; + + torture_assert(tctx, + test_DeletePrinter(tctx, b, &t->handle), + "failed to delete printer"); + + torture_assert(tctx, + test_EnumPrinters_findname(tctx, b, PRINTER_ENUM_LOCAL, 1, + printer_name, &found), + "failed to enumerate printers"); + + torture_assert(tctx, !found, "deleted printer still there"); + } + + if (t->added_driver) { torture_assert(tctx, remove_printer_driver(tctx, dcerpc_server_name(p), &t->driver), @@ -8599,21 +8615,6 @@ static bool torture_rpc_spoolss_printer_teardown_common(struct torture_context * "failed to delete printer driver via spoolss"); } - if (!t->wellknown) { - const char *printer_name = t->info2.printername; - - torture_assert(tctx, - test_DeletePrinter(tctx, b, &t->handle), - "failed to delete printer"); - - torture_assert(tctx, - test_EnumPrinters_findname(tctx, b, PRINTER_ENUM_LOCAL, 1, - printer_name, &found), - "failed to enumerate printers"); - - torture_assert(tctx, !found, "deleted printer still there"); - } - return true; } -- 2.14.1 From 202e8f845127d107b64c8a1d3f0f6856cf538360 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Tue, 8 Aug 2017 12:05:24 +0200 Subject: [PATCH 3/3] s4:torture: The teardown function should just return The teardown functions should not return on error but finish cleaning up! BUG: https://bugzilla.samba.org/show_bug.cgi?id=12984 Signed-off-by: Andreas Schneider Reviewed-by: Guenther Deschner (cherry picked from commit c90069b26424752b15922de9cb796c431d2f3e08) --- source4/torture/rpc/spoolss.c | 49 +++++++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/source4/torture/rpc/spoolss.c b/source4/torture/rpc/spoolss.c index b35a1a59560..d81841fea6c 100644 --- a/source4/torture/rpc/spoolss.c +++ b/source4/torture/rpc/spoolss.c @@ -8575,6 +8575,7 @@ static bool torture_rpc_spoolss_printer_teardown_common(struct torture_context * struct dcerpc_pipe *p = t->spoolss_pipe; struct dcerpc_binding_handle *b = NULL; const char *server_name_slash; + bool ok = true; if (p == NULL) { return true; @@ -8586,36 +8587,52 @@ static bool torture_rpc_spoolss_printer_teardown_common(struct torture_context * if (!t->wellknown) { const char *printer_name = t->info2.printername; - torture_assert(tctx, + torture_assert_goto(tctx, test_DeletePrinter(tctx, b, &t->handle), + ok, + remove_driver, "failed to delete printer"); - torture_assert(tctx, + torture_assert_goto(tctx, test_EnumPrinters_findname(tctx, b, PRINTER_ENUM_LOCAL, 1, printer_name, &found), + ok, + remove_driver, "failed to enumerate printers"); - torture_assert(tctx, !found, "deleted printer still there"); + torture_assert_goto(tctx, + !found, + ok, + remove_driver, + "deleted printer still there"); } +remove_driver: if (t->added_driver) { - torture_assert(tctx, - remove_printer_driver(tctx, dcerpc_server_name(p), &t->driver), - "failed to remove printer driver"); + ok = remove_printer_driver(tctx, + dcerpc_server_name(p), + &t->driver); + if (!ok) { + torture_warning(tctx, + "failed to remove printer driver\n"); + } - torture_assert(tctx, - test_DeletePrinterDriverEx_exp(tctx, b, - server_name_slash, - t->driver.info8.driver_name, - t->driver.info8.architecture, - DPD_DELETE_ALL_FILES, - t->driver.info8.version, - WERR_OK), - "failed to delete printer driver via spoolss"); + ok = test_DeletePrinterDriverEx_exp(tctx, b, + server_name_slash, + t->driver.info8.driver_name, + t->driver.info8.architecture, + DPD_DELETE_ALL_FILES, + t->driver.info8.version, + WERR_OK); + if (!ok) { + torture_warning(tctx, + "failed to delete printer driver via " + "spoolss\n"); + } } - return true; + return ok; } static bool torture_rpc_spoolss_printer_teardown(struct torture_context *tctx, void *data) -- 2.14.1