diff options
author | Günther Deschner <gd@samba.org> | 2010-03-15 17:08:23 +0100 |
---|---|---|
committer | Günther Deschner <gd@samba.org> | 2010-03-15 17:27:12 +0100 |
commit | 6f36e9d5045a062784d21dbfdd720df4cbb91182 (patch) | |
tree | 29f7011a3a1903fdb7dfba8bd264dea9450176da /testprogs/win32/spoolss | |
parent | 08ec9b7e734dcdd46440abba49e980cae01b1e44 (diff) | |
download | samba-6f36e9d5045a062784d21dbfdd720df4cbb91182.tar.gz samba-6f36e9d5045a062784d21dbfdd720df4cbb91182.tar.bz2 samba-6f36e9d5045a062784d21dbfdd720df4cbb91182.zip |
testprogs: add EnumPrinterData test to win32 spoolss test.
Guenther
Diffstat (limited to 'testprogs/win32/spoolss')
-rw-r--r-- | testprogs/win32/spoolss/error.c | 2 | ||||
-rw-r--r-- | testprogs/win32/spoolss/spoolss.c | 65 |
2 files changed, 67 insertions, 0 deletions
diff --git a/testprogs/win32/spoolss/error.c b/testprogs/win32/spoolss/error.c index a74312ab61..e5ad661dd4 100644 --- a/testprogs/win32/spoolss/error.c +++ b/testprogs/win32/spoolss/error.c @@ -45,6 +45,8 @@ const char *errstr(DWORD error) return "ERROR_INVALID_DATA"; case ERROR_MORE_DATA: return "ERROR_MORE_DATA"; + case ERROR_NO_MORE_ITEMS: + return "ERROR_NO_MORE_ITEMS"; #ifdef ERROR_INVALID_DATATYPE case ERROR_INVALID_DATATYPE: return "ERROR_INVALID_DATATYPE"; diff --git a/testprogs/win32/spoolss/spoolss.c b/testprogs/win32/spoolss/spoolss.c index c4c5017ede..d98aee2e73 100644 --- a/testprogs/win32/spoolss/spoolss.c +++ b/testprogs/win32/spoolss/spoolss.c @@ -682,6 +682,70 @@ static BOOL test_EnumJobs(struct torture_context *tctx, /**************************************************************************** ****************************************************************************/ +static BOOL test_EnumPrinterData(struct torture_context *tctx, + LPSTR servername, + HANDLE handle) +{ + DWORD err = 0; + LPTSTR value_name; + LPBYTE data; + DWORD index = 0; + DWORD type; + DWORD value_offered = 0, value_needed; + DWORD data_offered = 0, data_needed; + char tmp[1024]; + + torture_comment(tctx, "Testing EnumPrinterData(%d) (value offered: %d, data_offered: %d)\n", + index, value_offered, data_offered); + + err = EnumPrinterData(handle, 0, NULL, 0, &value_needed, NULL, NULL, 0, &data_needed); + if (err) { + sprintf(tmp, "EnumPrinterData(%d) failed on [%s] (value size = %d, data size = %d), error: %s\n", + index, servername, value_offered, data_offered, errstr(err)); + torture_fail(tctx, tmp); + } + + value_name = malloc(value_needed); + torture_assert(tctx, value_name, "malloc failed"); + data = malloc(data_needed); + torture_assert(tctx, data, "malloc failed"); + + value_offered = value_needed; + data_offered = data_needed; + + do { + + value_needed = 0; + data_needed = 0; + + torture_comment(tctx, "Testing EnumPrinterData(%d) (value offered: %d, data_offered: %d)\n", + index, value_offered, data_offered); + + err = EnumPrinterData(handle, index++, value_name, value_offered, &value_needed, &type, data, data_offered, &data_needed); + if (err == ERROR_NO_MORE_ITEMS) { + break; + } + if (err) { + sprintf(tmp, "EnumPrinterData(%d) failed on [%s] (value size = %d, data size = %d), error: %s\n", + index, servername, value_offered, data_offered, errstr(err)); + torture_fail(tctx, tmp); + } + + if (tctx->print) { + print_printer_data(NULL, value_name, data_needed, data, type); + } + + } while (err != ERROR_NO_MORE_ITEMS); + + free(value_name); + free(data); + + return TRUE; +} + +/**************************************************************************** +****************************************************************************/ + static BOOL test_EnumPrinterDataEx(struct torture_context *tctx, LPSTR servername, LPSTR keyname, @@ -985,6 +1049,7 @@ static BOOL test_OnePrinter(struct torture_context *tctx, ret &= test_EachJob(tctx, printername, handle); ret &= test_EnumPrinterKey(tctx, printername, handle, ""); ret &= test_EnumPrinterKey(tctx, printername, handle, "PrinterDriverData"); + ret &= test_EnumPrinterData(tctx, printername, handle); ret &= test_EnumPrinterDataEx(tctx, printername, "PrinterDriverData", handle, NULL, NULL); ret &= test_DeviceModes(tctx, printername, handle); ret &= test_PrinterData(tctx, printername, handle); |