The branch, master has been updated
       via  9185fd0... testprogs: pass down architecture in spoolss test.
       via  487a03a... testprogs: add win32 spoolss testsuite.
      from  57be1d0... s4 torture: Add RAW-OPEN-NTCREATEDIR to test error 
checking for open directories as files

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 9185fd0a93e2530c778b7d31f90311f8618b4fb7
Author: Günther Deschner <g...@samba.org>
Date:   Wed Jan 6 23:15:09 2010 +0100

    testprogs: pass down architecture in spoolss test.
    
    Guenther

commit 487a03a1586e478baaadada184836be98c609aa0
Author: Günther Deschner <g...@samba.org>
Date:   Mon Dec 14 23:54:42 2009 +0100

    testprogs: add win32 spoolss testsuite.
    
    Guenther

-----------------------------------------------------------------------

Summary of changes:
 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       |  780 +++++++++++++++++++++++++++++++
 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, 1286 insertions(+), 0 deletions(-)
 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


Changeset truncated at 500 lines:

diff --git a/testprogs/win32/spoolss/Makefile b/testprogs/win32/spoolss/Makefile
new file mode 100644
index 0000000..96efcea
--- /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 0000000..82fc7ed
--- /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 0000000..9d6cf4b
--- /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 0000000..e523c15
--- /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 <http://www.gnu.org/licenses/>.
+*/
+
+#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 0000000..581c109
--- /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 <http://www.gnu.org/licenses/>.
+*/
+
+#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 0000000..d014b14
--- /dev/null
+++ b/testprogs/win32/spoolss/spoolss.c
@@ -0,0 +1,780 @@
+/*
+   Unix SMB/CIFS implementation.
+   test suite for spoolss rpc operations
+
+   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 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 <http://www.gnu.org/licenses/>.
+*/
+
+/****************************************************************************
+****************************************************************************/
+
+#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,
+                            LPSTR architecture)
+{
+       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, 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, architecture, 
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;
+       }


-- 
Samba Shared Repository

Reply via email to