rpcrt4/tests: Add some tests for marshalling embedded conformant arrays.

Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
feature/deterministic
Dmitry Timoshkov 2020-06-08 16:54:05 +08:00 committed by Alexandre Julliard
parent bd995ea871
commit 59c0dbb642
2 changed files with 81 additions and 0 deletions

View File

@ -94,6 +94,9 @@ static int (__cdecl *sum_cps)(cps_t *cps);
static int (__cdecl *sum_cpsc)(cpsc_t *cpsc);
static int (__cdecl *get_cpsc)(int n, cpsc_t *cpsc);
static int (__cdecl *sum_complex_array)(int n, refpint_t pi[]);
static int (__cdecl *sum_blob)(cs_blob_t *blob);
static int (__cdecl *sum_data)(cs_data_t *data);
static int (__cdecl *sum_container)(cs_container_t *container);
static int (__cdecl *square_puint)(puint_t p);
static int (__cdecl *sum_puints)(puints_t *p);
static int (__cdecl *sum_cpuints)(cpuints_t *p);
@ -185,6 +188,9 @@ static void (__cdecl *test_handle)(ctx_handle_t ctx_handle);
X(sum_cpsc) \
X(get_cpsc) \
X(sum_complex_array) \
X(sum_blob) \
X(sum_data) \
X(sum_container) \
X(square_puint) \
X(sum_puints) \
X(sum_cpuints) \
@ -507,6 +513,36 @@ int __cdecl s_sum_complex_array(int n, refpint_t pi[])
return total;
}
int __cdecl s_sum_blob(cs_blob_t *blob)
{
int i, total = 0;
for (i = 0; i < blob->n; i++)
total += blob->ca[i];
return total;
}
int __cdecl s_sum_data(cs_data_t *data)
{
int i, total = 0;
for (i = 0; i < data->blob.n; i++)
total += data->blob.ca[i];
return total;
}
int __cdecl s_sum_container(cs_container_t *container)
{
int i, total = 0;
for (i = 0; i < container->data.blob.n; i++)
total += container->data.blob.ca[i];
return total;
}
int __cdecl s_dot_two_vectors(vector_t vs[2])
{
return vs[0].x * vs[1].x + vs[0].y * vs[1].y + vs[0].z * vs[1].z;
@ -1618,6 +1654,9 @@ array_tests(void)
vector_t vs[2] = {{1, -2, 3}, {4, -5, -6}};
cps_t cps;
cpsc_t cpsc;
cs_blob_t blob;
cs_data_t data;
cs_container_t container;
cs_t *cs;
int n;
int ca[5] = {1, -2, 3, -4, 5};
@ -1761,6 +1800,21 @@ array_tests(void)
ok(sum_ptr_array(ptr_array) == 3, "RPC sum_ptr_array\n");
ok(sum_array_ptr(&array) == 7, "RPC sum_array_ptr\n");
blob.n = ARRAY_SIZE(c);
blob.ca = c;
n = sum_blob(&blob);
ok(n == 45, "RPC sum_blob = %d\n", n);
data.blob.n = ARRAY_SIZE(c);
data.blob.ca = c;
n = sum_data(&data);
ok(n == 45, "RPC sum_data = %d\n", n);
container.data.blob.n = ARRAY_SIZE(c);
container.data.blob.ca = c;
n = sum_container(&container);
ok(n == 45, "RPC sum_container = %d\n", n);
}
void __cdecl s_authinfo_test(unsigned int protseq, int secure)

View File

@ -169,6 +169,30 @@ cpp_quote("#ifndef SKIP_TYPE_DECLS")
[size_is(n)] int ca[];
} cs_t;
typedef struct
{
int n;
[size_is(n)] int *ca;
} cs_blob_t;
typedef struct
{
/* FIXME: widl generates incorrect correlation descriptor and the tests crash */
#if 0
int dummy[1]; /* to make offset to conformant array unique */
#endif
cs_blob_t blob;
} cs_data_t;
typedef struct
{
/* FIXME: widl generates incorrect correlation descriptor and the tests crash */
#if 0
int dummy[2]; /* to make offset to conformant array unique */
#endif
cs_data_t data;
} cs_container_t;
typedef struct
{
int *pn;
@ -191,6 +215,9 @@ cpp_quote("#endif")
int sum_cpsc(cpsc_t *cpsc);
int get_cpsc(int n, [out] cpsc_t *cpsc );
int sum_complex_array(int n, [size_is(n)] refpint_t pi[]);
int sum_blob([in] cs_blob_t *blob);
int sum_data([in] cs_data_t *data);
int sum_container([in] cs_container_t *container);
cpp_quote("#ifndef SKIP_TYPE_DECLS")
typedef [wire_marshal(int)] void *puint_t;