Commit f8248882 authored by Rob Shearman's avatar Rob Shearman Committed by Alexandre Julliard

rpcrt4: Add test for using a conformant varying structure with pointers.

parent e22af18e
......@@ -654,6 +654,24 @@ s_get_numbers(int length, int size, pints_t n[])
}
void
s_get_numbers_struct(numbers_struct_t **ns)
{
int i;
*ns = midl_user_allocate(FIELD_OFFSET(numbers_struct_t, numbers[5]));
if (!*ns) return;
(*ns)->length = 5;
(*ns)->size = 5;
for (i = 0; i < (*ns)->length; i++)
{
(*ns)->numbers[i].pi = NULL;
(*ns)->numbers[i].ppi = NULL;
(*ns)->numbers[i].pppi = NULL;
}
(*ns)->numbers[0].pi = midl_user_allocate(sizeof(*(*ns)->numbers[i].pi));
*(*ns)->numbers[0].pi = 5;
}
void
s_stop(void)
{
ok(RPC_S_OK == RpcMgmtStopServerListening(NULL), "RpcMgmtStopServerListening\n");
......@@ -1096,6 +1114,7 @@ array_tests(void)
doub_carr_t *dc;
int *pi;
pints_t api[5];
numbers_struct_t *ns;
ok(cstr_length(str1, sizeof str1) == strlen(str1), "RPC cstr_length\n");
......@@ -1177,12 +1196,24 @@ array_tests(void)
api[0].pi = pi;
get_5numbers(1, api);
ok(api[0].pi == pi, "RPC varying array [out] pointer changed from %p to %p\n", pi, api[0].pi);
ok(*api[0].pi == 0, "pi unmarshalled incorrectly %d\n", *pi);
ok(*api[0].pi == 0, "pi unmarshalled incorrectly %d\n", *api[0].pi);
api[0].pi = pi;
get_numbers(1, 1, api);
ok(api[0].pi == pi, "RPC conformant varying array [out] pointer changed from %p to %p\n", pi, api[0].pi);
ok(*api[0].pi == 0, "pi unmarshalled incorrectly %d\n", *pi);
ok(*api[0].pi == 0, "pi unmarshalled incorrectly %d\n", *api[0].pi);
ns = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, FIELD_OFFSET(numbers_struct_t, numbers[5]));
ns->length = 5;
ns->size = 5;
ns->numbers[0].pi = pi;
get_numbers_struct(&ns);
todo_wine {
ok(ns->numbers[0].pi == pi, "RPC conformant varying struct embedded pointer changed from %p to %p\n", pi, ns->numbers[0].pi);
}
ok(*ns->numbers[0].pi == 5, "pi unmarshalled incorrectly %d\n", *ns->numbers[0].pi);
HeapFree(GetProcessHeap(), 0, ns);
HeapFree(GetProcessHeap(), 0, pi);
}
......
......@@ -319,8 +319,17 @@ cpp_quote("#endif")
type as a return value. */
s123_t *get_s123(void);
typedef struct
{
unsigned int length;
unsigned int size;
[size_is(size), length_is(length)] pints_t numbers[];
} numbers_struct_t;
void get_5numbers([in] int count, [out, length_is(count)] pints_t pn[5]);
void get_numbers([in] int length, [in] int size, [out, length_is(length), size_is(size)] pints_t pn[]);
void get_numbers_struct([out] numbers_struct_t **ns);
str_t get_filename(void);
void context_handle_test(void);
void stop(void);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment