[PATCH 2/2] spoolss/tests: Fix tests on Vista
Detlef Riekenberg
wine.dev at web.de
Wed Jul 9 14:52:00 CDT 2008
---
dlls/spoolss/tests/spoolss.c | 73 +++++++++++++++++++++++++++++++++--------
1 files changed, 58 insertions(+), 15 deletions(-)
diff --git a/dlls/spoolss/tests/spoolss.c b/dlls/spoolss/tests/spoolss.c
index b0b544c..ba9a12c 100644
--- a/dlls/spoolss/tests/spoolss.c
+++ b/dlls/spoolss/tests/spoolss.c
@@ -34,6 +34,7 @@ static HMODULE hwinspool;
static HMODULE hspl;
static BOOL (WINAPI * pBuildOtherNamesFromMachineName)(LPWSTR **, LPDWORD);
+static BOOL (WINAPI * pFreeOtherNames)(LPWSTR **, LPDWORD);
static DWORD (WINAPI * pSplInitializeWinSpoolDrv)(LPVOID *);
#define WINSPOOL_TABLESIZE 16
@@ -41,6 +42,7 @@ static DWORD (WINAPI * pSplInitializeWinSpoolDrv)(LPVOID *);
static LPVOID fn_spl[WINSPOOL_TABLESIZE];
static LPVOID fn_w2k[WINSPOOL_TABLESIZE];
static LPVOID fn_xp[WINSPOOL_TABLESIZE];
+static LPVOID fn_v[WINSPOOL_TABLESIZE];
/* ########################### */
@@ -54,12 +56,12 @@ static LPCSTR load_functions(void)
ptr = "BuildOtherNamesFromMachineName";
pBuildOtherNamesFromMachineName = (void *) GetProcAddress(hspl, ptr);
- if (!pBuildOtherNamesFromMachineName) return ptr;
+
+ ptr = "FreeOtherNames";
+ pFreeOtherNames = (void *) GetProcAddress(hspl, ptr);
ptr = "SplInitializeWinSpoolDrv";
pSplInitializeWinSpoolDrv = (void *) GetProcAddress(hspl, ptr);
- if (!pSplInitializeWinSpoolDrv) return ptr;
-
ptr = "winspool.drv";
hwinspool = LoadLibraryA(ptr);
@@ -89,6 +91,18 @@ static LPCSTR load_functions(void)
fn_xp[7] = (void *) GetProcAddress(hwinspool, (LPSTR) 214); /* RefCntUnloadDriver */
fn_xp[8] = (void *) GetProcAddress(hwinspool, (LPSTR) 215); /* ForceUnloadDriver */
+ memset(fn_v, 0xff, sizeof(fn_v));
+ fn_v[0] = (void *) GetProcAddress(hwinspool, "OpenPrinterW");
+ fn_v[1] = (void *) GetProcAddress(hwinspool, "ClosePrinter");
+ fn_v[2] = (void *) GetProcAddress(hwinspool, "SpoolerDevQueryPrintW");
+ fn_v[3] = (void *) GetProcAddress(hwinspool, "SpoolerPrinterEvent");
+ fn_v[4] = (void *) GetProcAddress(hwinspool, "DocumentPropertiesW");
+ fn_v[5] = (void *) GetProcAddress(hwinspool, (LPSTR) 212); /* LoadPrinterDriver */
+ fn_v[6] = (void *) GetProcAddress(hwinspool, (LPSTR) 213); /* RefCntLoadDriver */
+ fn_v[7] = (void *) GetProcAddress(hwinspool, (LPSTR) 214); /* RefCntUnloadDriver */
+ fn_v[8] = (void *) GetProcAddress(hwinspool, (LPSTR) 215); /* ForceUnloadDriver */
+ fn_v[9] = (void *) GetProcAddress(hwinspool, (LPSTR) 251); /* 0xfb */
+
return NULL;
}
@@ -104,19 +118,37 @@ static void test_BuildOtherNamesFromMachineName(void)
buffers = NULL;
numentries = 0;
+ if ((!pBuildOtherNamesFromMachineName) || (!pFreeOtherNames)) {
+ skip("BuildOtherNamesFromMachineName or FreeOtherNames not found\n");
+ return;
+ }
+
+ /* using NULL as parameter for BuildOtherNamesFromMachineName result in a crash */
SetLastError(0xdeadbeef);
res = pBuildOtherNamesFromMachineName(&buffers, &numentries);
- /* An array with 3 stringpointer is returned:
+ /* An array with 3 or more stringpointer is returned:
entry_#0: "" (empty String)
entry_#1: <hostname> (this is the same as the computername)
- entry_#2: <ip-address> (string with the ip-address of <hostname>)
+ entry_#2: <ip-address> (string with an ip-address for <hostname>)
+ entry_#3: <ip-address> (string with an ip-address for <hostname>)
+ ...
*/
todo_wine
- ok( res && (buffers != NULL) && (numentries == 3) && (buffers[0] != NULL) && (buffers[0][0] == '\0'),
- "got %u with %u and %p,%u (%p:%d)\n", res, GetLastError(), buffers, numentries,
- ((numentries > 0) && buffers) ? buffers[0] : NULL,
- ((numentries > 0) && buffers && buffers[0]) ? lstrlenW(buffers[0]) : -1);
+ ok( res && (buffers != NULL) && (numentries >= 3),
+ "got %u with %u and %p (%u entries)\n", res, GetLastError(), buffers, numentries);
+
+ /* validate the results */
+ if ( res && (buffers != NULL) && (numentries >= 3)) {
+ ok(buffers[0] && !buffers[0][0],
+ "#0: %p has len %d (expected an empty string)\n", buffers[0], lstrlenW(buffers[0]));
+ }
+
+ /* using NULL as parameter for FreeOtherNames result in a crash */
+ /* both variables are returned unchanged */
+ SetLastError(0xdeadbeef);
+ res = pFreeOtherNames(&buffers, &numentries);
+ ok(res, "got %u with %u for %p and %u\n", res, GetLastError(), buffers, numentries);
}
@@ -124,21 +156,33 @@ static void test_BuildOtherNamesFromMachineName(void)
static void test_SplInitializeWinSpoolDrv(VOID)
{
+ LPVOID *fn_ref = fn_xp;
DWORD res;
LONG id;
- BOOL is_xp;
+
+ if (!pSplInitializeWinSpoolDrv) {
+ skip("SplInitializeWinSpoolDrv not found\n");
+ return;
+ }
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]);
+ /* functions 0 to 5 are the same in "spoolss.dll" from w2k and above */
+ if (fn_spl[6] == fn_w2k[6]) {
+ fn_ref = fn_w2k;
+ }
+ if (fn_spl[9] == fn_v[9]) {
+ fn_ref = fn_v;
+ }
+
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]);
+ ok( fn_spl[id] == fn_ref[id],
+ "(#%02u) spoolss: %p (vista: %p, xp: %p, w2k: %p)\n", id,
+ fn_spl[id], fn_v[id], fn_xp[id], fn_w2k[id]);
id++;
}
}
@@ -149,7 +193,6 @@ START_TEST(spoolss)
{
LPCSTR ptr;
- /* spoolss.dll does not exist on win9x */
ptr = load_functions();
if (ptr) {
skip("%s not found\n", ptr);
--
1.5.4.3
--=-7Z+Ea+zBnSRtLO+fJdAD--
More information about the wine-patches
mailing list