Detlef Riekenberg : localspl/tests: Add tests for XcvDataPort_AddPort.

Alexandre Julliard julliard at wine.codeweavers.com
Fri Mar 16 07:20:21 CDT 2007


Module: wine
Branch: master
Commit: e3c778eb58dcb2efa38ebd1f64fb41f135611d47
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=e3c778eb58dcb2efa38ebd1f64fb41f135611d47

Author: Detlef Riekenberg <wine.dev at web.de>
Date:   Thu Mar 15 22:47:13 2007 +0100

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..2770862 100644
--- a/dlls/localspl/tests/localmon.c
+++ b/dlls/localspl/tests/localmon.c
@@ -66,6 +66,7 @@ static BOOL  (WINAPI *pConfigurePortUI)(PCWSTR, HWND, PCWSTR);
 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);




More information about the wine-cvs mailing list