push 149f0a5527ac85057a8ef03858d34d91c36f97e8
[wine/hacks.git] / dlls / rpcrt4 / tests / server.c
blob2a32b45b2f5908d0783607317c1711b3765a5c08
1 /*
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
21 #include <windows.h>
22 #include "wine/test.h"
23 #include "server.h"
24 #include "server_defines.h"
26 #include <stddef.h>
27 #include <stdio.h>
28 #include <stdlib.h>
30 #define PORT "4114"
31 #define PIPE "\\pipe\\wine_rpcrt4_test"
33 #define INT_CODE 4198
35 static const char *progname;
36 static BOOL old_windows_version;
38 static HANDLE stop_event;
40 static void (WINAPI *pNDRSContextMarshall2)(RPC_BINDING_HANDLE, NDR_SCONTEXT, void*, NDR_RUNDOWN, void*, ULONG);
41 static NDR_SCONTEXT (WINAPI *pNDRSContextUnmarshall2)(RPC_BINDING_HANDLE, void*, ULONG, void*, ULONG);
42 static RPC_STATUS (WINAPI *pRpcServerRegisterIfEx)(RPC_IF_HANDLE,UUID*, RPC_MGR_EPV*, unsigned int,
43 unsigned int,RPC_IF_CALLBACK_FN*);
45 /* type check statements generated in header file */
46 fnprintf *p_printf = printf;
48 static void InitFunctionPointers(void)
50 HMODULE hrpcrt4 = GetModuleHandleA("rpcrt4.dll");
52 pNDRSContextMarshall2 = (void *)GetProcAddress(hrpcrt4, "NDRSContextMarshall2");
53 pNDRSContextUnmarshall2 = (void *)GetProcAddress(hrpcrt4, "NDRSContextUnmarshall2");
54 pRpcServerRegisterIfEx = (void *)GetProcAddress(hrpcrt4, "RpcServerRegisterIfEx");
56 if (!pNDRSContextMarshall2) old_windows_version = TRUE;
59 void __RPC_FAR *__RPC_USER
60 midl_user_allocate(SIZE_T n)
62 return HeapAlloc(GetProcessHeap(), 0, n);
65 void __RPC_USER
66 midl_user_free(void __RPC_FAR *p)
68 HeapFree(GetProcessHeap(), 0, p);
71 static char *
72 xstrdup(const char *s)
74 char *d = HeapAlloc(GetProcessHeap(), 0, strlen(s) + 1);
75 strcpy(d, s);
76 return d;
79 int
80 s_int_return(void)
82 return INT_CODE;
85 int
86 s_square(int x)
88 return x * x;
91 int
92 s_sum(int x, int y)
94 return x + y;
97 void
98 s_square_out(int x, int *y)
100 *y = s_square(x);
103 void
104 s_square_ref(int *x)
106 *x = s_square(*x);
110 s_str_length(const char *s)
112 return strlen(s);
116 s_str_t_length(str_t s)
118 return strlen(s);
122 s_cstr_length(const char *s, int n)
124 int len = 0;
125 while (0 < n-- && *s++)
126 ++len;
127 return len;
131 s_dot_self(vector_t *v)
133 return s_square(v->x) + s_square(v->y) + s_square(v->z);
136 double
137 s_square_half(double x, double *y)
139 *y = x / 2.0;
140 return x * x;
143 float
144 s_square_half_float(float x, float *y)
146 *y = x / 2.0f;
147 return x * x;
150 LONG
151 s_square_half_long(LONG x, LONG *y)
153 *y = x / 2;
154 return x * x;
158 s_sum_fixed_array(int a[5])
160 return a[0] + a[1] + a[2] + a[3] + a[4];
164 s_pints_sum(pints_t *pints)
166 return *pints->pi + **pints->ppi + ***pints->pppi;
169 double
170 s_ptypes_sum(ptypes_t *pt)
172 return *pt->pc + *pt->ps + *pt->pl + *pt->pf + *pt->pd;
176 s_dot_pvectors(pvectors_t *p)
178 return p->pu->x * (*p->pv)->x + p->pu->y * (*p->pv)->y + p->pu->z * (*p->pv)->z;
182 s_sum_sp(sp_t *sp)
184 return sp->x + sp->s->x;
187 double
188 s_square_sun(sun_t *su)
190 switch (su->s)
192 case SUN_I: return su->u.i * su->u.i;
193 case SUN_F1:
194 case SUN_F2: return su->u.f * su->u.f;
195 case SUN_PI: return (*su->u.pi) * (*su->u.pi);
196 default:
197 return 0.0;
202 s_test_list_length(test_list_t *list)
204 return (list->t == TL_LIST
205 ? 1 + s_test_list_length(list->u.tail)
206 : 0);
210 s_sum_fixed_int_3d(int m[2][3][4])
212 int i, j, k;
213 int sum = 0;
215 for (i = 0; i < 2; ++i)
216 for (j = 0; j < 3; ++j)
217 for (k = 0; k < 4; ++k)
218 sum += m[i][j][k];
220 return sum;
224 s_sum_conf_array(int x[], int n)
226 int *p = x, *end = p + n;
227 int sum = 0;
229 while (p < end)
230 sum += *p++;
232 return sum;
236 s_sum_conf_ptr_by_conf_ptr(int n1, int *n2_then_x1, int *x2)
238 int i;
239 int sum = 0;
240 if(n1 == 0)
241 return 0;
243 for(i = 1; i < n1; ++i)
244 sum += n2_then_x1[i];
246 for(i = 0; i < *n2_then_x1; ++i)
247 sum += x2[i];
249 return sum;
253 s_sum_unique_conf_array(int x[], int n)
255 return s_sum_conf_array(x, n);
259 s_sum_unique_conf_ptr(int *x, int n)
261 return x ? s_sum_conf_array(x, n) : 0;
265 s_sum_var_array(int x[20], int n)
267 ok(0 <= n, "RPC sum_var_array\n");
268 ok(n <= 20, "RPC sum_var_array\n");
270 return s_sum_conf_array(x, n);
274 s_dot_two_vectors(vector_t vs[2])
276 return vs[0].x * vs[1].x + vs[0].y * vs[1].y + vs[0].z * vs[1].z;
280 s_sum_cs(cs_t *cs)
282 return s_sum_conf_array(cs->ca, cs->n);
286 s_sum_cps(cps_t *cps)
288 int sum = 0;
289 int i;
291 for (i = 0; i < *cps->pn; ++i)
292 sum += cps->ca1[i];
294 for (i = 0; i < 2 * cps->n; ++i)
295 sum += cps->ca2[i];
297 return sum;
301 s_sum_cpsc(cpsc_t *cpsc)
303 int sum = 0;
304 int i;
305 for (i = 0; i < (cpsc->c ? cpsc->a : cpsc->b); ++i)
306 sum += cpsc->ca[i];
307 return sum;
311 s_square_puint(puint_t p)
313 int n = atoi(p);
314 return n * n;
318 s_sum_puints(puints_t *p)
320 int sum = 0;
321 int i;
322 for (i = 0; i < p->n; ++i)
323 sum += atoi(p->ps[i]);
324 return sum;
328 s_sum_cpuints(cpuints_t *p)
330 int sum = 0;
331 int i;
332 for (i = 0; i < p->n; ++i)
333 sum += atoi(p->ps[i]);
334 return sum;
338 s_dot_copy_vectors(vector_t u, vector_t v)
340 return u.x * v.x + u.y * v.y + u.z * v.z;
344 s_square_test_us(test_us_t *tus)
346 int n = atoi(tus->us.x);
347 return n * n;
350 double
351 s_square_encu(encu_t *eu)
353 switch (eu->t)
355 case ENCU_I: return eu->tagged_union.i * eu->tagged_union.i;
356 case ENCU_F: return eu->tagged_union.f * eu->tagged_union.f;
357 default:
358 return 0.0;
362 double
363 s_square_unencu(int t, unencu_t *eu)
365 switch (t)
367 case ENCU_I: return eu->i * eu->i;
368 case ENCU_F: return eu->f * eu->f;
369 default:
370 return 0.0;
374 void
375 s_check_se2(se_t *s)
377 ok(s->f == E2, "check_se2\n");
381 s_sum_parr(int *a[3])
383 return s_sum_pcarr(a, 3);
387 s_sum_pcarr(int *a[], int n)
389 int i, s = 0;
390 for (i = 0; i < n; ++i)
391 s += *a[i];
392 return s;
396 s_enum_ord(e_t e)
398 switch (e)
400 case E1: return 1;
401 case E2: return 2;
402 case E3: return 3;
403 case E4: return 4;
404 default:
405 return 0;
409 double
410 s_square_encue(encue_t *eue)
412 switch (eue->t)
414 case E1: return eue->tagged_union.i1 * eue->tagged_union.i1;
415 case E2: return eue->tagged_union.f2 * eue->tagged_union.f2;
416 default:
417 return 0.0;
422 s_sum_toplev_conf_2n(int *x, int n)
424 int sum = 0;
425 int i;
426 for (i = 0; i < 2 * n; ++i)
427 sum += x[i];
428 return sum;
432 s_sum_toplev_conf_cond(int *x, int a, int b, int c)
434 int sum = 0;
435 int n = c ? a : b;
436 int i;
437 for (i = 0; i < n; ++i)
438 sum += x[i];
439 return sum;
442 double
443 s_sum_aligns(aligns_t *a)
445 return a->c + a->i + a->s + a->d;
449 s_sum_padded(padded_t *p)
451 return p->i + p->c;
455 s_sum_padded2(padded_t ps[2])
457 return s_sum_padded(&ps[0]) + s_sum_padded(&ps[1]);
461 s_sum_padded_conf(padded_t *ps, int n)
463 int sum = 0;
464 int i;
465 for (i = 0; i < n; ++i)
466 sum += s_sum_padded(&ps[i]);
467 return sum;
471 s_sum_bogus(bogus_t *b)
473 return *b->h.p1 + *b->p2 + *b->p3 + b->c;
476 void
477 s_check_null(int *null)
479 ok(!null, "RPC check_null\n");
483 s_str_struct_len(str_struct_t *s)
485 return lstrlenA(s->s);
489 s_wstr_struct_len(wstr_struct_t *s)
491 return lstrlenW(s->s);
495 s_sum_doub_carr(doub_carr_t *dc)
497 int i, j;
498 int sum = 0;
499 for (i = 0; i < dc->n; ++i)
500 for (j = 0; j < dc->a[i]->n; ++j)
501 sum += dc->a[i]->a[j];
502 return sum;
505 void
506 s_make_pyramid_doub_carr(unsigned char n, doub_carr_t **dc)
508 doub_carr_t *t;
509 int i, j;
510 t = MIDL_user_allocate(FIELD_OFFSET(doub_carr_t, a[n]));
511 t->n = n;
512 for (i = 0; i < n; ++i)
514 int v = i + 1;
515 t->a[i] = MIDL_user_allocate(FIELD_OFFSET(doub_carr_1_t, a[v]));
516 t->a[i]->n = v;
517 for (j = 0; j < v; ++j)
518 t->a[i]->a[j] = j + 1;
520 *dc = t;
523 unsigned
524 s_hash_bstr(bstr_t b)
526 short n = b[-1];
527 short *s = b;
528 unsigned hash = 0;
529 short i;
530 for (i = 0; i < n; ++i)
531 hash = 5 * hash + (unsigned) s[i];
532 return hash;
535 void
536 s_get_name(name_t *name)
538 const char bossman[] = "Jeremy White";
539 memcpy(name->name, bossman, min(name->size, sizeof(bossman)));
540 /* ensure nul-termination */
541 if (name->size < sizeof(bossman))
542 name->name[name->size - 1] = 0;
546 s_sum_pcarr2(int n, int **pa)
548 return s_sum_conf_array(*pa, n);
552 s_sum_L1_norms(int n, vector_t *vs)
554 int i;
555 int sum = 0;
556 for (i = 0; i < n; ++i)
557 sum += abs(vs[i].x) + abs(vs[i].y) + abs(vs[i].z);
558 return sum;
561 s123_t *
562 s_get_s123(void)
564 s123_t *s = MIDL_user_allocate(sizeof *s);
565 s->f1 = 1;
566 s->f2 = 2;
567 s->f3 = 3;
568 return s;
571 str_t
572 s_get_filename(void)
574 return (char *)__FILE__;
577 int s_echo_ranged_int(int n)
579 return n;
582 void s_get_ranged_enum(renum_t *re)
584 *re = RE3;
587 void
588 s_context_handle_test(void)
590 NDR_SCONTEXT h;
591 RPC_BINDING_HANDLE binding;
592 RPC_STATUS status;
593 unsigned char buf[20];
594 static RPC_SERVER_INTERFACE server_if =
596 sizeof(RPC_SERVER_INTERFACE),
597 {{0x00000000,0x4114,0x0704,{0x23,0x01,0x00,0x00,0x00,0x00,0x00,0x00}},{1,0}},
598 {{0x8a885d04,0x1ceb,0x11c9,{0x9f,0xe8,0x08,0x00,0x2b,0x10,0x48,0x60}},{2,0}},
599 NULL,
607 binding = I_RpcGetCurrentCallHandle();
608 ok(binding != NULL, "I_RpcGetCurrentCallHandle returned NULL\n");
610 if (!pNDRSContextMarshall2 || !pNDRSContextUnmarshall2)
612 win_skip("NDRSContextMarshall2 or NDRSContextUnmarshall2 not exported from rpcrt4.dll\n");
613 return;
616 h = pNDRSContextUnmarshall2(binding, NULL, NDR_LOCAL_DATA_REPRESENTATION, NULL, 0);
617 ok(h != NULL, "NDRSContextUnmarshall2 returned NULL\n");
619 /* marshal a context handle with NULL userContext */
620 memset(buf, 0xcc, sizeof(buf));
621 pNDRSContextMarshall2(binding, h, buf, NULL, NULL, 0);
622 ok(*(ULONG *)buf == 0, "attributes should have been set to 0 instead of 0x%x\n", *(ULONG *)buf);
623 ok(UuidIsNil((UUID *)&buf[4], &status), "uuid should have been nil\n");
625 h = pNDRSContextUnmarshall2(binding, NULL, NDR_LOCAL_DATA_REPRESENTATION, NULL, 0);
626 ok(h != NULL, "NDRSContextUnmarshall2 returned NULL\n");
628 /* marshal a context handle with non-NULL userContext */
629 memset(buf, 0xcc, sizeof(buf));
630 h->userContext = (void *)0xdeadbeef;
631 pNDRSContextMarshall2(binding, h, buf, NULL, NULL, 0);
632 ok(*(ULONG *)buf == 0, "attributes should have been set to 0 instead of 0x%x\n", *(ULONG *)buf);
633 ok(!UuidIsNil((UUID *)&buf[4], &status), "uuid should not have been nil\n");
635 /* raises ERROR_INVALID_HANDLE exception on Vista upwards */
636 if (0)
638 h = pNDRSContextUnmarshall2(binding, buf, NDR_LOCAL_DATA_REPRESENTATION, NULL, 0);
639 ok(h != NULL, "NDRSContextUnmarshall2 returned NULL\n");
640 ok(h->userContext == (void *)0xdeadbeef, "userContext of interface didn't unmarshal properly: %p\n", h->userContext);
642 /* marshal a context handle with an interface specified */
643 h = pNDRSContextUnmarshall2(binding, NULL, NDR_LOCAL_DATA_REPRESENTATION, &server_if.InterfaceId, 0);
644 ok(h != NULL, "NDRSContextUnmarshall2 returned NULL\n");
646 memset(buf, 0xcc, sizeof(buf));
647 h->userContext = (void *)0xcafebabe;
648 pNDRSContextMarshall2(binding, h, buf, NULL, &server_if.InterfaceId, 0);
649 ok(*(ULONG *)buf == 0, "attributes should have been set to 0 instead of 0x%x\n", *(ULONG *)buf);
650 ok(!UuidIsNil((UUID *)&buf[4], &status), "uuid should not have been nil\n");
652 h = pNDRSContextUnmarshall2(binding, buf, NDR_LOCAL_DATA_REPRESENTATION, &server_if.InterfaceId, 0);
653 ok(h != NULL, "NDRSContextUnmarshall2 returned NULL\n");
654 ok(h->userContext == (void *)0xcafebabe, "userContext of interface didn't unmarshal properly: %p\n", h->userContext);
657 /* test same interface data, but different pointer */
658 /* raises ERROR_INVALID_HANDLE exception */
659 if (0)
661 RPC_SERVER_INTERFACE server_if_clone = server_if;
663 pNDRSContextUnmarshall2(binding, buf, NDR_LOCAL_DATA_REPRESENTATION, &server_if_clone.InterfaceId, 0);
666 /* test different interface data, but different pointer */
667 /* raises ERROR_INVALID_HANDLE exception */
668 if (0)
670 static RPC_SERVER_INTERFACE server_if2 =
672 sizeof(RPC_SERVER_INTERFACE),
673 {{0x00000000,0x4114,0x0704,{0x23,0x01,0x00,0x00,0x00,0x00,0x00,0x00}},{1,0}},
674 {{0x8a885d04,0x1ceb,0x11c9,{0x9f,0xe8,0x08,0x00,0x2b,0x10,0x48,0x60}},{2,0}},
675 NULL,
682 pNDRSContextMarshall2(binding, h, buf, NULL, &server_if.InterfaceId, 0);
684 pNDRSContextUnmarshall2(binding, buf, NDR_LOCAL_DATA_REPRESENTATION, &server_if2.InterfaceId, 0);
688 void
689 s_get_numbers(int length, int size, pints_t n[])
691 int i;
692 for (i = 0; i < length; i++)
694 n[i].pi = midl_user_allocate(sizeof(*n[i].pi));
695 *n[i].pi = i;
696 n[i].ppi = NULL;
697 n[i].pppi = NULL;
701 void
702 s_get_numbers_struct(numbers_struct_t **ns)
704 int i;
705 *ns = midl_user_allocate(FIELD_OFFSET(numbers_struct_t, numbers[5]));
706 if (!*ns) return;
707 (*ns)->length = 5;
708 (*ns)->size = 5;
709 for (i = 0; i < (*ns)->length; i++)
711 (*ns)->numbers[i].pi = NULL;
712 (*ns)->numbers[i].ppi = NULL;
713 (*ns)->numbers[i].pppi = NULL;
715 (*ns)->numbers[0].pi = midl_user_allocate(sizeof(*(*ns)->numbers[i].pi));
716 *(*ns)->numbers[0].pi = 5;
719 void
720 s_full_pointer_test(int *a, int *b)
722 ok(*a == 42, "Expected *a to be 42 instead of %d\n", *a);
723 ok(*b == 42, "Expected *b to be 42 instead of %d\n", *a);
724 ok(a == b, "Expected a (%p) to point to the same memory as b (%p)\n", a, b);
727 void
728 s_full_pointer_null_test(int *a, int *b)
730 ok(*a == 42, "Expected *a to be 42 instead of %d\n", *a);
731 ok(b == NULL, "Expected b to be NULL instead of %p\n", b);
734 void
735 s_stop(void)
737 ok(RPC_S_OK == RpcMgmtStopServerListening(NULL), "RpcMgmtStopServerListening\n");
738 ok(RPC_S_OK == RpcServerUnregisterIf(NULL, NULL, FALSE), "RpcServerUnregisterIf\n");
739 ok(SetEvent(stop_event), "SetEvent\n");
742 static void
743 make_cmdline(char buffer[MAX_PATH], const char *test)
745 sprintf(buffer, "%s server %s", progname, test);
748 static void
749 run_client(const char *test)
751 char cmdline[MAX_PATH];
752 PROCESS_INFORMATION info;
753 STARTUPINFOA startup;
755 memset(&startup, 0, sizeof startup);
756 startup.cb = sizeof startup;
758 make_cmdline(cmdline, test);
759 ok(CreateProcessA(NULL, cmdline, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess\n");
760 winetest_wait_child_process( info.hProcess );
761 ok(CloseHandle(info.hProcess), "CloseHandle\n");
762 ok(CloseHandle(info.hThread), "CloseHandle\n");
765 static void
766 basic_tests(void)
768 char string[] = "I am a string";
769 WCHAR wstring[] = {'I',' ','a','m',' ','a',' ','w','s','t','r','i','n','g', 0};
770 int f[5] = {1, 3, 0, -2, -4};
771 vector_t a = {1, 3, 7};
772 vector_t vec1 = {4, -2, 1}, vec2 = {-5, 2, 3}, *pvec2 = &vec2;
773 pvectors_t pvecs = {&vec1, &pvec2};
774 sp_inner_t spi = {42};
775 sp_t sp = {-13, &spi};
776 aligns_t aligns;
777 pints_t pints;
778 ptypes_t ptypes;
779 padded_t padded;
780 padded_t padded2[2];
781 bogus_t bogus;
782 int i1, i2, i3, *pi2, *pi3, **ppi3;
783 double u, v;
784 float s, t;
785 LONG q, r;
786 short h;
787 char c;
788 int x;
789 str_struct_t ss = {string};
790 wstr_struct_t ws = {wstring};
791 str_t str;
792 se_t se;
793 renum_t re;
795 ok(int_return() == INT_CODE, "RPC int_return\n");
797 ok(square(7) == 49, "RPC square\n");
798 ok(sum(23, -4) == 19, "RPC sum\n");
800 x = 0;
801 square_out(11, &x);
802 ok(x == 121, "RPC square_out\n");
804 x = 5;
805 square_ref(&x);
806 ok(x == 25, "RPC square_ref\n");
808 ok(str_length(string) == strlen(string), "RPC str_length\n");
809 ok(str_t_length(string) == strlen(string), "RPC str_length\n");
810 ok(dot_self(&a) == 59, "RPC dot_self\n");
812 ok(str_struct_len(&ss) == lstrlenA(string), "RPC str_struct_len\n");
813 ok(wstr_struct_len(&ws) == lstrlenW(wstring), "RPC str_struct_len\n");
815 v = 0.0;
816 u = square_half(3.0, &v);
817 ok(u == 9.0, "RPC square_half\n");
818 ok(v == 1.5, "RPC square_half\n");
820 t = 0.0f;
821 s = square_half_float(3.0f, &t);
822 ok(s == 9.0f, "RPC square_half_float\n");
823 ok(t == 1.5f, "RPC square_half_float\n");
825 r = 0;
826 q = square_half_long(3, &r);
827 ok(q == 9, "RPC square_half_long\n");
828 ok(r == 1, "RPC square_half_long\n");
830 i1 = 19;
831 i2 = -3;
832 i3 = -29;
833 pi2 = &i2;
834 pi3 = &i3;
835 ppi3 = &pi3;
836 pints.pi = &i1;
837 pints.ppi = &pi2;
838 pints.pppi = &ppi3;
839 ok(pints_sum(&pints) == -13, "RPC pints_sum\n");
841 c = 10;
842 h = 3;
843 q = 14;
844 s = -5.0f;
845 u = 11.0;
846 ptypes.pc = &c;
847 ptypes.ps = &h;
848 ptypes.pl = &q;
849 ptypes.pf = &s;
850 ptypes.pd = &u;
851 ok(ptypes_sum(&ptypes) == 33.0, "RPC ptypes_sum\n");
853 ok(dot_pvectors(&pvecs) == -21, "RPC dot_pvectors\n");
854 ok(dot_copy_vectors(vec1, vec2) == -21, "RPC dot_copy_vectors\n");
855 ok(sum_fixed_array(f) == -2, "RPC sum_fixed_array\n");
856 ok(sum_sp(&sp) == 29, "RPC sum_sp\n");
858 ok(enum_ord(E1) == 1, "RPC enum_ord\n");
859 ok(enum_ord(E2) == 2, "RPC enum_ord\n");
860 ok(enum_ord(E3) == 3, "RPC enum_ord\n");
861 ok(enum_ord(E4) == 4, "RPC enum_ord\n");
863 se.f = E2;
864 check_se2(&se);
866 memset(&aligns, 0, sizeof(aligns));
867 aligns.c = 3;
868 aligns.i = 4;
869 aligns.s = 5;
870 aligns.d = 6.0;
871 ok(sum_aligns(&aligns) == 18.0, "RPC sum_aligns\n");
873 padded.i = -3;
874 padded.c = 8;
875 ok(sum_padded(&padded) == 5, "RPC sum_padded\n");
876 padded2[0].i = -5;
877 padded2[0].c = 1;
878 padded2[1].i = 3;
879 padded2[1].c = 7;
880 ok(sum_padded2(padded2) == 6, "RPC sum_padded2\n");
881 padded2[0].i = -5;
882 padded2[0].c = 1;
883 padded2[1].i = 3;
884 padded2[1].c = 7;
885 ok(sum_padded_conf(padded2, 2) == 6, "RPC sum_padded_conf\n");
887 i1 = 14;
888 i2 = -7;
889 i3 = -4;
890 bogus.h.p1 = &i1;
891 bogus.p2 = &i2;
892 bogus.p3 = &i3;
893 bogus.c = 9;
894 ok(sum_bogus(&bogus) == 12, "RPC sum_bogus\n");
896 check_null(NULL);
898 str = get_filename();
899 ok(!strcmp(str, __FILE__), "get_filename() returned %s instead of %s\n", str, __FILE__);
900 midl_user_free(str);
902 x = echo_ranged_int(0);
903 ok(x == 0, "echo_ranged_int() returned %d instead of 0\n", x);
904 x = echo_ranged_int(100);
905 ok(x == 100, "echo_ranged_int() returned %d instead of 100\n", x);
907 if (!old_windows_version)
909 get_ranged_enum(&re);
910 ok(re == RE3, "get_ranged_enum() returned %d instead of RE3\n", re);
914 static void
915 union_tests(void)
917 encue_t eue;
918 encu_t eu;
919 unencu_t uneu;
920 sun_t su;
921 int i;
923 su.s = SUN_I;
924 su.u.i = 9;
925 ok(square_sun(&su) == 81.0, "RPC square_sun\n");
927 su.s = SUN_F1;
928 su.u.f = 5.0;
929 ok(square_sun(&su) == 25.0, "RPC square_sun\n");
931 su.s = SUN_F2;
932 su.u.f = -2.0;
933 ok(square_sun(&su) == 4.0, "RPC square_sun\n");
935 su.s = SUN_PI;
936 su.u.pi = &i;
937 i = 11;
938 ok(square_sun(&su) == 121.0, "RPC square_sun\n");
940 eu.t = ENCU_I;
941 eu.tagged_union.i = 7;
942 ok(square_encu(&eu) == 49.0, "RPC square_encu\n");
944 eu.t = ENCU_F;
945 eu.tagged_union.f = 3.0;
946 ok(square_encu(&eu) == 9.0, "RPC square_encu\n");
948 uneu.i = 4;
949 ok(square_unencu(ENCU_I, &uneu) == 16.0, "RPC square_unencu\n");
951 uneu.f = 5.0;
952 ok(square_unencu(ENCU_F, &uneu) == 25.0, "RPC square_unencu\n");
954 eue.t = E1;
955 eue.tagged_union.i1 = 8;
956 ok(square_encue(&eue) == 64.0, "RPC square_encue\n");
958 eue.t = E2;
959 eue.tagged_union.f2 = 10.0;
960 ok(square_encue(&eue) == 100.0, "RPC square_encue\n");
963 static test_list_t *
964 null_list(void)
966 test_list_t *n = HeapAlloc(GetProcessHeap(), 0, sizeof *n);
967 n->t = TL_NULL;
968 n->u.x = 0;
969 return n;
972 static test_list_t *
973 make_list(test_list_t *tail)
975 test_list_t *n = HeapAlloc(GetProcessHeap(), 0, sizeof *n);
976 n->t = TL_LIST;
977 n->u.tail = tail;
978 return n;
981 static void
982 free_list(test_list_t *list)
984 if (list->t == TL_LIST)
985 free_list(list->u.tail);
986 HeapFree(GetProcessHeap(), 0, list);
989 ULONG __RPC_USER
990 puint_t_UserSize(ULONG *flags, ULONG start, puint_t *p)
992 return start + sizeof(int);
995 unsigned char * __RPC_USER
996 puint_t_UserMarshal(ULONG *flags, unsigned char *buffer, puint_t *p)
998 int n = atoi(*p);
999 memcpy(buffer, &n, sizeof n);
1000 return buffer + sizeof n;
1003 unsigned char * __RPC_USER
1004 puint_t_UserUnmarshal(ULONG *flags, unsigned char *buffer, puint_t *p)
1006 int n;
1007 memcpy(&n, buffer, sizeof n);
1008 *p = HeapAlloc(GetProcessHeap(), 0, 10);
1009 sprintf(*p, "%d", n);
1010 return buffer + sizeof n;
1013 void __RPC_USER
1014 puint_t_UserFree(ULONG *flags, puint_t *p)
1016 HeapFree(GetProcessHeap(), 0, *p);
1019 ULONG __RPC_USER
1020 us_t_UserSize(ULONG *flags, ULONG start, us_t *pus)
1022 return start + sizeof(struct wire_us);
1025 unsigned char * __RPC_USER
1026 us_t_UserMarshal(ULONG *flags, unsigned char *buffer, us_t *pus)
1028 struct wire_us wus;
1029 wus.x = atoi(pus->x);
1030 memcpy(buffer, &wus, sizeof wus);
1031 return buffer + sizeof wus;
1034 unsigned char * __RPC_USER
1035 us_t_UserUnmarshal(ULONG *flags, unsigned char *buffer, us_t *pus)
1037 struct wire_us wus;
1038 memcpy(&wus, buffer, sizeof wus);
1039 pus->x = HeapAlloc(GetProcessHeap(), 0, 10);
1040 sprintf(pus->x, "%d", wus.x);
1041 return buffer + sizeof wus;
1044 void __RPC_USER
1045 us_t_UserFree(ULONG *flags, us_t *pus)
1047 HeapFree(GetProcessHeap(), 0, pus->x);
1050 ULONG __RPC_USER
1051 bstr_t_UserSize(ULONG *flags, ULONG start, bstr_t *b)
1053 return start + FIELD_OFFSET(user_bstr_t, data[(*b)[-1]]);
1056 unsigned char * __RPC_USER
1057 bstr_t_UserMarshal(ULONG *flags, unsigned char *buffer, bstr_t *b)
1059 wire_bstr_t wb = (wire_bstr_t) buffer;
1060 wb->n = (*b)[-1];
1061 memcpy(&wb->data, *b, wb->n * sizeof wb->data[0]);
1062 return buffer + FIELD_OFFSET(user_bstr_t, data[wb->n]);
1065 unsigned char * __RPC_USER
1066 bstr_t_UserUnmarshal(ULONG *flags, unsigned char *buffer, bstr_t *b)
1068 wire_bstr_t wb = (wire_bstr_t) buffer;
1069 short *data = HeapAlloc(GetProcessHeap(), 0, (wb->n + 1) * sizeof *data);
1070 data[0] = wb->n;
1071 memcpy(&data[1], wb->data, wb->n * sizeof data[1]);
1072 *b = &data[1];
1073 return buffer + FIELD_OFFSET(user_bstr_t, data[wb->n]);
1076 void __RPC_USER
1077 bstr_t_UserFree(ULONG *flags, bstr_t *b)
1079 HeapFree(GetProcessHeap(), 0, &((*b)[-1]));
1082 static void
1083 pointer_tests(void)
1085 int a[] = {1, 2, 3, 4};
1086 char p1[] = "11";
1087 test_list_t *list = make_list(make_list(make_list(null_list())));
1088 test_us_t tus = {{p1}};
1089 int *pa[4];
1090 puints_t pus;
1091 cpuints_t cpus;
1092 short bstr_data[] = { 5, 'H', 'e', 'l', 'l', 'o' };
1093 bstr_t bstr = &bstr_data[1];
1094 name_t name;
1095 void *buffer;
1096 int *pa2;
1097 s123_t *s123;
1098 int val = 42;
1100 ok(test_list_length(list) == 3, "RPC test_list_length\n");
1101 ok(square_puint(p1) == 121, "RPC square_puint\n");
1102 pus.n = 4;
1103 pus.ps = HeapAlloc(GetProcessHeap(), 0, pus.n * sizeof pus.ps[0]);
1104 pus.ps[0] = xstrdup("5");
1105 pus.ps[1] = xstrdup("6");
1106 pus.ps[2] = xstrdup("7");
1107 pus.ps[3] = xstrdup("8");
1108 ok(sum_puints(&pus) == 26, "RPC sum_puints\n");
1109 HeapFree(GetProcessHeap(), 0, pus.ps[0]);
1110 HeapFree(GetProcessHeap(), 0, pus.ps[1]);
1111 HeapFree(GetProcessHeap(), 0, pus.ps[2]);
1112 HeapFree(GetProcessHeap(), 0, pus.ps[3]);
1113 HeapFree(GetProcessHeap(), 0, pus.ps);
1114 cpus.n = 4;
1115 cpus.ps = HeapAlloc(GetProcessHeap(), 0, cpus.n * sizeof cpus.ps[0]);
1116 cpus.ps[0] = xstrdup("5");
1117 cpus.ps[1] = xstrdup("6");
1118 cpus.ps[2] = xstrdup("7");
1119 cpus.ps[3] = xstrdup("8");
1120 ok(sum_cpuints(&cpus) == 26, "RPC sum_puints\n");
1121 HeapFree(GetProcessHeap(), 0, cpus.ps[0]);
1122 HeapFree(GetProcessHeap(), 0, cpus.ps[1]);
1123 HeapFree(GetProcessHeap(), 0, cpus.ps[2]);
1124 HeapFree(GetProcessHeap(), 0, cpus.ps[3]);
1125 HeapFree(GetProcessHeap(), 0, cpus.ps);
1126 ok(square_test_us(&tus) == 121, "RPC square_test_us\n");
1128 pa[0] = &a[0];
1129 pa[1] = &a[1];
1130 pa[2] = &a[2];
1131 ok(sum_parr(pa) == 6, "RPC sum_parr\n");
1133 pa[0] = &a[0];
1134 pa[1] = &a[1];
1135 pa[2] = &a[2];
1136 pa[3] = &a[3];
1137 ok(sum_pcarr(pa, 4) == 10, "RPC sum_pcarr\n");
1139 ok(hash_bstr(bstr) == s_hash_bstr(bstr), "RPC hash_bstr_data\n");
1141 free_list(list);
1143 if (!old_windows_version)
1145 name.size = 10;
1146 name.name = buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, name.size);
1147 get_name(&name);
1148 ok(name.name == buffer, "[in,out] pointer should have stayed as %p but instead changed to %p\n", name.name, buffer);
1149 ok(!strcmp(name.name, "Jeremy Wh"), "name didn't unmarshall properly, expected \"Jeremy Wh\", but got \"%s\"\n", name.name);
1150 HeapFree(GetProcessHeap(), 0, name.name);
1153 pa2 = a;
1154 ok(sum_pcarr2(4, &pa2) == 10, "RPC sum_pcarr2\n");
1156 s123 = get_s123();
1157 ok(s123->f1 == 1 && s123->f2 == 2 && s123->f3 == 3, "RPC get_s123\n");
1158 MIDL_user_free(s123);
1160 full_pointer_test(&val, &val);
1161 full_pointer_null_test(&val, NULL);
1164 static int
1165 check_pyramid_doub_carr(doub_carr_t *dc)
1167 int i, j;
1168 for (i = 0; i < dc->n; ++i)
1169 for (j = 0; j < dc->a[i]->n; ++j)
1170 if (dc->a[i]->a[j] != j + 1)
1171 return FALSE;
1172 return TRUE;
1175 static void
1176 free_pyramid_doub_carr(doub_carr_t *dc)
1178 int i;
1179 for (i = 0; i < dc->n; ++i)
1180 MIDL_user_free(dc->a[i]);
1181 MIDL_user_free(dc);
1184 static void
1185 array_tests(void)
1187 int m[2][3][4] =
1189 {{1, 2, 3, 4}, {-1, -3, -5, -7}, {0, 2, 4, 6}},
1190 {{1, -2, 3, -4}, {2, 3, 5, 7}, {-4, -1, -14, 4114}}
1192 int c[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
1193 int c2[] = {10, 100, 200};
1194 vector_t vs[2] = {{1, -2, 3}, {4, -5, -6}};
1195 cps_t cps;
1196 cpsc_t cpsc;
1197 cs_t *cs;
1198 int n;
1199 int ca[5] = {1, -2, 3, -4, 5};
1200 doub_carr_t *dc;
1201 int *pi;
1202 pints_t api[5];
1203 numbers_struct_t *ns;
1205 if (!old_windows_version)
1207 const char str1[25] = "Hello";
1208 ok(cstr_length(str1, sizeof str1) == strlen(str1), "RPC cstr_length\n");
1211 ok(sum_fixed_int_3d(m) == 4116, "RPC sum_fixed_int_3d\n");
1213 ok(sum_conf_array(c, 10) == 45, "RPC sum_conf_array\n");
1214 ok(sum_conf_array(&c[5], 2) == 11, "RPC sum_conf_array\n");
1215 ok(sum_conf_array(&c[7], 1) == 7, "RPC sum_conf_array\n");
1216 ok(sum_conf_array(&c[2], 0) == 0, "RPC sum_conf_array\n");
1218 ok(sum_conf_ptr_by_conf_ptr(1, c2, c) == 45, "RPC sum_conf_ptr_by_conf_ptr\n");
1219 ok(sum_conf_ptr_by_conf_ptr(3, c2, c) == 345, "RPC sum_conf_ptr_by_conf_ptr\n");
1220 c2[0] = 0;
1221 ok(sum_conf_ptr_by_conf_ptr(3, c2, c) == 300, "RPC sum_conf_ptr_by_conf_ptr\n");
1223 ok(sum_unique_conf_array(ca, 4) == -2, "RPC sum_unique_conf_array\n");
1224 ok(sum_unique_conf_ptr(ca, 5) == 3, "RPC sum_unique_conf_array\n");
1225 ok(sum_unique_conf_ptr(NULL, 10) == 0, "RPC sum_unique_conf_array\n");
1227 ok(sum_var_array(c, 10) == 45, "RPC sum_conf_array\n");
1228 ok(sum_var_array(&c[5], 2) == 11, "RPC sum_conf_array\n");
1229 ok(sum_var_array(&c[7], 1) == 7, "RPC sum_conf_array\n");
1230 ok(sum_var_array(&c[2], 0) == 0, "RPC sum_conf_array\n");
1232 ok(dot_two_vectors(vs) == -4, "RPC dot_two_vectors\n");
1233 cs = HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(cs_t, ca[5]));
1234 cs->n = 5;
1235 cs->ca[0] = 3;
1236 cs->ca[1] = 5;
1237 cs->ca[2] = -2;
1238 cs->ca[3] = -1;
1239 cs->ca[4] = -4;
1240 ok(sum_cs(cs) == 1, "RPC sum_cs\n");
1241 HeapFree(GetProcessHeap(), 0, cs);
1243 n = 5;
1244 cps.pn = &n;
1245 cps.ca1 = &c[2];
1246 cps.n = 3;
1247 cps.ca2 = &c[3];
1248 ok(sum_cps(&cps) == 53, "RPC sum_cps\n");
1250 cpsc.a = 4;
1251 cpsc.b = 5;
1252 cpsc.c = 1;
1253 cpsc.ca = c;
1254 ok(sum_cpsc(&cpsc) == 6, "RPC sum_cpsc\n");
1255 cpsc.a = 4;
1256 cpsc.b = 5;
1257 cpsc.c = 0;
1258 cpsc.ca = c;
1259 ok(sum_cpsc(&cpsc) == 10, "RPC sum_cpsc\n");
1261 ok(sum_toplev_conf_2n(c, 3) == 15, "RPC sum_toplev_conf_2n\n");
1262 ok(sum_toplev_conf_cond(c, 5, 6, 1) == 10, "RPC sum_toplev_conf_cond\n");
1263 ok(sum_toplev_conf_cond(c, 5, 6, 0) == 15, "RPC sum_toplev_conf_cond\n");
1265 dc = HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(doub_carr_t, a[2]));
1266 dc->n = 2;
1267 dc->a[0] = HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(doub_carr_1_t, a[3]));
1268 dc->a[0]->n = 3;
1269 dc->a[0]->a[0] = 5;
1270 dc->a[0]->a[1] = 1;
1271 dc->a[0]->a[2] = 8;
1272 dc->a[1] = HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(doub_carr_1_t, a[2]));
1273 dc->a[1]->n = 2;
1274 dc->a[1]->a[0] = 2;
1275 dc->a[1]->a[1] = 3;
1276 ok(sum_doub_carr(dc) == 19, "RPC sum_doub_carr\n");
1277 HeapFree(GetProcessHeap(), 0, dc->a[0]);
1278 HeapFree(GetProcessHeap(), 0, dc->a[1]);
1279 HeapFree(GetProcessHeap(), 0, dc);
1281 dc = NULL;
1282 make_pyramid_doub_carr(4, &dc);
1283 ok(check_pyramid_doub_carr(dc), "RPC make_pyramid_doub_carr\n");
1284 free_pyramid_doub_carr(dc);
1286 ok(sum_L1_norms(2, vs) == 21, "RPC sum_L1_norms\n");
1288 memset(api, 0, sizeof(api));
1289 pi = HeapAlloc(GetProcessHeap(), 0, sizeof(*pi));
1290 *pi = -1;
1291 api[0].pi = pi;
1292 get_numbers(1, 1, api);
1293 ok(api[0].pi == pi, "RPC conformant varying array [out] pointer changed from %p to %p\n", pi, api[0].pi);
1294 ok(*api[0].pi == 0, "pi unmarshalled incorrectly %d\n", *api[0].pi);
1296 if (!old_windows_version)
1298 ns = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, FIELD_OFFSET(numbers_struct_t, numbers[5]));
1299 ns->length = 5;
1300 ns->size = 5;
1301 ns->numbers[0].pi = pi;
1302 get_numbers_struct(&ns);
1303 ok(ns->numbers[0].pi == pi, "RPC conformant varying struct embedded pointer changed from %p to %p\n", pi, ns->numbers[0].pi);
1304 ok(*ns->numbers[0].pi == 5, "pi unmarshalled incorrectly %d\n", *ns->numbers[0].pi);
1305 HeapFree(GetProcessHeap(), 0, ns);
1307 HeapFree(GetProcessHeap(), 0, pi);
1310 static void
1311 run_tests(void)
1313 basic_tests();
1314 union_tests();
1315 pointer_tests();
1316 array_tests();
1317 context_handle_test();
1320 static void
1321 client(const char *test)
1323 if (strcmp(test, "tcp_basic") == 0)
1325 static unsigned char iptcp[] = "ncacn_ip_tcp";
1326 static unsigned char address[] = "127.0.0.1";
1327 static unsigned char port[] = PORT;
1328 unsigned char *binding;
1330 ok(RPC_S_OK == RpcStringBindingCompose(NULL, iptcp, address, port, NULL, &binding), "RpcStringBindingCompose\n");
1331 ok(RPC_S_OK == RpcBindingFromStringBinding(binding, &IServer_IfHandle), "RpcBindingFromStringBinding\n");
1333 run_tests();
1335 ok(RPC_S_OK == RpcStringFree(&binding), "RpcStringFree\n");
1336 ok(RPC_S_OK == RpcBindingFree(&IServer_IfHandle), "RpcBindingFree\n");
1338 else if (strcmp(test, "ncalrpc_basic") == 0)
1340 static unsigned char ncalrpc[] = "ncalrpc";
1341 static unsigned char guid[] = "00000000-4114-0704-2301-000000000000";
1342 unsigned char *binding;
1344 ok(RPC_S_OK == RpcStringBindingCompose(NULL, ncalrpc, NULL, guid, NULL, &binding), "RpcStringBindingCompose\n");
1345 ok(RPC_S_OK == RpcBindingFromStringBinding(binding, &IServer_IfHandle), "RpcBindingFromStringBinding\n");
1347 run_tests();
1349 ok(RPC_S_OK == RpcStringFree(&binding), "RpcStringFree\n");
1350 ok(RPC_S_OK == RpcBindingFree(&IServer_IfHandle), "RpcBindingFree\n");
1352 else if (strcmp(test, "np_basic") == 0)
1354 static unsigned char np[] = "ncacn_np";
1355 static unsigned char address[] = "\\\\.";
1356 static unsigned char pipe[] = PIPE;
1357 unsigned char *binding;
1359 ok(RPC_S_OK == RpcStringBindingCompose(NULL, np, address, pipe, NULL, &binding), "RpcStringBindingCompose\n");
1360 ok(RPC_S_OK == RpcBindingFromStringBinding(binding, &IServer_IfHandle), "RpcBindingFromStringBinding\n");
1362 run_tests();
1363 stop();
1365 ok(RPC_S_OK == RpcStringFree(&binding), "RpcStringFree\n");
1366 ok(RPC_S_OK == RpcBindingFree(&IServer_IfHandle), "RpcBindingFree\n");
1370 static void
1371 server(void)
1373 static unsigned char iptcp[] = "ncacn_ip_tcp";
1374 static unsigned char port[] = PORT;
1375 static unsigned char np[] = "ncacn_np";
1376 static unsigned char pipe[] = PIPE;
1377 static unsigned char ncalrpc[] = "ncalrpc";
1378 static unsigned char guid[] = "00000000-4114-0704-2301-000000000000";
1379 RPC_STATUS status, iptcp_status, np_status, ncalrpc_status;
1380 DWORD ret;
1382 iptcp_status = RpcServerUseProtseqEp(iptcp, 20, port, NULL);
1383 ok(iptcp_status == RPC_S_OK, "RpcServerUseProtseqEp(ncacn_ip_tcp) failed with status %d\n", iptcp_status);
1385 ncalrpc_status = RpcServerUseProtseqEp(ncalrpc, 0, guid, NULL);
1386 ok(ncalrpc_status == RPC_S_OK, "RpcServerUseProtseqEp(ncalrpc) failed with status %d\n", ncalrpc_status);
1388 np_status = RpcServerUseProtseqEp(np, 0, pipe, NULL);
1389 if (np_status == RPC_S_PROTSEQ_NOT_SUPPORTED)
1390 skip("Protocol sequence ncacn_np is not supported\n");
1391 else
1392 ok(np_status == RPC_S_OK, "RpcServerUseProtseqEp(ncacn_np) failed with status %d\n", np_status);
1394 if (pRpcServerRegisterIfEx)
1396 trace("Using RpcServerRegisterIfEx\n");
1397 status = pRpcServerRegisterIfEx(s_IServer_v0_0_s_ifspec, NULL, NULL,
1398 RPC_IF_ALLOW_CALLBACKS_WITH_NO_AUTH,
1399 RPC_C_LISTEN_MAX_CALLS_DEFAULT, NULL);
1401 else
1402 status = RpcServerRegisterIf(s_IServer_v0_0_s_ifspec, NULL, NULL);
1403 ok(status == RPC_S_OK, "RpcServerRegisterIf failed with status %d\n", status);
1404 status = RpcServerListen(1, 20, TRUE);
1405 ok(status == RPC_S_OK, "RpcServerListen failed with status %d\n", status);
1406 stop_event = CreateEvent(NULL, FALSE, FALSE, NULL);
1407 ok(stop_event != NULL, "CreateEvent failed with error %d\n", GetLastError());
1409 if (iptcp_status == RPC_S_OK)
1410 run_client("tcp_basic");
1411 else
1412 skip("tcp_basic tests skipped due to earlier failure\n");
1414 if (ncalrpc_status == RPC_S_OK)
1415 run_client("ncalrpc_basic");
1416 else
1417 skip("ncalrpc_basic tests skipped due to earlier failure\n");
1419 if (np_status == RPC_S_OK)
1420 run_client("np_basic");
1421 else
1423 skip("np_basic tests skipped due to earlier failure\n");
1424 /* np client is what signals stop_event, so bail out if we didn't run do it */
1425 return;
1428 ret = WaitForSingleObject(stop_event, 1000);
1429 ok(WAIT_OBJECT_0 == ret, "WaitForSingleObject\n");
1430 /* if the stop event didn't fire then RpcMgmtWaitServerListen will wait
1431 * forever, so don't bother calling it in this case */
1432 if (ret == WAIT_OBJECT_0)
1434 status = RpcMgmtWaitServerListen();
1435 todo_wine {
1436 ok(status == RPC_S_OK, "RpcMgmtWaitServerListening failed with status %d\n", status);
1441 START_TEST(server)
1443 int argc;
1444 char **argv;
1446 InitFunctionPointers();
1448 argc = winetest_get_mainargs(&argv);
1449 progname = argv[0];
1451 if (argc == 3)
1453 RpcTryExcept
1455 client(argv[2]);
1457 RpcExcept(TRUE)
1459 trace("Exception %d\n", RpcExceptionCode());
1461 RpcEndExcept
1463 else
1464 server();