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.
9 use Test
::More tests
=> 22 * 8;
10 use FindBin
qw($RealBin);
12 use Util qw(test_samba4_ndr);
14 test_samba4_ndr
("noptr-push",
19 [public] uint16 echo_TestRef([in] xstruct foo);
22 struct ndr_push *ndr = ndr_push_init_ctx(NULL);
24 struct echo_TestRef r;
27 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) {
28 fprintf(stderr, "push failed\n");
32 if (ndr->offset != 2) {
33 fprintf(stderr, "Offset(%d) != 2\n", ndr->offset);
37 if (ndr->data[0] != 13 || ndr->data[1] != 0) {
38 fprintf(stderr, "Data incorrect\n");
43 test_samba4_ndr
("ptr-embedded-push",
48 [public] uint16 echo_TestRef([in] xstruct foo);
52 struct ndr_push *ndr = ndr_push_init_ctx(NULL);
53 struct echo_TestRef r;
56 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
62 if (ndr->data[0] == 0 && ndr->data[1] == 0 &&
63 ndr->data[2] == 0 && ndr->data[3] == 0)
66 if (ndr->data[4] != 13 || ndr->data[5] != 0)
70 test_samba4_ndr
("ptr-embedded-push-null",
75 [public] uint16 echo_TestRef([in] xstruct foo);
78 struct ndr_push *ndr = ndr_push_init_ctx(NULL);
79 struct echo_TestRef r;
82 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
88 if (ndr->data[0] != 0 || ndr->data[1] != 0 ||
89 ndr->data[2] != 0 || ndr->data[3] != 0)
93 test_samba4_ndr
("refptr-embedded-push",
99 [public] uint16 echo_TestRef([in] xstruct foo);
103 struct ndr_push *ndr = ndr_push_init_ctx(NULL);
104 struct echo_TestRef r;
107 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
110 if (ndr->offset != 6)
113 if (ndr->data[0] == 0 && ndr->data[1] == 0 &&
114 ndr->data[2] == 0 && ndr->data[3] == 0)
117 if (ndr->data[4] != 13 || ndr->data[5] != 0)
121 test_samba4_ndr
("refptr-embedded-push-null",
127 [public] uint16 echo_TestRef([in] xstruct foo);
130 struct ndr_push *ndr = ndr_push_init_ctx(NULL);
131 struct echo_TestRef r;
134 if (NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
136 /* Windows gives [client runtime error 0x6f4] */
139 test_samba4_ndr
("ptr-top-push",
145 [public] uint16 echo_TestRef([in] xstruct *foo);
148 struct ndr_push *ndr = ndr_push_init_ctx(NULL);
149 struct echo_TestRef r;
154 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
157 if (ndr->offset != 2)
160 if (ndr->data[0] != 13 || ndr->data[1] != 0)
164 test_samba4_ndr
("ptr-top-push-null",
170 [public] uint16 echo_TestRef([in] xstruct *foo);
173 struct ndr_push *ndr = ndr_push_init_ctx(NULL);
174 struct echo_TestRef r;
177 if (NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
180 /* Windows gives [client runtime error 0x6f4] */
184 test_samba4_ndr
("refptr-top-push",
190 [public] uint16 echo_TestRef([in,ref] xstruct *foo);
193 struct ndr_push *ndr = ndr_push_init_ctx(NULL);
194 struct echo_TestRef r;
199 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
202 if (ndr->offset != 2)
205 if (ndr->data[0] != 13 || ndr->data[1] != 0)
209 test_samba4_ndr
("refptr-top-push-null",
215 [public] uint16 echo_TestRef([in,ref] xstruct *foo);
218 struct ndr_push *ndr = ndr_push_init_ctx(NULL);
219 struct echo_TestRef r;
222 if (NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
225 /* Windows gives [client runtime error 0x6f4] */
229 test_samba4_ndr
("uniqueptr-top-push",
234 [public] uint16 echo_TestRef([in,unique] xstruct *foo);
237 struct ndr_push *ndr = ndr_push_init_ctx(NULL);
238 struct echo_TestRef r;
243 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
246 if (ndr->offset != 6)
249 if (ndr->data[0] == 0 && ndr->data[1] == 0 &&
250 ndr->data[2] == 0 && ndr->data[3] == 0)
253 if (ndr->data[4] != 13 || ndr->data[5] != 0)
257 test_samba4_ndr
("uniqueptr-top-push-null",
262 [public] uint16 echo_TestRef([in,unique] xstruct *foo);
265 struct ndr_push *ndr = ndr_push_init_ctx(NULL);
266 struct echo_TestRef r;
269 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
272 if (ndr->offset != 4)
275 if (ndr->data[0] != 0 || ndr->data[1] != 0 ||
276 ndr->data[2] != 0 || ndr->data[3] != 0)
281 test_samba4_ndr
("ptr-top-out-pull",
287 [public] void echo_TestRef([out] xstruct *foo);
290 uint8_t data[] = { 0x0D, 0x00 };
291 DATA_BLOB b = { data, 2 };
292 struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL, NULL);
294 struct echo_TestRef r;
298 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_echo_TestRef(ndr, NDR_OUT, &r)))
304 if (r.out.foo->x != 13)
308 test_samba4_ndr
("ptr-top-out-pull-null",
314 [public] void echo_TestRef([out] xstruct *foo);
317 uint8_t data[] = { 0x0D, 0x00 };
318 DATA_BLOB b = { data, 2 };
319 struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL, NULL);
320 struct echo_TestRef r;
324 if (NDR_ERR_CODE_IS_SUCCESS(ndr_pull_echo_TestRef(ndr, NDR_OUT, &r)))
327 /* Windows gives [client runtime error 0x6f4] */
331 test_samba4_ndr
("refptr-top-out-pull",
337 [public] void echo_TestRef([out,ref] xstruct *foo);
340 uint8_t data[] = { 0x0D, 0x00 };
341 DATA_BLOB b = { data, 2 };
342 struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL, NULL);
344 struct echo_TestRef r;
348 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_echo_TestRef(ndr, NDR_OUT, &r)))
354 if (r.out.foo->x != 13)
358 test_samba4_ndr
("refptr-top-out-pull-null",
364 [public] void echo_TestRef([out,ref] xstruct *foo);
367 uint8_t data[] = { 0x0D, 0x00 };
368 DATA_BLOB b = { data, 2 };
369 struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL, NULL);
370 struct echo_TestRef r;
374 if (NDR_ERR_CODE_IS_SUCCESS(ndr_pull_echo_TestRef(ndr, NDR_OUT, &r)))
377 /* Windows gives [client runtime error 0x6f4] */
381 test_samba4_ndr
("ptr-top-push-double",
383 [public] void echo_TestRef([in] uint16 **foo);
385 ' struct ndr_push *ndr = ndr_push_init_ctx(NULL);
386 struct echo_TestRef r;
391 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
394 if (ndr->offset != 6)
397 if (ndr->data[0] == 0 && ndr->data[1] == 0 &&
398 ndr->data[2] == 0 && ndr->data[3] == 0)
401 if (ndr->data[4] != 0x0D || ndr->data[5] != 0x00)
406 skip
"ptr-top-push-double-sndnull is known to fail", 8;
408 test_samba4_ndr
("ptr-top-push-double-sndnull",
410 [public] void echo_TestRef([in] uint16 **foo);
412 ' struct ndr_push *ndr = ndr_push_init_ctx(NULL);
413 struct echo_TestRef r;
417 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
420 if (ndr->offset != 4)
423 if (ndr->data[0] != 0 || ndr->data[1] != 0 ||
424 ndr->data[2] != 0 || ndr->data[3] != 0)
429 test_samba4_ndr
("ptr-top-push-double-fstnull",
431 [public] void echo_TestRef([in] uint16 **foo);
433 ' struct ndr_push *ndr = ndr_push_init_ctx(NULL);
434 struct echo_TestRef r;
437 if (NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
440 /* Windows gives [client runtime error 0x6f4] */
445 test_samba4_ndr
("refptr-top-push-double",
447 [public] void echo_TestRef([in,ref] uint16 **foo);
449 ' struct ndr_push *ndr = ndr_push_init_ctx(NULL);
450 struct echo_TestRef r;
455 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
458 if (ndr->offset != 6)
461 if (ndr->data[0] == 0 && ndr->data[1] == 0 &&
462 ndr->data[2] == 0 && ndr->data[3] == 0)
465 if (ndr->data[4] != 0x0D || ndr->data[5] != 0x00)
471 skip
"refptr-top-push-double-sndnull is known to fail", 8;
473 test_samba4_ndr
("refptr-top-push-double-sndnull",
475 [public] void echo_TestRef([in,ref] uint16 **foo);
477 ' struct ndr_push *ndr = ndr_push_init_ctx(NULL);
478 struct echo_TestRef r;
482 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
485 if (ndr->offset != 4)
488 if (ndr->data[0] != 0 || ndr->data[1] != 0 ||
489 ndr->data[2] != 0 || ndr->data[3] != 0)
494 test_samba4_ndr
("refptr-top-push-double-fstnull",
496 [public] void echo_TestRef([in,ref] uint16 **foo);
498 ' struct ndr_push *ndr = ndr_push_init_ctx(NULL);
499 struct echo_TestRef r;
502 if (NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
505 /* Windows gives [client runtime error 0x6f4] */
510 skip
"ignore-ptrs are not supported yet", 8;
511 test_samba4_ndr
("ignore-ptr",
513 [public] void echo_TestRef([in,ignore] uint16 *foo, [in] uint16 *bar);
515 ' struct ndr_push *ndr = ndr_push_init_ctx(NULL);
516 struct echo_TestRef r;
521 if (NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
524 if (ndr->offset != 4)