rpcrt4: Make the NdrAllocate tests pass on XP SP2 and greater.

This commit is contained in:
Rob Shearman 2007-12-12 14:48:28 +00:00 committed by Alexandre Julliard
parent f3e59a3d70
commit 33c4c25dad
1 changed files with 45 additions and 15 deletions

View File

@ -952,12 +952,19 @@ static void test_ndr_allocate(void)
MIDL_STUB_MESSAGE StubMsg; MIDL_STUB_MESSAGE StubMsg;
MIDL_STUB_DESC StubDesc; MIDL_STUB_DESC StubDesc;
void *p1, *p2; void *p1, *p2;
struct tag_mem_list_t struct tag_mem_list_v1_t
{ {
DWORD magic; DWORD magic;
void *ptr; void *ptr;
struct tag_mem_list_t *next; struct tag_mem_list_v1_t *next;
} *mem_list; } *mem_list_v1;
struct tag_mem_list_v2_t
{
DWORD magic;
DWORD size;
DWORD unknown;
struct tag_mem_list_v2_t *next;
} *mem_list_v2;
const DWORD magic_MEML = 'M' << 24 | 'E' << 16 | 'M' << 8 | 'L'; const DWORD magic_MEML = 'M' << 24 | 'E' << 16 | 'M' << 8 | 'L';
StubDesc = Object_StubDesc; StubDesc = Object_StubDesc;
@ -966,23 +973,46 @@ static void test_ndr_allocate(void)
ok(StubMsg.pMemoryList == NULL, "memlist %p\n", StubMsg.pMemoryList); ok(StubMsg.pMemoryList == NULL, "memlist %p\n", StubMsg.pMemoryList);
my_alloc_called = my_free_called = 0; my_alloc_called = my_free_called = 0;
p1 = NdrAllocate(&StubMsg, 10); p1 = NdrAllocate(&StubMsg, 10);
p2 = NdrAllocate(&StubMsg, 20); p2 = NdrAllocate(&StubMsg, 24);
ok(my_alloc_called == 2, "alloc called %d\n", my_alloc_called); ok(my_alloc_called == 2, "alloc called %d\n", my_alloc_called);
mem_list = StubMsg.pMemoryList;
todo_wine { todo_wine {
ok(mem_list != NULL, "mem_list NULL\n"); ok(StubMsg.pMemoryList != NULL, "StubMsg.pMemoryList NULL\n");
} }
if(mem_list) if(StubMsg.pMemoryList)
{ {
ok(mem_list->magic == magic_MEML, "magic %08x\n", mem_list->magic); mem_list_v2 = StubMsg.pMemoryList;
ok(mem_list->ptr == p2, "ptr != p2\n"); if (mem_list_v2->size == 24)
ok(mem_list->next != NULL, "next NULL\n");
mem_list = mem_list->next;
if(mem_list)
{ {
ok(mem_list->magic == magic_MEML, "magic %08x\n", mem_list->magic); trace("v2 mem list format\n");
ok(mem_list->ptr == p1, "ptr != p2\n"); ok((char *)mem_list_v2 == (char *)p2 + 24, "expected mem_list_v2 pointer %p, but got %p\n", (char *)p2 + 24, mem_list_v2);
ok(mem_list->next == NULL, "next %p\n", mem_list->next); ok(mem_list_v2->magic == magic_MEML, "magic %08x\n", mem_list_v2->magic);
ok(mem_list_v2->size == 24, "wrong size for p2 %d\n", mem_list_v2->size);
ok(mem_list_v2->unknown == 0, "wrong unknown for p2 0x%x\n", mem_list_v2->unknown);
ok(mem_list_v2->next != NULL, "next NULL\n");
mem_list_v2 = mem_list_v2->next;
if(mem_list_v2)
{
ok((char *)mem_list_v2 == (char *)p1 + 16, "expected mem_list_v2 pointer %p, but got %p\n", (char *)p1 + 16, mem_list_v2);
ok(mem_list_v2->magic == magic_MEML, "magic %08x\n", mem_list_v2->magic);
ok(mem_list_v2->size == 16, "wrong size for p1 %d\n", mem_list_v2->size);
ok(mem_list_v2->unknown == 0, "wrong unknown for p1 0x%x\n", mem_list_v2->unknown);
ok(mem_list_v2->next == NULL, "next %p\n", mem_list_v2->next);
}
}
else
{
trace("v1 mem list format\n");
mem_list_v1 = StubMsg.pMemoryList;
ok(mem_list_v1->magic == magic_MEML, "magic %08x\n", mem_list_v1->magic);
ok(mem_list_v1->ptr == p2, "ptr != p2\n");
ok(mem_list_v1->next != NULL, "next NULL\n");
mem_list_v1 = mem_list_v1->next;
if(mem_list_v1)
{
ok(mem_list_v1->magic == magic_MEML, "magic %08x\n", mem_list_v1->magic);
ok(mem_list_v1->ptr == p1, "ptr != p1\n");
ok(mem_list_v1->next == NULL, "next %p\n", mem_list_v1->next);
}
} }
} }
/* NdrFree isn't exported so we can't test free'ing */ /* NdrFree isn't exported so we can't test free'ing */