localspl/tests: [1/2] Rename hXcv for special tests
Detlef Riekenberg
wine.dev at web.de
Sun Mar 18 18:09:26 CDT 2007
We open and close the Xcv-Channel in every test.
That is not needed for most cases.
localspl/tests: Rename hXcv for special tests
Next step is open and close hXcv only once and
reuse that handle
--
By by ... Detlef
-------------- next part --------------
>From d0e4176f522758ddaf0d75da62a7fe9e3e731931 Mon Sep 17 00:00:00 2001
From: Detlef Riekenberg <wine.dev at web.de>
Date: Sun, 18 Mar 2007 19:37:33 +0100
Subject: [PATCH] localspl/tests: Rename hXcv for special tests
---
dlls/localspl/tests/localmon.c | 79 +++++++++++++++++++---------------------
1 files changed, 38 insertions(+), 41 deletions(-)
diff --git a/dlls/localspl/tests/localmon.c b/dlls/localspl/tests/localmon.c
index 7030b1f..db43907 100644
--- a/dlls/localspl/tests/localmon.c
+++ b/dlls/localspl/tests/localmon.c
@@ -65,6 +65,9 @@ static BOOL (WINAPI *pAddPortUI)(PCWSTR
static BOOL (WINAPI *pConfigurePortUI)(PCWSTR, HWND, PCWSTR);
static BOOL (WINAPI *pDeletePortUI)(PCWSTR, HWND, PCWSTR);
+static HANDLE hXcv_noaccess;
+
+/* ########################### */
static const WCHAR cmd_AddPortW[] = {'A','d','d','P','o','r','t',0};
static const WCHAR cmd_ConfigureLPTPortCommandOKW[] = {'C','o','n','f','i','g','u','r','e',
@@ -345,7 +348,7 @@ static void test_InitializePrintMonitor(
static void test_XcvClosePort(void)
{
DWORD res;
- HANDLE hXcv;
+ HANDLE hXcv2;
if (0)
@@ -357,19 +360,19 @@ static void test_XcvClosePort(void)
SetLastError(0xdeadbeef);
- hXcv = (HANDLE) 0xdeadbeef;
- res = pXcvOpenPort(emptyW, SERVER_ACCESS_ADMINISTER, &hXcv);
- ok(res, "returned %d with %u and %p (expected '!= 0')\n", res, GetLastError(), hXcv);
+ hXcv2 = (HANDLE) 0xdeadbeef;
+ res = pXcvOpenPort(emptyW, SERVER_ACCESS_ADMINISTER, &hXcv2);
+ ok(res, "returned %d with %u and %p (expected '!= 0')\n", res, GetLastError(), hXcv2);
if (res) {
SetLastError(0xdeadbeef);
- res = pXcvClosePort(hXcv);
+ res = pXcvClosePort(hXcv2);
ok( res, "returned %d with %u (expected '!= 0')\n", res, GetLastError());
if (0)
{
/* test for "Double Free": crash with native localspl.dll (w2k+xp) */
- res = pXcvClosePort(hXcv);
+ res = pXcvClosePort(hXcv2);
}
}
}
@@ -797,22 +800,15 @@ static void test_XcvDataPort_MonitorUI(v
/* small check without access-rights: */
- hXcv = (HANDLE) 0xdeadbeef;
- SetLastError(0xdeadbeef);
- res = pXcvOpenPort(emptyW, 0, &hXcv);
- ok(res, "returned %d with %u and %p (expected '!= 0')\n", res, GetLastError(), hXcv);
- if (!res) return;
+ if (!hXcv_noaccess) return;
/* The ACCESS_MASK is ignored for "MonitorUI" */
memset(buffer, 0, len);
needed = (DWORD) 0xdeadbeef;
SetLastError(0xdeadbeef);
- res = pXcvDataPort(hXcv, cmd_MonitorUIW, NULL, 0, buffer, sizeof(buffer), &needed);
+ res = pXcvDataPort(hXcv_noaccess, cmd_MonitorUIW, NULL, 0, buffer, sizeof(buffer), &needed);
ok( res == ERROR_SUCCESS, "returned %d with %u and 0x%x "
"(expected 'ERROR_SUCCESS')\n", res, GetLastError(), needed);
-
- pXcvClosePort(hXcv);
-
}
/* ########################### */
@@ -956,20 +952,14 @@ static void test_XcvDataPort_PortIsValid
/* small check without access-rights: */
- hXcv = (HANDLE) 0xdeadbeef;
- SetLastError(0xdeadbeef);
- res = pXcvOpenPort(emptyW, 0, &hXcv);
- ok(res, "returned %d with %u and %p (expected '!= 0')\n", res, GetLastError(), hXcv);
- if (!res) return;
+ if (!hXcv_noaccess) return;
/* The ACCESS_MASK from XcvOpenPort is ignored in "PortIsValid" */
needed = (DWORD) 0xdeadbeef;
SetLastError(0xdeadbeef);
- res = pXcvDataPort(hXcv, cmd_PortIsValidW, (PBYTE) portname_lpt1W, sizeof(portname_lpt1W), NULL, 0, &needed);
+ res = pXcvDataPort(hXcv_noaccess, cmd_PortIsValidW, (PBYTE) portname_lpt1W, sizeof(portname_lpt1W), NULL, 0, &needed);
ok( res == ERROR_SUCCESS, "returned %d with %u (expected ERROR_SUCCESS)\n", res, GetLastError());
- pXcvClosePort(hXcv);
-
}
/* ########################### */
@@ -977,45 +967,45 @@ static void test_XcvDataPort_PortIsValid
static void test_XcvOpenPort(void)
{
DWORD res;
- HANDLE hXcv;
+ HANDLE hXcv2;
if (0)
{
/* crash with native localspl.dll (w2k+xp) */
- res = pXcvOpenPort(NULL, SERVER_ACCESS_ADMINISTER, &hXcv);
+ res = pXcvOpenPort(NULL, SERVER_ACCESS_ADMINISTER, &hXcv2);
res = pXcvOpenPort(emptyW, SERVER_ACCESS_ADMINISTER, NULL);
}
/* The returned handle is the result from a previous "spoolss.dll,DllAllocSplMem" */
SetLastError(0xdeadbeef);
- hXcv = (HANDLE) 0xdeadbeef;
- res = pXcvOpenPort(emptyW, SERVER_ACCESS_ADMINISTER, &hXcv);
- ok(res, "returned %d with %u and %p (expected '!= 0')\n", res, GetLastError(), hXcv);
- if (res) pXcvClosePort(hXcv);
+ hXcv2 = (HANDLE) 0xdeadbeef;
+ res = pXcvOpenPort(emptyW, SERVER_ACCESS_ADMINISTER, &hXcv2);
+ ok(res, "returned %d with %u and %p (expected '!= 0')\n", res, GetLastError(), hXcv2);
+ if (res) pXcvClosePort(hXcv2);
/* The ACCESS_MASK is not checked in XcvOpenPort */
SetLastError(0xdeadbeef);
- hXcv = (HANDLE) 0xdeadbeef;
- res = pXcvOpenPort(emptyW, 0, &hXcv);
- ok(res, "returned %d with %u and %p (expected '!= 0')\n", res, GetLastError(), hXcv);
- if (res) pXcvClosePort(hXcv);
+ hXcv2 = (HANDLE) 0xdeadbeef;
+ res = pXcvOpenPort(emptyW, 0, &hXcv2);
+ ok(res, "returned %d with %u and %p (expected '!= 0')\n", res, GetLastError(), hXcv2);
+ if (res) pXcvClosePort(hXcv2);
/* A copy of pszObject is saved in the Memory-Block */
SetLastError(0xdeadbeef);
- hXcv = (HANDLE) 0xdeadbeef;
- res = pXcvOpenPort(portname_lpt1W, SERVER_ALL_ACCESS, &hXcv);
- ok(res, "returned %d with %u and %p (expected '!= 0')\n", res, GetLastError(), hXcv);
- if (res) pXcvClosePort(hXcv);
+ hXcv2 = (HANDLE) 0xdeadbeef;
+ res = pXcvOpenPort(portname_lpt1W, SERVER_ALL_ACCESS, &hXcv2);
+ ok(res, "returned %d with %u and %p (expected '!= 0')\n", res, GetLastError(), hXcv2);
+ if (res) pXcvClosePort(hXcv2);
SetLastError(0xdeadbeef);
- hXcv = (HANDLE) 0xdeadbeef;
- res = pXcvOpenPort(portname_fileW, SERVER_ALL_ACCESS, &hXcv);
- ok(res, "returned %d with %u and %p (expected '!= 0')\n", res, GetLastError(), hXcv);
- if (res) pXcvClosePort(hXcv);
+ hXcv2 = (HANDLE) 0xdeadbeef;
+ res = pXcvOpenPort(portname_fileW, SERVER_ALL_ACCESS, &hXcv2);
+ ok(res, "returned %d with %u and %p (expected '!= 0')\n", res, GetLastError(), hXcv2);
+ if (res) pXcvClosePort(hXcv2);
}
@@ -1084,6 +1074,12 @@ START_TEST(localmon)
GET_MONITOR_FUNC(XcvOpenPort);
GET_MONITOR_FUNC(XcvDataPort);
GET_MONITOR_FUNC(XcvClosePort);
+
+ if ((pXcvOpenPort) && (pXcvDataPort) && (pXcvClosePort)) {
+ SetLastError(0xdeadbeef);
+ res = pXcvOpenPort(emptyW, 0, &hXcv_noaccess);
+ ok(res, "hXcv_noaccess: %d with %u and %p (expected '!= 0')\n", res, GetLastError(), hXcv_noaccess);
+ }
}
if ((!pInitializePrintMonitorUI) && (pXcvOpenPort) && (pXcvDataPort) && (pXcvClosePort)) {
@@ -1137,6 +1133,7 @@ START_TEST(localmon)
test_XcvDataPort_PortIsValid();
test_XcvOpenPort();
}
+ if (hXcv_noaccess) pXcvClosePort(hXcv_noaccess);
/* Cleanup our temporary file */
DeleteFileW(tempfileW);
--
1.4.1
More information about the wine-patches
mailing list