testprogs: add EnumPrinterKey test to spoolss test.
authorGünther Deschner <gd@samba.org>
Mon, 11 Jan 2010 14:40:16 +0000 (15:40 +0100)
committerGünther Deschner <gd@samba.org>
Tue, 12 Jan 2010 11:12:05 +0000 (12:12 +0100)
Guenther

testprogs/win32/spoolss/error.c
testprogs/win32/spoolss/printlib.c
testprogs/win32/spoolss/printlib_proto.h
testprogs/win32/spoolss/spoolss.c

index ba15c1e62d48190f3e1e7fdf253fa9289b2c3c6a..6296f07c358a03b76f164f35c28e6a615bde791d 100644 (file)
@@ -31,6 +31,8 @@ const char *errstr(DWORD error)
                return "ERROR_ACCESS_DENIED";
        case ERROR_INVALID_PARAMETER:
                return "ERROR_INVALID_PARAMETER";
+       case ERROR_INVALID_HANDLE:
+               return "ERROR_INVALID_HANDLE";
        case ERROR_CALL_NOT_IMPLEMENTED:
                return "ERROR_CALL_NOT_IMPLEMENTED";
        case ERROR_INSUFFICIENT_BUFFER:
@@ -109,6 +111,8 @@ const char *errstr(DWORD error)
 #endif
        case ERROR_CANCELLED:
                return "ERROR_CANCELLED";
+       case RPC_S_SERVER_UNAVAILABLE:
+               return "RPC_S_SERVER_UNAVAILABLE";
        default:
                break;
        }
index c40ca6c2e179ee7be195c7a443286b64b3b1abd7..9fc9d046f234ce41ba22a77886d3e811c071e882 100644 (file)
@@ -606,3 +606,17 @@ void print_printer_enum_values(PRINTER_ENUM_VALUES *info)
 
        return;
 }
+
+void print_printer_keys(LPSTR buffer)
+{
+       LPSTR p = NULL;
+
+       p = buffer;
+
+       while (p && *p) {
+               printf("%s\n", p);
+               for (; *p; p = CharNext(p)) {
+                       p = CharNext(p);
+               }
+       }
+}
index fd6db2277067cccf60a744a2c64b19b796ccd4d7..d408523ac478edb2af9808bddaea72f18b68b742 100644 (file)
@@ -39,6 +39,7 @@ void print_driver_info_4 (PDRIVER_INFO_4 info);
 void print_driver_info_6 (PDRIVER_INFO_6 info);
 void print_doc_info_1 (PDOC_INFO_1 info);
 void print_printer_enum_values (PRINTER_ENUM_VALUES *info);
+void print_printer_keys(LPSTR buffer);
 #undef _PRINTF_ATTRIBUTE
 #define _PRINTF_ATTRIBUTE(a1, a2)
 
index 5c77413268b72f65899ee1adbdd5073a02d54613..66b9191bae17008eae17970e5ea460619e21a16e 100644 (file)
@@ -403,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)
@@ -561,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;
@@ -731,7 +769,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) {
@@ -756,9 +794,10 @@ 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);