localspl/tests: Improve the tests in test_XcvDataPort_AddPort by properly checking return values and avoiding a duplicate test. (try 2)

Gerald Pfeifer gerald at pfeifer.com
Sun May 9 05:48:34 CDT 2010


Turns out I had submitted a patch against the wrong tree since an 
earlier patch of mine had now caused a conflict.  My bad, sorry.

This one passes testing at the Wine Test Bot, cf.
  https://testbot.winehq.org/JobDetails.pl?Key=1975

Gerald

---
diff --git a/dlls/localspl/tests/localmon.c b/dlls/localspl/tests/localmon.c
index 496be71..413a95a 100644
--- a/dlls/localspl/tests/localmon.c
+++ b/dlls/localspl/tests/localmon.c
@@ -775,6 +775,8 @@ static void test_XcvClosePort(void)
 
 static void test_XcvDataPort_AddPort(void)
 {
+    DWORD   res;
+
     /*
      * 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.
@@ -787,28 +789,28 @@ static void test_XcvDataPort_AddPort(void)
     {
     /* create a Port for a normal, writable file */
     SetLastError(0xdeadbeef);
-    pXcvDataPort(hXcv, cmd_AddPortW, (PBYTE) tempfileW, (lstrlenW(tempfileW) + 1) * sizeof(WCHAR), NULL, 0, NULL);
+    res = pXcvDataPort(hXcv, cmd_AddPortW, (PBYTE) tempfileW, (lstrlenW(tempfileW) + 1) * sizeof(WCHAR), NULL, 0, NULL);
+    ok( res == ERROR_SUCCESS, "returned %d with %u (expected ERROR_SUCCESS)\n", res, GetLastError());
 
     /* add our testport again */
     SetLastError(0xdeadbeef);
-    pXcvDataPort(hXcv, cmd_AddPortW, (PBYTE) tempfileW, (lstrlenW(tempfileW) + 1) * sizeof(WCHAR), NULL, 0, NULL);
+    res = pXcvDataPort(hXcv, cmd_AddPortW, (PBYTE) tempfileW, (lstrlenW(tempfileW) + 1) * sizeof(WCHAR), NULL, 0, NULL);
+    ok( res == ERROR_ALREADY_EXISTS, "returned %d with %u (expected ERROR_ALREADY_EXISTS)\n", res, GetLastError());
 
     /* create a well-known Port  */
     SetLastError(0xdeadbeef);
-    pXcvDataPort(hXcv, cmd_AddPortW, (PBYTE) portname_lpt1W, (lstrlenW(portname_lpt1W) + 1) * sizeof(WCHAR), NULL, 0, NULL);
-
-    SetLastError(0xdeadbeef);
-    pXcvDataPort(hXcv, cmd_AddPortW, (PBYTE) portname_lpt1W, (lstrlenW(portname_lpt1W) + 1) * sizeof(WCHAR), NULL, 0, NULL);
-    /* native localspl.dll on wine: ERROR_ALREADY_EXISTS */
+    res = pXcvDataPort(hXcv, cmd_AddPortW, (PBYTE) portname_lpt1W, (lstrlenW(portname_lpt1W) + 1) * sizeof(WCHAR), NULL, 0, NULL);
+    ok( res == ERROR_ALREADY_EXISTS, "returned %d with %u (expected ERROR_ALREADY_EXISTS)\n", res, GetLastError());
 
     /* ERROR_ALREADY_EXISTS is also returned from native localspl.dll on wine,
        when "RPT1:" was already installed for redmonnt.dll:
-       pXcvDataPort(hXcv, cmd_AddPortW, (PBYTE) portname_rpt1W, ...
+       res = pXcvDataPort(hXcv, cmd_AddPortW, (PBYTE) portname_rpt1W, ...
     */
 
     /* cleanup */
     SetLastError(0xdeadbeef);
-    pXcvDataPort(hXcv, cmd_DeletePortW, (PBYTE) tempfileW, (lstrlenW(tempfileW) + 1) * sizeof(WCHAR), NULL, 0, NULL);
+    res = pXcvDataPort(hXcv, cmd_DeletePortW, (PBYTE) tempfileW, (lstrlenW(tempfileW) + 1) * sizeof(WCHAR), NULL, 0, NULL);
+    ok( res == ERROR_SUCCESS, "returned %d with %u (expected ERROR_SUCCESS)\n", res, GetLastError());
     }
 
 }



More information about the wine-patches mailing list