s4-smbtorture: only run the cupsaddsmb adobe driver test against s3.
[kai/samba.git] / source4 / torture / rpc / spoolss.c
index e525793680e6e13e5e6c07e80a3ea2f2d5cdee00..dfd1c7ee33b99dc8c1ef7c2a35a35539533db31b 100644 (file)
@@ -45,6 +45,9 @@
 #define TORTURE_PRINTER_EX             "torture_printer_ex"
 #define TORTURE_DRIVER                 "torture_driver"
 #define TORTURE_DRIVER_EX              "torture_driver_ex"
+#define TORTURE_DRIVER_ADOBE           "torture_driver_adobe"
+#define TORTURE_DRIVER_EX_ADOBE                "torture_driver_ex_adobe"
+#define TORTURE_DRIVER_ADOBE_CUPSADDSMB        "torture_driver_adobe_cupsaddsmb"
 
 #define TOP_LEVEL_PRINT_KEY "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Print"
 #define TOP_LEVEL_PRINT_PRINTERS_KEY TOP_LEVEL_PRINT_KEY "\\Printers"
@@ -8599,7 +8602,7 @@ static bool upload_printer_driver_file(struct torture_context *tctx,
        const char *local_name = talloc_asprintf(tctx, "%s/%s", d->local.driver_directory, file_name);
        const char *remote_name = talloc_asprintf(tctx, "%s\\%s", remote_dir, file_name);
 
-       if (!file_name) {
+       if (!file_name || strlen(file_name) == 0) {
                return true;
        }
 
@@ -8731,7 +8734,7 @@ static bool remove_printer_driver_file(struct torture_context *tctx,
        const char *remote_name;
        const char *remote_dir =  driver_directory_dir(d->remote.driver_directory);
 
-       if (!file_name) {
+       if (!file_name || strlen(file_name) == 0) {
                return true;
        }
 
@@ -8767,9 +8770,11 @@ static bool remove_printer_driver(struct torture_context *tctx,
        torture_assert(tctx,
                remove_printer_driver_file(tctx, cli, d, d->info8.data_file),
                "failed to remove data_file");
-       torture_assert(tctx,
-               remove_printer_driver_file(tctx, cli, d, d->info8.config_file),
-               "failed to remove config_file");
+       if (!strequal(d->info8.config_file, d->info8.driver_path)) {
+               torture_assert(tctx,
+                       remove_printer_driver_file(tctx, cli, d, d->info8.config_file),
+                       "failed to remove config_file");
+       }
        torture_assert(tctx,
                remove_printer_driver_file(tctx, cli, d, d->info8.help_file),
                "failed to remove help_file");
@@ -8853,7 +8858,9 @@ static bool test_add_driver_arg(struct torture_context *tctx,
 
        info8.driver_path       = talloc_asprintf(tctx, "%s\\%s", d->remote.driver_directory, d->info8.driver_path);
        info8.data_file         = talloc_asprintf(tctx, "%s\\%s", d->remote.driver_directory, d->info8.data_file);
-       info8.config_file       = talloc_asprintf(tctx, "%s\\%s", d->remote.driver_directory, d->info8.config_file);
+       if (d->info8.config_file) {
+               info8.config_file       = talloc_asprintf(tctx, "%s\\%s", d->remote.driver_directory, d->info8.config_file);
+       }
 
        for (i=0; i < ARRAY_SIZE(levels); i++) {
 
@@ -8966,6 +8973,69 @@ static bool test_add_driver_32(struct torture_context *tctx,
        return test_add_driver_arg(tctx, p, d);
 }
 
+static bool test_add_driver_adobe(struct torture_context *tctx,
+                                 struct dcerpc_pipe *p)
+{
+       struct torture_driver_context *d;
+
+       d = talloc_zero(tctx, struct torture_driver_context);
+
+       d->info8.version                = SPOOLSS_DRIVER_VERSION_9X;
+       d->info8.driver_name            = TORTURE_DRIVER_ADOBE;
+       d->info8.architecture           = NULL;
+       d->info8.driver_path            = talloc_strdup(d, "ADOBEPS4.DRV");
+       d->info8.data_file              = talloc_strdup(d, "DEFPRTR2.PPD");
+       d->info8.config_file            = talloc_strdup(d, "ADOBEPS4.DRV");
+#if 0
+       d->info8.help_file              = talloc_strdup(d, "ADOBEPS4.HLP");
+       d->info8.monitor_name           = talloc_strdup(d, "PSMON.DLL");
+#endif
+       d->local.environment            = talloc_strdup(d, "Windows 4.0");
+       d->local.driver_directory       = talloc_strdup(d, "/usr/share/cups/drivers/adobe/");
+       d->ex                           = false;
+
+       return test_add_driver_arg(tctx, p, d);
+}
+
+static bool test_add_driver_adobe_cupsaddsmb(struct torture_context *tctx,
+                                            struct dcerpc_pipe *p)
+{
+       struct torture_driver_context *d;
+       struct spoolss_StringArray *a;
+
+       if (!torture_setting_bool(tctx, "samba3", false)) {
+               torture_skip(tctx, "skipping cupsaddsmb test which only works against samba3");
+       }
+
+       d = talloc_zero(tctx, struct torture_driver_context);
+
+       d->info8.version                = SPOOLSS_DRIVER_VERSION_9X;
+       d->info8.driver_name            = TORTURE_DRIVER_ADOBE_CUPSADDSMB;
+       d->info8.architecture           = NULL;
+       d->info8.driver_path            = talloc_strdup(d, "ADOBEPS4.DRV");
+       d->info8.data_file              = talloc_strdup(d, "DEFPRTR2.PPD");
+       d->info8.config_file            = NULL;
+       d->info8.help_file              = talloc_strdup(d, "ADOBEPS4.HLP");
+       d->info8.monitor_name           = talloc_strdup(d, "PSMON.DLL");
+       d->info8.default_datatype       = talloc_strdup(d, "RAW");
+
+       a                               = talloc_zero(d, struct spoolss_StringArray);
+       a->string                       = talloc_zero_array(a, const char *, 7);
+       a->string[0]                    = talloc_strdup(a->string, "ADOBEPS4.DRV");
+       a->string[1]                    = talloc_strdup(a->string, "DEFPRTR2.PPD");
+       a->string[2]                    = talloc_strdup(a->string, "ADOBEPS4.HLP");
+       a->string[3]                    = talloc_strdup(a->string, "PSMON.DLL");
+       a->string[4]                    = talloc_strdup(a->string, "ADFONTS.MFM");
+       a->string[5]                    = talloc_strdup(a->string, "ICONLIB.DLL");
+
+       d->info8.dependent_files        = a;
+       d->local.environment            = talloc_strdup(d, "Windows 4.0");
+       d->local.driver_directory       = talloc_strdup(d, "/usr/share/cups/drivers/adobe/");
+       d->ex                           = false;
+
+       return test_add_driver_arg(tctx, p, d);
+}
+
 struct torture_suite *torture_rpc_spoolss_driver(TALLOC_CTX *mem_ctx)
 {
        struct torture_suite *suite = torture_suite_create(mem_ctx, "SPOOLSS-DRIVER");
@@ -8978,5 +9048,9 @@ struct torture_suite *torture_rpc_spoolss_driver(TALLOC_CTX *mem_ctx)
        torture_rpc_tcase_add_test(tcase, "add_driver_32", test_add_driver_32);
        torture_rpc_tcase_add_test(tcase, "add_driver_ex_32", test_add_driver_ex_32);
 
+       torture_rpc_tcase_add_test(tcase, "add_driver_adobe", test_add_driver_adobe);
+
+       torture_rpc_tcase_add_test(tcase, "add_driver_adobe_cupsaddsmb", test_add_driver_adobe_cupsaddsmb);
+
        return suite;
 }