2 * Tests for WIDL and RPC server/clients.
4 * Copyright (C) Google 2007 (Dan Hipschman)
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "wine/test.h"
24 #include "server_defines.h"
31 #define PIPE "\\pipe\\wine_rpcrt4_test"
35 static const char *progname
;
37 static HANDLE stop_event
;
39 void __RPC_FAR
*__RPC_USER
40 midl_user_allocate(size_t n
)
46 midl_user_free(void __RPC_FAR
*p
)
52 xstrdup(const char *s
)
54 char *d
= HeapAlloc(GetProcessHeap(), 0, strlen(s
) + 1);
78 s_square_out(int x
, int *y
)
90 s_str_length(const char *s
)
96 s_cstr_length(const char *s
, int n
)
99 while (0 < n
-- && *s
++)
105 s_dot_self(vector_t
*v
)
107 return s_square(v
->x
) + s_square(v
->y
) + s_square(v
->z
);
111 s_square_half(double x
, double *y
)
118 s_square_half_float(float x
, float *y
)
125 s_square_half_long(long x
, long *y
)
132 s_sum_fixed_array(int a
[5])
134 return a
[0] + a
[1] + a
[2] + a
[3] + a
[4];
138 s_pints_sum(pints_t
*pints
)
140 return *pints
->pi
+ **pints
->ppi
+ ***pints
->pppi
;
144 s_ptypes_sum(ptypes_t
*pt
)
146 return *pt
->pc
+ *pt
->ps
+ *pt
->pl
+ *pt
->pf
+ *pt
->pd
;
150 s_dot_pvectors(pvectors_t
*p
)
152 return p
->pu
->x
* (*p
->pv
)->x
+ p
->pu
->y
* (*p
->pv
)->y
+ p
->pu
->z
* (*p
->pv
)->z
;
158 return sp
->x
+ sp
->s
->x
;
162 s_square_sun(sun_t
*su
)
166 case SUN_I
: return su
->u
.i
* su
->u
.i
;
168 case SUN_F2
: return su
->u
.f
* su
->u
.f
;
169 case SUN_PI
: return (*su
->u
.pi
) * (*su
->u
.pi
);
176 s_test_list_length(test_list_t
*list
)
178 return (list
->t
== TL_LIST
179 ? 1 + s_test_list_length(list
->u
.tail
)
184 s_sum_fixed_int_3d(int m
[2][3][4])
189 for (i
= 0; i
< 2; ++i
)
190 for (j
= 0; j
< 3; ++j
)
191 for (k
= 0; k
< 4; ++k
)
198 s_sum_conf_array(int x
[], int n
)
200 int *p
= x
, *end
= p
+ n
;
210 s_sum_unique_conf_array(int x
[], int n
)
212 return s_sum_conf_array(x
, n
);
216 s_sum_unique_conf_ptr(int *x
, int n
)
218 return x
? s_sum_conf_array(x
, n
) : 0;
222 s_sum_var_array(int x
[20], int n
)
224 ok(0 <= n
, "RPC sum_var_array\n");
225 ok(n
<= 20, "RPC sum_var_array\n");
227 return s_sum_conf_array(x
, n
);
231 s_dot_two_vectors(vector_t vs
[2])
233 return vs
[0].x
* vs
[1].x
+ vs
[0].y
* vs
[1].y
+ vs
[0].z
* vs
[1].z
;
239 return s_sum_conf_array(cs
->ca
, cs
->n
);
243 s_sum_cps(cps_t
*cps
)
248 for (i
= 0; i
< *cps
->pn
; ++i
)
251 for (i
= 0; i
< 2 * cps
->n
; ++i
)
258 s_sum_cpsc(cpsc_t
*cpsc
)
262 for (i
= 0; i
< (cpsc
->c
? cpsc
->a
: cpsc
->b
); ++i
)
268 s_square_puint(puint_t p
)
275 s_sum_puints(puints_t
*p
)
279 for (i
= 0; i
< p
->n
; ++i
)
280 sum
+= atoi(p
->ps
[i
]);
285 s_sum_cpuints(cpuints_t
*p
)
289 for (i
= 0; i
< p
->n
; ++i
)
290 sum
+= atoi(p
->ps
[i
]);
295 s_dot_copy_vectors(vector_t u
, vector_t v
)
297 return u
.x
* v
.x
+ u
.y
* v
.y
+ u
.z
* v
.z
;
301 s_square_test_us(test_us_t
*tus
)
303 int n
= atoi(tus
->us
.x
);
308 s_square_encu(encu_t
*eu
)
312 case ENCU_I
: return eu
->tagged_union
.i
* eu
->tagged_union
.i
;
313 case ENCU_F
: return eu
->tagged_union
.f
* eu
->tagged_union
.f
;
320 s_sum_parr(int *a
[3])
322 return s_sum_pcarr(a
, 3);
326 s_sum_pcarr(int *a
[], int n
)
329 for (i
= 0; i
< n
; ++i
)
349 s_square_encue(encue_t
*eue
)
353 case E1
: return eue
->tagged_union
.i1
* eue
->tagged_union
.i1
;
354 case E2
: return eue
->tagged_union
.f2
* eue
->tagged_union
.f2
;
361 s_sum_toplev_conf_2n(int *x
, int n
)
365 for (i
= 0; i
< 2 * n
; ++i
)
371 s_sum_toplev_conf_cond(int *x
, int a
, int b
, int c
)
376 for (i
= 0; i
< n
; ++i
)
382 s_sum_aligns(aligns_t
*a
)
384 return a
->c
+ a
->i
+ a
->s
+ a
->d
;
388 s_sum_padded(padded_t
*p
)
394 s_sum_padded2(padded_t ps
[2])
396 return s_sum_padded(&ps
[0]) + s_sum_padded(&ps
[1]);
400 s_sum_padded_conf(padded_t
*ps
, int n
)
404 for (i
= 0; i
< n
; ++i
)
405 sum
+= s_sum_padded(&ps
[i
]);
410 s_sum_bogus(bogus_t
*b
)
412 return *b
->h
.p1
+ *b
->p2
+ *b
->p3
+ b
->c
;
416 s_check_null(int *null
)
418 ok(!null
, "RPC check_null\n");
422 s_str_struct_len(str_struct_t
*s
)
424 return lstrlenA(s
->s
);
428 s_wstr_struct_len(wstr_struct_t
*s
)
430 return lstrlenW(s
->s
);
434 s_sum_doub_carr(doub_carr_t
*dc
)
438 for (i
= 0; i
< dc
->n
; ++i
)
439 for (j
= 0; j
< dc
->a
[i
]->n
; ++j
)
440 sum
+= dc
->a
[i
]->a
[j
];
445 s_make_pyramid_doub_carr(unsigned char n
, doub_carr_t
**dc
)
449 t
= MIDL_user_allocate(FIELD_OFFSET(doub_carr_t
, a
[n
]));
451 for (i
= 0; i
< n
; ++i
)
454 t
->a
[i
] = MIDL_user_allocate(FIELD_OFFSET(doub_carr_1_t
, a
[v
]));
456 for (j
= 0; j
< v
; ++j
)
457 t
->a
[i
]->a
[j
] = j
+ 1;
463 s_hash_bstr(bstr_t b
)
469 for (i
= 0; i
< n
; ++i
)
470 hash
= 5 * hash
+ (unsigned) s
[i
];
475 s_get_name(name_t
*name
)
477 const char bossman
[] = "Jeremy White";
478 memcpy(name
->name
, bossman
, min(name
->size
, sizeof(bossman
)));
479 /* ensure nul-termination */
480 if (name
->size
< sizeof(bossman
))
481 name
->name
[name
->size
- 1] = 0;
485 s_sum_pcarr2(int n
, int **pa
)
487 return s_sum_conf_array(*pa
, n
);
491 s_sum_L1_norms(int n
, vector_t
*vs
)
495 for (i
= 0; i
< n
; ++i
)
496 sum
+= abs(vs
[i
].x
) + abs(vs
[i
].y
) + abs(vs
[i
].z
);
503 return (char *)__FILE__
;
507 s_context_handle_test(void)
510 RPC_BINDING_HANDLE binding
;
512 unsigned char buf
[20];
513 static RPC_SERVER_INTERFACE server_if
=
515 sizeof(RPC_SERVER_INTERFACE
),
516 {{0x00000000,0x4114,0x0704,{0x23,0x01,0x00,0x00,0x00,0x00,0x00,0x00}},{1,0}},
517 {{0x8a885d04,0x1ceb,0x11c9,{0x9f,0xe8,0x08,0x00,0x2b,0x10,0x48,0x60}},{2,0}},
526 binding
= I_RpcGetCurrentCallHandle();
527 ok(binding
!= NULL
, "I_RpcGetCurrentCallHandle returned NULL\n");
529 h
= NDRSContextUnmarshall2(binding
, NULL
, NDR_LOCAL_DATA_REPRESENTATION
, NULL
, 0);
530 ok(h
!= NULL
, "NDRSContextUnmarshall2 returned NULL\n");
532 /* marshal a context handle with NULL userContext */
533 memset(buf
, 0xcc, sizeof(buf
));
534 NDRSContextMarshall2(binding
, h
, buf
, NULL
, NULL
, 0);
535 ok(*(ULONG
*)buf
== 0, "attributes should have been set to 0 instead of 0x%x\n", *(ULONG
*)buf
);
536 ok(UuidIsNil((UUID
*)&buf
[4], &status
), "uuid should have been nil\n");
538 h
= NDRSContextUnmarshall2(binding
, NULL
, NDR_LOCAL_DATA_REPRESENTATION
, NULL
, 0);
539 ok(h
!= NULL
, "NDRSContextUnmarshall2 returned NULL\n");
541 /* marshal a context handle with non-NULL userContext */
542 memset(buf
, 0xcc, sizeof(buf
));
543 h
->userContext
= (void *)0xdeadbeef;
544 NDRSContextMarshall2(binding
, h
, buf
, NULL
, NULL
, 0);
545 ok(*(ULONG
*)buf
== 0, "attributes should have been set to 0 instead of 0x%x\n", *(ULONG
*)buf
);
546 ok(!UuidIsNil((UUID
*)&buf
[4], &status
), "uuid should not have been nil\n");
548 h
= NDRSContextUnmarshall2(binding
, buf
, NDR_LOCAL_DATA_REPRESENTATION
, NULL
, 0);
549 ok(h
!= NULL
, "NDRSContextUnmarshall2 returned NULL\n");
550 ok(h
->userContext
== (void *)0xdeadbeef, "userContext of interface didn't unmarshal properly: %p\n", h
->userContext
);
552 /* marshal a context handle with an interface specified */
553 h
= NDRSContextUnmarshall2(binding
, NULL
, NDR_LOCAL_DATA_REPRESENTATION
, &server_if
.InterfaceId
, 0);
554 ok(h
!= NULL
, "NDRSContextUnmarshall2 returned NULL\n");
556 memset(buf
, 0xcc, sizeof(buf
));
557 h
->userContext
= (void *)0xcafebabe;
558 NDRSContextMarshall2(binding
, h
, buf
, NULL
, &server_if
.InterfaceId
, 0);
559 ok(*(ULONG
*)buf
== 0, "attributes should have been set to 0 instead of 0x%x\n", *(ULONG
*)buf
);
560 ok(!UuidIsNil((UUID
*)&buf
[4], &status
), "uuid should not have been nil\n");
562 h
= NDRSContextUnmarshall2(binding
, buf
, NDR_LOCAL_DATA_REPRESENTATION
, &server_if
.InterfaceId
, 0);
563 ok(h
!= NULL
, "NDRSContextUnmarshall2 returned NULL\n");
564 ok(h
->userContext
== (void *)0xcafebabe, "userContext of interface didn't unmarshal properly: %p\n", h
->userContext
);
566 /* test same interface data, but different pointer */
567 /* raises ERROR_INVALID_HANDLE exception */
570 RPC_SERVER_INTERFACE server_if_clone
= server_if
;
572 NDRSContextUnmarshall2(binding
, buf
, NDR_LOCAL_DATA_REPRESENTATION
, &server_if_clone
.InterfaceId
, 0);
575 /* test different interface data, but different pointer */
576 /* raises ERROR_INVALID_HANDLE exception */
579 static RPC_SERVER_INTERFACE server_if2
=
581 sizeof(RPC_SERVER_INTERFACE
),
582 {{0x00000000,0x4114,0x0704,{0x23,0x01,0x00,0x00,0x00,0x00,0x00,0x00}},{1,0}},
583 {{0x8a885d04,0x1ceb,0x11c9,{0x9f,0xe8,0x08,0x00,0x2b,0x10,0x48,0x60}},{2,0}},
591 NDRSContextMarshall2(binding
, h
, buf
, NULL
, &server_if
.InterfaceId
, 0);
593 NDRSContextUnmarshall2(binding
, buf
, NDR_LOCAL_DATA_REPRESENTATION
, &server_if2
.InterfaceId
, 0);
598 s_get_5numbers(int count
, pints_t n
[5])
601 for (i
= 0; i
< count
; i
++)
603 n
[i
].pi
= midl_user_allocate(sizeof(*n
[i
].pi
));
611 s_get_numbers(int length
, int size
, pints_t n
[])
614 for (i
= 0; i
< length
; i
++)
616 n
[i
].pi
= midl_user_allocate(sizeof(*n
[i
].pi
));
626 ok(RPC_S_OK
== RpcMgmtStopServerListening(NULL
), "RpcMgmtStopServerListening\n");
627 ok(RPC_S_OK
== RpcServerUnregisterIf(NULL
, NULL
, FALSE
), "RpcServerUnregisterIf\n");
628 ok(SetEvent(stop_event
), "SetEvent\n");
632 make_cmdline(char buffer
[MAX_PATH
], const char *test
)
634 sprintf(buffer
, "%s server %s", progname
, test
);
638 run_client(const char *test
)
640 char cmdline
[MAX_PATH
];
641 PROCESS_INFORMATION info
;
642 STARTUPINFOA startup
;
645 memset(&startup
, 0, sizeof startup
);
646 startup
.cb
= sizeof startup
;
648 make_cmdline(cmdline
, test
);
649 ok(CreateProcessA(NULL
, cmdline
, NULL
, NULL
, FALSE
, 0L, NULL
, NULL
, &startup
, &info
), "CreateProcess\n");
650 ok(WaitForSingleObject(info
.hProcess
, 30000) == WAIT_OBJECT_0
, "Child process termination\n");
651 ok(GetExitCodeProcess(info
.hProcess
, &exitcode
), "GetExitCodeProcess\n");
652 ok(CloseHandle(info
.hProcess
), "CloseHandle\n");
653 ok(CloseHandle(info
.hThread
), "CloseHandle\n");
655 return exitcode
== 0;
661 char string
[] = "I am a string";
662 WCHAR wstring
[] = {'I',' ','a','m',' ','a',' ','w','s','t','r','i','n','g', 0};
663 int f
[5] = {1, 3, 0, -2, -4};
664 vector_t a
= {1, 3, 7};
665 vector_t vec1
= {4, -2, 1}, vec2
= {-5, 2, 3}, *pvec2
= &vec2
;
666 pvectors_t pvecs
= {&vec1
, &pvec2
};
667 sp_inner_t spi
= {42};
668 sp_t sp
= {-13, &spi
};
675 int i1
, i2
, i3
, *pi2
, *pi3
, **ppi3
;
682 str_struct_t ss
= {string
};
683 wstr_struct_t ws
= {wstring
};
686 ok(int_return() == INT_CODE
, "RPC int_return\n");
688 ok(square(7) == 49, "RPC square\n");
689 ok(sum(23, -4) == 19, "RPC sum\n");
693 ok(x
== 121, "RPC square_out\n");
697 ok(x
== 25, "RPC square_ref\n");
699 ok(str_length(string
) == strlen(string
), "RPC str_length\n");
700 ok(dot_self(&a
) == 59, "RPC dot_self\n");
702 ok(str_struct_len(&ss
) == lstrlenA(string
), "RPC str_struct_len\n");
703 ok(wstr_struct_len(&ws
) == lstrlenW(wstring
), "RPC str_struct_len\n");
706 u
= square_half(3.0, &v
);
707 ok(u
== 9.0, "RPC square_half\n");
708 ok(v
== 1.5, "RPC square_half\n");
711 s
= square_half_float(3.0f
, &t
);
712 ok(s
== 9.0f
, "RPC square_half_float\n");
713 ok(t
== 1.5f
, "RPC square_half_float\n");
716 q
= square_half_long(3, &r
);
717 ok(q
== 9, "RPC square_half_long\n");
718 ok(r
== 1, "RPC square_half_long\n");
729 ok(pints_sum(&pints
) == -13, "RPC pints_sum\n");
741 ok(ptypes_sum(&ptypes
) == 33.0, "RPC ptypes_sum\n");
743 ok(dot_pvectors(&pvecs
) == -21, "RPC dot_pvectors\n");
744 ok(dot_copy_vectors(vec1
, vec2
) == -21, "RPC dot_copy_vectors\n");
745 ok(sum_fixed_array(f
) == -2, "RPC sum_fixed_array\n");
746 ok(sum_sp(&sp
) == 29, "RPC sum_sp\n");
748 ok(enum_ord(E1
) == 1, "RPC enum_ord\n");
749 ok(enum_ord(E2
) == 2, "RPC enum_ord\n");
750 ok(enum_ord(E3
) == 3, "RPC enum_ord\n");
751 ok(enum_ord(E4
) == 4, "RPC enum_ord\n");
753 memset(&aligns
, 0, sizeof(aligns
));
758 ok(sum_aligns(&aligns
) == 18.0, "RPC sum_aligns\n");
762 ok(sum_padded(&padded
) == 5, "RPC sum_padded\n");
767 ok(sum_padded2(padded2
) == 6, "RPC sum_padded2\n");
772 ok(sum_padded_conf(padded2
, 2) == 6, "RPC sum_padded_conf\n");
781 ok(sum_bogus(&bogus
) == 12, "RPC sum_bogus\n");
785 str
= get_filename();
786 ok(!strcmp(str
, __FILE__
), "get_filename() returned %s instead of %s\n", str
, __FILE__
);
800 ok(square_sun(&su
) == 81.0, "RPC square_sun\n");
804 ok(square_sun(&su
) == 25.0, "RPC square_sun\n");
808 ok(square_sun(&su
) == 4.0, "RPC square_sun\n");
813 ok(square_sun(&su
) == 121.0, "RPC square_sun\n");
816 eu
.tagged_union
.i
= 7;
817 ok(square_encu(&eu
) == 49.0, "RPC square_encu\n");
820 eu
.tagged_union
.f
= 3.0;
821 ok(square_encu(&eu
) == 9.0, "RPC square_encu\n");
824 eue
.tagged_union
.i1
= 8;
825 ok(square_encue(&eue
) == 64.0, "RPC square_encue\n");
828 eue
.tagged_union
.f2
= 10.0;
829 ok(square_encue(&eue
) == 100.0, "RPC square_encue\n");
835 test_list_t
*n
= HeapAlloc(GetProcessHeap(), 0, sizeof *n
);
842 make_list(test_list_t
*tail
)
844 test_list_t
*n
= HeapAlloc(GetProcessHeap(), 0, sizeof *n
);
851 free_list(test_list_t
*list
)
853 if (list
->t
== TL_LIST
)
854 free_list(list
->u
.tail
);
855 HeapFree(GetProcessHeap(), 0, list
);
859 puint_t_UserSize(ULONG
*flags
, ULONG start
, puint_t
*p
)
861 return start
+ sizeof(int);
864 unsigned char * __RPC_USER
865 puint_t_UserMarshal(ULONG
*flags
, unsigned char *buffer
, puint_t
*p
)
868 memcpy(buffer
, &n
, sizeof n
);
869 return buffer
+ sizeof n
;
872 unsigned char * __RPC_USER
873 puint_t_UserUnmarshal(ULONG
*flags
, unsigned char *buffer
, puint_t
*p
)
876 memcpy(&n
, buffer
, sizeof n
);
877 *p
= HeapAlloc(GetProcessHeap(), 0, 10);
878 sprintf(*p
, "%d", n
);
879 return buffer
+ sizeof n
;
883 puint_t_UserFree(ULONG
*flags
, puint_t
*p
)
885 HeapFree(GetProcessHeap(), 0, *p
);
889 us_t_UserSize(ULONG
*flags
, ULONG start
, us_t
*pus
)
891 return start
+ sizeof(struct wire_us
);
894 unsigned char * __RPC_USER
895 us_t_UserMarshal(ULONG
*flags
, unsigned char *buffer
, us_t
*pus
)
898 wus
.x
= atoi(pus
->x
);
899 memcpy(buffer
, &wus
, sizeof wus
);
900 return buffer
+ sizeof wus
;
903 unsigned char * __RPC_USER
904 us_t_UserUnmarshal(ULONG
*flags
, unsigned char *buffer
, us_t
*pus
)
907 memcpy(&wus
, buffer
, sizeof wus
);
908 pus
->x
= HeapAlloc(GetProcessHeap(), 0, 10);
909 sprintf(pus
->x
, "%d", wus
.x
);
910 return buffer
+ sizeof wus
;
914 us_t_UserFree(ULONG
*flags
, us_t
*pus
)
916 HeapFree(GetProcessHeap(), 0, pus
->x
);
920 bstr_t_UserSize(ULONG
*flags
, ULONG start
, bstr_t
*b
)
922 return start
+ FIELD_OFFSET(wire_bstr_t
, data
[(*b
)[-1]]);
925 unsigned char * __RPC_USER
926 bstr_t_UserMarshal(ULONG
*flags
, unsigned char *buffer
, bstr_t
*b
)
928 wire_bstr_t
*wb
= (wire_bstr_t
*) buffer
;
930 memcpy(&wb
->data
, *b
, wb
->n
* sizeof wb
->data
[0]);
931 return buffer
+ FIELD_OFFSET(wire_bstr_t
, data
[wb
->n
]);
934 unsigned char * __RPC_USER
935 bstr_t_UserUnmarshal(ULONG
*flags
, unsigned char *buffer
, bstr_t
*b
)
937 wire_bstr_t
*wb
= (wire_bstr_t
*) buffer
;
938 short *data
= HeapAlloc(GetProcessHeap(), 0, (wb
->n
+ 1) * sizeof *data
);
940 memcpy(&data
[1], wb
->data
, wb
->n
* sizeof data
[1]);
942 return buffer
+ FIELD_OFFSET(wire_bstr_t
, data
[wb
->n
]);
946 bstr_t_UserFree(ULONG
*flags
, bstr_t
*b
)
948 HeapFree(GetProcessHeap(), 0, &((*b
)[-1]));
954 int a
[] = {1, 2, 3, 4};
956 test_list_t
*list
= make_list(make_list(make_list(null_list())));
957 test_us_t tus
= {{p1
}};
961 short bstr_data
[] = { 5, 'H', 'e', 'l', 'l', 'o' };
962 bstr_t bstr
= &bstr_data
[1];
967 ok(test_list_length(list
) == 3, "RPC test_list_length\n");
968 ok(square_puint(p1
) == 121, "RPC square_puint\n");
970 pus
.ps
= HeapAlloc(GetProcessHeap(), 0, pus
.n
* sizeof pus
.ps
[0]);
971 pus
.ps
[0] = xstrdup("5");
972 pus
.ps
[1] = xstrdup("6");
973 pus
.ps
[2] = xstrdup("7");
974 pus
.ps
[3] = xstrdup("8");
975 ok(sum_puints(&pus
) == 26, "RPC sum_puints\n");
976 HeapFree(GetProcessHeap(), 0, pus
.ps
[0]);
977 HeapFree(GetProcessHeap(), 0, pus
.ps
[1]);
978 HeapFree(GetProcessHeap(), 0, pus
.ps
[2]);
979 HeapFree(GetProcessHeap(), 0, pus
.ps
[3]);
980 HeapFree(GetProcessHeap(), 0, pus
.ps
);
982 cpus
.ps
= HeapAlloc(GetProcessHeap(), 0, cpus
.n
* sizeof cpus
.ps
[0]);
983 cpus
.ps
[0] = xstrdup("5");
984 cpus
.ps
[1] = xstrdup("6");
985 cpus
.ps
[2] = xstrdup("7");
986 cpus
.ps
[3] = xstrdup("8");
987 ok(sum_cpuints(&cpus
) == 26, "RPC sum_puints\n");
988 HeapFree(GetProcessHeap(), 0, cpus
.ps
[0]);
989 HeapFree(GetProcessHeap(), 0, cpus
.ps
[1]);
990 HeapFree(GetProcessHeap(), 0, cpus
.ps
[2]);
991 HeapFree(GetProcessHeap(), 0, cpus
.ps
[3]);
992 HeapFree(GetProcessHeap(), 0, cpus
.ps
);
993 ok(square_test_us(&tus
) == 121, "RPC square_test_us\n");
998 ok(sum_parr(pa
) == 6, "RPC sum_parr\n");
1004 ok(sum_pcarr(pa
, 4) == 10, "RPC sum_pcarr\n");
1006 ok(hash_bstr(bstr
) == s_hash_bstr(bstr
), "RPC hash_bstr_data\n");
1011 name
.name
= buffer
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, name
.size
);
1013 ok(name
.name
== buffer
, "[in,out] pointer should have stayed as %p but instead changed to %p\n", name
.name
, buffer
);
1014 ok(!strcmp(name
.name
, "Jeremy Wh"), "name didn't unmarshall properly, expected \"Jeremy Wh\", but got \"%s\"\n", name
.name
);
1015 HeapFree(GetProcessHeap(), 0, name
.name
);
1018 ok(sum_pcarr2(4, &pa2
) == 10, "RPC sum_pcarr2\n");
1022 check_pyramid_doub_carr(doub_carr_t
*dc
)
1025 for (i
= 0; i
< dc
->n
; ++i
)
1026 for (j
= 0; j
< dc
->a
[i
]->n
; ++j
)
1027 if (dc
->a
[i
]->a
[j
] != j
+ 1)
1033 free_pyramid_doub_carr(doub_carr_t
*dc
)
1036 for (i
= 0; i
< dc
->n
; ++i
)
1037 MIDL_user_free(dc
->a
[i
]);
1044 const char str1
[25] = "Hello";
1047 {{1, 2, 3, 4}, {-1, -3, -5, -7}, {0, 2, 4, 6}},
1048 {{1, -2, 3, -4}, {2, 3, 5, 7}, {-4, -1, -14, 4114}}
1050 int c
[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
1051 vector_t vs
[2] = {{1, -2, 3}, {4, -5, -6}};
1056 int ca
[5] = {1, -2, 3, -4, 5};
1061 ok(cstr_length(str1
, sizeof str1
) == strlen(str1
), "RPC cstr_length\n");
1063 ok(sum_fixed_int_3d(m
) == 4116, "RPC sum_fixed_int_3d\n");
1065 ok(sum_conf_array(c
, 10) == 45, "RPC sum_conf_array\n");
1066 ok(sum_conf_array(&c
[5], 2) == 11, "RPC sum_conf_array\n");
1067 ok(sum_conf_array(&c
[7], 1) == 7, "RPC sum_conf_array\n");
1068 ok(sum_conf_array(&c
[2], 0) == 0, "RPC sum_conf_array\n");
1070 ok(sum_unique_conf_array(ca
, 4) == -2, "RPC sum_unique_conf_array\n");
1071 ok(sum_unique_conf_ptr(ca
, 5) == 3, "RPC sum_unique_conf_array\n");
1072 ok(sum_unique_conf_ptr(NULL
, 10) == 0, "RPC sum_unique_conf_array\n");
1074 ok(sum_var_array(c
, 10) == 45, "RPC sum_conf_array\n");
1075 ok(sum_var_array(&c
[5], 2) == 11, "RPC sum_conf_array\n");
1076 ok(sum_var_array(&c
[7], 1) == 7, "RPC sum_conf_array\n");
1077 ok(sum_var_array(&c
[2], 0) == 0, "RPC sum_conf_array\n");
1079 ok(dot_two_vectors(vs
) == -4, "RPC dot_two_vectors\n");
1080 cs
= HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(cs_t
, ca
[5]));
1087 ok(sum_cs(cs
) == 1, "RPC sum_cs\n");
1088 HeapFree(GetProcessHeap(), 0, cs
);
1095 ok(sum_cps(&cps
) == 53, "RPC sum_cps\n");
1101 ok(sum_cpsc(&cpsc
) == 6, "RPC sum_cpsc\n");
1106 ok(sum_cpsc(&cpsc
) == 10, "RPC sum_cpsc\n");
1108 ok(sum_toplev_conf_2n(c
, 3) == 15, "RPC sum_toplev_conf_2n\n");
1109 ok(sum_toplev_conf_cond(c
, 5, 6, 1) == 10, "RPC sum_toplev_conf_cond\n");
1110 ok(sum_toplev_conf_cond(c
, 5, 6, 0) == 15, "RPC sum_toplev_conf_cond\n");
1112 dc
= malloc(FIELD_OFFSET(doub_carr_t
, a
[2]));
1114 dc
->a
[0] = malloc(FIELD_OFFSET(doub_carr_1_t
, a
[3]));
1119 dc
->a
[1] = malloc(FIELD_OFFSET(doub_carr_1_t
, a
[2]));
1123 ok(sum_doub_carr(dc
) == 19, "RPC sum_doub_carr\n");
1129 make_pyramid_doub_carr(4, &dc
);
1130 ok(check_pyramid_doub_carr(dc
), "RPC make_pyramid_doub_carr\n");
1131 free_pyramid_doub_carr(dc
);
1133 ok(sum_L1_norms(2, vs
) == 21, "RPC sum_L1_norms\n");
1135 memset(api
, 0, sizeof(api
));
1136 pi
= HeapAlloc(GetProcessHeap(), 0, sizeof(*pi
));
1139 get_5numbers(1, api
);
1140 ok(api
[0].pi
== pi
, "RPC varying array [out] pointer changed from %p to %p\n", pi
, api
[0].pi
);
1141 ok(*api
[0].pi
== 0, "pi unmarshalled incorrectly %d\n", *pi
);
1144 get_numbers(1, 1, api
);
1145 ok(api
[0].pi
== pi
, "RPC conformant varying array [out] pointer changed from %p to %p\n", pi
, api
[0].pi
);
1146 ok(*api
[0].pi
== 0, "pi unmarshalled incorrectly %d\n", *pi
);
1147 HeapFree(GetProcessHeap(), 0, pi
);
1157 context_handle_test();
1161 client(const char *test
)
1163 if (strcmp(test
, "tcp_basic") == 0)
1165 static unsigned char iptcp
[] = "ncacn_ip_tcp";
1166 static unsigned char address
[] = "127.0.0.1";
1167 static unsigned char port
[] = PORT
;
1168 unsigned char *binding
;
1170 ok(RPC_S_OK
== RpcStringBindingCompose(NULL
, iptcp
, address
, port
, NULL
, &binding
), "RpcStringBindingCompose\n");
1171 ok(RPC_S_OK
== RpcBindingFromStringBinding(binding
, &IServer_IfHandle
), "RpcBindingFromStringBinding\n");
1175 ok(RPC_S_OK
== RpcStringFree(&binding
), "RpcStringFree\n");
1176 ok(RPC_S_OK
== RpcBindingFree(&IServer_IfHandle
), "RpcBindingFree\n");
1178 else if (strcmp(test
, "np_basic") == 0)
1180 static unsigned char np
[] = "ncacn_np";
1181 static unsigned char address
[] = "\\\\.";
1182 static unsigned char pipe
[] = PIPE
;
1183 unsigned char *binding
;
1185 ok(RPC_S_OK
== RpcStringBindingCompose(NULL
, np
, address
, pipe
, NULL
, &binding
), "RpcStringBindingCompose\n");
1186 ok(RPC_S_OK
== RpcBindingFromStringBinding(binding
, &IServer_IfHandle
), "RpcBindingFromStringBinding\n");
1191 ok(RPC_S_OK
== RpcStringFree(&binding
), "RpcStringFree\n");
1192 ok(RPC_S_OK
== RpcBindingFree(&IServer_IfHandle
), "RpcBindingFree\n");
1199 static unsigned char iptcp
[] = "ncacn_ip_tcp";
1200 static unsigned char port
[] = PORT
;
1201 static unsigned char np
[] = "ncacn_np";
1202 static unsigned char pipe
[] = PIPE
;
1204 ok(RPC_S_OK
== RpcServerUseProtseqEp(iptcp
, 20, port
, NULL
), "RpcServerUseProtseqEp\n");
1205 //ok(RPC_S_OK == RpcServerRegisterIf(s_IServer_v0_0_s_ifspec, NULL, NULL), "RpcServerRegisterIf\n");
1206 ok(RPC_S_OK
== RpcServerListen(1, 20, TRUE
), "RpcServerListen\n");
1208 stop_event
= CreateEvent(NULL
, FALSE
, FALSE
, NULL
);
1209 ok(stop_event
!= NULL
, "CreateEvent failed\n");
1211 ok(run_client("tcp_basic"), "tcp_basic client test failed\n");
1213 ok(RPC_S_OK
== RpcServerUseProtseqEp(np
, 0, pipe
, NULL
), "RpcServerUseProtseqEp\n");
1214 ok(run_client("np_basic"), "np_basic client test failed\n");
1216 ok(WAIT_OBJECT_0
== WaitForSingleObject(stop_event
, 60000), "WaitForSingleObject\n");
1218 ok(RPC_S_OK
== RpcMgmtWaitServerListen(), "RpcMgmtWaitServerListening\n");
1227 argc
= winetest_get_mainargs(&argv
);
1238 trace("Exception %d\n", RpcExceptionCode());