localspl/tests: [1/2] Add tests for XcvDataPort_AddPort
Detlef Riekenberg
wine.dev at web.de
Thu Mar 15 16:47:13 CDT 2007
localspl/tests: Add tests for XcvDataPort_AddPort
--
By by ... Detlef
-------------- next part --------------
>From db56280ff413df7ac163ab6021acbeb1a5ad7b71 Mon Sep 17 00:00:00 2001
From: Detlef Riekenberg <wine.dev at web.de>
Date: Thu, 15 Mar 2007 22:40:04 +0100
Subject: [PATCH] localspl/tests: Add tests for XcvDataPort_AddPort
---
dlls/localspl/tests/localmon.c | 75 ++++++++++++++++++++++++++++++++++++----
1 files changed, 68 insertions(+), 7 deletions(-)
diff --git a/dlls/localspl/tests/localmon.c b/dlls/localspl/tests/localmon.c
index bce9a48..210b60e 100644
--- a/dlls/localspl/tests/localmon.c
+++ b/dlls/localspl/tests/localmon.c
@@ -66,6 +66,7 @@ static BOOL (WINAPI *pConfigurePortUI)(
static BOOL (WINAPI *pDeletePortUI)(PCWSTR, HWND, PCWSTR);
+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',
'L','P','T','P','o','r','t',
'C','o','m','m','a','n','d','O','K',0};
@@ -376,6 +377,59 @@ static void test_XcvClosePort(void)
/* ########################### */
+static void test_XcvDataPort_AddPort(void)
+{
+ DWORD res;
+ HANDLE hXcv;
+
+
+ hXcv = (HANDLE) 0xdeadbeef;
+ SetLastError(0xdeadbeef);
+ res = pXcvOpenPort(emptyW, SERVER_ALL_ACCESS, &hXcv);
+ ok(res, "hXcv: %d with %u and %p (expected '!= 0')\n", res, GetLastError(), hXcv);
+ if (!res) return;
+
+ /*
+ * The following tests crash with native localspl.dll on w2k and xp,
+ * but it works, when the native dll (w2k and xp) is used in wine.
+ * also tested (same crash): replacing emptyW with portname_lpt1W
+ * and replacing "NULL, 0, NULL" with "buffer, MAX_PATH, &needed"
+ *
+ * We need to use a different API (AddPortEx) instead
+ */
+ if (0)
+ {
+ /* create a Port for a normal, writeable file */
+ SetLastError(0xdeadbeef);
+ res = pXcvDataPort(hXcv, cmd_AddPortW, (PBYTE) tempfileW, (lstrlenW(tempfileW) + 1) * sizeof(WCHAR), NULL, 0, NULL);
+
+ /* add our testport again */
+ SetLastError(0xdeadbeef);
+ res = pXcvDataPort(hXcv, cmd_AddPortW, (PBYTE) tempfileW, (lstrlenW(tempfileW) + 1) * sizeof(WCHAR), NULL, 0, NULL);
+
+ /* create a well-known Port */
+ SetLastError(0xdeadbeef);
+ res = pXcvDataPort(hXcv, cmd_AddPortW, (PBYTE) portname_lpt1W, (lstrlenW(portname_lpt1W) + 1) * sizeof(WCHAR), NULL, 0, NULL);
+
+ SetLastError(0xdeadbeef);
+ res = pXcvDataPort(hXcv, cmd_AddPortW, (PBYTE) portname_lpt1W, (lstrlenW(portname_lpt1W) + 1) * sizeof(WCHAR), NULL, 0, NULL);
+ /* native localspl.dll on wine: ERROR_ALREADY_EXISTS */
+
+ /* ERROR_ALREADY_EXISTS is also returned from native localspl.dll on wine,
+ when "RPT1:" was already installed for redmonnt.dll:
+ res = pXcvDataPort(hXcv, cmd_AddPortW, (PBYTE) portname_rpt1W, ...
+ */
+
+ /* cleanup */
+ SetLastError(0xdeadbeef);
+ res = pXcvDataPort(hXcv, cmd_DeletePortW, (PBYTE) tempfileW, (lstrlenW(tempfileW) + 1) * sizeof(WCHAR), NULL, 0, NULL);
+ }
+
+ pXcvClosePort(hXcv);
+}
+
+/* ########################### */
+
static void test_XcvDataPort_ConfigureLPTPortCommandOK(void)
{
CHAR org_value[16];
@@ -1080,13 +1134,20 @@ START_TEST(localmon)
test_ConfigurePort();
test_DeletePort();
test_EnumPorts();
- test_XcvClosePort();
- test_XcvDataPort_ConfigureLPTPortCommandOK();
- test_XcvDataPort_DeletePort();
- test_XcvDataPort_GetTransmissionRetryTimeout();
- test_XcvDataPort_MonitorUI();
- test_XcvDataPort_PortIsValid();
- test_XcvOpenPort();
+ if ((pXcvOpenPort == NULL) || (pXcvDataPort == NULL) || (pXcvClosePort == NULL)) {
+ skip("Xcv not supported\n");
+ }
+ else
+ {
+ test_XcvClosePort();
+ test_XcvDataPort_AddPort();
+ test_XcvDataPort_ConfigureLPTPortCommandOK();
+ test_XcvDataPort_DeletePort();
+ test_XcvDataPort_GetTransmissionRetryTimeout();
+ test_XcvDataPort_MonitorUI();
+ test_XcvDataPort_PortIsValid();
+ test_XcvOpenPort();
+ }
/* Cleanup our temporary file */
DeleteFileW(tempfileW);
--
1.4.1
More information about the wine-patches
mailing list