[PATCH] user32/tests: Avoid crash on win9x in dde
Detlef Riekenberg
wine.dev at web.de
Wed Oct 29 17:37:31 CDT 2008
---
dlls/user32/tests/dde.c | 173 ++++++++++++++++++++++++++++++-----------------
1 files changed, 112 insertions(+), 61 deletions(-)
diff --git a/dlls/user32/tests/dde.c b/dlls/user32/tests/dde.c
index 968cd26..3cce3e0 100644
--- a/dlls/user32/tests/dde.c
+++ b/dlls/user32/tests/dde.c
@@ -40,6 +40,28 @@ static WCHAR exec_cmdW[] = {'u','n','i','c','o','d','e',' ','d','d','e',' ','c',
static WNDPROC old_dde_client_wndproc;
static const DWORD default_timeout = 200;
+static BOOL is_win9x;
+
+/* #################### */
+
+static BOOL check_os(void)
+{
+ LPARAM lparam;
+ BOOL res;
+
+ /* win9x returns 0, NT returns a HGLOBAL */
+ lparam = PackDDElParam(WM_DDE_POKE, 0, 0xbeef);
+
+ res = FreeDDElParam(WM_DDE_POKE, lparam);
+ if (!res || (lparam == 0)) {
+ win_skip("%d, 0x%lx: some WM_DDE_* features are not supported\n", res, lparam);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/* #################### */
static void flush_events(void)
{
@@ -1055,9 +1077,14 @@ static void test_msg_client()
/* WM_DDE_POKE, no ddepoke */
lparam = PackDDElParam(WM_DDE_POKE, 0, item);
- PostMessageA(server_hwnd, WM_DDE_POKE, (WPARAM)client_hwnd, lparam);
+ /* win9x returns 0 here and crash in PostMessageA */
+ if (lparam) {
+ PostMessageA(server_hwnd, WM_DDE_POKE, (WPARAM)client_hwnd, lparam);
+ flush_events();
+ }
+ else
+ ok(broken(is_win9x), "no lparam for WM_DDE_POKE\n");
- flush_events();
/* WM_DDE_POKE, no item */
lparam = PackDDElParam(WM_DDE_POKE, (UINT_PTR)hglobal, 0);
@@ -1522,15 +1549,17 @@ static void test_DdeCreateDataHandle(void)
item = DdeCreateStringHandleA(dde_inst, "item", CP_WINANSI);
ok(item != NULL, "Expected non-NULL hsz\n");
- /* invalid instance id */
- DdeGetLastError(dde_inst);
- hdata = DdeCreateDataHandle(0xdeadbeef, (LPBYTE)"data", MAX_PATH, 0, item, CF_TEXT, 0);
- err = DdeGetLastError(dde_inst);
- todo_wine
- {
- ok(hdata == NULL, "Expected NULL, got %p\n", hdata);
- ok(err == DMLERR_INVALIDPARAMETER,
- "Expected DMLERR_INVALIDPARAMETER, got %d\n", err);
+ /* invalid instance id (this crash on win9x) */
+ if (!is_win9x) {
+ DdeGetLastError(dde_inst);
+ hdata = DdeCreateDataHandle(0xdeadbeef, (LPBYTE)"data", MAX_PATH, 0, item, CF_TEXT, 0);
+ err = DdeGetLastError(dde_inst);
+ todo_wine
+ {
+ ok(hdata == NULL, "Expected NULL, got %p\n", hdata);
+ ok(err == DMLERR_INVALIDPARAMETER,
+ "Expected DMLERR_INVALIDPARAMETER, got %d\n", err);
+ }
}
/* 0 instance id */
@@ -1826,19 +1855,24 @@ static void test_PackDDElParam(void)
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
lparam = PackDDElParam(WM_DDE_ADVISE, 0xcafe, 0xbeef);
- ptr = GlobalLock((HGLOBAL)lparam);
- ok(ptr != NULL, "Expected non-NULL ptr\n");
- ok(ptr[0] == 0xcafe, "Expected 0xcafe, got %08lx\n", ptr[0]);
- ok(ptr[1] == 0xbeef, "Expected 0xbeef, got %08lx\n", ptr[1]);
+ /* win9x returns 0 here */
+ if (lparam) {
+ ptr = GlobalLock((HGLOBAL)lparam);
+ ok(ptr != NULL, "Expected non-NULL ptr\n");
+ ok(ptr[0] == 0xcafe, "Expected 0xcafe, got %08lx\n", ptr[0]);
+ ok(ptr[1] == 0xbeef, "Expected 0xbeef, got %08lx\n", ptr[1]);
- ret = GlobalUnlock((HGLOBAL)lparam);
- ok(ret == 1, "Expected 1, got %d\n", ret);
+ ret = GlobalUnlock((HGLOBAL)lparam);
+ ok(ret == 1, "Expected 1, got %d\n", ret);
- lo = hi = 0;
- ret = UnpackDDElParam(WM_DDE_ADVISE, lparam, &lo, &hi);
- ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
- ok(lo == 0xcafe, "Expected 0xcafe, got %08lx\n", lo);
- ok(hi == 0xbeef, "Expected 0xbeef, got %08lx\n", hi);
+ lo = hi = 0;
+ ret = UnpackDDElParam(WM_DDE_ADVISE, lparam, &lo, &hi);
+ ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
+ ok(lo == 0xcafe, "Expected 0xcafe, got %08lx\n", lo);
+ ok(hi == 0xbeef, "Expected 0xbeef, got %08lx\n", hi);
+ }
+ else
+ ok(broken(is_win9x), "no lparam for WM_DDE_ADVISE\n");
ret = FreeDDElParam(WM_DDE_ADVISE, lparam);
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
@@ -1865,42 +1899,52 @@ static void test_PackDDElParam(void)
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
lparam = PackDDElParam(WM_DDE_ACK, 0xcafe, 0xbeef);
- ptr = GlobalLock((HGLOBAL)lparam);
- ok(ptr != NULL, "Expected non-NULL ptr\n");
- ok(ptr[0] == 0xcafe, "Expected 0xcafe, got %08lx\n", ptr[0]);
- ok(ptr[1] == 0xbeef, "Expected 0xbeef, got %08lx\n", ptr[1]);
+ /* win9x returns the input (0xbeef<<16 | 0xcafe) here */
+ if (lparam != 0xbeefcafe) {
+ ptr = GlobalLock((HGLOBAL)lparam);
+ ok(ptr != NULL, "Expected non-NULL ptr\n");
+ ok(ptr[0] == 0xcafe, "Expected 0xcafe, got %08lx\n", ptr[0]);
+ ok(ptr[1] == 0xbeef, "Expected 0xbeef, got %08lx\n", ptr[1]);
- ret = GlobalUnlock((HGLOBAL)lparam);
- ok(ret == 1, "Expected 1, got %d\n", ret);
+ ret = GlobalUnlock((HGLOBAL)lparam);
+ ok(ret == 1, "Expected 1, got %d\n", ret);
- lo = hi = 0;
- ret = UnpackDDElParam(WM_DDE_ACK, lparam, &lo, &hi);
- ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
- ok(lo == 0xcafe, "Expected 0xcafe, got %08lx\n", lo);
- ok(hi == 0xbeef, "Expected 0xbeef, got %08lx\n", hi);
+ lo = hi = 0;
+ ret = UnpackDDElParam(WM_DDE_ACK, lparam, &lo, &hi);
+ ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
+ ok(lo == 0xcafe, "Expected 0xcafe, got %08lx\n", lo);
+ ok(hi == 0xbeef, "Expected 0xbeef, got %08lx\n", hi);
- ret = FreeDDElParam(WM_DDE_ACK, lparam);
- ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
+ ret = FreeDDElParam(WM_DDE_ACK, lparam);
+ ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
- hglobal = GlobalFree((HGLOBAL)lparam);
- ok(hglobal == (HGLOBAL)lparam, "Expected lparam, got %d\n", ret);
- ok(GetLastError() == ERROR_INVALID_HANDLE,
- "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
+ hglobal = GlobalFree((HGLOBAL)lparam);
+ ok(hglobal == (HGLOBAL)lparam, "Expected lparam, got %d\n", ret);
+ ok(GetLastError() == ERROR_INVALID_HANDLE,
+ "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
+ }
+ else
+ ok(broken(is_win9x), "got lparam 0x%lx for WM_DDE_ACK\n", lparam);
lparam = PackDDElParam(WM_DDE_DATA, 0xcafe, 0xbeef);
- ptr = GlobalLock((HGLOBAL)lparam);
- ok(ptr != NULL, "Expected non-NULL ptr\n");
- ok(ptr[0] == 0xcafe, "Expected 0xcafe, got %08lx\n", ptr[0]);
- ok(ptr[1] == 0xbeef, "Expected 0xbeef, got %08lx\n", ptr[1]);
+ /* win9x returns 0 here */
+ if (lparam) {
+ ptr = GlobalLock((HGLOBAL)lparam);
+ ok(ptr != NULL, "Expected non-NULL ptr\n");
+ ok(ptr[0] == 0xcafe, "Expected 0xcafe, got %08lx\n", ptr[0]);
+ ok(ptr[1] == 0xbeef, "Expected 0xbeef, got %08lx\n", ptr[1]);
- ret = GlobalUnlock((HGLOBAL)lparam);
- ok(ret == 1, "Expected 1, got %d\n", ret);
+ ret = GlobalUnlock((HGLOBAL)lparam);
+ ok(ret == 1, "Expected 1, got %d\n", ret);
- lo = hi = 0;
- ret = UnpackDDElParam(WM_DDE_DATA, lparam, &lo, &hi);
- ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
- ok(lo == 0xcafe, "Expected 0xcafe, got %08lx\n", lo);
- ok(hi == 0xbeef, "Expected 0xbeef, got %08lx\n", hi);
+ lo = hi = 0;
+ ret = UnpackDDElParam(WM_DDE_DATA, lparam, &lo, &hi);
+ ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
+ ok(lo == 0xcafe, "Expected 0xcafe, got %08lx\n", lo);
+ ok(hi == 0xbeef, "Expected 0xbeef, got %08lx\n", hi);
+ }
+ else
+ ok(broken(is_win9x), "no lparam for WM_DDE_DATA\n");
ret = FreeDDElParam(WM_DDE_DATA, lparam);
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
@@ -1927,19 +1971,24 @@ static void test_PackDDElParam(void)
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
lparam = PackDDElParam(WM_DDE_POKE, 0xcafe, 0xbeef);
- ptr = GlobalLock((HGLOBAL)lparam);
- ok(ptr != NULL, "Expected non-NULL ptr\n");
- ok(ptr[0] == 0xcafe, "Expected 0xcafe, got %08lx\n", ptr[0]);
- ok(ptr[1] == 0xbeef, "Expected 0xbeef, got %08lx\n", ptr[1]);
+ /* win9x returns 0 here */
+ if (lparam) {
+ ptr = GlobalLock((HGLOBAL)lparam);
+ ok(ptr != NULL, "Expected non-NULL ptr\n");
+ ok(ptr[0] == 0xcafe, "Expected 0xcafe, got %08lx\n", ptr[0]);
+ ok(ptr[1] == 0xbeef, "Expected 0xbeef, got %08lx\n", ptr[1]);
- ret = GlobalUnlock((HGLOBAL)lparam);
- ok(ret == 1, "Expected 1, got %d\n", ret);
+ ret = GlobalUnlock((HGLOBAL)lparam);
+ ok(ret == 1, "Expected 1, got %d\n", ret);
- lo = hi = 0;
- ret = UnpackDDElParam(WM_DDE_POKE, lparam, &lo, &hi);
- ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
- ok(lo == 0xcafe, "Expected 0xcafe, got %08lx\n", lo);
- ok(hi == 0xbeef, "Expected 0xbeef, got %08lx\n", hi);
+ lo = hi = 0;
+ ret = UnpackDDElParam(WM_DDE_POKE, lparam, &lo, &hi);
+ ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
+ ok(lo == 0xcafe, "Expected 0xcafe, got %08lx\n", lo);
+ ok(hi == 0xbeef, "Expected 0xbeef, got %08lx\n", hi);
+ }
+ else
+ ok(broken(is_win9x), "no lparam for WM_DDE_POKE\n");
ret = FreeDDElParam(WM_DDE_POKE, lparam);
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
@@ -2393,6 +2442,8 @@ START_TEST(dde)
STARTUPINFO startup;
PROCESS_INFORMATION proc;
+ /* some tests crash on win9x. skip them, when needed */
+ is_win9x = check_os();
argc = winetest_get_mainargs(&argv);
if (argc == 3)
{
--
1.5.4.3
--=-GBs5IEcCAf8IEQQ1spRA--
More information about the wine-patches
mailing list