Rob Shearman : ole32: Fix some tests that fail on NT4 and Win9x.
Alexandre Julliard
julliard at winehq.org
Wed Jan 28 08:03:18 CST 2009
Module: wine
Branch: master
Commit: 9353dff5b3e07f2a2a65983c2311b54dc3792325
URL: http://source.winehq.org/git/wine.git/?a=commit;h=9353dff5b3e07f2a2a65983c2311b54dc3792325
Author: Rob Shearman <robertshearman at gmail.com>
Date: Wed Jan 28 12:48:40 2009 +0000
ole32: Fix some tests that fail on NT4 and Win9x.
Round the expected sizes up to the alignment used by HeapSize, which
is 4 on Win9x and NT4 but 1 in more recent versions.
Additionally fix an IGlobalInterfaceTable test which erroneously
succeeds on these older OSs.
---
dlls/ole32/tests/marshal.c | 20 ++++++++++++++++++--
dlls/ole32/tests/moniker.c | 25 +++++++++++++++++++------
2 files changed, 37 insertions(+), 8 deletions(-)
diff --git a/dlls/ole32/tests/marshal.c b/dlls/ole32/tests/marshal.c
index 316bcd4..ff72647 100644
--- a/dlls/ole32/tests/marshal.c
+++ b/dlls/ole32/tests/marshal.c
@@ -2040,6 +2040,19 @@ static void test_WM_QUIT_handling(void)
}
}
+static SIZE_T round_heap_size(SIZE_T size)
+{
+ static SIZE_T heap_size_alignment = -1;
+ if (heap_size_alignment == -1)
+ {
+ void *p = HeapAlloc(GetProcessHeap(), 0, 1);
+ heap_size_alignment = HeapSize(GetProcessHeap(), 0, p);
+ HeapFree(GetProcessHeap(), 0, p);
+ }
+
+ return ((size + heap_size_alignment - 1) & ~(heap_size_alignment - 1));
+}
+
static void test_freethreadedmarshaldata(IStream *pStream, MSHCTX mshctx, void *ptr, DWORD mshlflags)
{
HGLOBAL hglobal;
@@ -2056,7 +2069,7 @@ static void test_freethreadedmarshaldata(IStream *pStream, MSHCTX mshctx, void *
if (mshctx == MSHCTX_INPROC)
{
- DWORD expected_size = 3*sizeof(DWORD) + sizeof(GUID);
+ DWORD expected_size = round_heap_size(3*sizeof(DWORD) + sizeof(GUID));
ok(size == expected_size, "size should have been %d instead of %d\n", expected_size, size);
ok(*(DWORD *)marshal_data == mshlflags, "expected 0x%x, but got 0x%x for mshctx\n", mshlflags, *(DWORD *)marshal_data);
@@ -2715,9 +2728,12 @@ static DWORD CALLBACK get_global_interface_proc(LPVOID pv)
hr = IGlobalInterfaceTable_GetInterfaceFromGlobal(params->git, params->cookie, &IID_IClassFactory, (void **)&cf);
ok(hr == CO_E_NOTINITIALIZED ||
- hr == E_UNEXPECTED, /* win2k */
+ broken(hr == E_UNEXPECTED) /* win2k */ ||
+ broken(hr == S_OK) /* NT 4 */,
"IGlobalInterfaceTable_GetInterfaceFromGlobal should have failed with error CO_E_NOTINITIALIZED or E_UNEXPECTED instead of 0x%08x\n",
hr);
+ if (hr == S_OK)
+ IClassFactory_Release(cf);
CoInitialize(NULL);
diff --git a/dlls/ole32/tests/moniker.c b/dlls/ole32/tests/moniker.c
index c74fc84..08ef2ee 100644
--- a/dlls/ole32/tests/moniker.c
+++ b/dlls/ole32/tests/moniker.c
@@ -82,6 +82,19 @@ static void UnlockModule(void)
InterlockedDecrement(&cLocks);
}
+static SIZE_T round_heap_size(SIZE_T size)
+{
+ static SIZE_T heap_size_alignment = -1;
+ if (heap_size_alignment == -1)
+ {
+ void *p = HeapAlloc(GetProcessHeap(), 0, 1);
+ heap_size_alignment = HeapSize(GetProcessHeap(), 0, p);
+ HeapFree(GetProcessHeap(), 0, p);
+ }
+
+ return ((size + heap_size_alignment - 1) & ~(heap_size_alignment - 1));
+}
+
static HRESULT WINAPI Test_IClassFactory_QueryInterface(
LPCLASSFACTORY iface,
REFIID riid,
@@ -1204,12 +1217,12 @@ static void test_moniker(
moniker_data = GlobalLock(hglobal);
/* first check we have the right amount of data */
- ok(moniker_size == sizeof_expected_moniker_saved_data,
+ ok(moniker_size == round_heap_size(sizeof_expected_moniker_saved_data),
"%s: Size of saved data differs (expected %d, actual %d)\n",
- testname, sizeof_expected_moniker_saved_data, moniker_size);
+ testname, (DWORD)round_heap_size(sizeof_expected_moniker_saved_data), moniker_size);
/* then do a byte-by-byte comparison */
- for (i = 0; i < min(moniker_size, sizeof_expected_moniker_saved_data); i++)
+ for (i = 0; i < min(moniker_size, round_heap_size(sizeof_expected_moniker_saved_data)); i++)
{
if (expected_moniker_saved_data[i] != moniker_data[i])
{
@@ -1250,14 +1263,14 @@ static void test_moniker(
moniker_data = GlobalLock(hglobal);
/* first check we have the right amount of data */
- ok(moniker_size == sizeof_expected_moniker_marshal_data,
+ ok(moniker_size == round_heap_size(sizeof_expected_moniker_marshal_data),
"%s: Size of marshaled data differs (expected %d, actual %d)\n",
- testname, sizeof_expected_moniker_marshal_data, moniker_size);
+ testname, (DWORD)round_heap_size(sizeof_expected_moniker_marshal_data), moniker_size);
/* then do a byte-by-byte comparison */
if (expected_moniker_marshal_data)
{
- for (i = 0; i < min(moniker_size, sizeof_expected_moniker_marshal_data); i++)
+ for (i = 0; i < min(moniker_size, round_heap_size(sizeof_expected_moniker_marshal_data)); i++)
{
if (expected_moniker_marshal_data[i] != moniker_data[i])
{
More information about the wine-cvs
mailing list