From 487a03a1586e478baaadada184836be98c609aa0 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 14 Dec 2009 23:54:42 +0100 Subject: testprogs: add win32 spoolss testsuite. Guenther --- testprogs/win32/spoolss/Makefile | 38 ++ testprogs/win32/spoolss/Makefile.mingw | 22 + testprogs/win32/spoolss/README | 1 + testprogs/win32/spoolss/error.c | 115 +++++ testprogs/win32/spoolss/error.h | 36 ++ testprogs/win32/spoolss/spoolss.c | 771 ++++++++++++++++++++++++++++++++ testprogs/win32/spoolss/spoolss.h | 50 +++ testprogs/win32/spoolss/string.h | 15 + testprogs/win32/spoolss/torture.c | 106 +++++ testprogs/win32/spoolss/torture.h | 91 ++++ testprogs/win32/spoolss/torture_proto.h | 32 ++ 11 files changed, 1277 insertions(+) create mode 100644 testprogs/win32/spoolss/Makefile create mode 100644 testprogs/win32/spoolss/Makefile.mingw create mode 100644 testprogs/win32/spoolss/README create mode 100644 testprogs/win32/spoolss/error.c create mode 100644 testprogs/win32/spoolss/error.h create mode 100644 testprogs/win32/spoolss/spoolss.c create mode 100644 testprogs/win32/spoolss/spoolss.h create mode 100644 testprogs/win32/spoolss/string.h create mode 100644 testprogs/win32/spoolss/torture.c create mode 100644 testprogs/win32/spoolss/torture.h create mode 100644 testprogs/win32/spoolss/torture_proto.h (limited to 'testprogs') diff --git a/testprogs/win32/spoolss/Makefile b/testprogs/win32/spoolss/Makefile new file mode 100644 index 0000000000..96efceacf4 --- /dev/null +++ b/testprogs/win32/spoolss/Makefile @@ -0,0 +1,38 @@ +CFLAGS = /nologo /Zi /MT /Gm- /W4 /FR /D_CRT_SECURE_NO_WARNINGS +LIBS = kernel32.lib gdi32.lib user32.lib shell32.lib \ + advapi32.lib ole32.lib ws2_32.lib rpcrt4.lib +WINSPOOL_LIBS = winspool.lib + +all: spoolss.exe + +.cpp.obj: + cl /c $(CFLAGS) $*.cpp + +.c.obj: + cl /c $(CFLAGS) $*.c + +clean: cleantmp + -del *.dll 2>nul + +cleantmp: + -del *~ *.o *.obj *.sbr *.bsc *.pdb *.lib *.ilk *.exp 2>nul + -del test_s.c test_c.c test.h 2>nul + +############################### +# helpers +############################### + +error.obj: error.c + +torture.obj: torture.c + +############################### +# binaries +############################### + +spoolss.obj: spoolss.c + +spoolss.exe: spoolss.obj error.obj torture.obj + cl $(CFLAGS) /Fe$@ spoolss.obj error.obj torture.obj \ + /link /incremental:no /subsystem:console $(LIBS) $(WINSPOOL_LIBS) + diff --git a/testprogs/win32/spoolss/Makefile.mingw b/testprogs/win32/spoolss/Makefile.mingw new file mode 100644 index 0000000000..82fc7ed488 --- /dev/null +++ b/testprogs/win32/spoolss/Makefile.mingw @@ -0,0 +1,22 @@ +MAKE=mingw32-make +CFLAGS=-I../../../ -I/usr/i686-pc-mingw32/sys-root/mingw/include +LDFLAGS=-L/usr/i686-pc-mingw32/sys-root/mingw/lib +CC=/usr/bin/i686-pc-mingw32-gcc +LIBS=-lwinspool + +all: spoolss.exe + +clean: + rm -vf *.exe tags + +ctags: + ctags `find . -name "*.[ch]" | grep -v include/proto.h` + ctags --c-kinds=-p -a `find /usr/i686-pc-mingw32/sys-root/mingw/include -name "*.[ch]" | grep -v /CVS/` + +proto: + mkproto.pl torture.c --private=torture_proto.h --public=torture_proto_pub.h --srcdir=. --builddir=. + +spoolss.exe: spoolss.c torture.c error.c + @echo Compiling spoolss.exe + @$(CC) $(CFLAGS) $(LDFLAGS) spoolss.c torture.c error.c $(LIBS) -o spoolss.exe + diff --git a/testprogs/win32/spoolss/README b/testprogs/win32/spoolss/README new file mode 100644 index 0000000000..9d6cf4b7fb --- /dev/null +++ b/testprogs/win32/spoolss/README @@ -0,0 +1 @@ +FIXME diff --git a/testprogs/win32/spoolss/error.c b/testprogs/win32/spoolss/error.c new file mode 100644 index 0000000000..e523c15864 --- /dev/null +++ b/testprogs/win32/spoolss/error.c @@ -0,0 +1,115 @@ +/* + Unix SMB/CIFS implementation. + test suite for spoolss rpc operations + + Copyright (C) Guenther Deschner 2009 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "spoolss.h" + +const char *errstr(DWORD error) +{ + static char tmp[20]; + + switch (error) { + case ERROR_ACCESS_DENIED: + return "ERROR_ACCESS_DENIED"; + case ERROR_INVALID_PARAMETER: + return "ERROR_INVALID_PARAMETER"; + case ERROR_CALL_NOT_IMPLEMENTED: + return "ERROR_CALL_NOT_IMPLEMENTED"; + case ERROR_INSUFFICIENT_BUFFER: + return "ERROR_INSUFFICIENT_BUFFER"; + case ERROR_INVALID_NAME: + return "ERROR_INVALID_NAME"; + case ERROR_INVALID_LEVEL: + return "ERROR_INVALID_LEVEL"; + case ERROR_MORE_DATA: + return "ERROR_MORE_DATA"; +#ifdef ERROR_INVALID_DATATYPE + case ERROR_INVALID_DATATYPE: + return "ERROR_INVALID_DATATYPE"; +#endif + case ERROR_INVALID_ENVIRONMENT: + return "ERROR_INVALID_ENVIRONMENT"; + case ERROR_INVALID_PRINTER_COMMAND: + return "ERROR_INVALID_PRINTER_COMMAND"; + case ERROR_PRINTER_ALREADY_EXISTS: + return "ERROR_PRINTER_ALREADY_EXISTS"; + case ERROR_INVALID_PRINTER_NAME: + return "ERROR_INVALID_PRINTER_NAME"; + case ERROR_INVALID_PRIORITY: + return "ERROR_INVALID_PRIORITY"; + case ERROR_INVALID_SEPARATOR_FILE: + return "ERROR_INVALID_SEPARATOR_FILE"; + case ERROR_UNKNOWN_PRINTPROCESSOR: + return "ERROR_UNKNOWN_PRINTPROCESSOR"; + case ERROR_UNKNOWN_PRINTER_DRIVER: + return "ERROR_UNKNOWN_PRINTER_DRIVER"; + case ERROR_UNKNOWN_PORT: + return "ERROR_UNKNOWN_PORT"; + case ERROR_PRINTER_DRIVER_ALREADY_INSTALLED: + return "ERROR_PRINTER_DRIVER_ALREADY_INSTALLED"; + case ERROR_UNKNOWN_PRINT_MONITOR: + return "ERROR_UNKNOWN_PRINT_MONITOR"; + case ERROR_PRINTER_DRIVER_IN_USE: + return "ERROR_PRINTER_DRIVER_IN_USE"; + case ERROR_SPOOL_FILE_NOT_FOUND: + return "ERROR_SPOOL_FILE_NOT_FOUND"; + case ERROR_SPL_NO_STARTDOC: + return "ERROR_SPL_NO_STARTDOC"; + case ERROR_SPL_NO_ADDJOB: + return "ERROR_SPL_NO_ADDJOB"; + case ERROR_PRINT_PROCESSOR_ALREADY_INSTALLED: + return "ERROR_PRINT_PROCESSOR_ALREADY_INSTALLED"; + case ERROR_PRINT_MONITOR_ALREADY_INSTALLED: + return "ERROR_PRINT_MONITOR_ALREADY_INSTALLED"; + case ERROR_INVALID_PRINT_MONITOR: + return "ERROR_INVALID_PRINT_MONITOR"; + case ERROR_PRINT_MONITOR_IN_USE: + return "ERROR_PRINT_MONITOR_IN_USE"; + case ERROR_PRINTER_HAS_JOBS_QUEUED: + return "ERROR_PRINTER_HAS_JOBS_QUEUED"; + case ERROR_PRINTER_NOT_FOUND: + return "ERROR_PRINTER_NOT_FOUND"; + case ERROR_PRINTER_DRIVER_WARNED: + return "ERROR_PRINTER_DRIVER_WARNED"; + case ERROR_PRINTER_DRIVER_BLOCKED: + return "ERROR_PRINTER_DRIVER_BLOCKED"; +#ifdef ERROR_PRINTER_DRIVER_PACKAGE_IN_USE + case ERROR_PRINTER_DRIVER_PACKAGE_IN_USE: + return "ERROR_PRINTER_DRIVER_PACKAGE_IN_USE"; +#endif +#ifdef ERROR_CORE_DRIVER_PACKAGE_NOT_FOUND + case ERROR_CORE_DRIVER_PACKAGE_NOT_FOUND: + return "ERROR_CORE_DRIVER_PACKAGE_NOT_FOUND"; +#endif +#ifdef ERROR_PRINTER_DRIVER_DOWNLOAD_NEEDED + case ERROR_PRINTER_DRIVER_DOWNLOAD_NEEDED: + return "ERROR_PRINTER_DRIVER_DOWNLOAD_NEEDED"; +#endif +#ifdef ERROR_PRINT_JOB_RESTART_REQUIRED + case ERROR_PRINT_JOB_RESTART_REQUIRED: + return "ERROR_PRINT_JOB_RESTART_REQUIRED"; +#endif + default: + break; + } + + sprintf(tmp, "0x%08x", error); + + return tmp; +} diff --git a/testprogs/win32/spoolss/error.h b/testprogs/win32/spoolss/error.h new file mode 100644 index 0000000000..581c1097c1 --- /dev/null +++ b/testprogs/win32/spoolss/error.h @@ -0,0 +1,36 @@ +/* + Unix SMB/CIFS implementation. + test suite for spoolss rpc operations + + Copyright (C) Guenther Deschner 2009 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef ERROR_INVALID_PARAMETER +#define ERROR_INVALID_PARAMETER 87 +#endif + +#ifndef ERROR_INSUFFICIENT_BUFFER +#define ERROR_INSUFFICIENT_BUFFER 0x007a +#endif + +#if 0 +#ifdef STATUS_PENDING +#undef STATUS_PENDING +#define STATUS_PENDING 0x0103 +#endif +#endif + +const char *errstr(DWORD error); diff --git a/testprogs/win32/spoolss/spoolss.c b/testprogs/win32/spoolss/spoolss.c new file mode 100644 index 0000000000..200f89602b --- /dev/null +++ b/testprogs/win32/spoolss/spoolss.c @@ -0,0 +1,771 @@ +/* + Unix SMB/CIFS implementation. + test suite for spoolss rpc operations + + Copyright (C) Guenther Deschner 2009 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/**************************************************************************** +****************************************************************************/ + +#include "spoolss.h" +#include "string.h" +#include "torture.h" + +/**************************************************************************** +****************************************************************************/ + +static BOOL test_OpenPrinter(struct torture_context *tctx, + LPSTR printername, + HANDLE handle) +{ + torture_comment(tctx, "Testing OpenPrinter(%s)", printername); + + if (!OpenPrinter(printername, handle, NULL)) { + char tmp[1024]; + sprintf(tmp, "failed to open printer %s, error was: 0x%08x\n", + printername, GetLastError()); + torture_fail(tctx, tmp); + } + + return TRUE; +} + +/**************************************************************************** +****************************************************************************/ + +static BOOL test_ClosePrinter(struct torture_context *tctx, + HANDLE handle) +{ + torture_comment(tctx, "Testing ClosePrinter"); + + if (!ClosePrinter(handle)) { + char tmp[1024]; + sprintf(tmp, "failed to close printer, error was: %s\n", + errstr(GetLastError())); + torture_fail(tctx, tmp); + } + + return TRUE; +} + + +/**************************************************************************** +****************************************************************************/ + +static BOOL test_EnumPrinters(struct torture_context *tctx, + LPSTR servername) +{ + DWORD levels[] = { 1, 2, 5 }; + DWORD success[] = { 1, 1, 1 }; + DWORD i; + DWORD flags = PRINTER_ENUM_NAME; + LPBYTE buffer = NULL; + + for (i=0; i < ARRAY_SIZE(levels); i++) { + + DWORD needed = 0; + DWORD returned = 0; + DWORD err = 0; + char tmp[1024]; + + torture_comment(tctx, "Testing EnumPrinters level %d", levels[i]); + + EnumPrinters(flags, servername, 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 (!EnumPrinters(flags, servername, levels[i], buffer, needed, &needed, &returned)) { + err = GetLastError(); + } + } + if (err) { + sprintf(tmp, "EnumPrinters failed level %d on [%s] (buffer size = %d), error: %s\n", + levels[i], servername, needed, errstr(err)); + if (success[i]) { + torture_fail(tctx, tmp); + } else { + torture_warning(tctx, tmp); + } + } + + free(buffer); + buffer = NULL; + } + + return TRUE; +} + +/**************************************************************************** +****************************************************************************/ + +static BOOL test_EnumDrivers(struct torture_context *tctx, + LPSTR servername) +{ + DWORD levels[] = { 1, 2, 3, 4, 5, 6, 8 }; + DWORD success[] = { 1, 1, 1, 1, 1, 1, 1 }; + DWORD i; + LPBYTE buffer = NULL; + + for (i=0; i < ARRAY_SIZE(levels); i++) { + + DWORD needed = 0; + DWORD returned = 0; + DWORD err = 0; + char tmp[1024]; + + torture_comment(tctx, "Testing EnumPrinterDrivers level %d", levels[i]); + + EnumPrinterDrivers(servername, "Windows NT x86", 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 (!EnumPrinterDrivers(servername, "Windows NT x86", levels[i], buffer, needed, &needed, &returned)) { + err = GetLastError(); + } + } + if (err) { + sprintf(tmp, "EnumPrinterDrivers failed level %d on [%s] (buffer size = %d), error: %s\n", + levels[i], servername, needed, errstr(err)); + if (success[i]) { + torture_fail(tctx, tmp); + } else { + torture_warning(tctx, tmp); + } + } + + free(buffer); + buffer = NULL; + } + + return TRUE; +} + +/**************************************************************************** +****************************************************************************/ + +static BOOL test_EnumForms(struct torture_context *tctx, + LPSTR servername, + HANDLE handle) +{ + DWORD levels[] = { 1, 2 }; + DWORD success[] = { 1, 0 }; + DWORD i; + LPBYTE buffer = NULL; + + for (i=0; i < ARRAY_SIZE(levels); i++) { + + DWORD needed = 0; + DWORD returned = 0; + DWORD err = 0; + char tmp[1024]; + + torture_comment(tctx, "Testing EnumForms level %d", levels[i]); + + EnumForms(handle, 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 (!EnumForms(handle, levels[i], buffer, needed, &needed, &returned)) { + err = GetLastError(); + } + } + if (err) { + sprintf(tmp, "EnumForms failed level %d on [%s] (buffer size = %d), error: %s\n", + levels[i], servername, needed, errstr(err)); + if (success[i]) { + torture_fail(tctx, tmp); + } else { + torture_warning(tctx, tmp); + } + } + + free(buffer); + buffer = NULL; + } + + return TRUE; +} + +/**************************************************************************** +****************************************************************************/ + +static BOOL test_EnumPorts(struct torture_context *tctx, + LPSTR servername) +{ + DWORD levels[] = { 1, 2 }; + DWORD success[] = { 1, 1 }; + DWORD i; + LPBYTE buffer = NULL; + + for (i=0; i < ARRAY_SIZE(levels); i++) { + + DWORD needed = 0; + DWORD returned = 0; + DWORD err = 0; + char tmp[1024]; + + torture_comment(tctx, "Testing EnumPorts level %d", levels[i]); + + EnumPorts(servername, 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 (!EnumPorts(servername, levels[i], buffer, needed, &needed, &returned)) { + err = GetLastError(); + } + } + if (err) { + sprintf(tmp, "EnumPorts failed level %d on [%s] (buffer size = %d), error: %s\n", + levels[i], servername, needed, errstr(err)); + if (success[i]) { + torture_fail(tctx, tmp); + } else { + torture_warning(tctx, tmp); + } + } + + free(buffer); + buffer = NULL; + } + + return TRUE; +} + +/**************************************************************************** +****************************************************************************/ + +static BOOL test_EnumMonitors(struct torture_context *tctx, + LPSTR servername) +{ + DWORD levels[] = { 1, 2 }; + DWORD success[] = { 1, 1 }; + DWORD i; + LPBYTE buffer = NULL; + + for (i=0; i < ARRAY_SIZE(levels); i++) { + + DWORD needed = 0; + DWORD returned = 0; + DWORD err = 0; + char tmp[1024]; + + torture_comment(tctx, "Testing EnumMonitors level %d", levels[i]); + + EnumMonitors(servername, 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 (!EnumMonitors(servername, levels[i], buffer, needed, &needed, &returned)) { + err = GetLastError(); + } + } + if (err) { + sprintf(tmp, "EnumMonitors failed level %d on [%s] (buffer size = %d), error: %s\n", + levels[i], servername, needed, errstr(err)); + if (success[i]) { + torture_fail(tctx, tmp); + } else { + torture_warning(tctx, tmp); + } + } + + free(buffer); + buffer = NULL; + } + + return TRUE; +} + +/**************************************************************************** +****************************************************************************/ + +static BOOL test_EnumPrintProcessors(struct torture_context *tctx, + LPSTR servername) +{ + DWORD levels[] = { 1 }; + DWORD success[] = { 1 }; + DWORD i; + LPBYTE buffer = NULL; + + for (i=0; i < ARRAY_SIZE(levels); i++) { + + DWORD needed = 0; + DWORD returned = 0; + DWORD err = 0; + char tmp[1024]; + + torture_comment(tctx, "Testing EnumPrintProcessors level %d", levels[i]); + + EnumPrintProcessors(servername, "Windows NT x86", 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 (!EnumPrintProcessors(servername, "Windows NT x86", levels[i], buffer, needed, &needed, &returned)) { + err = GetLastError(); + } + } + if (err) { + sprintf(tmp, "EnumPrintProcessors failed level %d on [%s] (buffer size = %d), error: %s\n", + levels[i], servername, needed, errstr(err)); + if (success[i]) { + torture_fail(tctx, tmp); + } else { + torture_warning(tctx, tmp); + } + } + + free(buffer); + buffer = NULL; + } + + return TRUE; +} + +/**************************************************************************** +****************************************************************************/ + +static BOOL test_EnumPrintProcessorDatatypes(struct torture_context *tctx, + LPSTR servername) +{ + DWORD levels[] = { 1 }; + DWORD success[] = { 1 }; + DWORD i; + LPBYTE buffer = NULL; + + for (i=0; i < ARRAY_SIZE(levels); i++) { + + DWORD needed = 0; + DWORD returned = 0; + DWORD err = 0; + char tmp[1024]; + + torture_comment(tctx, "Testing EnumPrintProcessorDatatypes level %d", levels[i]); + + EnumPrintProcessorDatatypes(servername, "Windows NT x86", 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, "Windows NT x86", levels[i], buffer, needed, &needed, &returned)) { + err = GetLastError(); + } + } + if (err) { + sprintf(tmp, "EnumPrintProcessorDatatypes failed level %d on [%s] (buffer size = %d), error: %s\n", + levels[i], servername, needed, errstr(err)); + if (success[i]) { + torture_fail(tctx, tmp); + } else { + torture_warning(tctx, tmp); + } + } + + free(buffer); + buffer = NULL; + } + + return TRUE; +} + +/**************************************************************************** +****************************************************************************/ + +static BOOL test_GetPrinter(struct torture_context *tctx, + LPSTR printername, + HANDLE handle) +{ + DWORD levels[] = { 1, 2, 3, 4, 5, 6, 7, 8 }; + DWORD success[] = { 1, 1, 1, 1, 1, 1, 1, 1 }; + DWORD i; + LPBYTE buffer = NULL; + + for (i=0; i < ARRAY_SIZE(levels); i++) { + + DWORD needed = 0; + DWORD err = 0; + char tmp[1024]; + + torture_comment(tctx, "Testing GetPrinter level %d", levels[i]); + + GetPrinter(handle, levels[i], NULL, 0, &needed); + err = GetLastError(); + if (err == ERROR_INSUFFICIENT_BUFFER) { + err = 0; + buffer = malloc(needed); + torture_assert(tctx, buffer, "malloc failed"); + if (!GetPrinter(handle, levels[i], buffer, needed, &needed)) { + err = GetLastError(); + } + } + if (err) { + sprintf(tmp, "GetPrinter failed level %d on [%s] (buffer size = %d), error: %s\n", + levels[i], printername, needed, errstr(err)); + if (success[i]) { + torture_fail(tctx, tmp); + } else { + torture_warning(tctx, tmp); + } + } + + free(buffer); + buffer = NULL; + } + + return TRUE; +} + +/**************************************************************************** +****************************************************************************/ + +static BOOL test_GetPrinterDriver(struct torture_context *tctx, + LPSTR printername, + HANDLE handle) +{ + DWORD levels[] = { 1, 2, 3, 4, 5, 6, 8, 101}; + DWORD success[] = { 1, 1, 1, 1, 1, 1, 1, 1 }; + DWORD i; + LPBYTE buffer = NULL; + + for (i=0; i < ARRAY_SIZE(levels); i++) { + + DWORD needed = 0; + DWORD err = 0; + char tmp[1024]; + + torture_comment(tctx, "Testing GetPrinterDriver level %d", levels[i]); + + GetPrinterDriver(handle, "Windows NT x86", levels[i], NULL, 0, &needed); + err = GetLastError(); + if (err == ERROR_INSUFFICIENT_BUFFER) { + err = 0; + buffer = malloc(needed); + torture_assert(tctx, buffer, "malloc failed"); + if (!GetPrinterDriver(handle, "Windows NT x86", levels[i], buffer, needed, &needed)) { + err = GetLastError(); + } + } + if (err) { + sprintf(tmp, "GetPrinterDriver failed level %d on [%s] (buffer size = %d), error: %s\n", + levels[i], printername, needed, errstr(err)); + if (success[i]) { + torture_fail(tctx, tmp); + } else { + torture_warning(tctx, tmp); + } + } + + free(buffer); + buffer = NULL; + } + + return TRUE; +} + + +/**************************************************************************** +****************************************************************************/ + +static BOOL test_EnumJobs(struct torture_context *tctx, + LPSTR printername, + HANDLE handle) +{ + DWORD levels[] = { 1, 2, 3, 4 }; + DWORD success[] = { 1, 1, 1, 1 }; + DWORD i; + LPBYTE buffer = NULL; + + for (i=0; i < ARRAY_SIZE(levels); i++) { + + DWORD needed = 0; + DWORD returned = 0; + DWORD err = 0; + char tmp[1024]; + + torture_comment(tctx, "Testing EnumJobs level %d", levels[i]); + + EnumJobs(handle, 0, 100, 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 (!EnumJobs(handle, 0, 100, levels[i], buffer, needed, &needed, &returned)) { + err = GetLastError(); + } + } + if (err) { + sprintf(tmp, "EnumJobs failed level %d on [%s] (buffer size = %d), error: %s\n", + levels[i], printername, needed, errstr(err)); + if (success[i]) { + torture_fail(tctx, tmp); + } else { + torture_warning(tctx, tmp); + } + } + + free(buffer); + buffer = NULL; + } + + return TRUE; +} + +/**************************************************************************** +****************************************************************************/ + +static BOOL test_OnePrinter(struct torture_context *tctx, + LPSTR printername) +{ + HANDLE handle; + BOOL ret = TRUE; + + torture_comment(tctx, "Testing Printer %s", printername); + + ret &= test_OpenPrinter(tctx, printername, &handle); + ret &= test_GetPrinter(tctx, printername, handle); + ret &= test_GetPrinterDriver(tctx, printername, handle); + ret &= test_EnumForms(tctx, printername, handle); + ret &= test_EnumJobs(tctx, printername, handle); + ret &= test_ClosePrinter(tctx, handle); + + return ret; +} + +/**************************************************************************** +****************************************************************************/ + +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) +{ + DWORD needed = 0; + DWORD returned = 0; + DWORD err = 0; + char tmp[1024]; + DWORD i; + DWORD flags = PRINTER_ENUM_NAME; + PPRINTER_INFO_1 buffer = NULL; + + torture_comment(tctx, "Testing EnumPrinters level %d", 1); + + EnumPrinters(flags, servername, 1, NULL, 0, &needed, &returned); + err = GetLastError(); + if (err == ERROR_INSUFFICIENT_BUFFER) { + err = 0; + buffer = (PPRINTER_INFO_1)malloc(needed); + torture_assert(tctx, buffer, "malloc failed"); + if (!EnumPrinters(flags, servername, 1, (LPBYTE)buffer, needed, &needed, &returned)) { + err = GetLastError(); + } + } + if (err) { + sprintf(tmp, "EnumPrinters failed level %d on [%s] (buffer size = %d), error: %s\n", + 1, servername, needed, errstr(err)); + torture_fail(tctx, tmp); + } + + for (i=0; i < returned; i++) { + torture_assert(tctx, test_OnePrinter(tctx, buffer[i].pName), + "failed to test one printer"); + } + + free(buffer); + + return TRUE; +} + +/**************************************************************************** +****************************************************************************/ + +static BOOL test_GetPrintProcessorDirectory(struct torture_context *tctx, + LPSTR servername) +{ + DWORD levels[] = { 1 }; + DWORD success[] = { 1 }; + DWORD i; + LPBYTE buffer = NULL; + + for (i=0; i < ARRAY_SIZE(levels); i++) { + + DWORD needed = 0; + DWORD err = 0; + char tmp[1024]; + + torture_comment(tctx, "Testing GetPrintProcessorDirectory level %d", levels[i]); + + GetPrintProcessorDirectory(servername, "Windows NT x86", levels[i], NULL, 0, &needed); + err = GetLastError(); + if (err == ERROR_INSUFFICIENT_BUFFER) { + err = 0; + buffer = malloc(needed); + torture_assert(tctx, buffer, "malloc failed"); + if (!GetPrintProcessorDirectory(servername, "Windows NT x86", levels[i], buffer, needed, &needed)) { + err = GetLastError(); + } + } + if (err) { + sprintf(tmp, "GetPrintProcessorDirectory failed level %d on [%s] (buffer size = %d), error: %s\n", + levels[i], servername, needed, errstr(err)); + if (success[i]) { + torture_fail(tctx, tmp); + } else { + torture_warning(tctx, tmp); + } + } + + free(buffer); + buffer = NULL; + } + + return TRUE; +} + +/**************************************************************************** +****************************************************************************/ + +static BOOL test_GetPrinterDriverDirectory(struct torture_context *tctx, + LPSTR servername) +{ + DWORD levels[] = { 1 }; + DWORD success[] = { 1 }; + DWORD i; + LPBYTE buffer = NULL; + + for (i=0; i < ARRAY_SIZE(levels); i++) { + + DWORD needed = 0; + DWORD err = 0; + char tmp[1024]; + + torture_comment(tctx, "Testing GetPrinterDriverDirectory level %d", levels[i]); + + GetPrinterDriverDirectory(servername, "Windows NT x86", levels[i], NULL, 0, &needed); + err = GetLastError(); + if (err == ERROR_INSUFFICIENT_BUFFER) { + err = 0; + buffer = malloc(needed); + torture_assert(tctx, buffer, "malloc failed"); + if (!GetPrinterDriverDirectory(servername, "Windows NT x86", levels[i], buffer, needed, &needed)) { + err = GetLastError(); + } + } + if (err) { + sprintf(tmp, "GetPrinterDriverDirectory failed level %d on [%s] (buffer size = %d), error: %s\n", + levels[i], servername, needed, errstr(err)); + if (success[i]) { + torture_fail(tctx, tmp); + } else { + torture_warning(tctx, tmp); + } + } + + free(buffer); + buffer = NULL; + } + + return TRUE; +} + + +/**************************************************************************** +****************************************************************************/ + +int main(int argc, char *argv[]) +{ + BOOL ret = FALSE; + LPSTR servername; + HANDLE handle; + struct torture_context *tctx; + + if (argc < 2) { + fprintf(stderr, "usage: %s [print]\n", argv[0]); + exit(-1); + } + + tctx = malloc(sizeof(struct torture_context)); + if (!tctx) { + fprintf(stderr, "out of memory\n"); + exit(-1); + } + memset(tctx, '\0', sizeof(*tctx)); + + servername = argv[1]; + + if (argc >= 3) { + if (strcmp(argv[2], "print") == 0) { + tctx->print = TRUE; + } + } + + ret &= test_EnumPrinters(tctx, servername); + ret &= test_EnumDrivers(tctx, servername); + ret &= test_OpenPrinter(tctx, servername, &handle); + ret &= test_EnumForms(tctx, servername, handle); + ret &= test_ClosePrinter(tctx, handle); + ret &= test_EnumPorts(tctx, servername); + ret &= test_EnumMonitors(tctx, servername); + ret &= test_EnumPrintProcessors(tctx, servername); + ret &= test_EnumPrintProcessorDatatypes(tctx, servername); + ret &= test_GetPrintProcessorDirectory(tctx, servername); + ret &= test_GetPrinterDriverDirectory(tctx, servername); + ret &= test_EachPrinter(tctx, servername); + ret &= test_EachDriver(tctx, servername); + + if (!ret) { + if (tctx->last_reason) { + fprintf(stderr, "failed: %s\n", tctx->last_reason); + } + free(tctx); + return -1; + } + + printf("%s run successfully\n", argv[0]); + + free(tctx); + return 0; +} diff --git a/testprogs/win32/spoolss/spoolss.h b/testprogs/win32/spoolss/spoolss.h new file mode 100644 index 0000000000..adf178670f --- /dev/null +++ b/testprogs/win32/spoolss/spoolss.h @@ -0,0 +1,50 @@ +/* + Unix SMB/CIFS implementation. + test suite for spoolss rpc operations + + Copyright (C) Guenther Deschner 2009 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#if 0 +#include "lib/replace/replace.h" +#endif + +#include +#include + +#include "error.h" + +#if 0 +#include "lib/talloc/talloc.h" +#include "libcli/util/ntstatus.h" +#include "lib/torture/torture.h" +#endif + +#ifndef ARRAY_SIZE +#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0])) +#endif + +#ifndef true +#define true TRUE +#endif + +#ifndef false +#define false FALSE +#endif + +#ifndef PRINTER_ENUM_NAME +#define PRINTER_ENUM_NAME 8 +#endif diff --git a/testprogs/win32/spoolss/string.h b/testprogs/win32/spoolss/string.h new file mode 100644 index 0000000000..17561eb7ad --- /dev/null +++ b/testprogs/win32/spoolss/string.h @@ -0,0 +1,15 @@ +/* __location__ macro replacement taken from talloc.h */ + +/* + this uses a little trick to allow __LINE__ to be stringified +*/ +#ifndef __location__ +#define __STRING_LINE1__(s) #s +#define __STRING_LINE2__(s) __STRING_LINE1__(s) +#define __STRING_LINE3__ __STRING_LINE2__(__LINE__) +#define __location__ __FILE__ ":" __STRING_LINE3__ +#endif + +#ifndef __STRING +#define __STRING(s) #s +#endif diff --git a/testprogs/win32/spoolss/torture.c b/testprogs/win32/spoolss/torture.c new file mode 100644 index 0000000000..27872a6ccc --- /dev/null +++ b/testprogs/win32/spoolss/torture.c @@ -0,0 +1,106 @@ +/* + Unix SMB/CIFS implementation. + SMB torture UI functions + + Copyright (C) Jelmer Vernooij 2006 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "spoolss.h" +#include "torture.h" + +/**************************************************************************** +****************************************************************************/ + +void torture_warning(struct torture_context *context, const char *comment, ...) +{ + va_list ap; + char tmp[1024]; + +#if 0 + if (!context->results->ui_ops->warning) + return; +#endif + + va_start(ap, comment); + if (vsprintf(tmp, comment, ap) == -1) { + return; + } + va_end(ap); + + fprintf(stderr, "WARNING: %s\n", tmp); +#if 0 + context->results->ui_ops->warning(context, tmp); + + free(tmp); +#endif +} + +/**************************************************************************** +****************************************************************************/ + +void torture_result(struct torture_context *context, + enum torture_result result, const char *fmt, ...) +{ + va_list ap; + char tmp[1024]; + + va_start(ap, fmt); + + if (context->last_reason) { + torture_warning(context, "%s", context->last_reason); + free(context->last_reason); + context->last_reason = NULL; + } + + context->last_result = result; + if (vsprintf(tmp, fmt, ap) == -1) { + return; + } + context->last_reason = malloc(sizeof(tmp)); + if (!context->last_reason) { + return; + } + memcpy(context->last_reason, tmp, sizeof(tmp)); + + va_end(ap); +} + +/**************************************************************************** +****************************************************************************/ + +void torture_comment(struct torture_context *context, const char *comment, ...) +{ + va_list ap; + char tmp[1024]; +#if 0 + if (!context->results->ui_ops->comment) + return; +#endif + va_start(ap, comment); + if (vsprintf(tmp, comment, ap) == -1) { + return; + } + va_end(ap); + +#if 0 + context->results->ui_ops->comment(context, tmp); +#endif + fprintf(stdout, "%s\n", tmp); + +#if 0 + free(tmp); +#endif +} diff --git a/testprogs/win32/spoolss/torture.h b/testprogs/win32/spoolss/torture.h new file mode 100644 index 0000000000..23746cc2b7 --- /dev/null +++ b/testprogs/win32/spoolss/torture.h @@ -0,0 +1,91 @@ +/* + Unix SMB/CIFS implementation. + SMB torture UI functions + + Copyright (C) Jelmer Vernooij 2006 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef __TORTURE_UI_H__ +#define __TORTURE_UI_H__ + +/**************************************************************************** +****************************************************************************/ + +enum torture_result { + TORTURE_OK=0, + TORTURE_FAIL=1, + TORTURE_ERROR=2, + TORTURE_SKIP=3 +}; + +struct torture_context { + enum torture_result last_result; + char *last_reason; + BOOL print; +}; + +/**************************************************************************** +****************************************************************************/ + +#define torture_assert(torture_ctx,expr,cmt) do {\ + if (!(expr)) {\ + torture_result(torture_ctx, TORTURE_FAIL, __location__": Expression `%s' failed: %s", __STRING(expr), cmt); \ + return false;\ + }\ +} while(0) + +#define torture_assert_str_equal(torture_ctx,got,expected,cmt)\ + do { const char *__got = (got), *__expected = (expected); \ + if (strcmp_safe(__got, __expected) != 0) { \ + torture_result(torture_ctx, TORTURE_FAIL, \ + __location__": "#got" was %s, expected %s: %s", \ + __got, __expected, cmt); \ + return false; \ + } \ + } while(0) + +#define torture_assert_int_equal(torture_ctx,got,expected,cmt)\ + do { int __got = (got), __expected = (expected); \ + if (__got != __expected) { \ + torture_result(torture_ctx, TORTURE_FAIL, \ + __location__": "#got" was %d, expected %d: %s", \ + __got, __expected, cmt); \ + return false; \ + } \ + } while(0) + +#define torture_assert_mem_equal(torture_ctx,got,expected,len,cmt)\ + do { const void *__got = (got), *__expected = (expected); \ + if (memcmp(__got, __expected, len) != 0) { \ + torture_result(torture_ctx, TORTURE_FAIL, \ + __location__": "#got" of len %d did not match "#expected": %s", (int)len, cmt); \ + return false; \ + } \ + } while(0) + +#define torture_skip(torture_ctx,cmt) do {\ + torture_result(torture_ctx, TORTURE_SKIP, __location__": %s", cmt);\ + return true; \ + } while(0) + +#define torture_fail(torture_ctx,cmt) do {\ + torture_result(torture_ctx, TORTURE_FAIL, __location__": %s", cmt);\ + return false; \ + } while (0) + +#include "torture_proto.h" + +#endif diff --git a/testprogs/win32/spoolss/torture_proto.h b/testprogs/win32/spoolss/torture_proto.h new file mode 100644 index 0000000000..5d1dd8804b --- /dev/null +++ b/testprogs/win32/spoolss/torture_proto.h @@ -0,0 +1,32 @@ +#ifndef __TORTURE_PROTO_H__ +#define __TORTURE_PROTO_H__ + +#undef _PRINTF_ATTRIBUTE +#define _PRINTF_ATTRIBUTE(a1, a2) PRINTF_ATTRIBUTE(a1, a2) +/* This file was automatically generated by mkproto.pl. DO NOT EDIT */ + +/* this file contains prototypes for functions that are private + * to this subsystem or library. These functions should not be + * used outside this particular subsystem! */ + + +/* The following definitions come from torture.c */ + + +/**************************************************************************** +****************************************************************************/ +void torture_warning(struct torture_context *context, const char *comment, ...); + +/**************************************************************************** +****************************************************************************/ +void torture_result(struct torture_context *context, + enum torture_result result, const char *fmt, ...); + +/**************************************************************************** +****************************************************************************/ +void torture_comment(struct torture_context *context, const char *comment, ...); +#undef _PRINTF_ATTRIBUTE +#define _PRINTF_ATTRIBUTE(a1, a2) + +#endif /* __TORTURE_PROTO_H__ */ + -- cgit From 9185fd0a93e2530c778b7d31f90311f8618b4fb7 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 6 Jan 2010 23:15:09 +0100 Subject: testprogs: pass down architecture in spoolss test. Guenther --- testprogs/win32/spoolss/spoolss.c | 65 ++++++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 28 deletions(-) (limited to 'testprogs') diff --git a/testprogs/win32/spoolss/spoolss.c b/testprogs/win32/spoolss/spoolss.c index 200f89602b..d014b14e70 100644 --- a/testprogs/win32/spoolss/spoolss.c +++ b/testprogs/win32/spoolss/spoolss.c @@ -2,7 +2,7 @@ Unix SMB/CIFS implementation. test suite for spoolss rpc operations - Copyright (C) Guenther Deschner 2009 + Copyright (C) Guenther Deschner 2009-2010 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -115,7 +115,8 @@ static BOOL test_EnumPrinters(struct torture_context *tctx, ****************************************************************************/ static BOOL test_EnumDrivers(struct torture_context *tctx, - LPSTR servername) + LPSTR servername, + LPSTR architecture) { DWORD levels[] = { 1, 2, 3, 4, 5, 6, 8 }; DWORD success[] = { 1, 1, 1, 1, 1, 1, 1 }; @@ -131,13 +132,13 @@ static BOOL test_EnumDrivers(struct torture_context *tctx, torture_comment(tctx, "Testing EnumPrinterDrivers level %d", levels[i]); - EnumPrinterDrivers(servername, "Windows NT x86", levels[i], NULL, 0, &needed, &returned); + EnumPrinterDrivers(servername, architecture, 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 (!EnumPrinterDrivers(servername, "Windows NT x86", levels[i], buffer, needed, &needed, &returned)) { + if (!EnumPrinterDrivers(servername, architecture, levels[i], buffer, needed, &needed, &returned)) { err = GetLastError(); } } @@ -304,7 +305,8 @@ static BOOL test_EnumMonitors(struct torture_context *tctx, ****************************************************************************/ static BOOL test_EnumPrintProcessors(struct torture_context *tctx, - LPSTR servername) + LPSTR servername, + LPSTR architecture) { DWORD levels[] = { 1 }; DWORD success[] = { 1 }; @@ -320,13 +322,13 @@ static BOOL test_EnumPrintProcessors(struct torture_context *tctx, torture_comment(tctx, "Testing EnumPrintProcessors level %d", levels[i]); - EnumPrintProcessors(servername, "Windows NT x86", levels[i], NULL, 0, &needed, &returned); + EnumPrintProcessors(servername, architecture, 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 (!EnumPrintProcessors(servername, "Windows NT x86", levels[i], buffer, needed, &needed, &returned)) { + if (!EnumPrintProcessors(servername, architecture, levels[i], buffer, needed, &needed, &returned)) { err = GetLastError(); } } @@ -351,7 +353,8 @@ static BOOL test_EnumPrintProcessors(struct torture_context *tctx, ****************************************************************************/ static BOOL test_EnumPrintProcessorDatatypes(struct torture_context *tctx, - LPSTR servername) + LPSTR servername, + LPSTR architecture) { DWORD levels[] = { 1 }; DWORD success[] = { 1 }; @@ -367,13 +370,13 @@ static BOOL test_EnumPrintProcessorDatatypes(struct torture_context *tctx, torture_comment(tctx, "Testing EnumPrintProcessorDatatypes level %d", levels[i]); - EnumPrintProcessorDatatypes(servername, "Windows NT x86", levels[i], NULL, 0, &needed, &returned); + EnumPrintProcessorDatatypes(servername, architecture, 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, "Windows NT x86", levels[i], buffer, needed, &needed, &returned)) { + if (!EnumPrintProcessorDatatypes(servername, architecture, levels[i], buffer, needed, &needed, &returned)) { err = GetLastError(); } } @@ -446,6 +449,7 @@ static BOOL test_GetPrinter(struct torture_context *tctx, static BOOL test_GetPrinterDriver(struct torture_context *tctx, LPSTR printername, + LPSTR architecture, HANDLE handle) { DWORD levels[] = { 1, 2, 3, 4, 5, 6, 8, 101}; @@ -461,13 +465,13 @@ static BOOL test_GetPrinterDriver(struct torture_context *tctx, torture_comment(tctx, "Testing GetPrinterDriver level %d", levels[i]); - GetPrinterDriver(handle, "Windows NT x86", levels[i], NULL, 0, &needed); + GetPrinterDriver(handle, architecture, levels[i], NULL, 0, &needed); err = GetLastError(); if (err == ERROR_INSUFFICIENT_BUFFER) { err = 0; buffer = malloc(needed); torture_assert(tctx, buffer, "malloc failed"); - if (!GetPrinterDriver(handle, "Windows NT x86", levels[i], buffer, needed, &needed)) { + if (!GetPrinterDriver(handle, architecture, levels[i], buffer, needed, &needed)) { err = GetLastError(); } } @@ -541,7 +545,8 @@ static BOOL test_EnumJobs(struct torture_context *tctx, ****************************************************************************/ static BOOL test_OnePrinter(struct torture_context *tctx, - LPSTR printername) + LPSTR printername, + LPSTR architecture) { HANDLE handle; BOOL ret = TRUE; @@ -550,7 +555,7 @@ static BOOL test_OnePrinter(struct torture_context *tctx, ret &= test_OpenPrinter(tctx, printername, &handle); ret &= test_GetPrinter(tctx, printername, handle); - ret &= test_GetPrinterDriver(tctx, printername, handle); + ret &= test_GetPrinterDriver(tctx, printername, architecture, handle); ret &= test_EnumForms(tctx, printername, handle); ret &= test_EnumJobs(tctx, printername, handle); ret &= test_ClosePrinter(tctx, handle); @@ -581,7 +586,8 @@ static BOOL test_EachDriver(struct torture_context *tctx, ****************************************************************************/ static BOOL test_EachPrinter(struct torture_context *tctx, - LPSTR servername) + LPSTR servername, + LPSTR architecture) { DWORD needed = 0; DWORD returned = 0; @@ -610,7 +616,7 @@ static BOOL test_EachPrinter(struct torture_context *tctx, } for (i=0; i < returned; i++) { - torture_assert(tctx, test_OnePrinter(tctx, buffer[i].pName), + torture_assert(tctx, test_OnePrinter(tctx, buffer[i].pName, architecture), "failed to test one printer"); } @@ -623,7 +629,8 @@ static BOOL test_EachPrinter(struct torture_context *tctx, ****************************************************************************/ static BOOL test_GetPrintProcessorDirectory(struct torture_context *tctx, - LPSTR servername) + LPSTR servername, + LPSTR architecture) { DWORD levels[] = { 1 }; DWORD success[] = { 1 }; @@ -638,13 +645,13 @@ static BOOL test_GetPrintProcessorDirectory(struct torture_context *tctx, torture_comment(tctx, "Testing GetPrintProcessorDirectory level %d", levels[i]); - GetPrintProcessorDirectory(servername, "Windows NT x86", levels[i], NULL, 0, &needed); + GetPrintProcessorDirectory(servername, architecture, levels[i], NULL, 0, &needed); err = GetLastError(); if (err == ERROR_INSUFFICIENT_BUFFER) { err = 0; buffer = malloc(needed); torture_assert(tctx, buffer, "malloc failed"); - if (!GetPrintProcessorDirectory(servername, "Windows NT x86", levels[i], buffer, needed, &needed)) { + if (!GetPrintProcessorDirectory(servername, architecture, levels[i], buffer, needed, &needed)) { err = GetLastError(); } } @@ -669,7 +676,8 @@ static BOOL test_GetPrintProcessorDirectory(struct torture_context *tctx, ****************************************************************************/ static BOOL test_GetPrinterDriverDirectory(struct torture_context *tctx, - LPSTR servername) + LPSTR servername, + LPSTR architecture) { DWORD levels[] = { 1 }; DWORD success[] = { 1 }; @@ -684,13 +692,13 @@ static BOOL test_GetPrinterDriverDirectory(struct torture_context *tctx, torture_comment(tctx, "Testing GetPrinterDriverDirectory level %d", levels[i]); - GetPrinterDriverDirectory(servername, "Windows NT x86", levels[i], NULL, 0, &needed); + GetPrinterDriverDirectory(servername, architecture, levels[i], NULL, 0, &needed); err = GetLastError(); if (err == ERROR_INSUFFICIENT_BUFFER) { err = 0; buffer = malloc(needed); torture_assert(tctx, buffer, "malloc failed"); - if (!GetPrinterDriverDirectory(servername, "Windows NT x86", levels[i], buffer, needed, &needed)) { + if (!GetPrinterDriverDirectory(servername, architecture, levels[i], buffer, needed, &needed)) { err = GetLastError(); } } @@ -719,6 +727,7 @@ int main(int argc, char *argv[]) { BOOL ret = FALSE; LPSTR servername; + LPSTR architecture = "Windows NT x86"; HANDLE handle; struct torture_context *tctx; @@ -743,17 +752,17 @@ int main(int argc, char *argv[]) } ret &= test_EnumPrinters(tctx, servername); - ret &= test_EnumDrivers(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_EnumPorts(tctx, servername); ret &= test_EnumMonitors(tctx, servername); - ret &= test_EnumPrintProcessors(tctx, servername); - ret &= test_EnumPrintProcessorDatatypes(tctx, servername); - ret &= test_GetPrintProcessorDirectory(tctx, servername); - ret &= test_GetPrinterDriverDirectory(tctx, servername); - ret &= test_EachPrinter(tctx, servername); + ret &= test_EnumPrintProcessors(tctx, servername, architecture); + ret &= test_EnumPrintProcessorDatatypes(tctx, servername, architecture); + 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) { -- cgit From 339afda877138ebe3869aa971361b88f196ff9d8 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 16 Dec 2009 22:36:18 +0100 Subject: testprogs: add support for "print" option in win32 spoolss torture test. Guenther --- testprogs/win32/spoolss/Makefile | 6 +- testprogs/win32/spoolss/Makefile.mingw | 5 +- testprogs/win32/spoolss/printlib.c | 608 +++++++++++++++++++++++++++++++ testprogs/win32/spoolss/printlib_proto.h | 46 +++ testprogs/win32/spoolss/spoolss.c | 4 + testprogs/win32/spoolss/spoolss.h | 1 + 6 files changed, 666 insertions(+), 4 deletions(-) create mode 100644 testprogs/win32/spoolss/printlib.c create mode 100644 testprogs/win32/spoolss/printlib_proto.h (limited to 'testprogs') diff --git a/testprogs/win32/spoolss/Makefile b/testprogs/win32/spoolss/Makefile index 96efceacf4..8c9d71683e 100644 --- a/testprogs/win32/spoolss/Makefile +++ b/testprogs/win32/spoolss/Makefile @@ -22,6 +22,8 @@ cleantmp: # helpers ############################### +printlib.obj: printlib.c + error.obj: error.c torture.obj: torture.c @@ -32,7 +34,7 @@ torture.obj: torture.c spoolss.obj: spoolss.c -spoolss.exe: spoolss.obj error.obj torture.obj - cl $(CFLAGS) /Fe$@ spoolss.obj error.obj torture.obj \ +spoolss.exe: spoolss.obj printlib.obj error.obj torture.obj + cl $(CFLAGS) /Fe$@ spoolss.obj printlib.obj error.obj torture.obj \ /link /incremental:no /subsystem:console $(LIBS) $(WINSPOOL_LIBS) diff --git a/testprogs/win32/spoolss/Makefile.mingw b/testprogs/win32/spoolss/Makefile.mingw index 82fc7ed488..4ff7155250 100644 --- a/testprogs/win32/spoolss/Makefile.mingw +++ b/testprogs/win32/spoolss/Makefile.mingw @@ -14,9 +14,10 @@ ctags: ctags --c-kinds=-p -a `find /usr/i686-pc-mingw32/sys-root/mingw/include -name "*.[ch]" | grep -v /CVS/` proto: + mkproto.pl printlib.c --private=printlib_proto.h --public=printlib_proto_pub.h --srcdir=. --builddir=. mkproto.pl torture.c --private=torture_proto.h --public=torture_proto_pub.h --srcdir=. --builddir=. -spoolss.exe: spoolss.c torture.c error.c +spoolss.exe: spoolss.c printlib.c torture.c error.c @echo Compiling spoolss.exe - @$(CC) $(CFLAGS) $(LDFLAGS) spoolss.c torture.c error.c $(LIBS) -o spoolss.exe + @$(CC) $(CFLAGS) $(LDFLAGS) spoolss.c printlib.c torture.c error.c $(LIBS) -o spoolss.exe diff --git a/testprogs/win32/spoolss/printlib.c b/testprogs/win32/spoolss/printlib.c new file mode 100644 index 0000000000..c40ca6c2e1 --- /dev/null +++ b/testprogs/win32/spoolss/printlib.c @@ -0,0 +1,608 @@ +/* + Unix SMB/CIFS implementation. + test suite for spoolss rpc operations + + Copyright (C) Gerald (Jerry) Carter 2007 + Copyright (C) Guenther Deschner 2009-2010 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include +#include + +void print_devmode(DEVMODE *pDevModeIn) +{ + if (pDevModeIn == NULL) { + printf("\tDevice Mode\t= (null)\n"); + return; + } + + printf("\tDEVMODE:----------\n"); + printf("\tDeviceName: [%s]\n", pDevModeIn->dmDeviceName); + printf("\tSpecVersion: %d\n", pDevModeIn->dmSpecVersion); + printf("\tDriverVersion: %d\n", pDevModeIn->dmDriverVersion); + printf("\tSize: %d\n", pDevModeIn->dmSize); + printf("\tDriverExtra: %d\n", pDevModeIn->dmDriverExtra); + printf("\tFields: 0x%x\n", pDevModeIn->dmFields); + + if (pDevModeIn->dmFields & DM_ORIENTATION) + printf("\tOrientation: %d\n", pDevModeIn->dmOrientation); + if (pDevModeIn->dmFields & DM_PAPERSIZE) + printf("\tPaperSize: %d\n", pDevModeIn->dmPaperSize); + if (pDevModeIn->dmFields & DM_PAPERLENGTH) + printf("\tPaperLength: %d\n", pDevModeIn->dmPaperLength); + if (pDevModeIn->dmFields & DM_PAPERWIDTH) + printf("\tPaperWidth: %d\n", pDevModeIn->dmPaperWidth); +// if (pDevModeIn->dmFields & DM_POSITION) +// printf("\tPosition: %d\n", pDevModeIn->dmPosition); + if (pDevModeIn->dmFields & DM_SCALE) + printf("\tScale: %d\n", pDevModeIn->dmScale); + if (pDevModeIn->dmFields & DM_COPIES) + printf("\tCopies: %d\n", pDevModeIn->dmCopies ); + if (pDevModeIn->dmFields & DM_DEFAULTSOURCE) + printf("\tDefaultSource: %d\n", pDevModeIn->dmDefaultSource); + if (pDevModeIn->dmFields & DM_PRINTQUALITY) + printf("\tPrintQuality: %d\n", pDevModeIn->dmPrintQuality); + if (pDevModeIn->dmFields & DM_COLOR) + printf("\tColor: %d\n", pDevModeIn->dmColor); + if (pDevModeIn->dmFields & DM_DUPLEX) + printf("\tDuplex: %d\n", pDevModeIn->dmDuplex); + if (pDevModeIn->dmFields & DM_YRESOLUTION) + printf("\tYResolution: %d\n", pDevModeIn->dmYResolution); + if (pDevModeIn->dmFields & DM_TTOPTION) + printf("\tTTOption: %d\n", pDevModeIn->dmTTOption); + if (pDevModeIn->dmFields & DM_COLLATE) + printf("\tCollate: %d\n", pDevModeIn->dmCollate); + if (pDevModeIn->dmFields & DM_FORMNAME) + printf("\tForm: [%s]\n", pDevModeIn->dmFormName); + if (pDevModeIn->dmFields & DM_LOGPIXELS) + printf("\tLogPixels: %d\n", pDevModeIn->dmLogPixels); + if (pDevModeIn->dmFields & DM_BITSPERPEL) + printf("\tBitsPerPel: %d\n", pDevModeIn->dmBitsPerPel); + if (pDevModeIn->dmFields & DM_PELSWIDTH) + printf("\tPelsWidth: %d\n", pDevModeIn->dmPelsWidth); + if (pDevModeIn->dmFields & DM_PELSHEIGHT) + printf("\tPelsHeight: %d\n", pDevModeIn->dmPelsHeight); + if (pDevModeIn->dmFields & DM_DISPLAYFLAGS) + printf("\tDisplayFlags: %d\n", pDevModeIn->dmDisplayFlags); +// if (pDevModeIn->dmFields & DM_NUP) +// printf("\tNup: %d\n", pDevModeIn->dmNup); + if (pDevModeIn->dmFields & DM_DISPLAYFREQUENCY) + printf("\tDisplayFrequency:%d\n", pDevModeIn->dmDisplayFrequency); + if (pDevModeIn->dmFields & DM_ICMMETHOD) + printf("\tICMMethod: %d\n", pDevModeIn->dmICMMethod); + if (pDevModeIn->dmFields & DM_ICMINTENT) + printf("\tICMIntent: %d\n", pDevModeIn->dmICMIntent); + if (pDevModeIn->dmFields & DM_MEDIATYPE) + printf("\tMediaType: %d\n", pDevModeIn->dmMediaType); + if (pDevModeIn->dmFields & DM_DITHERTYPE) + printf("\tDitherType: %d\n", pDevModeIn->dmDitherType); +// if (pDevModeIn->dmFields & DM_PANNINGWIDTH) +// printf("\tPanningWidth: %d\n", pDevModeIn->dmPanningWidth); +// if (pDevModeIn->dmFields & DM_PANNINGHEIGHT) +// printf("\tPanningHeight: %d\n", pDevModeIn->dmPanningHeight); + +#if 0 + if (bForceIn) { + printf("DEVMODE\n"); + Dump((BYTE*)pDevModeIn, sizeof(DEVMODE), LEADER); + + if (pDevModeIn->dmDriverExtra) { + printf("DriverExtra\n"); + Dump((BYTE*)pDevModeIn + sizeof(DEVMODE), pDevModeIn->dmDriverExtra, LEADER); + } + } +#endif + + return; +} + +void print_acl(const char* str, ACL *acl) +{ + printf("%s\n", str); + if (acl == NULL) + return; + + printf("\t\tACL Revision \t\t 0x%x\n", acl->AclRevision); + printf("\t\tSbz1\t\t 0x%x\n", acl->Sbz1); + printf("\t\tSbz2\t\t 0x%x\n", acl->Sbz2); + printf("\t\tACL Size\t\t 0x%x\n", acl->AclSize); + printf("\t\tACL Count\t\t 0x%x\n", acl->AceCount); + + return; +} + +void print_sid(const char* str, SID *sid) +{ + DWORD i = 0; + + printf("%s\n", str); + printf("0x%x\n", sid); + if (sid == NULL) + return; + printf("\t\tRevision\t\t0x%x\n", sid->Revision); + printf("\t\tSubAuthorityCount\t0x%x\n", sid->SubAuthorityCount); + printf("\t\tSubAuthority\n\t"); + while (i < sid->SubAuthorityCount) { + printf("\t0x%x", sid->SubAuthority[i]); + if (i%4 == 3) + printf("\n\t"); + i++; + } + + return; +} + +void print_secdesc(SECURITY_DESCRIPTOR *secdesc) +{ + if (secdesc == NULL) { + printf("\tSecurity Descriptor\t= (null)\n"); + return; + } + + printf("\tRevision\t= 0x%x\n", secdesc->Revision); + printf("\tSbz1\t\t= 0x%x\n", secdesc->Sbz1); +#if 0 + print_sid("\tOwner\t\t= ", secdesc->Owner); + print_sid("\tGroup\t\t= ",secdesc->Group); + print_acl("\tSacl\t\t= ", secdesc->Sacl); + print_acl("\tDacl\t\t= ", secdesc->Dacl); +#endif + return; +} + +void PrintLastError() +{ + LPVOID lpMsgBuf; + DWORD status; + + status = GetLastError(); + + FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language + (LPTSTR)&lpMsgBuf, 0, NULL); + printf("ERROR [0x%x] : %s\n", status, (char*)lpMsgBuf); + LocalFree(lpMsgBuf); + + return; +} + + +void print_job_info_1(PJOB_INFO_1 info) +{ + printf("\tJob ID\t\t= %d\n", info->JobId); + printf("\tPrinter Name\t= %s\n", info->pPrinterName); + printf("\tMachine Name\t= %s\n", info->pMachineName); + printf("\tUser Name\t= %s\n", info->pUserName); + printf("\tDocument\t= %s\n", info->pDocument); + printf("\tDatatype\t= %s\n", info->pDatatype); + printf("\tStatus\t\t= %s\n", info->pStatus); + printf("\tStatus\t= %d\n", info->Status); + printf("\tPriority\t= %d\n", info->Priority); + printf("\tPosition\t= %d\n", info->Position); + printf("\tTotal Pages\t= %d\n", info->TotalPages); + printf("\tPages Printed\t= %d\n", info->PagesPrinted); + printf("\tSubmitted (DD:MM:YY HH:MM:SS)\t= %d:%d:%d %d:%d:%d UTC\n", + info->Submitted.wDay, info->Submitted.wMonth, + info->Submitted.wYear, info->Submitted.wHour, + info->Submitted.wMinute, info->Submitted.wSecond); + + return; +} + +void print_job_info_2(PJOB_INFO_2 info) +{ + printf("\tJob ID\t\t= %d\n", info->JobId); + printf("\tPrinter Name\t= %s\n", info->pPrinterName); + printf("\tMachine Name\t= %s\n", info->pMachineName); + printf("\tUser Name\t= %s\n", info->pUserName); + printf("\tDocument\t= %s\n", info->pDocument); + printf("\tDatatype\t= %s\n", info->pDatatype); + printf("\tNotify Name\t= %s\n", info->pNotifyName); + printf("\tPrint Processor\t= %s\n", info->pPrintProcessor); + printf("\tParameters\t= %s\n", info->pParameters); + printf("\tDriver Name\t= %s\n", info->pDriverName); + printf("\tStatus\t\t= %s\n", info->pStatus); + printf("\tStatus\t\t= %d\n", info->Status); + printf("\tPriority\t= %d\n", info->Priority); + printf("\tPosition\t= %d\n", info->Position); + printf("\tTotal Pages\t= %d\n", info->TotalPages); + printf("\tPages Printed\t= %d\n", info->PagesPrinted); + printf("\tStart Time\t= %d\n", info->StartTime); + printf("\tUntil Time\t= %d\n", info->UntilTime); + printf("\tTime\t\t= %d\n", info->Time); + printf("\tSize\t\t= %d\n", info->Size); + printf("\tSubmitted (DD:MM:YY HH:MM:SS)\t= %d:%d:%d %d:%d:%d UTC\n", + info->Submitted.wDay, info->Submitted.wMonth, + info->Submitted.wYear, info->Submitted.wHour, + info->Submitted.wMinute, info->Submitted.wSecond); + printf("\tDevice Mode Information\n"); + printf("\t-----------------------\n"); + print_devmode(info->pDevMode); + printf("\tSecurity Descriptor Information\n"); + printf("\t-------------------------------\n"); + print_secdesc(info->pSecurityDescriptor); + + return; +} + +void print_job_info_3(PJOB_INFO_3 info) +{ + printf("\tJob ID\t\t= %d\n", info->JobId); + printf("\tJob ID Next Job\t= %d\n", info->NextJobId); + printf("\tReserved (must be 0)\t= %d\n",info->Reserved); + + return; +} + +void print_monitor_info_1(PMONITOR_INFO_1 info) +{ + printf("\tMonitor Name\t= %s\n", info->pName); + + return; +} + +void print_monitor_info_2(PMONITOR_INFO_2 info) +{ + printf("\tMonitor Name\t= %s\n", info->pName); + printf("\tEnvironment\t= %s\n", info->pEnvironment); + printf("\tDLL Name\t= %s\n", info->pDLLName); + + return; +} + +void print_form_info_1(PFORM_INFO_1 info) +{ + printf("\tForm Name\t= %s\n", info->pName); + printf("\tFlags\t\t= 0x%x\n", info->Flags); + printf("\tSize\t\t= %d x %d\n", info->Size.cx, info->Size.cy); + printf("\tRectangle\t= [left]%d [right]%d [top]%d [bottom]%d\n", + info->ImageableArea.left, info->ImageableArea.right, + info->ImageableArea.top, info->ImageableArea.bottom); + + return; +} + +void print_printer_info_1(PPRINTER_INFO_1 info) +{ + printf("\tPrinter Name\t= %s\n", info->pName); + printf("\tDescription\t= %s\n", info->pDescription); + printf("\tComment\t\t= %s\n", info->pComment); + printf("\tFlags\t\t= 0x%x\n", info->Flags); + + return; +} + +void print_printer_info_2(PPRINTER_INFO_2 info) +{ + printf("\tServer Name\t\t= %s\n", info->pServerName); + printf("\tPrinter Name\t\t= %s\n", info->pPrinterName); + printf("\tPort Name\t\t= %s\n", info->pPortName); + printf("\tShare Name\t\t= %s\n", info->pShareName); + printf("\tDriver Name\t\t= %s\n", info->pDriverName); + printf("\tComment\t\t\t= %s\n", info->pComment); + printf("\tLocation\t\t= %s\n", info->pLocation); + printf("\tSeparator File\t\t= %s\n", info->pSepFile); + printf("\tDefault Data Type\t= %s\n", info->pDatatype); + printf("\tPrint Processor\t\t= %s\n", info->pPrintProcessor); + printf("\tParameters\t\t= %s\n", info->pParameters); + printf("\tAttributes\t\t= 0x%x\n", info->Attributes); + printf("\tPriority\t\t= 0x%x\n", info->Priority); + printf("\tDefault Priority\t= 0x%x\n", info->DefaultPriority); + printf("\tStart Time\t\t= 0x%x\n", info->StartTime); + printf("\tUntil Time\t\t= 0x%x\n", info->UntilTime); + printf("\tStatus\t\t\t= 0x%x\n", info->Status); + printf("\tcJobs\t\t\t= 0x%x\n", info->cJobs); + printf("\tAverage PPM\t\t= 0x%x\n", info->AveragePPM); + + printf("\tDevice Mode Information\n"); + printf("\t-----------------------\n"); + print_devmode(info->pDevMode); +#if 0 + printf("\tSecurity Descriptor Information\n"); + printf("\t-------------------------------\n"); + print_secdesc(info->pSecurityDescriptor); +#endif + return; +} + +void print_printer_info_5(PPRINTER_INFO_5 info) +{ + printf("\tPrinter Name\t\t\t= %s\n", info->pPrinterName); + printf("\tPort Name\t\t\t= %s\n", info->pPortName); + printf("\tAttributes\t\t\t= 0x%x\n", info->Attributes); + printf("\tDev NotSelect Timeout\t= 0x%x\n", info->DeviceNotSelectedTimeout); + printf("\tTX RetryTimeout\t\t= 0x%x\n", info->TransmissionRetryTimeout); + return; +} + +void print_printer_info_6(PPRINTER_INFO_6 info) +{ + printf("\tStatus\t\t\t= 0x%x\n", info->dwStatus); + return; +} + +void print_printer_info_7(PPRINTER_INFO_7 info) +{ + printf("\tObject GUID\t\t\t= %s\n", info->pszObjectGUID); + printf("\tAction\t\t\t= 0x%x\n", info->dwAction); + return; +} + +void print_printer_info_8(PPRINTER_INFO_8 info) +{ + print_devmode(info->pDevMode); +} + +void print_printer_info_9(PPRINTER_INFO_9 info) +{ + print_devmode(info->pDevMode); +} + +void print_printer_info_bylevel(DWORD level, LPBYTE buffer, DWORD count) +{ + DWORD i; + PPRINTER_INFO_1 buffer1 = NULL; + PPRINTER_INFO_2 buffer2 = NULL; + PPRINTER_INFO_3 buffer3 = NULL; + PPRINTER_INFO_4 buffer4 = NULL; + PPRINTER_INFO_5 buffer5 = NULL; + PPRINTER_INFO_6 buffer6 = NULL; + PPRINTER_INFO_7 buffer7 = NULL; + PPRINTER_INFO_8 buffer8 = NULL; + + if (!buffer) { + return; + } + + switch (level) { + case 1: + buffer1 = (PPRINTER_INFO_1)buffer; + break; + case 2: + buffer2 = (PPRINTER_INFO_2)buffer; + break; + case 3: + buffer3 = (PPRINTER_INFO_3)buffer; + break; + case 4: + buffer4 = (PPRINTER_INFO_4)buffer; + break; + case 5: + buffer5 = (PPRINTER_INFO_5)buffer; + break; + case 6: + buffer6 = (PPRINTER_INFO_6)buffer; + break; + case 7: + buffer7 = (PPRINTER_INFO_7)buffer; + break; + case 8: + buffer8 = (PPRINTER_INFO_8)buffer; + break; + default: + break; + } + + printf("Printer Info Level %d:\n", level); + + switch (level) { + case 1: + for (i=0; ipName); + + return; +} + +void print_driver_info_1(PDRIVER_INFO_1 info) +{ + printf("\tDriver Name\t= %s\n\n", info->pName); + + return; +} + +void print_driver_info_2(PDRIVER_INFO_2 info) +{ + printf("\tDriver Name\t= %s\n", info->pName); + printf("\tEnvironment\t= %s\n", info->pEnvironment); + printf("\tVersion\t\t= %d\n", info->cVersion); + printf("\tDriver Path\t= %s\n", info->pDriverPath); + printf("\tData File\t= %s\n", info->pDataFile); + printf("\tConfig File\t= %s\n\n", info->pConfigFile); + + return; +} + +void print_driver_info_3(PDRIVER_INFO_3 info) +{ + char *ptr = NULL; + + printf("\tDriver Name\t= %s\n", info->pName); + printf("\tEnvironment\t= %s\n", info->pEnvironment); + printf("\tVersion\t\t= %d\n", info->cVersion); + printf("\tDriver Path\t= %s\n", info->pDriverPath); + printf("\tData File\t= %s\n", info->pDataFile); + printf("\tConfig File\t= %s\n", info->pConfigFile); + printf("\tHelp Path\t= %s\n", info->pHelpFile); + printf("\tMonitor Name\t= %s\n", info->pMonitorName); + printf("\tData Type\t= %s\n", info->pDefaultDataType); + ptr = (char*)info->pDependentFiles; + while ((ptr != NULL) && (*ptr != '\0')) { + printf("\tDependent Files\t= %s\n", ptr); + for (;*ptr != '\0'; ptr++) + /* printf("%s\n", ptr); */ + ; + ptr++; + } + + return; +} + +void print_driver_info_4(PDRIVER_INFO_4 info) +{ + char *ptr = NULL; + + printf("\tDriver Name\t= %s\n", info->pName); + printf("\tEnvironment\t= %s\n", info->pEnvironment); + printf("\tVersion\t\t= %d\n", info->cVersion); + printf("\tDriver Path\t= %s\n", info->pDriverPath); + printf("\tData File\t= %s\n", info->pDataFile); + printf("\tConfig File\t= %s\n", info->pConfigFile); + printf("\tHelp Path\t= %s\n", info->pHelpFile); + printf("\tMonitor Name\t= %s\n", info->pMonitorName); + printf("\tData Type\t= %s\n", info->pDefaultDataType); + printf("\tPrevious Names\t= %s\n", info->pszzPreviousNames); + ptr = (char*)info->pDependentFiles; + while ((ptr != NULL) && (*ptr != '\0')) { + printf("\tDependent Files\t= %s\n", ptr); + for (;*ptr != '\0'; ptr++) + /* printf("%s\n", ptr); */ + ; + ptr++; + } + + return; +} + +void print_driver_info_6(PDRIVER_INFO_6 info) +{ + char *ptr = NULL; + + printf("\tDriver Name\t= %s\n", info->pName); + printf("\tEnvironment\t= %s\n", info->pEnvironment); + printf("\tVersion\t\t= %d\n", info->cVersion); + printf("\tDriver Path\t= %s\n", info->pDriverPath); + printf("\tData File\t= %s\n", info->pDataFile); + printf("\tConfig File\t= %s\n", info->pConfigFile); + printf("\tHelp Path\t= %s\n", info->pHelpFile); + printf("\tMonitor Name\t= %s\n", info->pMonitorName); + printf("\tData Type\t= %s\n", info->pDefaultDataType); + printf("\tPrevious Names\t= %s\n", info->pszzPreviousNames); + ptr = (char*)info->pDependentFiles; + if (ptr != NULL) { + while (*ptr != '\0') { + printf("\tDependent Files\t= %s\n", ptr); + for (;*ptr != '\0'; ptr++) + /* printf("%s\n", ptr); */ + ; + ptr++; + } + } else { + printf("\tPrevious Names\t= (null)\n"); + } + + ptr = (char*)info->pszzPreviousNames; + if (ptr != NULL) { + while (*ptr != '\0') { + printf("\tPrevious Names\t= %s\n", ptr); + for (;*ptr != '\0'; ptr++) + /* printf("%s\n", ptr); */ + ; + ptr++; + } + } else { + printf("\tPrevious Names\t= (null)\n"); + } + + printf("\tDriver Date\t= %d\n", info->ftDriverDate); + printf("\tDriver Version\t= %d\n", info->dwlDriverVersion); + printf("\tManufacture Name = %s\n", info->pszMfgName); + printf("\tOEM URL\t\t= %s\n", info->pszOEMUrl); + printf("\tHardware ID\t= %s\n", info->pszHardwareID); + printf("\tProvider\t= %s\n", info->pszProvider); + return; +} + +void print_doc_info_1(PDOC_INFO_1 info) +{ + printf("\tDocument Name\t= %s\n", info->pDocName); + printf("\tOutput Filename\t= %s\n", info->pOutputFile); + printf("\tDatatype\t= %s\n", info->pDatatype); + return; +} + +void print_printer_enum_values(PRINTER_ENUM_VALUES *info) +{ + DWORD i = 0; + + printf("\tValue Name\t= %s [0x%x]\n", info->pValueName, info->cbValueName); + printf("\tType\t\t= 0x%x\n", info->dwType); + printf("\tSize\t\t= 0x%x\n", info->cbData); + + while (i < info->cbData) { + printf("\t0x%x", *(info->pData++)); + if (i%4 == 3) + printf("\n"); + i++; + } + printf("\n"); + + return; +} diff --git a/testprogs/win32/spoolss/printlib_proto.h b/testprogs/win32/spoolss/printlib_proto.h new file mode 100644 index 0000000000..fd6db22770 --- /dev/null +++ b/testprogs/win32/spoolss/printlib_proto.h @@ -0,0 +1,46 @@ +#ifndef __PRINTLIB_H__ +#define __PRINTLIB_H__ + +#undef _PRINTF_ATTRIBUTE +#define _PRINTF_ATTRIBUTE(a1, a2) PRINTF_ATTRIBUTE(a1, a2) +/* This file was automatically generated by mkproto.pl. DO NOT EDIT */ + +/* this file contains prototypes for functions that are private + * to this subsystem or library. These functions should not be + * used outside this particular subsystem! */ + + +/* The following definitions come from printlib.c */ + +void print_devmode (DEVMODE *pDevModeIn); +void print_acl (const char* str, ACL *acl); +void print_sid (const char* str, SID *sid); +void print_secdesc (SECURITY_DESCRIPTOR *secdesc); +void PrintLastError(); +void print_job_info_1(PJOB_INFO_1 info); +void print_job_info_2(PJOB_INFO_2 info); +void print_job_info_3(PJOB_INFO_3 info); +void print_monitor_info_1 (PMONITOR_INFO_1 info); +void print_monitor_info_2 (PMONITOR_INFO_2 info); +void print_form_info_1 (PFORM_INFO_1 info); +void print_printer_info_1 (PPRINTER_INFO_1 info); +void print_printer_info_2 (PPRINTER_INFO_2 info); +void print_printer_info_5 (PPRINTER_INFO_5 info); +void print_printer_info_6 (PPRINTER_INFO_6 info); +void print_printer_info_7 (PPRINTER_INFO_7 info); +void print_printer_info_8 (PPRINTER_INFO_8 info); +void print_printer_info_9 (PPRINTER_INFO_9 info); +void print_printer_info_bylevel(DWORD level, LPBYTE buffer, DWORD count); +void print_printprocessor_info_1 (PPRINTPROCESSOR_INFO_1 info); +void print_driver_info_1 (PDRIVER_INFO_1 info); +void print_driver_info_2 (PDRIVER_INFO_2 info); +void print_driver_info_3 (PDRIVER_INFO_3 info); +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); +#undef _PRINTF_ATTRIBUTE +#define _PRINTF_ATTRIBUTE(a1, a2) + +#endif /* __PRINTLIB_H__ */ + diff --git a/testprogs/win32/spoolss/spoolss.c b/testprogs/win32/spoolss/spoolss.c index d014b14e70..c550b99923 100644 --- a/testprogs/win32/spoolss/spoolss.c +++ b/testprogs/win32/spoolss/spoolss.c @@ -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; } diff --git a/testprogs/win32/spoolss/spoolss.h b/testprogs/win32/spoolss/spoolss.h index adf178670f..f025fccb3f 100644 --- a/testprogs/win32/spoolss/spoolss.h +++ b/testprogs/win32/spoolss/spoolss.h @@ -26,6 +26,7 @@ #include #include "error.h" +#include "printlib_proto.h" #if 0 #include "lib/talloc/talloc.h" -- cgit From 4aefb33b9fa4b93fea7035c505e480949bfb843b Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 11 Jan 2010 12:33:22 +0100 Subject: testprogs: add more error codes to spoolss test. Guenther --- testprogs/win32/spoolss/error.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'testprogs') diff --git a/testprogs/win32/spoolss/error.c b/testprogs/win32/spoolss/error.c index e523c15864..ba15c1e62d 100644 --- a/testprogs/win32/spoolss/error.c +++ b/testprogs/win32/spoolss/error.c @@ -25,6 +25,8 @@ const char *errstr(DWORD error) static char tmp[20]; switch (error) { + case ERROR_FILE_NOT_FOUND: + return "ERROR_FILE_NOT_FOUND"; case ERROR_ACCESS_DENIED: return "ERROR_ACCESS_DENIED"; case ERROR_INVALID_PARAMETER: @@ -105,6 +107,8 @@ const char *errstr(DWORD error) case ERROR_PRINT_JOB_RESTART_REQUIRED: return "ERROR_PRINT_JOB_RESTART_REQUIRED"; #endif + case ERROR_CANCELLED: + return "ERROR_CANCELLED"; default: break; } -- cgit From 3e7b7bfd27fad1680f9f331e5b8d736bc3733e05 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 11 Jan 2010 12:34:56 +0100 Subject: testprogs: fix EnumPrintProcessorDatatypes spoolss test. Guenther --- testprogs/win32/spoolss/spoolss.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'testprogs') diff --git a/testprogs/win32/spoolss/spoolss.c b/testprogs/win32/spoolss/spoolss.c index c550b99923..718fb379ea 100644 --- a/testprogs/win32/spoolss/spoolss.c +++ b/testprogs/win32/spoolss/spoolss.c @@ -357,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 }; @@ -374,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(); } } @@ -763,7 +762,7 @@ int main(int argc, char *argv[]) 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); -- cgit From 9a1b298e3d32252dd83fd2146b578e5150a06c7b Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 11 Jan 2010 12:37:45 +0100 Subject: testprogs: test each printer, do not abort after first failure. Guenther --- testprogs/win32/spoolss/spoolss.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'testprogs') diff --git a/testprogs/win32/spoolss/spoolss.c b/testprogs/win32/spoolss/spoolss.c index 718fb379ea..16f45b02f3 100644 --- a/testprogs/win32/spoolss/spoolss.c +++ b/testprogs/win32/spoolss/spoolss.c @@ -599,6 +599,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); @@ -619,13 +620,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; } /**************************************************************************** -- cgit From 403dc10e8ff46282dd7f4afbd5e5f3fbcc73177d Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 11 Jan 2010 12:38:22 +0100 Subject: testprogs: fix driver levels in spoolss test. Guenther --- testprogs/win32/spoolss/spoolss.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'testprogs') diff --git a/testprogs/win32/spoolss/spoolss.c b/testprogs/win32/spoolss/spoolss.c index 16f45b02f3..5c77413268 100644 --- a/testprogs/win32/spoolss/spoolss.c +++ b/testprogs/win32/spoolss/spoolss.c @@ -122,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; @@ -455,8 +455,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; -- cgit From 3c1b51795dcf6b6e85701a49ea9d862b9ae610bd Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 11 Jan 2010 15:40:16 +0100 Subject: testprogs: add EnumPrinterKey test to spoolss test. Guenther --- testprogs/win32/spoolss/error.c | 4 +++ testprogs/win32/spoolss/printlib.c | 14 ++++++++++ testprogs/win32/spoolss/printlib_proto.h | 1 + testprogs/win32/spoolss/spoolss.c | 47 +++++++++++++++++++++++++++++--- 4 files changed, 62 insertions(+), 4 deletions(-) (limited to 'testprogs') diff --git a/testprogs/win32/spoolss/error.c b/testprogs/win32/spoolss/error.c index ba15c1e62d..6296f07c35 100644 --- a/testprogs/win32/spoolss/error.c +++ b/testprogs/win32/spoolss/error.c @@ -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; } diff --git a/testprogs/win32/spoolss/printlib.c b/testprogs/win32/spoolss/printlib.c index c40ca6c2e1..9fc9d046f2 100644 --- a/testprogs/win32/spoolss/printlib.c +++ b/testprogs/win32/spoolss/printlib.c @@ -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); + } + } +} diff --git a/testprogs/win32/spoolss/printlib_proto.h b/testprogs/win32/spoolss/printlib_proto.h index fd6db22770..d408523ac4 100644 --- a/testprogs/win32/spoolss/printlib_proto.h +++ b/testprogs/win32/spoolss/printlib_proto.h @@ -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) diff --git a/testprogs/win32/spoolss/spoolss.c b/testprogs/win32/spoolss/spoolss.c index 5c77413268..66b9191bae 100644 --- a/testprogs/win32/spoolss/spoolss.c +++ b/testprogs/win32/spoolss/spoolss.c @@ -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); -- cgit From 0ae4cc839d435bb974b456c9c0f91bf545e181f2 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 11 Jan 2010 15:40:37 +0100 Subject: testprogs: remove unused test_EachDriver from spoolss test. Guenther --- testprogs/win32/spoolss/spoolss.c | 20 -------------------- 1 file changed, 20 deletions(-) (limited to 'testprogs') diff --git a/testprogs/win32/spoolss/spoolss.c b/testprogs/win32/spoolss/spoolss.c index 66b9191bae..d68ca89f48 100644 --- a/testprogs/win32/spoolss/spoolss.c +++ b/testprogs/win32/spoolss/spoolss.c @@ -607,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) @@ -805,7 +786,6 @@ int main(int argc, char *argv[]) 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) { -- cgit