testprogs: add "samba3" and "architecture=" options to spoolss tester.
[samba.git] / testprogs / win32 / spoolss / spoolss.c
index 73713c62bb471fdaf6127fde39ef91fb026e074f..12641f02b95a0ae0276d4b34a02b34eef09b3c7e 100644 (file)
@@ -157,6 +157,10 @@ static BOOL test_EnumDrivers(struct torture_context *tctx,
                        }
                }
 
+               if (tctx->print) {
+                       print_driver_info_bylevel(levels[i], buffer, returned);
+               }
+
                free(buffer);
                buffer = NULL;
        }
@@ -205,6 +209,10 @@ static BOOL test_GetForm(struct torture_context *tctx,
                        }
                }
 
+               if (tctx->print) {
+                       print_form_info_bylevel(levels[i], buffer, 1);
+               }
+
                free(buffer);
                buffer = NULL;
        }
@@ -220,7 +228,7 @@ static BOOL test_EnumForms(struct torture_context *tctx,
                           HANDLE handle)
 {
        DWORD levels[]  = { 1, 2 };
-       DWORD success[] = { 1, 0 };
+       DWORD success[] = { 1, 1 };
        DWORD i;
        LPBYTE buffer = NULL;
 
@@ -233,6 +241,11 @@ static BOOL test_EnumForms(struct torture_context *tctx,
 
                torture_comment(tctx, "Testing EnumForms level %d", levels[i]);
 
+               if (tctx->samba3 && levels[i] == 2) {
+                       torture_comment(tctx, "skipping level %d enum against samba\n", levels[i]);
+                       continue;
+               }
+
                EnumForms(handle, levels[i], NULL, 0, &needed, &returned);
                err = GetLastError();
                if (err == ERROR_INSUFFICIENT_BUFFER) {
@@ -253,6 +266,10 @@ static BOOL test_EnumForms(struct torture_context *tctx,
                        }
                }
 
+               if (tctx->print) {
+                       print_form_info_bylevel(levels[i], buffer, returned);
+               }
+
                free(buffer);
                buffer = NULL;
        }
@@ -300,6 +317,10 @@ static BOOL test_EnumPorts(struct torture_context *tctx,
                        }
                }
 
+               if (tctx->print) {
+                       print_port_info_bylevel(levels[i], buffer, returned);
+               }
+
                free(buffer);
                buffer = NULL;
        }
@@ -347,6 +368,10 @@ static BOOL test_EnumMonitors(struct torture_context *tctx,
                        }
                }
 
+               if (tctx->print) {
+                       print_monitor_info_bylevel(levels[i], buffer, returned);
+               }
+
                free(buffer);
                buffer = NULL;
        }
@@ -395,6 +420,10 @@ static BOOL test_EnumPrintProcessors(struct torture_context *tctx,
                        }
                }
 
+               if (tctx->print) {
+                       print_printprocessor_info_bylevel(levels[i], buffer, returned);
+               }
+
                free(buffer);
                buffer = NULL;
        }
@@ -442,6 +471,10 @@ static BOOL test_EnumPrintProcessorDatatypes(struct torture_context *tctx,
                        }
                }
 
+               if (tctx->print) {
+                       print_datatypes_info_bylevel(levels[i], buffer, returned);
+               }
+
                free(buffer);
                buffer = NULL;
        }
@@ -525,6 +558,10 @@ static BOOL test_GetPrinter(struct torture_context *tctx,
                        }
                }
 
+               if (tctx->print) {
+                       print_printer_info_bylevel(levels[i], buffer, 1);
+               }
+
                free(buffer);
                buffer = NULL;
        }
@@ -573,6 +610,10 @@ static BOOL test_GetPrinterDriver(struct torture_context *tctx,
                        }
                }
 
+               if (tctx->print) {
+                       print_driver_info_bylevel(levels[i], buffer, 1);
+               }
+
                free(buffer);
                buffer = NULL;
        }
@@ -602,6 +643,11 @@ static BOOL test_EnumJobs(struct torture_context *tctx,
 
                torture_comment(tctx, "Testing EnumJobs level %d", levels[i]);
 
+               if (tctx->samba3 && levels[i] == 4) {
+                       torture_comment(tctx, "skipping level %d enum against samba\n", levels[i]);
+                       continue;
+               }
+
                EnumJobs(handle, 0, 100, levels[i], NULL, 0, &needed, &returned);
                err = GetLastError();
                if (err == ERROR_INSUFFICIENT_BUFFER) {
@@ -622,6 +668,10 @@ static BOOL test_EnumJobs(struct torture_context *tctx,
                        }
                }
 
+               if (tctx->print) {
+                       print_job_info_bylevel(levels[i], buffer, returned);
+               }
+
                free(buffer);
                buffer = NULL;
        }
@@ -988,6 +1038,21 @@ static BOOL test_PrinterData(struct torture_context *tctx,
 /****************************************************************************
 ****************************************************************************/
 
+const char *get_string_param(const char *str)
+{
+       const char *p;
+
+       p = strchr(str, '=');
+       if (!p) {
+               return NULL;
+       }
+
+       return (p+1);
+}
+
+/****************************************************************************
+****************************************************************************/
+
 int main(int argc, char *argv[])
 {
        BOOL ret = FALSE;
@@ -996,9 +1061,10 @@ int main(int argc, char *argv[])
        HANDLE server_handle;
        PRINTER_DEFAULTS defaults_admin, defaults_use;
        struct torture_context *tctx;
+       int i;
 
        if (argc < 2) {
-               fprintf(stderr, "usage: %s <servername> [print]\n", argv[0]);
+               fprintf(stderr, "usage: %s <servername> [print] [samba3] [architecture=ARCHITECTURE]\n", argv[0]);
                exit(-1);
        }
 
@@ -1011,12 +1077,20 @@ int main(int argc, char *argv[])
 
        servername = argv[1];
 
-       if (argc >= 3) {
-               if (strcmp(argv[2], "print") == 0) {
+       for (i=1; i < argc; i++) {
+               if (strcmp(argv[i], "print") == 0) {
                        tctx->print = TRUE;
                }
+               if (strcmp(argv[i], "samba3") == 0) {
+                       tctx->samba3 = TRUE;
+               }
+               if (strncmp(argv[i], "architecture", strlen("architecture")) == 0) {
+                       architecture = get_string_param(argv[i]);
+               }
        }
 
+       printf("Running testsuite with architecture: %s\n", architecture);
+
        defaults_admin.pDatatype = NULL;
        defaults_admin.pDevMode = NULL;
        defaults_admin.DesiredAccess = PRINTER_ACCESS_ADMINISTER;