Rob Shearman : rpcrt4: Add tests for a pointer to a conformant strings.
Alexandre Julliard
julliard at winehq.org
Tue Dec 4 13:25:22 CST 2007
Module: wine
Branch: master
Commit: c866b06806c081e751919eb7c7ce6d0d02f5b522
URL: http://source.winehq.org/git/wine.git/?a=commit;h=c866b06806c081e751919eb7c7ce6d0d02f5b522
Author: Rob Shearman <rob at codeweavers.com>
Date: Tue Dec 4 13:23:09 2007 +0000
rpcrt4: Add tests for a pointer to a conformant strings.
---
dlls/rpcrt4/tests/ndr_marshall.c | 108 ++++++++++++++++++++++++++++++++++++++
1 files changed, 108 insertions(+), 0 deletions(-)
diff --git a/dlls/rpcrt4/tests/ndr_marshall.c b/dlls/rpcrt4/tests/ndr_marshall.c
index c935d08..25448e9 100644
--- a/dlls/rpcrt4/tests/ndr_marshall.c
+++ b/dlls/rpcrt4/tests/ndr_marshall.c
@@ -1107,6 +1107,113 @@ todo_wine {
HeapFree(GetProcessHeap(), 0, StubMsg.RpcMsg->Buffer);
}
+static void test_conformant_string(void)
+{
+ RPC_MESSAGE RpcMessage;
+ MIDL_STUB_MESSAGE StubMsg;
+ MIDL_STUB_DESC StubDesc;
+ void *ptr;
+ unsigned char *mem, *mem_orig;
+ char memsrc[] = "This is a test string";
+
+ static const unsigned char fmtstr_conf_str[] =
+ {
+ 0x11, 0x8, /* FC_RP [simple_pointer] */
+ 0x22, /* FC_C_CSTRING */
+ 0x5c, /* FC_PAD */
+ };
+
+ StubDesc = Object_StubDesc;
+ StubDesc.pFormatTypes = fmtstr_conf_str;
+
+ NdrClientInitializeNew(
+ &RpcMessage,
+ &StubMsg,
+ &StubDesc,
+ 0);
+
+ StubMsg.BufferLength = 0;
+ NdrPointerBufferSize( &StubMsg,
+ (unsigned char *)memsrc,
+ fmtstr_conf_str );
+ ok(StubMsg.BufferLength >= sizeof(memsrc) + 12, "length %d\n", StubMsg.BufferLength);
+
+ /*NdrGetBuffer(&_StubMsg, _StubMsg.BufferLength, NULL);*/
+ StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = HeapAlloc(GetProcessHeap(), 0, StubMsg.BufferLength);
+ StubMsg.BufferEnd = StubMsg.BufferStart + StubMsg.BufferLength;
+
+ ptr = NdrPointerMarshall( &StubMsg, (unsigned char *)memsrc, fmtstr_conf_str );
+ ok(ptr == NULL, "ret %p\n", ptr);
+ ok(StubMsg.Buffer - StubMsg.BufferStart == sizeof(memsrc) + 12, "Buffer %p Start %p len %d\n",
+ StubMsg.Buffer, StubMsg.BufferStart, 12 + sizeof(memsrc));
+ ok(!memcmp(StubMsg.BufferStart + 12, memsrc, sizeof(memsrc)), "incorrectly marshaled\n");
+
+ StubMsg.Buffer = StubMsg.BufferStart;
+ StubMsg.MemorySize = 0;
+ mem = NULL;
+
+ /* Client */
+ my_alloc_called = 0;
+ StubMsg.Buffer = StubMsg.BufferStart;
+ mem = mem_orig = HeapAlloc(GetProcessHeap(), 0, sizeof(memsrc));
+ NdrPointerUnmarshall( &StubMsg, &mem, fmtstr_conf_str, 0);
+ ok(mem == mem_orig, "mem not alloced\n");
+ ok(my_alloc_called == 0, "alloc called %d\n", my_alloc_called);
+
+ my_alloc_called = 0;
+ StubMsg.Buffer = StubMsg.BufferStart;
+ NdrPointerUnmarshall( &StubMsg, &mem, fmtstr_conf_str, 1);
+todo_wine {
+ ok(mem == mem_orig, "mem not alloced\n");
+ ok(my_alloc_called == 0, "alloc called %d\n", my_alloc_called);
+}
+
+ my_free_called = 0;
+ StubMsg.Buffer = StubMsg.BufferStart;
+ NdrPointerFree( &StubMsg, mem, fmtstr_conf_str );
+ ok(my_free_called == 1, "free called %d\n", my_free_called);
+
+ /* Server */
+ my_alloc_called = 0;
+ StubMsg.IsClient = 0;
+ mem = NULL;
+ StubMsg.Buffer = StubMsg.BufferStart;
+ NdrPointerUnmarshall( &StubMsg, &mem, fmtstr_conf_str, 0);
+todo_wine {
+ ok(mem == StubMsg.BufferStart + 12, "mem not pointing at buffer\n");
+ ok(my_alloc_called == 0, "alloc called %d\n", my_alloc_called);
+}
+ my_alloc_called = 0;
+ mem = NULL;
+ StubMsg.Buffer = StubMsg.BufferStart;
+ NdrPointerUnmarshall( &StubMsg, &mem, fmtstr_conf_str, 1);
+todo_wine {
+ ok(mem == StubMsg.BufferStart + 12, "mem not pointing at buffer\n");
+ ok(my_alloc_called == 0, "alloc called %d\n", my_alloc_called);
+}
+
+ my_alloc_called = 0;
+ mem = mem_orig;
+ StubMsg.Buffer = StubMsg.BufferStart;
+ NdrPointerUnmarshall( &StubMsg, &mem, fmtstr_conf_str, 0);
+todo_wine {
+ ok(mem == StubMsg.BufferStart + 12, "mem not pointing at buffer\n");
+ ok(my_alloc_called == 0, "alloc called %d\n", my_alloc_called);
+}
+
+ my_alloc_called = 0;
+ mem = mem_orig;
+ StubMsg.Buffer = StubMsg.BufferStart;
+ NdrPointerUnmarshall( &StubMsg, &mem, fmtstr_conf_str, 1);
+todo_wine {
+ ok(mem == StubMsg.BufferStart + 12, "mem not pointing at buffer\n");
+ ok(my_alloc_called == 0, "alloc called %d\n", my_alloc_called);
+}
+
+ HeapFree(GetProcessHeap(), 0, mem_orig);
+ HeapFree(GetProcessHeap(), 0, StubMsg.RpcMsg->Buffer);
+}
+
START_TEST( ndr_marshall )
{
test_ndr_simple_type();
@@ -1116,4 +1223,5 @@ START_TEST( ndr_marshall )
test_client_init();
test_ndr_allocate();
test_conformant_array();
+ test_conformant_string();
}
More information about the wine-cvs
mailing list