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);
600 ok(RPC_S_OK
== RpcMgmtStopServerListening(NULL
), "RpcMgmtStopServerListening\n");
601 ok(RPC_S_OK
== RpcServerUnregisterIf(NULL
, NULL
, FALSE
), "RpcServerUnregisterIf\n");
602 ok(SetEvent(stop_event
), "SetEvent\n");
606 make_cmdline(char buffer
[MAX_PATH
], const char *test
)
608 sprintf(buffer
, "%s server %s", progname
, test
);
612 run_client(const char *test
)
614 char cmdline
[MAX_PATH
];
615 PROCESS_INFORMATION info
;
616 STARTUPINFOA startup
;
619 memset(&startup
, 0, sizeof startup
);
620 startup
.cb
= sizeof startup
;
622 make_cmdline(cmdline
, test
);
623 ok(CreateProcessA(NULL
, cmdline
, NULL
, NULL
, FALSE
, 0L, NULL
, NULL
, &startup
, &info
), "CreateProcess\n");
624 ok(WaitForSingleObject(info
.hProcess
, 30000) == WAIT_OBJECT_0
, "Child process termination\n");
625 ok(GetExitCodeProcess(info
.hProcess
, &exitcode
), "GetExitCodeProcess\n");
626 ok(CloseHandle(info
.hProcess
), "CloseHandle\n");
627 ok(CloseHandle(info
.hThread
), "CloseHandle\n");
629 return exitcode
== 0;
635 char string
[] = "I am a string";
636 WCHAR wstring
[] = {'I',' ','a','m',' ','a',' ','w','s','t','r','i','n','g', 0};
637 int f
[5] = {1, 3, 0, -2, -4};
638 vector_t a
= {1, 3, 7};
639 vector_t vec1
= {4, -2, 1}, vec2
= {-5, 2, 3}, *pvec2
= &vec2
;
640 pvectors_t pvecs
= {&vec1
, &pvec2
};
641 sp_inner_t spi
= {42};
642 sp_t sp
= {-13, &spi
};
649 int i1
, i2
, i3
, *pi2
, *pi3
, **ppi3
;
656 str_struct_t ss
= {string
};
657 wstr_struct_t ws
= {wstring
};
660 ok(int_return() == INT_CODE
, "RPC int_return\n");
662 ok(square(7) == 49, "RPC square\n");
663 ok(sum(23, -4) == 19, "RPC sum\n");
667 ok(x
== 121, "RPC square_out\n");
671 ok(x
== 25, "RPC square_ref\n");
673 ok(str_length(string
) == strlen(string
), "RPC str_length\n");
674 ok(dot_self(&a
) == 59, "RPC dot_self\n");
676 ok(str_struct_len(&ss
) == lstrlenA(string
), "RPC str_struct_len\n");
677 ok(wstr_struct_len(&ws
) == lstrlenW(wstring
), "RPC str_struct_len\n");
680 u
= square_half(3.0, &v
);
681 ok(u
== 9.0, "RPC square_half\n");
682 ok(v
== 1.5, "RPC square_half\n");
685 s
= square_half_float(3.0f
, &t
);
686 ok(s
== 9.0f
, "RPC square_half_float\n");
687 ok(t
== 1.5f
, "RPC square_half_float\n");
690 q
= square_half_long(3, &r
);
691 ok(q
== 9, "RPC square_half_long\n");
692 ok(r
== 1, "RPC square_half_long\n");
703 ok(pints_sum(&pints
) == -13, "RPC pints_sum\n");
715 ok(ptypes_sum(&ptypes
) == 33.0, "RPC ptypes_sum\n");
717 ok(dot_pvectors(&pvecs
) == -21, "RPC dot_pvectors\n");
718 ok(dot_copy_vectors(vec1
, vec2
) == -21, "RPC dot_copy_vectors\n");
719 ok(sum_fixed_array(f
) == -2, "RPC sum_fixed_array\n");
720 ok(sum_sp(&sp
) == 29, "RPC sum_sp\n");
722 ok(enum_ord(E1
) == 1, "RPC enum_ord\n");
723 ok(enum_ord(E2
) == 2, "RPC enum_ord\n");
724 ok(enum_ord(E3
) == 3, "RPC enum_ord\n");
725 ok(enum_ord(E4
) == 4, "RPC enum_ord\n");
727 memset(&aligns
, 0, sizeof(aligns
));
732 ok(sum_aligns(&aligns
) == 18.0, "RPC sum_aligns\n");
736 ok(sum_padded(&padded
) == 5, "RPC sum_padded\n");
741 ok(sum_padded2(padded2
) == 6, "RPC sum_padded2\n");
746 ok(sum_padded_conf(padded2
, 2) == 6, "RPC sum_padded_conf\n");
755 ok(sum_bogus(&bogus
) == 12, "RPC sum_bogus\n");
759 str
= get_filename();
760 ok(!strcmp(str
, __FILE__
), "get_filename() returned %s instead of %s\n", str
, __FILE__
);
774 ok(square_sun(&su
) == 81.0, "RPC square_sun\n");
778 ok(square_sun(&su
) == 25.0, "RPC square_sun\n");
782 ok(square_sun(&su
) == 4.0, "RPC square_sun\n");
787 ok(square_sun(&su
) == 121.0, "RPC square_sun\n");
790 eu
.tagged_union
.i
= 7;
791 ok(square_encu(&eu
) == 49.0, "RPC square_encu\n");
794 eu
.tagged_union
.f
= 3.0;
795 ok(square_encu(&eu
) == 9.0, "RPC square_encu\n");
798 eue
.tagged_union
.i1
= 8;
799 ok(square_encue(&eue
) == 64.0, "RPC square_encue\n");
802 eue
.tagged_union
.f2
= 10.0;
803 ok(square_encue(&eue
) == 100.0, "RPC square_encue\n");
809 test_list_t
*n
= HeapAlloc(GetProcessHeap(), 0, sizeof *n
);
816 make_list(test_list_t
*tail
)
818 test_list_t
*n
= HeapAlloc(GetProcessHeap(), 0, sizeof *n
);
825 free_list(test_list_t
*list
)
827 if (list
->t
== TL_LIST
)
828 free_list(list
->u
.tail
);
829 HeapFree(GetProcessHeap(), 0, list
);
833 puint_t_UserSize(ULONG
*flags
, ULONG start
, puint_t
*p
)
835 return start
+ sizeof(int);
838 unsigned char * __RPC_USER
839 puint_t_UserMarshal(ULONG
*flags
, unsigned char *buffer
, puint_t
*p
)
842 memcpy(buffer
, &n
, sizeof n
);
843 return buffer
+ sizeof n
;
846 unsigned char * __RPC_USER
847 puint_t_UserUnmarshal(ULONG
*flags
, unsigned char *buffer
, puint_t
*p
)
850 memcpy(&n
, buffer
, sizeof n
);
851 *p
= HeapAlloc(GetProcessHeap(), 0, 10);
852 sprintf(*p
, "%d", n
);
853 return buffer
+ sizeof n
;
857 puint_t_UserFree(ULONG
*flags
, puint_t
*p
)
859 HeapFree(GetProcessHeap(), 0, *p
);
863 us_t_UserSize(ULONG
*flags
, ULONG start
, us_t
*pus
)
865 return start
+ sizeof(struct wire_us
);
868 unsigned char * __RPC_USER
869 us_t_UserMarshal(ULONG
*flags
, unsigned char *buffer
, us_t
*pus
)
872 wus
.x
= atoi(pus
->x
);
873 memcpy(buffer
, &wus
, sizeof wus
);
874 return buffer
+ sizeof wus
;
877 unsigned char * __RPC_USER
878 us_t_UserUnmarshal(ULONG
*flags
, unsigned char *buffer
, us_t
*pus
)
881 memcpy(&wus
, buffer
, sizeof wus
);
882 pus
->x
= HeapAlloc(GetProcessHeap(), 0, 10);
883 sprintf(pus
->x
, "%d", wus
.x
);
884 return buffer
+ sizeof wus
;
888 us_t_UserFree(ULONG
*flags
, us_t
*pus
)
890 HeapFree(GetProcessHeap(), 0, pus
->x
);
894 bstr_t_UserSize(ULONG
*flags
, ULONG start
, bstr_t
*b
)
896 return start
+ FIELD_OFFSET(wire_bstr_t
, data
[(*b
)[-1]]);
899 unsigned char * __RPC_USER
900 bstr_t_UserMarshal(ULONG
*flags
, unsigned char *buffer
, bstr_t
*b
)
902 wire_bstr_t
*wb
= (wire_bstr_t
*) buffer
;
904 memcpy(&wb
->data
, *b
, wb
->n
* sizeof wb
->data
[0]);
905 return buffer
+ FIELD_OFFSET(wire_bstr_t
, data
[wb
->n
]);
908 unsigned char * __RPC_USER
909 bstr_t_UserUnmarshal(ULONG
*flags
, unsigned char *buffer
, bstr_t
*b
)
911 wire_bstr_t
*wb
= (wire_bstr_t
*) buffer
;
912 short *data
= HeapAlloc(GetProcessHeap(), 0, (wb
->n
+ 1) * sizeof *data
);
914 memcpy(&data
[1], wb
->data
, wb
->n
* sizeof data
[1]);
916 return buffer
+ FIELD_OFFSET(wire_bstr_t
, data
[wb
->n
]);
920 bstr_t_UserFree(ULONG
*flags
, bstr_t
*b
)
922 HeapFree(GetProcessHeap(), 0, &((*b
)[-1]));
928 int a
[] = {1, 2, 3, 4};
930 test_list_t
*list
= make_list(make_list(make_list(null_list())));
931 test_us_t tus
= {{p1
}};
935 short bstr_data
[] = { 5, 'H', 'e', 'l', 'l', 'o' };
936 bstr_t bstr
= &bstr_data
[1];
941 ok(test_list_length(list
) == 3, "RPC test_list_length\n");
942 ok(square_puint(p1
) == 121, "RPC square_puint\n");
944 pus
.ps
= HeapAlloc(GetProcessHeap(), 0, pus
.n
* sizeof pus
.ps
[0]);
945 pus
.ps
[0] = xstrdup("5");
946 pus
.ps
[1] = xstrdup("6");
947 pus
.ps
[2] = xstrdup("7");
948 pus
.ps
[3] = xstrdup("8");
949 ok(sum_puints(&pus
) == 26, "RPC sum_puints\n");
950 HeapFree(GetProcessHeap(), 0, pus
.ps
[0]);
951 HeapFree(GetProcessHeap(), 0, pus
.ps
[1]);
952 HeapFree(GetProcessHeap(), 0, pus
.ps
[2]);
953 HeapFree(GetProcessHeap(), 0, pus
.ps
[3]);
954 HeapFree(GetProcessHeap(), 0, pus
.ps
);
956 cpus
.ps
= HeapAlloc(GetProcessHeap(), 0, cpus
.n
* sizeof cpus
.ps
[0]);
957 cpus
.ps
[0] = xstrdup("5");
958 cpus
.ps
[1] = xstrdup("6");
959 cpus
.ps
[2] = xstrdup("7");
960 cpus
.ps
[3] = xstrdup("8");
961 ok(sum_cpuints(&cpus
) == 26, "RPC sum_puints\n");
962 HeapFree(GetProcessHeap(), 0, cpus
.ps
[0]);
963 HeapFree(GetProcessHeap(), 0, cpus
.ps
[1]);
964 HeapFree(GetProcessHeap(), 0, cpus
.ps
[2]);
965 HeapFree(GetProcessHeap(), 0, cpus
.ps
[3]);
966 HeapFree(GetProcessHeap(), 0, cpus
.ps
);
967 ok(square_test_us(&tus
) == 121, "RPC square_test_us\n");
972 ok(sum_parr(pa
) == 6, "RPC sum_parr\n");
978 ok(sum_pcarr(pa
, 4) == 10, "RPC sum_pcarr\n");
980 ok(hash_bstr(bstr
) == s_hash_bstr(bstr
), "RPC hash_bstr_data\n");
985 name
.name
= buffer
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, name
.size
);
987 ok(name
.name
== buffer
, "[in,out] pointer should have stayed as %p but instead changed to %p\n", name
.name
, buffer
);
988 ok(!strcmp(name
.name
, "Jeremy Wh"), "name didn't unmarshall properly, expected \"Jeremy Wh\", but got \"%s\"\n", name
.name
);
989 HeapFree(GetProcessHeap(), 0, name
.name
);
992 ok(sum_pcarr2(4, &pa2
) == 10, "RPC sum_pcarr2\n");
996 check_pyramid_doub_carr(doub_carr_t
*dc
)
999 for (i
= 0; i
< dc
->n
; ++i
)
1000 for (j
= 0; j
< dc
->a
[i
]->n
; ++j
)
1001 if (dc
->a
[i
]->a
[j
] != j
+ 1)
1007 free_pyramid_doub_carr(doub_carr_t
*dc
)
1010 for (i
= 0; i
< dc
->n
; ++i
)
1011 MIDL_user_free(dc
->a
[i
]);
1018 const char str1
[25] = "Hello";
1021 {{1, 2, 3, 4}, {-1, -3, -5, -7}, {0, 2, 4, 6}},
1022 {{1, -2, 3, -4}, {2, 3, 5, 7}, {-4, -1, -14, 4114}}
1024 int c
[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
1025 vector_t vs
[2] = {{1, -2, 3}, {4, -5, -6}};
1030 int ca
[5] = {1, -2, 3, -4, 5};
1033 ok(cstr_length(str1
, sizeof str1
) == strlen(str1
), "RPC cstr_length\n");
1035 ok(sum_fixed_int_3d(m
) == 4116, "RPC sum_fixed_int_3d\n");
1037 ok(sum_conf_array(c
, 10) == 45, "RPC sum_conf_array\n");
1038 ok(sum_conf_array(&c
[5], 2) == 11, "RPC sum_conf_array\n");
1039 ok(sum_conf_array(&c
[7], 1) == 7, "RPC sum_conf_array\n");
1040 ok(sum_conf_array(&c
[2], 0) == 0, "RPC sum_conf_array\n");
1042 ok(sum_unique_conf_array(ca
, 4) == -2, "RPC sum_unique_conf_array\n");
1043 ok(sum_unique_conf_ptr(ca
, 5) == 3, "RPC sum_unique_conf_array\n");
1044 ok(sum_unique_conf_ptr(NULL
, 10) == 0, "RPC sum_unique_conf_array\n");
1046 ok(sum_var_array(c
, 10) == 45, "RPC sum_conf_array\n");
1047 ok(sum_var_array(&c
[5], 2) == 11, "RPC sum_conf_array\n");
1048 ok(sum_var_array(&c
[7], 1) == 7, "RPC sum_conf_array\n");
1049 ok(sum_var_array(&c
[2], 0) == 0, "RPC sum_conf_array\n");
1051 ok(dot_two_vectors(vs
) == -4, "RPC dot_two_vectors\n");
1052 cs
= HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(cs_t
, ca
[5]));
1059 ok(sum_cs(cs
) == 1, "RPC sum_cs\n");
1060 HeapFree(GetProcessHeap(), 0, cs
);
1067 ok(sum_cps(&cps
) == 53, "RPC sum_cps\n");
1073 ok(sum_cpsc(&cpsc
) == 6, "RPC sum_cpsc\n");
1078 ok(sum_cpsc(&cpsc
) == 10, "RPC sum_cpsc\n");
1080 ok(sum_toplev_conf_2n(c
, 3) == 15, "RPC sum_toplev_conf_2n\n");
1081 ok(sum_toplev_conf_cond(c
, 5, 6, 1) == 10, "RPC sum_toplev_conf_cond\n");
1082 ok(sum_toplev_conf_cond(c
, 5, 6, 0) == 15, "RPC sum_toplev_conf_cond\n");
1084 dc
= malloc(FIELD_OFFSET(doub_carr_t
, a
[2]));
1086 dc
->a
[0] = malloc(FIELD_OFFSET(doub_carr_1_t
, a
[3]));
1091 dc
->a
[1] = malloc(FIELD_OFFSET(doub_carr_1_t
, a
[2]));
1095 ok(sum_doub_carr(dc
) == 19, "RPC sum_doub_carr\n");
1101 make_pyramid_doub_carr(4, &dc
);
1102 ok(check_pyramid_doub_carr(dc
), "RPC make_pyramid_doub_carr\n");
1103 free_pyramid_doub_carr(dc
);
1105 ok(sum_L1_norms(2, vs
) == 21, "RPC sum_L1_norms\n");
1115 context_handle_test();
1119 client(const char *test
)
1121 if (strcmp(test
, "tcp_basic") == 0)
1123 static unsigned char iptcp
[] = "ncacn_ip_tcp";
1124 static unsigned char address
[] = "127.0.0.1";
1125 static unsigned char port
[] = PORT
;
1126 unsigned char *binding
;
1128 ok(RPC_S_OK
== RpcStringBindingCompose(NULL
, iptcp
, address
, port
, NULL
, &binding
), "RpcStringBindingCompose\n");
1129 ok(RPC_S_OK
== RpcBindingFromStringBinding(binding
, &IServer_IfHandle
), "RpcBindingFromStringBinding\n");
1133 ok(RPC_S_OK
== RpcStringFree(&binding
), "RpcStringFree\n");
1134 ok(RPC_S_OK
== RpcBindingFree(&IServer_IfHandle
), "RpcBindingFree\n");
1136 else if (strcmp(test
, "np_basic") == 0)
1138 static unsigned char np
[] = "ncacn_np";
1139 static unsigned char address
[] = "\\\\.";
1140 static unsigned char pipe
[] = PIPE
;
1141 unsigned char *binding
;
1143 ok(RPC_S_OK
== RpcStringBindingCompose(NULL
, np
, address
, pipe
, NULL
, &binding
), "RpcStringBindingCompose\n");
1144 ok(RPC_S_OK
== RpcBindingFromStringBinding(binding
, &IServer_IfHandle
), "RpcBindingFromStringBinding\n");
1149 ok(RPC_S_OK
== RpcStringFree(&binding
), "RpcStringFree\n");
1150 ok(RPC_S_OK
== RpcBindingFree(&IServer_IfHandle
), "RpcBindingFree\n");
1157 static unsigned char iptcp
[] = "ncacn_ip_tcp";
1158 static unsigned char port
[] = PORT
;
1159 static unsigned char np
[] = "ncacn_np";
1160 static unsigned char pipe
[] = PIPE
;
1162 ok(RPC_S_OK
== RpcServerUseProtseqEp(iptcp
, 20, port
, NULL
), "RpcServerUseProtseqEp\n");
1163 ok(RPC_S_OK
== RpcServerRegisterIf(s_IServer_v0_0_s_ifspec
, NULL
, NULL
), "RpcServerRegisterIf\n");
1164 ok(RPC_S_OK
== RpcServerListen(1, 20, TRUE
), "RpcServerListen\n");
1166 stop_event
= CreateEvent(NULL
, FALSE
, FALSE
, NULL
);
1167 ok(stop_event
!= NULL
, "CreateEvent failed\n");
1169 ok(run_client("tcp_basic"), "tcp_basic client test failed\n");
1171 ok(RPC_S_OK
== RpcServerUseProtseqEp(np
, 0, pipe
, NULL
), "RpcServerUseProtseqEp\n");
1172 ok(run_client("np_basic"), "np_basic client test failed\n");
1174 ok(WAIT_OBJECT_0
== WaitForSingleObject(stop_event
, 60000), "WaitForSingleObject\n");
1176 ok(RPC_S_OK
== RpcMgmtWaitServerListen(), "RpcMgmtWaitServerListening\n");
1185 argc
= winetest_get_mainargs(&argv
);
1196 trace("Exception %d\n", RpcExceptionCode());