testprogs: remove unused test_EachDriver from spoolss test.
[ira/wip.git] / testprogs / win32 / spoolss / spoolss.c
index d014b14e70b06aad6474d86dacbdf6b1efe596af..d68ca89f48abed565504a56a22a093f516cffe03 100644 (file)
@@ -104,6 +104,10 @@ static BOOL test_EnumPrinters(struct torture_context *tctx,
                        }
                }
 
+               if (tctx->print) {
+                       print_printer_info_bylevel(levels[i], buffer, returned);
+               }
+
                free(buffer);
                buffer = NULL;
        }
@@ -118,8 +122,8 @@ static BOOL test_EnumDrivers(struct torture_context *tctx,
                             LPSTR servername,
                             LPSTR architecture)
 {
-       DWORD levels[]  = { 1, 2, 3, 4, 5, 6, 8 };
-       DWORD success[] = { 1, 1, 1, 1, 1, 1, 1 };
+       DWORD levels[]  = { 1, 2, 3, 4, 5, 6 };
+       DWORD success[] = { 1, 1, 1, 1, 1, 1 };
        DWORD i;
        LPBYTE buffer = NULL;
 
@@ -353,8 +357,7 @@ static BOOL test_EnumPrintProcessors(struct torture_context *tctx,
 ****************************************************************************/
 
 static BOOL test_EnumPrintProcessorDatatypes(struct torture_context *tctx,
-                                            LPSTR servername,
-                                            LPSTR architecture)
+                                            LPSTR servername)
 {
        DWORD levels[]  = { 1 };
        DWORD success[] = { 1 };
@@ -370,13 +373,13 @@ static BOOL test_EnumPrintProcessorDatatypes(struct torture_context *tctx,
 
                torture_comment(tctx, "Testing EnumPrintProcessorDatatypes level %d", levels[i]);
 
-               EnumPrintProcessorDatatypes(servername, architecture, levels[i], NULL, 0, &needed, &returned);
+               EnumPrintProcessorDatatypes(servername, "winprint", levels[i], NULL, 0, &needed, &returned);
                err = GetLastError();
                if (err == ERROR_INSUFFICIENT_BUFFER) {
                        err = 0;
                        buffer = malloc(needed);
                        torture_assert(tctx, buffer, "malloc failed");
-                       if (!EnumPrintProcessorDatatypes(servername, architecture, levels[i], buffer, needed, &needed, &returned)) {
+                       if (!EnumPrintProcessorDatatypes(servername, "winprint", levels[i], buffer, needed, &needed, &returned)) {
                                err = GetLastError();
                        }
                }
@@ -400,6 +403,42 @@ static BOOL test_EnumPrintProcessorDatatypes(struct torture_context *tctx,
 /****************************************************************************
 ****************************************************************************/
 
+static BOOL test_EnumPrinterKey(struct torture_context *tctx,
+                               LPSTR servername,
+                               HANDLE handle,
+                               LPCSTR key)
+{
+       LPSTR buffer = NULL;
+       DWORD needed = 0;
+       DWORD err = 0;
+       char tmp[1024];
+
+       torture_comment(tctx, "Testing EnumPrinterKey(%s)", key);
+
+       err = EnumPrinterKey(handle, key, NULL, 0, &needed);
+       if (err == ERROR_MORE_DATA) {
+               buffer = (LPTSTR)malloc(needed);
+               torture_assert(tctx, buffer, "malloc failed");
+               err = EnumPrinterKey(handle, key, buffer, needed, &needed);
+       }
+       if (err) {
+               sprintf(tmp, "EnumPrinterKey(%s) failed on [%s] (buffer size = %d), error: %s\n",
+                       key, servername, needed, errstr(err));
+               torture_fail(tctx, tmp);
+       }
+
+       if (tctx->print) {
+               print_printer_keys(buffer);
+       }
+
+       free(buffer);
+
+       return TRUE;
+}
+
+/****************************************************************************
+****************************************************************************/
+
 static BOOL test_GetPrinter(struct torture_context *tctx,
                            LPSTR printername,
                            HANDLE handle)
@@ -452,8 +491,8 @@ static BOOL test_GetPrinterDriver(struct torture_context *tctx,
                                  LPSTR architecture,
                                  HANDLE handle)
 {
-       DWORD levels[]  = { 1, 2, 3, 4, 5, 6, 8, 101};
-       DWORD success[] = { 1, 1, 1, 1, 1, 1, 1, 1 };
+       DWORD levels[]  = { 1, 2, 3, 4, 5, 6, 8 };
+       DWORD success[] = { 1, 1, 1, 1, 1, 1, 1 };
        DWORD i;
        LPBYTE buffer = NULL;
 
@@ -558,6 +597,8 @@ static BOOL test_OnePrinter(struct torture_context *tctx,
        ret &= test_GetPrinterDriver(tctx, printername, architecture, handle);
        ret &= test_EnumForms(tctx, printername, handle);
        ret &= test_EnumJobs(tctx, printername, handle);
+       ret &= test_EnumPrinterKey(tctx, printername, handle, "");
+       ret &= test_EnumPrinterKey(tctx, printername, handle, "PrinterDriverData");
        ret &= test_ClosePrinter(tctx, handle);
 
        return ret;
@@ -566,25 +607,6 @@ static BOOL test_OnePrinter(struct torture_context *tctx,
 /****************************************************************************
 ****************************************************************************/
 
-static BOOL test_OneDriver(struct torture_context *tctx,
-                          LPSTR printername,
-                          LPSTR drivername)
-{
-       return TRUE;
-}
-
-/****************************************************************************
-****************************************************************************/
-
-static BOOL test_EachDriver(struct torture_context *tctx,
-                           LPSTR servername)
-{
-       return TRUE;
-}
-
-/****************************************************************************
-****************************************************************************/
-
 static BOOL test_EachPrinter(struct torture_context *tctx,
                             LPSTR servername,
                             LPSTR architecture)
@@ -596,6 +618,7 @@ static BOOL test_EachPrinter(struct torture_context *tctx,
        DWORD i;
        DWORD flags = PRINTER_ENUM_NAME;
        PPRINTER_INFO_1 buffer = NULL;
+       BOOL ret = TRUE;
 
        torture_comment(tctx, "Testing EnumPrinters level %d", 1);
 
@@ -616,13 +639,12 @@ static BOOL test_EachPrinter(struct torture_context *tctx,
        }
 
        for (i=0; i < returned; i++) {
-               torture_assert(tctx, test_OnePrinter(tctx, buffer[i].pName, architecture),
-                       "failed to test one printer");
+               ret &= test_OnePrinter(tctx, buffer[i].pName, architecture);
        }
 
        free(buffer);
 
-       return TRUE;
+       return ret;
 }
 
 /****************************************************************************
@@ -728,7 +750,7 @@ int main(int argc, char *argv[])
        BOOL ret = FALSE;
        LPSTR servername;
        LPSTR architecture = "Windows NT x86";
-       HANDLE handle;
+       HANDLE server_handle;
        struct torture_context *tctx;
 
        if (argc < 2) {
@@ -753,17 +775,17 @@ int main(int argc, char *argv[])
 
        ret &= test_EnumPrinters(tctx, servername);
        ret &= test_EnumDrivers(tctx, servername, architecture);
-       ret &= test_OpenPrinter(tctx, servername, &handle);
-       ret &= test_EnumForms(tctx, servername, handle);
-       ret &= test_ClosePrinter(tctx, handle);
+       ret &= test_OpenPrinter(tctx, servername, &server_handle);
+/*     ret &= test_EnumPrinterKey(tctx, servername, server_handle, ""); */
+       ret &= test_EnumForms(tctx, servername, server_handle);
+       ret &= test_ClosePrinter(tctx, server_handle);
        ret &= test_EnumPorts(tctx, servername);
        ret &= test_EnumMonitors(tctx, servername);
        ret &= test_EnumPrintProcessors(tctx, servername, architecture);
-       ret &= test_EnumPrintProcessorDatatypes(tctx, servername, architecture);
+       ret &= test_EnumPrintProcessorDatatypes(tctx, servername);
        ret &= test_GetPrintProcessorDirectory(tctx, servername, architecture);
        ret &= test_GetPrinterDriverDirectory(tctx, servername, architecture);
        ret &= test_EachPrinter(tctx, servername, architecture);
-       ret &= test_EachDriver(tctx, servername);
 
        if (!ret) {
                if (tctx->last_reason) {