From cf122bab8c771e6bff95ba003c424f99fdf62f8d Mon Sep 17 00:00:00 2001 From: Detlef Riekenberg Date: Wed, 3 Oct 2007 01:01:12 +0200 Subject: [PATCH] spoolss/tests: Add tests for SplInitializeWinSpoolDrv. --- .gitignore | 4 + Makefile.in | 2 + configure | 3 + configure.ac | 1 + dlls/Makefile.in | 1 + dlls/spoolss/tests/Makefile.in | 13 ++++ dlls/spoolss/tests/spoolss.c | 129 +++++++++++++++++++++++++++++++++ programs/winetest/Makefile.in | 3 + programs/winetest/winetest.rc | 1 + 9 files changed, 157 insertions(+) create mode 100644 dlls/spoolss/tests/Makefile.in create mode 100644 dlls/spoolss/tests/spoolss.c diff --git a/.gitignore b/.gitignore index 0b383f3cfa7..ba3eb5b53fa 100644 --- a/.gitignore +++ b/.gitignore @@ -437,6 +437,9 @@ dlls/snmpapi/tests/snmpapi_crosstest.exe dlls/snmpapi/tests/testlist.c dlls/sound.drv16 dlls/spoolss/libspoolss.def +dlls/spoolss/tests/*.ok +dlls/spoolss/tests/spoolss_crosstest.exe +dlls/spoolss/tests/testlist.c dlls/stdole2.tlb/rsrc.res dlls/stdole2.tlb/std_ole_v2.tlb dlls/stdole32.tlb/rsrc.res @@ -728,6 +731,7 @@ programs/winetest/shdocvw_test.exe programs/winetest/shell32_test.exe programs/winetest/shlwapi_test.exe programs/winetest/snmpapi_test.exe +programs/winetest/spoolss_test.exe programs/winetest/urlmon_test.exe programs/winetest/user32_test.exe programs/winetest/usp10_test.exe diff --git a/Makefile.in b/Makefile.in index 737f10d6165..a977a554a3f 100644 --- a/Makefile.in +++ b/Makefile.in @@ -385,6 +385,7 @@ ALL_MAKEFILES = \ dlls/snmpapi/Makefile \ dlls/snmpapi/tests/Makefile \ dlls/spoolss/Makefile \ + dlls/spoolss/tests/Makefile \ dlls/stdole2.tlb/Makefile \ dlls/stdole32.tlb/Makefile \ dlls/sti/Makefile \ @@ -754,6 +755,7 @@ dlls/shlwapi/tests/Makefile: dlls/shlwapi/tests/Makefile.in dlls/Maketest.rules dlls/snmpapi/Makefile: dlls/snmpapi/Makefile.in dlls/Makedll.rules dlls/snmpapi/tests/Makefile: dlls/snmpapi/tests/Makefile.in dlls/Maketest.rules dlls/spoolss/Makefile: dlls/spoolss/Makefile.in dlls/Makedll.rules +dlls/spoolss/tests/Makefile: dlls/spoolss/tests/Makefile.in dlls/Maketest.rules dlls/stdole2.tlb/Makefile: dlls/stdole2.tlb/Makefile.in dlls/Makedll.rules dlls/stdole32.tlb/Makefile: dlls/stdole32.tlb/Makefile.in dlls/Makedll.rules dlls/sti/Makefile: dlls/sti/Makefile.in dlls/Makedll.rules diff --git a/configure b/configure index 8159d5885c9..e9a92daca18 100755 --- a/configure +++ b/configure @@ -20726,6 +20726,8 @@ ac_config_files="$ac_config_files dlls/snmpapi/tests/Makefile" ac_config_files="$ac_config_files dlls/spoolss/Makefile" +ac_config_files="$ac_config_files dlls/spoolss/tests/Makefile" + ac_config_files="$ac_config_files dlls/stdole2.tlb/Makefile" ac_config_files="$ac_config_files dlls/stdole32.tlb/Makefile" @@ -21773,6 +21775,7 @@ do "dlls/snmpapi/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/snmpapi/Makefile" ;; "dlls/snmpapi/tests/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/snmpapi/tests/Makefile" ;; "dlls/spoolss/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/spoolss/Makefile" ;; + "dlls/spoolss/tests/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/spoolss/tests/Makefile" ;; "dlls/stdole2.tlb/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/stdole2.tlb/Makefile" ;; "dlls/stdole32.tlb/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/stdole32.tlb/Makefile" ;; "dlls/sti/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/sti/Makefile" ;; diff --git a/configure.ac b/configure.ac index 956a7e99f06..34c6fca5b7b 100644 --- a/configure.ac +++ b/configure.ac @@ -1783,6 +1783,7 @@ AC_CONFIG_FILES([dlls/shlwapi/tests/Makefile]) AC_CONFIG_FILES([dlls/snmpapi/Makefile]) AC_CONFIG_FILES([dlls/snmpapi/tests/Makefile]) AC_CONFIG_FILES([dlls/spoolss/Makefile]) +AC_CONFIG_FILES([dlls/spoolss/tests/Makefile]) AC_CONFIG_FILES([dlls/stdole2.tlb/Makefile]) AC_CONFIG_FILES([dlls/stdole32.tlb/Makefile]) AC_CONFIG_FILES([dlls/sti/Makefile]) diff --git a/dlls/Makefile.in b/dlls/Makefile.in index 8d3c48ac257..2053a1f5d7d 100644 --- a/dlls/Makefile.in +++ b/dlls/Makefile.in @@ -299,6 +299,7 @@ TESTSUBDIRS = \ shell32/tests \ shlwapi/tests \ snmpapi/tests \ + spoolss/tests \ urlmon/tests \ user32/tests \ usp10/tests \ diff --git a/dlls/spoolss/tests/Makefile.in b/dlls/spoolss/tests/Makefile.in new file mode 100644 index 00000000000..f0e56ba2db3 --- /dev/null +++ b/dlls/spoolss/tests/Makefile.in @@ -0,0 +1,13 @@ +TOPSRCDIR = @top_srcdir@ +TOPOBJDIR = ../../.. +SRCDIR = @srcdir@ +VPATH = @srcdir@ +TESTDLL = spoolss.dll +IMPORTS = kernel32 + +CTESTS = \ + spoolss.c + +@MAKE_TEST_RULES@ + +@DEPENDENCIES@ # everything below this line is overwritten by make depend diff --git a/dlls/spoolss/tests/spoolss.c b/dlls/spoolss/tests/spoolss.c new file mode 100644 index 00000000000..3797785b1dc --- /dev/null +++ b/dlls/spoolss/tests/spoolss.c @@ -0,0 +1,129 @@ +/* + * Unit test suite for the Spooler-Service helper DLL + * + * Copyright 2007 Detlef Riekenberg + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + * + */ + +#include + +#include "windef.h" +#include "winbase.h" +#include "winerror.h" +#include "wine/test.h" + + + +/* ##### */ + +static HMODULE hwinspool; + +static HMODULE hspl; +static DWORD (WINAPI * pSplInitializeWinSpoolDrv)(LPVOID *); + +#define WINSPOOL_TABLESIZE 16 + +static LPVOID fn_spl[WINSPOOL_TABLESIZE]; +static LPVOID fn_w2k[WINSPOOL_TABLESIZE]; +static LPVOID fn_xp[WINSPOOL_TABLESIZE]; + +/* ########################### */ + +static LPCSTR load_functions(void) +{ + LPCSTR ptr; + + ptr = "spoolss.dll"; + hspl = LoadLibraryA(ptr); + if (!hspl) return ptr; + + ptr = "SplInitializeWinSpoolDrv"; + pSplInitializeWinSpoolDrv = (void *) GetProcAddress(hspl, ptr); + if (!pSplInitializeWinSpoolDrv) return ptr; + + + ptr = "winspool.drv"; + hwinspool = LoadLibraryA(ptr); + if (!hwinspool) return ptr; + + memset(fn_w2k, 0xff, sizeof(fn_w2k)); + fn_w2k[0] = (void *) GetProcAddress(hwinspool, "OpenPrinterW"); + fn_w2k[1] = (void *) GetProcAddress(hwinspool, "ClosePrinter"); + fn_w2k[2] = (void *) GetProcAddress(hwinspool, "SpoolerDevQueryPrintW"); + fn_w2k[3] = (void *) GetProcAddress(hwinspool, "SpoolerPrinterEvent"); + fn_w2k[4] = (void *) GetProcAddress(hwinspool, "DocumentPropertiesW"); + fn_w2k[5] = (void *) GetProcAddress(hwinspool, (LPSTR) 212); /* LoadPrinterDriver */ + fn_w2k[6] = (void *) GetProcAddress(hwinspool, "SetDefaultPrinterW"); + fn_w2k[7] = (void *) GetProcAddress(hwinspool, "GetDefaultPrinterW"); + fn_w2k[8] = (void *) GetProcAddress(hwinspool, (LPSTR) 213); /* RefCntLoadDriver */ + fn_w2k[9] = (void *) GetProcAddress(hwinspool, (LPSTR) 214); /* RefCntUnloadDriver */ + fn_w2k[10] = (void *) GetProcAddress(hwinspool, (LPSTR) 215); /* ForceUnloadDriver */ + + memset(fn_xp, 0xff, sizeof(fn_xp)); + fn_xp[0] = (void *) GetProcAddress(hwinspool, "OpenPrinterW"); + fn_xp[1] = (void *) GetProcAddress(hwinspool, "ClosePrinter"); + fn_xp[2] = (void *) GetProcAddress(hwinspool, "SpoolerDevQueryPrintW"); + fn_xp[3] = (void *) GetProcAddress(hwinspool, "SpoolerPrinterEvent"); + fn_xp[4] = (void *) GetProcAddress(hwinspool, "DocumentPropertiesW"); + fn_xp[5] = (void *) GetProcAddress(hwinspool, (LPSTR) 212); /* LoadPrinterDriver */ + fn_xp[6] = (void *) GetProcAddress(hwinspool, (LPSTR) 213); /* RefCntLoadDriver */ + fn_xp[7] = (void *) GetProcAddress(hwinspool, (LPSTR) 214); /* RefCntUnloadDriver */ + fn_xp[8] = (void *) GetProcAddress(hwinspool, (LPSTR) 215); /* ForceUnloadDriver */ + + return NULL; + +} + +/* ########################### */ + +static void test_SplInitializeWinSpoolDrv(VOID) +{ + DWORD res; + LONG id; + BOOL is_xp; + + memset(fn_spl, 0xff, sizeof(fn_spl)); + SetLastError(0xdeadbeef); + res = pSplInitializeWinSpoolDrv(fn_spl); + ok(res, "got %u with %u (expected '!= 0')\n", res, GetLastError()); + + /* functions 0 to 5 are the same with "spoolss.dll" from w2k and xp */ + is_xp = (fn_spl[6] == fn_xp[6]); + id = 0; + while (id < WINSPOOL_TABLESIZE) { + ok( fn_spl[id] == (is_xp ? fn_xp[id] : fn_w2k[id]), + "(#%02u) spoolss: %p, xp: %p, w2k: %p\n", id, fn_spl[id], fn_xp[id], fn_w2k[id]); + id++; + } +} + +/* ########################### */ + +START_TEST(spoolss) +{ + LPCSTR ptr; + + /* spoolss.dll does not exist on win9x */ + ptr = load_functions(); + if (ptr) { + skip("%s not found\n", ptr); + return; + } + + test_SplInitializeWinSpoolDrv(); + +} diff --git a/programs/winetest/Makefile.in b/programs/winetest/Makefile.in index a2a7f981be7..a6ac69dcafa 100644 --- a/programs/winetest/Makefile.in +++ b/programs/winetest/Makefile.in @@ -77,6 +77,7 @@ TESTBINS = \ shell32_test.exe \ shlwapi_test.exe \ snmpapi_test.exe \ + spoolss_test.exe \ urlmon_test.exe \ user32_test.exe \ usp10_test.exe \ @@ -202,6 +203,8 @@ shlwapi_test.exe: $(DLLDIR)/shlwapi/tests/shlwapi_test.exe$(DLLEXT) cp $(DLLDIR)/shlwapi/tests/shlwapi_test.exe$(DLLEXT) $@ && $(STRIP) $@ snmpapi_test.exe: $(DLLDIR)/snmpapi/tests/snmpapi_test.exe$(DLLEXT) cp $(DLLDIR)/snmpapi/tests/snmpapi_test.exe$(DLLEXT) $@ && $(STRIP) $@ +spoolss_test.exe: $(DLLDIR)/spoolss/tests/spoolss_test.exe$(DLLEXT) + cp $(DLLDIR)/spoolss/tests/spoolss_test.exe$(DLLEXT) $@ && $(STRIP) $@ urlmon_test.exe: $(DLLDIR)/urlmon/tests/urlmon_test.exe$(DLLEXT) cp $(DLLDIR)/urlmon/tests/urlmon_test.exe$(DLLEXT) $@ && $(STRIP) $@ user32_test.exe: $(DLLDIR)/user32/tests/user32_test.exe$(DLLEXT) diff --git a/programs/winetest/winetest.rc b/programs/winetest/winetest.rc index 566135fa039..aee8c2a43bd 100644 --- a/programs/winetest/winetest.rc +++ b/programs/winetest/winetest.rc @@ -135,6 +135,7 @@ shdocvw_test.exe TESTRES "shdocvw_test.exe" shell32_test.exe TESTRES "shell32_test.exe" shlwapi_test.exe TESTRES "shlwapi_test.exe" snmpapi_test.exe TESTRES "snmpapi_test.exe" +spoolss_test.exe TESTRES "spoolss_test.exe" urlmon_test.exe TESTRES "urlmon_test.exe" user32_test.exe TESTRES "user32_test.exe" usp10_test.exe TESTRES "usp10_test.exe"