wafsamba: Allow newer or the same python module versions to be installed,
[Samba.git] / pidl / tests / ndr_refptr.pl
blobd5dd83957a41c3fd560627c400d1e523c867057c
1 #!/usr/bin/perl
2 # Simple tests for pidl's handling of ref pointers, based
3 # on tridge's ref_notes.txt
4 # (C) 2005 Jelmer Vernooij <jelmer@samba.org>.
5 # Published under the GNU General Public License.
6 use strict;
8 use Test::More tests => 22 * 8;
9 use FindBin qw($RealBin);
10 use lib "$RealBin";
11 use Util qw(test_samba4_ndr);
13 test_samba4_ndr("noptr-push",
14 ' typedef struct {
15 uint16 x;
16 } xstruct;
18 [public] uint16 echo_TestRef([in] xstruct foo);
21 struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
22 uint16_t v = 13;
23 struct echo_TestRef r;
24 r.in.foo.x = v;
26 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) {
27 fprintf(stderr, "push failed\n");
28 return 1;
31 if (ndr->offset != 2) {
32 fprintf(stderr, "Offset(%d) != 2\n", ndr->offset);
33 return 2;
36 if (ndr->data[0] != 13 || ndr->data[1] != 0) {
37 fprintf(stderr, "Data incorrect\n");
38 return 3;
40 ');
42 test_samba4_ndr("ptr-embedded-push",
43 ' typedef struct {
44 uint16 *x;
45 } xstruct;
47 [public] uint16 echo_TestRef([in] xstruct foo);
50 uint16_t v = 13;
51 struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
52 struct echo_TestRef r;
53 r.in.foo.x = &v;
55 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
56 return 1;
58 if (ndr->offset != 6)
59 return 2;
61 if (ndr->data[0] == 0 && ndr->data[1] == 0 &&
62 ndr->data[2] == 0 && ndr->data[3] == 0)
63 return 3;
65 if (ndr->data[4] != 13 || ndr->data[5] != 0)
66 return 4;
67 ');
69 test_samba4_ndr("ptr-embedded-push-null",
70 ' typedef struct {
71 uint16 *x;
72 } xstruct;
74 [public] uint16 echo_TestRef([in] xstruct foo);
77 struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
78 struct echo_TestRef r;
79 r.in.foo.x = NULL;
81 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
82 return 1;
84 if (ndr->offset != 4)
85 return 2;
87 if (ndr->data[0] != 0 || ndr->data[1] != 0 ||
88 ndr->data[2] != 0 || ndr->data[3] != 0)
89 return 3;
90 ');
92 test_samba4_ndr("refptr-embedded-push",
94 typedef struct {
95 [ref] uint16 *x;
96 } xstruct;
98 [public] uint16 echo_TestRef([in] xstruct foo);
101 uint16_t v = 13;
102 struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
103 struct echo_TestRef r;
104 r.in.foo.x = &v;
106 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
107 return 1;
109 if (ndr->offset != 6)
110 return 2;
112 if (ndr->data[0] == 0 && ndr->data[1] == 0 &&
113 ndr->data[2] == 0 && ndr->data[3] == 0)
114 return 3;
116 if (ndr->data[4] != 13 || ndr->data[5] != 0)
117 return 4;
120 test_samba4_ndr("refptr-embedded-push-null",
122 typedef struct {
123 [ref] uint16 *x;
124 } xstruct;
126 [public] uint16 echo_TestRef([in] xstruct foo);
129 struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
130 struct echo_TestRef r;
131 r.in.foo.x = NULL;
133 if (NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
134 return 1;
135 /* Windows gives [client runtime error 0x6f4] */
138 test_samba4_ndr("ptr-top-push",
140 typedef struct {
141 uint16 x;
142 } xstruct;
144 [public] uint16 echo_TestRef([in] xstruct *foo);
147 struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
148 struct echo_TestRef r;
149 struct xstruct s;
150 s.x = 13;
151 r.in.foo = &s;
153 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
154 return 1;
156 if (ndr->offset != 2)
157 return 2;
159 if (ndr->data[0] != 13 || ndr->data[1] != 0)
160 return 3;
163 test_samba4_ndr("ptr-top-push-null",
165 typedef struct {
166 uint16 x;
167 } xstruct;
169 [public] uint16 echo_TestRef([in] xstruct *foo);
172 struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
173 struct echo_TestRef r;
174 r.in.foo = NULL;
176 if (NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
177 return 1;
179 /* Windows gives [client runtime error 0x6f4] */
183 test_samba4_ndr("refptr-top-push",
185 typedef struct {
186 uint16 x;
187 } xstruct;
189 [public] uint16 echo_TestRef([in,ref] xstruct *foo);
192 struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
193 struct echo_TestRef r;
194 struct xstruct s;
195 s.x = 13;
196 r.in.foo = &s;
198 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
199 return 1;
201 if (ndr->offset != 2)
202 return 2;
204 if (ndr->data[0] != 13 || ndr->data[1] != 0)
205 return 3;
208 test_samba4_ndr("refptr-top-push-null",
210 typedef struct {
211 uint16 x;
212 } xstruct;
214 [public] uint16 echo_TestRef([in,ref] xstruct *foo);
217 struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
218 struct echo_TestRef r;
219 r.in.foo = NULL;
221 if (NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
222 return 1;
224 /* Windows gives [client runtime error 0x6f4] */
228 test_samba4_ndr("uniqueptr-top-push",
229 ' typedef struct {
230 uint16 x;
231 } xstruct;
233 [public] uint16 echo_TestRef([in,unique] xstruct *foo);
236 struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
237 struct echo_TestRef r;
238 struct xstruct s;
239 s.x = 13;
240 r.in.foo = &s;
242 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
243 return 1;
245 if (ndr->offset != 6)
246 return 2;
248 if (ndr->data[0] == 0 && ndr->data[1] == 0 &&
249 ndr->data[2] == 0 && ndr->data[3] == 0)
250 return 3;
252 if (ndr->data[4] != 13 || ndr->data[5] != 0)
253 return 4;
256 test_samba4_ndr("uniqueptr-top-push-null",
257 ' typedef struct {
258 uint16 x;
259 } xstruct;
261 [public] uint16 echo_TestRef([in,unique] xstruct *foo);
264 struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
265 struct echo_TestRef r;
266 r.in.foo = NULL;
268 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
269 return 1;
271 if (ndr->offset != 4)
272 return 2;
274 if (ndr->data[0] != 0 || ndr->data[1] != 0 ||
275 ndr->data[2] != 0 || ndr->data[3] != 0)
276 return 3;
280 test_samba4_ndr("ptr-top-out-pull",
282 typedef struct {
283 uint16 x;
284 } xstruct;
286 [public] void echo_TestRef([out] xstruct *foo);
289 uint8_t data[] = { 0x0D, 0x00 };
290 DATA_BLOB b = { data, 2 };
291 struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL, NULL);
292 struct xstruct s;
293 struct echo_TestRef r;
295 r.out.foo = &s;
297 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_echo_TestRef(ndr, NDR_OUT, &r)))
298 return 1;
300 if (!r.out.foo)
301 return 2;
303 if (r.out.foo->x != 13)
304 return 3;
305 ');
307 test_samba4_ndr("ptr-top-out-pull-null",
309 typedef struct {
310 uint16 x;
311 } xstruct;
313 [public] void echo_TestRef([out] xstruct *foo);
316 uint8_t data[] = { 0x0D, 0x00 };
317 DATA_BLOB b = { data, 2 };
318 struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL, NULL);
319 struct echo_TestRef r;
321 r.out.foo = NULL;
323 if (NDR_ERR_CODE_IS_SUCCESS(ndr_pull_echo_TestRef(ndr, NDR_OUT, &r)))
324 return 1;
326 /* Windows gives [client runtime error 0x6f4] */
330 test_samba4_ndr("refptr-top-out-pull",
332 typedef struct {
333 uint16 x;
334 } xstruct;
336 [public] void echo_TestRef([out,ref] xstruct *foo);
339 uint8_t data[] = { 0x0D, 0x00 };
340 DATA_BLOB b = { data, 2 };
341 struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL, NULL);
342 struct xstruct s;
343 struct echo_TestRef r;
345 r.out.foo = &s;
347 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_echo_TestRef(ndr, NDR_OUT, &r)))
348 return 1;
350 if (!r.out.foo)
351 return 2;
353 if (r.out.foo->x != 13)
354 return 3;
355 ');
357 test_samba4_ndr("refptr-top-out-pull-null",
359 typedef struct {
360 uint16 x;
361 } xstruct;
363 [public] void echo_TestRef([out,ref] xstruct *foo);
366 uint8_t data[] = { 0x0D, 0x00 };
367 DATA_BLOB b = { data, 2 };
368 struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL, NULL);
369 struct echo_TestRef r;
371 r.out.foo = NULL;
373 if (NDR_ERR_CODE_IS_SUCCESS(ndr_pull_echo_TestRef(ndr, NDR_OUT, &r)))
374 return 1;
376 /* Windows gives [client runtime error 0x6f4] */
380 test_samba4_ndr("ptr-top-push-double",
382 [public] void echo_TestRef([in] uint16 **foo);
384 ' struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
385 struct echo_TestRef r;
386 uint16_t v = 13;
387 uint16_t *pv = &v;
388 r.in.foo = &pv;
390 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
391 return 1;
393 if (ndr->offset != 6)
394 return 2;
396 if (ndr->data[0] == 0 && ndr->data[1] == 0 &&
397 ndr->data[2] == 0 && ndr->data[3] == 0)
398 return 3;
400 if (ndr->data[4] != 0x0D || ndr->data[5] != 0x00)
401 return 4;
404 SKIP: {
405 skip "ptr-top-push-double-sndnull is known to fail", 8;
407 test_samba4_ndr("ptr-top-push-double-sndnull",
409 [public] void echo_TestRef([in] uint16 **foo);
411 ' struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
412 struct echo_TestRef r;
413 uint16_t *pv = NULL;
414 r.in.foo = &pv;
416 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
417 return 1;
419 if (ndr->offset != 4)
420 return 2;
422 if (ndr->data[0] != 0 || ndr->data[1] != 0 ||
423 ndr->data[2] != 0 || ndr->data[3] != 0)
424 return 3;
428 test_samba4_ndr("ptr-top-push-double-fstnull",
430 [public] void echo_TestRef([in] uint16 **foo);
432 ' struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
433 struct echo_TestRef r;
434 r.in.foo = NULL;
436 if (NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
437 return 1;
439 /* Windows gives [client runtime error 0x6f4] */
444 test_samba4_ndr("refptr-top-push-double",
446 [public] void echo_TestRef([in,ref] uint16 **foo);
448 ' struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
449 struct echo_TestRef r;
450 uint16_t v = 13;
451 uint16_t *pv = &v;
452 r.in.foo = &pv;
454 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
455 return 1;
457 if (ndr->offset != 6)
458 return 2;
460 if (ndr->data[0] == 0 && ndr->data[1] == 0 &&
461 ndr->data[2] == 0 && ndr->data[3] == 0)
462 return 3;
464 if (ndr->data[4] != 0x0D || ndr->data[5] != 0x00)
465 return 4;
468 SKIP: {
470 skip "refptr-top-push-double-sndnull is known to fail", 8;
472 test_samba4_ndr("refptr-top-push-double-sndnull",
474 [public] void echo_TestRef([in,ref] uint16 **foo);
476 ' struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
477 struct echo_TestRef r;
478 uint16_t *pv = NULL;
479 r.in.foo = &pv;
481 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
482 return 1;
484 if (ndr->offset != 4)
485 return 2;
487 if (ndr->data[0] != 0 || ndr->data[1] != 0 ||
488 ndr->data[2] != 0 || ndr->data[3] != 0)
489 return 3;
493 test_samba4_ndr("refptr-top-push-double-fstnull",
495 [public] void echo_TestRef([in,ref] uint16 **foo);
497 ' struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
498 struct echo_TestRef r;
499 r.in.foo = NULL;
501 if (NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
502 return 1;
504 /* Windows gives [client runtime error 0x6f4] */
508 SKIP: {
509 skip "ignore-ptrs are not supported yet", 8;
510 test_samba4_ndr("ignore-ptr",
512 [public] void echo_TestRef([in,ignore] uint16 *foo, [in] uint16 *bar);
514 ' struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
515 struct echo_TestRef r;
516 uint16_t v = 10;
517 r.in.foo = &v;
518 r.in.bar = &v;
520 if (NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
521 return 1;
523 if (ndr->offset != 4)
524 return 2;