push a4e6cd544f3f0a66d1be479be027045d2ab3dba0
[wine/hacks.git] / dlls / rpcrt4 / tests / server.c
blob55da875c69e19e94c0eaa52ebcf15cd63a962377
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;
37 static HANDLE stop_event;
39 void __RPC_FAR *__RPC_USER
40 midl_user_allocate(size_t n)
42 return malloc(n);
45 void __RPC_USER
46 midl_user_free(void __RPC_FAR *p)
48 free(p);
51 int
52 s_int_return(void)
54 return INT_CODE;
57 int
58 s_square(int x)
60 return x * x;
63 int
64 s_sum(int x, int y)
66 return x + y;
69 void
70 s_square_out(int x, int *y)
72 *y = s_square(x);
75 void
76 s_square_ref(int *x)
78 *x = s_square(*x);
81 int
82 s_str_length(const char *s)
84 return strlen(s);
87 int
88 s_cstr_length(const char *s, int n)
90 int len = 0;
91 while (0 < n-- && *s++)
92 ++len;
93 return len;
96 int
97 s_dot_self(vector_t *v)
99 return s_square(v->x) + s_square(v->y) + s_square(v->z);
102 double
103 s_square_half(double x, double *y)
105 *y = x / 2.0;
106 return x * x;
109 float
110 s_square_half_float(float x, float *y)
112 *y = x / 2.0f;
113 return x * x;
116 long
117 s_square_half_long(long x, long *y)
119 *y = x / 2;
120 return x * x;
124 s_sum_fixed_array(int a[5])
126 return a[0] + a[1] + a[2] + a[3] + a[4];
130 s_pints_sum(pints_t *pints)
132 return *pints->pi + **pints->ppi + ***pints->pppi;
135 double
136 s_ptypes_sum(ptypes_t *pt)
138 return *pt->pc + *pt->ps + *pt->pl + *pt->pf + *pt->pd;
142 s_dot_pvectors(pvectors_t *p)
144 return p->pu->x * (*p->pv)->x + p->pu->y * (*p->pv)->y + p->pu->z * (*p->pv)->z;
148 s_sum_sp(sp_t *sp)
150 return sp->x + sp->s->x;
153 double
154 s_square_sun(sun_t *su)
156 switch (su->s)
158 case SUN_I: return su->u.i * su->u.i;
159 case SUN_F1:
160 case SUN_F2: return su->u.f * su->u.f;
161 case SUN_PI: return (*su->u.pi) * (*su->u.pi);
162 default:
163 return 0.0;
168 s_test_list_length(test_list_t *list)
170 return (list->t == TL_LIST
171 ? 1 + s_test_list_length(list->u.tail)
172 : 0);
176 s_sum_fixed_int_3d(int m[2][3][4])
178 int i, j, k;
179 int sum = 0;
181 for (i = 0; i < 2; ++i)
182 for (j = 0; j < 3; ++j)
183 for (k = 0; k < 4; ++k)
184 sum += m[i][j][k];
186 return sum;
190 s_sum_conf_array(int x[], int n)
192 int *p = x, *end = p + n;
193 int sum = 0;
195 while (p < end)
196 sum += *p++;
198 return sum;
202 s_sum_unique_conf_array(int x[], int n)
204 return s_sum_conf_array(x, n);
208 s_sum_unique_conf_ptr(int *x, int n)
210 return x ? s_sum_conf_array(x, n) : 0;
214 s_sum_var_array(int x[20], int n)
216 ok(0 <= n, "RPC sum_var_array\n");
217 ok(n <= 20, "RPC sum_var_array\n");
219 return s_sum_conf_array(x, n);
223 s_dot_two_vectors(vector_t vs[2])
225 return vs[0].x * vs[1].x + vs[0].y * vs[1].y + vs[0].z * vs[1].z;
229 s_sum_cs(cs_t *cs)
231 return s_sum_conf_array(cs->ca, cs->n);
235 s_sum_cps(cps_t *cps)
237 int sum = 0;
238 int i;
240 for (i = 0; i < *cps->pn; ++i)
241 sum += cps->ca1[i];
243 for (i = 0; i < 2 * cps->n; ++i)
244 sum += cps->ca2[i];
246 return sum;
250 s_sum_cpsc(cpsc_t *cpsc)
252 int sum = 0;
253 int i;
254 for (i = 0; i < (cpsc->c ? cpsc->a : cpsc->b); ++i)
255 sum += cpsc->ca[i];
256 return sum;
260 s_square_puint(puint_t p)
262 int n = atoi(p);
263 return n * n;
267 s_dot_copy_vectors(vector_t u, vector_t v)
269 return u.x * v.x + u.y * v.y + u.z * v.z;
273 s_square_test_us(test_us_t *tus)
275 int n = atoi(tus->us.x);
276 return n * n;
279 double
280 s_square_encu(encu_t *eu)
282 switch (eu->t)
284 case ENCU_I: return eu->tagged_union.i * eu->tagged_union.i;
285 case ENCU_F: return eu->tagged_union.f * eu->tagged_union.f;
286 default:
287 return 0.0;
292 s_sum_parr(int *a[3])
294 return s_sum_pcarr(a, 3);
298 s_sum_pcarr(int *a[], int n)
300 int i, s = 0;
301 for (i = 0; i < n; ++i)
302 s += *a[i];
303 return s;
307 s_enum_ord(e_t e)
309 switch (e)
311 case E1: return 1;
312 case E2: return 2;
313 case E3: return 3;
314 case E4: return 4;
315 default:
316 return 0;
320 double
321 s_square_encue(encue_t *eue)
323 switch (eue->t)
325 case E1: return eue->tagged_union.i1 * eue->tagged_union.i1;
326 case E2: return eue->tagged_union.f2 * eue->tagged_union.f2;
327 default:
328 return 0.0;
333 s_sum_toplev_conf_2n(int *x, int n)
335 int sum = 0;
336 int i;
337 for (i = 0; i < 2 * n; ++i)
338 sum += x[i];
339 return sum;
343 s_sum_toplev_conf_cond(int *x, int a, int b, int c)
345 int sum = 0;
346 int n = c ? a : b;
347 int i;
348 for (i = 0; i < n; ++i)
349 sum += x[i];
350 return sum;
353 double
354 s_sum_aligns(aligns_t *a)
356 return a->c + a->i + a->s + a->d;
360 s_sum_padded(padded_t *p)
362 return p->i + p->c;
366 s_sum_padded2(padded_t ps[2])
368 return s_sum_padded(&ps[0]) + s_sum_padded(&ps[1]);
372 s_sum_padded_conf(padded_t *ps, int n)
374 int sum = 0;
375 int i;
376 for (i = 0; i < n; ++i)
377 sum += s_sum_padded(&ps[i]);
378 return sum;
382 s_sum_bogus(bogus_t *b)
384 return *b->h.p1 + *b->p2 + *b->p3 + b->c;
387 void
388 s_check_null(int *null)
390 ok(!null, "RPC check_null\n");
394 s_str_struct_len(str_struct_t *s)
396 return lstrlenA(s->s);
400 s_wstr_struct_len(wstr_struct_t *s)
402 return lstrlenW(s->s);
405 void
406 s_stop(void)
408 ok(RPC_S_OK == RpcMgmtStopServerListening(NULL), "RpcMgmtStopServerListening\n");
409 ok(RPC_S_OK == RpcServerUnregisterIf(NULL, NULL, FALSE), "RpcServerUnregisterIf\n");
410 ok(SetEvent(stop_event), "SetEvent\n");
413 static void
414 make_cmdline(char buffer[MAX_PATH], const char *test)
416 sprintf(buffer, "%s server %s", progname, test);
419 static int
420 run_client(const char *test)
422 char cmdline[MAX_PATH];
423 PROCESS_INFORMATION info;
424 STARTUPINFOA startup;
425 DWORD exitcode;
427 memset(&startup, 0, sizeof startup);
428 startup.cb = sizeof startup;
430 make_cmdline(cmdline, test);
431 ok(CreateProcessA(NULL, cmdline, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess\n");
432 ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination\n");
433 ok(GetExitCodeProcess(info.hProcess, &exitcode), "GetExitCodeProcess\n");
434 ok(CloseHandle(info.hProcess), "CloseHandle\n");
435 ok(CloseHandle(info.hThread), "CloseHandle\n");
437 return exitcode == 0;
440 static void
441 basic_tests(void)
443 char string[] = "I am a string";
444 WCHAR wstring[] = {'I',' ','a','m',' ','a',' ','w','s','t','r','i','n','g', 0};
445 int f[5] = {1, 3, 0, -2, -4};
446 vector_t a = {1, 3, 7};
447 vector_t vec1 = {4, -2, 1}, vec2 = {-5, 2, 3}, *pvec2 = &vec2;
448 pvectors_t pvecs = {&vec1, &pvec2};
449 sp_inner_t spi = {42};
450 sp_t sp = {-13, &spi};
451 aligns_t aligns = {3, 4, 5, 6.0};
452 pints_t pints;
453 ptypes_t ptypes;
454 padded_t padded;
455 padded_t padded2[2];
456 bogus_t bogus;
457 int i1, i2, i3, *pi2, *pi3, **ppi3;
458 double u, v;
459 float s, t;
460 long q, r;
461 short h;
462 char c;
463 int x;
464 str_struct_t ss = {string};
465 wstr_struct_t ws = {wstring};
467 ok(int_return() == INT_CODE, "RPC int_return\n");
469 ok(square(7) == 49, "RPC square\n");
470 ok(sum(23, -4) == 19, "RPC sum\n");
472 x = 0;
473 square_out(11, &x);
474 ok(x == 121, "RPC square_out\n");
476 x = 5;
477 square_ref(&x);
478 ok(x == 25, "RPC square_ref\n");
480 ok(str_length(string) == strlen(string), "RPC str_length\n");
481 ok(dot_self(&a) == 59, "RPC dot_self\n");
483 ok(str_struct_len(&ss) == lstrlenA(string), "RPC str_struct_len\n");
484 ok(wstr_struct_len(&ws) == lstrlenW(wstring), "RPC str_struct_len\n");
486 v = 0.0;
487 u = square_half(3.0, &v);
488 ok(u == 9.0, "RPC square_half\n");
489 ok(v == 1.5, "RPC square_half\n");
491 t = 0.0f;
492 s = square_half_float(3.0f, &t);
493 ok(s == 9.0f, "RPC square_half_float\n");
494 ok(t == 1.5f, "RPC square_half_float\n");
496 r = 0;
497 q = square_half_long(3, &r);
498 ok(q == 9, "RPC square_half_long\n");
499 ok(r == 1, "RPC square_half_long\n");
501 i1 = 19;
502 i2 = -3;
503 i3 = -29;
504 pi2 = &i2;
505 pi3 = &i3;
506 ppi3 = &pi3;
507 pints.pi = &i1;
508 pints.ppi = &pi2;
509 pints.pppi = &ppi3;
510 ok(pints_sum(&pints) == -13, "RPC pints_sum\n");
512 c = 10;
513 h = 3;
514 q = 14;
515 s = -5.0f;
516 u = 11.0;
517 ptypes.pc = &c;
518 ptypes.ps = &h;
519 ptypes.pl = &q;
520 ptypes.pf = &s;
521 ptypes.pd = &u;
522 ok(ptypes_sum(&ptypes) == 33.0, "RPC ptypes_sum\n");
524 ok(dot_pvectors(&pvecs) == -21, "RPC dot_pvectors\n");
525 ok(dot_copy_vectors(vec1, vec2) == -21, "RPC dot_copy_vectors\n");
526 ok(sum_fixed_array(f) == -2, "RPC sum_fixed_array\n");
527 ok(sum_sp(&sp) == 29, "RPC sum_sp\n");
529 ok(enum_ord(E1) == 1, "RPC enum_ord\n");
530 ok(enum_ord(E2) == 2, "RPC enum_ord\n");
531 ok(enum_ord(E3) == 3, "RPC enum_ord\n");
532 ok(enum_ord(E4) == 4, "RPC enum_ord\n");
534 ok(sum_aligns(&aligns) == 18.0, "RPC sum_aligns\n");
536 padded.i = -3;
537 padded.c = 8;
538 ok(sum_padded(&padded) == 5, "RPC sum_padded\n");
539 padded2[0].i = -5;
540 padded2[0].c = 1;
541 padded2[1].i = 3;
542 padded2[1].c = 7;
543 ok(sum_padded2(padded2) == 6, "RPC sum_padded2\n");
544 padded2[0].i = -5;
545 padded2[0].c = 1;
546 padded2[1].i = 3;
547 padded2[1].c = 7;
548 ok(sum_padded_conf(padded2, 2) == 6, "RPC sum_padded_conf\n");
550 i1 = 14;
551 i2 = -7;
552 i3 = -4;
553 bogus.h.p1 = &i1;
554 bogus.p2 = &i2;
555 bogus.p3 = &i3;
556 bogus.c = 9;
557 ok(sum_bogus(&bogus) == 12, "RPC sum_bogus\n");
559 check_null(NULL);
562 static void
563 union_tests(void)
565 encue_t eue;
566 encu_t eu;
567 sun_t su;
568 int i;
570 su.s = SUN_I;
571 su.u.i = 9;
572 ok(square_sun(&su) == 81.0, "RPC square_sun\n");
574 su.s = SUN_F1;
575 su.u.f = 5.0;
576 ok(square_sun(&su) == 25.0, "RPC square_sun\n");
578 su.s = SUN_F2;
579 su.u.f = -2.0;
580 ok(square_sun(&su) == 4.0, "RPC square_sun\n");
582 su.s = SUN_PI;
583 su.u.pi = &i;
584 i = 11;
585 ok(square_sun(&su) == 121.0, "RPC square_sun\n");
587 eu.t = ENCU_I;
588 eu.tagged_union.i = 7;
589 ok(square_encu(&eu) == 49.0, "RPC square_encu\n");
591 eu.t = ENCU_F;
592 eu.tagged_union.f = 3.0;
593 ok(square_encu(&eu) == 9.0, "RPC square_encu\n");
595 eue.t = E1;
596 eue.tagged_union.i1 = 8;
597 ok(square_encue(&eue) == 64.0, "RPC square_encue\n");
599 eue.t = E2;
600 eue.tagged_union.f2 = 10.0;
601 ok(square_encue(&eue) == 100.0, "RPC square_encue\n");
604 static test_list_t *
605 null_list(void)
607 test_list_t *n = HeapAlloc(GetProcessHeap(), 0, sizeof *n);
608 n->t = TL_NULL;
609 return n;
612 static test_list_t *
613 make_list(test_list_t *tail)
615 test_list_t *n = HeapAlloc(GetProcessHeap(), 0, sizeof *n);
616 n->t = TL_LIST;
617 n->u.tail = tail;
618 return n;
621 static void
622 free_list(test_list_t *list)
624 if (list->t == TL_LIST)
625 free_list(list->u.tail);
626 HeapFree(GetProcessHeap(), 0, list);
629 ULONG __RPC_USER
630 puint_t_UserSize(ULONG *flags, ULONG start, puint_t *p)
632 return start + sizeof(int);
635 unsigned char * __RPC_USER
636 puint_t_UserMarshal(ULONG *flags, unsigned char *buffer, puint_t *p)
638 int n = atoi(*p);
639 memcpy(buffer, &n, sizeof n);
640 return buffer + sizeof n;
643 unsigned char * __RPC_USER
644 puint_t_UserUnmarshal(ULONG *flags, unsigned char *buffer, puint_t *p)
646 int n;
647 memcpy(&n, buffer, sizeof n);
648 *p = HeapAlloc(GetProcessHeap(), 0, 10);
649 sprintf(*p, "%d", n);
650 return buffer + sizeof n;
653 void __RPC_USER
654 puint_t_UserFree(ULONG *flags, puint_t *p)
656 HeapFree(GetProcessHeap(), 0, *p);
659 ULONG __RPC_USER
660 us_t_UserSize(ULONG *flags, ULONG start, us_t *pus)
662 return start + sizeof(struct wire_us);
665 unsigned char * __RPC_USER
666 us_t_UserMarshal(ULONG *flags, unsigned char *buffer, us_t *pus)
668 struct wire_us wus;
669 wus.x = atoi(pus->x);
670 memcpy(buffer, &wus, sizeof wus);
671 return buffer + sizeof wus;
674 unsigned char * __RPC_USER
675 us_t_UserUnmarshal(ULONG *flags, unsigned char *buffer, us_t *pus)
677 struct wire_us wus;
678 memcpy(&wus, buffer, sizeof wus);
679 pus->x = HeapAlloc(GetProcessHeap(), 0, 10);
680 sprintf(pus->x, "%d", wus.x);
681 return buffer + sizeof wus;
684 void __RPC_USER
685 us_t_UserFree(ULONG *flags, us_t *pus)
687 HeapFree(GetProcessHeap(), 0, pus->x);
690 static void
691 pointer_tests(void)
693 int a[] = {1, 2, 3, 4};
694 char p1[] = "11";
695 test_list_t *list = make_list(make_list(make_list(null_list())));
696 test_us_t tus = {{p1}};
697 int *pa[4];
699 ok(test_list_length(list) == 3, "RPC test_list_length\n");
700 ok(square_puint(p1) == 121, "RPC square_puint\n");
701 ok(square_test_us(&tus) == 121, "RPC square_test_us\n");
703 pa[0] = &a[0];
704 pa[1] = &a[1];
705 pa[2] = &a[2];
706 ok(sum_parr(pa) == 6, "RPC sum_parr\n");
708 pa[0] = &a[0];
709 pa[1] = &a[1];
710 pa[2] = &a[2];
711 pa[3] = &a[3];
712 ok(sum_pcarr(pa, 4) == 10, "RPC sum_pcarr\n");
714 free_list(list);
717 static void
718 array_tests(void)
720 const char str1[25] = "Hello";
721 int m[2][3][4] =
723 {{1, 2, 3, 4}, {-1, -3, -5, -7}, {0, 2, 4, 6}},
724 {{1, -2, 3, -4}, {2, 3, 5, 7}, {-4, -1, -14, 4114}}
726 int c[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
727 vector_t vs[2] = {{1, -2, 3}, {4, -5, -6}};
728 cps_t cps;
729 cpsc_t cpsc;
730 cs_t *cs;
731 int n;
732 int ca[5] = {1, -2, 3, -4, 5};
734 ok(cstr_length(str1, sizeof str1) == strlen(str1), "RPC cstr_length\n");
736 ok(sum_fixed_int_3d(m) == 4116, "RPC sum_fixed_int_3d\n");
738 ok(sum_conf_array(c, 10) == 45, "RPC sum_conf_array\n");
739 ok(sum_conf_array(&c[5], 2) == 11, "RPC sum_conf_array\n");
740 ok(sum_conf_array(&c[7], 1) == 7, "RPC sum_conf_array\n");
741 ok(sum_conf_array(&c[2], 0) == 0, "RPC sum_conf_array\n");
743 ok(sum_unique_conf_array(ca, 4) == -2, "RPC sum_unique_conf_array\n");
744 ok(sum_unique_conf_ptr(ca, 5) == 3, "RPC sum_unique_conf_array\n");
745 ok(sum_unique_conf_ptr(NULL, 10) == 0, "RPC sum_unique_conf_array\n");
747 ok(sum_var_array(c, 10) == 45, "RPC sum_conf_array\n");
748 ok(sum_var_array(&c[5], 2) == 11, "RPC sum_conf_array\n");
749 ok(sum_var_array(&c[7], 1) == 7, "RPC sum_conf_array\n");
750 ok(sum_var_array(&c[2], 0) == 0, "RPC sum_conf_array\n");
752 ok(dot_two_vectors(vs) == -4, "RPC dot_two_vectors\n");
753 cs = HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(cs_t, ca[5]));
754 cs->n = 5;
755 cs->ca[0] = 3;
756 cs->ca[1] = 5;
757 cs->ca[2] = -2;
758 cs->ca[3] = -1;
759 cs->ca[4] = -4;
760 ok(sum_cs(cs) == 1, "RPC sum_cs\n");
761 HeapFree(GetProcessHeap(), 0, cs);
763 n = 5;
764 cps.pn = &n;
765 cps.ca1 = &c[2];
766 cps.n = 3;
767 cps.ca2 = &c[3];
768 todo_wine ok(sum_cps(&cps) == 53, "RPC sum_cps\n");
770 cpsc.a = 4;
771 cpsc.b = 5;
772 cpsc.c = 1;
773 cpsc.ca = c;
774 todo_wine ok(sum_cpsc(&cpsc) == 6, "RPC sum_cpsc\n");
775 cpsc.a = 4;
776 cpsc.b = 5;
777 cpsc.c = 0;
778 cpsc.ca = c;
779 todo_wine ok(sum_cpsc(&cpsc) == 10, "RPC sum_cpsc\n");
781 ok(sum_toplev_conf_2n(c, 3) == 15, "RPC sum_toplev_conf_2n\n");
782 ok(sum_toplev_conf_cond(c, 5, 6, 1) == 10, "RPC sum_toplev_conf_cond\n");
783 ok(sum_toplev_conf_cond(c, 5, 6, 0) == 15, "RPC sum_toplev_conf_cond\n");
786 static void
787 run_tests(void)
789 basic_tests();
790 union_tests();
791 pointer_tests();
792 array_tests();
795 static void
796 client(const char *test)
798 if (strcmp(test, "tcp_basic") == 0)
800 static unsigned char iptcp[] = "ncacn_ip_tcp";
801 static unsigned char address[] = "127.0.0.1";
802 static unsigned char port[] = PORT;
803 unsigned char *binding;
805 ok(RPC_S_OK == RpcStringBindingCompose(NULL, iptcp, address, port, NULL, &binding), "RpcStringBindingCompose\n");
806 ok(RPC_S_OK == RpcBindingFromStringBinding(binding, &IServer_IfHandle), "RpcBindingFromStringBinding\n");
808 run_tests();
810 ok(RPC_S_OK == RpcStringFree(&binding), "RpcStringFree\n");
811 ok(RPC_S_OK == RpcBindingFree(&IServer_IfHandle), "RpcBindingFree\n");
813 else if (strcmp(test, "np_basic") == 0)
815 static unsigned char np[] = "ncacn_np";
816 static unsigned char address[] = "\\\\.";
817 static unsigned char pipe[] = PIPE;
818 unsigned char *binding;
820 ok(RPC_S_OK == RpcStringBindingCompose(NULL, np, address, pipe, NULL, &binding), "RpcStringBindingCompose\n");
821 ok(RPC_S_OK == RpcBindingFromStringBinding(binding, &IServer_IfHandle), "RpcBindingFromStringBinding\n");
823 run_tests();
824 stop();
826 ok(RPC_S_OK == RpcStringFree(&binding), "RpcStringFree\n");
827 ok(RPC_S_OK == RpcBindingFree(&IServer_IfHandle), "RpcBindingFree\n");
831 static void
832 server(void)
834 static unsigned char iptcp[] = "ncacn_ip_tcp";
835 static unsigned char port[] = PORT;
836 static unsigned char np[] = "ncacn_np";
837 static unsigned char pipe[] = PIPE;
839 ok(RPC_S_OK == RpcServerUseProtseqEp(iptcp, 20, port, NULL), "RpcServerUseProtseqEp\n");
840 ok(RPC_S_OK == RpcServerRegisterIf(s_IServer_v0_0_s_ifspec, NULL, NULL), "RpcServerRegisterIf\n");
841 ok(RPC_S_OK == RpcServerListen(1, 20, TRUE), "RpcServerListen\n");
843 stop_event = CreateEvent(NULL, FALSE, FALSE, NULL);
844 ok(stop_event != NULL, "CreateEvent failed\n");
846 ok(run_client("tcp_basic"), "tcp_basic client test failed\n");
848 ok(RPC_S_OK == RpcServerUseProtseqEp(np, 0, pipe, NULL), "RpcServerUseProtseqEp\n");
849 ok(run_client("np_basic"), "np_basic client test failed\n");
851 ok(WAIT_OBJECT_0 == WaitForSingleObject(stop_event, 60000), "WaitForSingleObject\n");
852 todo_wine {
853 ok(RPC_S_OK == RpcMgmtWaitServerListen(), "RpcMgmtWaitServerListening\n");
857 START_TEST(server)
859 int argc;
860 char **argv;
862 argc = winetest_get_mainargs(&argv);
863 progname = argv[0];
865 if (argc == 3)
867 RpcTryExcept
869 client(argv[2]);
871 RpcExcept(TRUE)
873 trace("Exception %d\n", RpcExceptionCode());
875 RpcEndExcept
877 else
878 server();