[04/11] ddraw/tests: Fix test failure/crash on VMware.

Octavian Voicu octavian.voicu at gmail.com
Mon Nov 7 16:27:07 CST 2011


--
Locking a P8 primary surface fails on VMware, leading to a crash.

Currently this test is never reached because of an earlier skip,
but this will change in a subsequent patch.
---
 dlls/ddraw/tests/visual.c |   21 +++++++++++++--------
 1 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/dlls/ddraw/tests/visual.c b/dlls/ddraw/tests/visual.c
index eef09ff..a2efd72 100644
--- a/dlls/ddraw/tests/visual.c
+++ b/dlls/ddraw/tests/visual.c
@@ -2430,7 +2430,7 @@ static void D3D3_ViewportClearTest(void)
     window = NULL;
 }
 
-static void p8_surface_fill_rect(IDirectDrawSurface *dest, UINT x, UINT y, UINT w, UINT h, BYTE colorindex)
+static HRESULT p8_surface_fill_rect(IDirectDrawSurface *dest, UINT x, UINT y, UINT w, UINT h, BYTE colorindex)
 {
     DDSURFACEDESC ddsd;
     HRESULT hr;
@@ -2441,7 +2441,9 @@ static void p8_surface_fill_rect(IDirectDrawSurface *dest, UINT x, UINT y, UINT
     ddsd.dwSize = sizeof(ddsd);
 
     hr = IDirectDrawSurface_Lock(dest, NULL, &ddsd, DDLOCK_WRITEONLY | DDLOCK_WAIT, NULL);
-    ok(hr==DD_OK, "IDirectDrawSurface_Lock returned: %x\n", hr);
+    ok(hr==DD_OK || broken(DDERR_CANTLOCKSURFACE) /* VMware */, "IDirectDrawSurface_Lock returned: %x\n", hr);
+    if (!SUCCEEDED(hr))
+        return hr;
 
     p = (BYTE *)ddsd.lpSurface + U1(ddsd).lPitch * y + x;
 
@@ -2454,6 +2456,8 @@ static void p8_surface_fill_rect(IDirectDrawSurface *dest, UINT x, UINT y, UINT
 
     hr = IDirectDrawSurface_Unlock(dest, NULL);
     ok(hr==DD_OK, "IDirectDrawSurface_UnLock returned: %x\n", hr);
+
+    return hr;
 }
 
 static COLORREF getPixelColor_GDI(IDirectDrawSurface *Surface, UINT x, UINT y)
@@ -2555,12 +2559,13 @@ static void p8_primary_test(void)
     hr = IDirectDrawSurface_SetPalette(Primary1, ddprimpal);
     ok(hr==DD_OK, "IDirectDrawSurface_SetPalette returned: %x\n", hr);
 
-    p8_surface_fill_rect(Primary1, 0, 0, 640, 480, 2);
-
-    color = getPixelColor_GDI(Primary1, 10, 10);
-    ok(GetRValue(color) == 0 && GetGValue(color) == 0 && GetBValue(color) == 0xFF,
-            "got R %02X G %02X B %02X, expected R 00 G 00 B FF\n",
-            GetRValue(color), GetGValue(color), GetBValue(color));
+    hr = p8_surface_fill_rect(Primary1, 0, 0, 640, 480, 2);
+    if (SUCCEEDED(hr)) {
+        color = getPixelColor_GDI(Primary1, 10, 10);
+        ok(GetRValue(color) == 0 && GetGValue(color) == 0 && GetBValue(color) == 0xFF,
+                "got R %02X G %02X B %02X, expected R 00 G 00 B FF\n",
+                GetRValue(color), GetGValue(color), GetBValue(color));
+    }
 
     memset(&ddbltfx, 0, sizeof(ddbltfx));
     ddbltfx.dwSize = sizeof(ddbltfx);
-- 
1.7.4.1




More information about the wine-patches mailing list