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.
8 use Test
::More tests
=> 22 * 8;
9 use FindBin
qw($RealBin);
11 use Util qw(test_samba4_ndr);
13 test_samba4_ndr
("noptr-push",
18 [public] uint16 echo_TestRef([in] xstruct foo);
21 struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
23 struct echo_TestRef r;
26 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) {
27 fprintf(stderr, "push failed\n");
31 if (ndr->offset != 2) {
32 fprintf(stderr, "Offset(%d) != 2\n", ndr->offset);
36 if (ndr->data[0] != 13 || ndr->data[1] != 0) {
37 fprintf(stderr, "Data incorrect\n");
42 test_samba4_ndr
("ptr-embedded-push",
47 [public] uint16 echo_TestRef([in] xstruct foo);
51 struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
52 struct echo_TestRef r;
55 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
61 if (ndr->data[0] == 0 && ndr->data[1] == 0 &&
62 ndr->data[2] == 0 && ndr->data[3] == 0)
65 if (ndr->data[4] != 13 || ndr->data[5] != 0)
69 test_samba4_ndr
("ptr-embedded-push-null",
74 [public] uint16 echo_TestRef([in] xstruct foo);
77 struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
78 struct echo_TestRef r;
81 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
87 if (ndr->data[0] != 0 || ndr->data[1] != 0 ||
88 ndr->data[2] != 0 || ndr->data[3] != 0)
92 test_samba4_ndr
("refptr-embedded-push",
98 [public] uint16 echo_TestRef([in] xstruct foo);
102 struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
103 struct echo_TestRef r;
106 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
109 if (ndr->offset != 6)
112 if (ndr->data[0] == 0 && ndr->data[1] == 0 &&
113 ndr->data[2] == 0 && ndr->data[3] == 0)
116 if (ndr->data[4] != 13 || ndr->data[5] != 0)
120 test_samba4_ndr
("refptr-embedded-push-null",
126 [public] uint16 echo_TestRef([in] xstruct foo);
129 struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
130 struct echo_TestRef r;
133 if (NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
135 /* Windows gives [client runtime error 0x6f4] */
138 test_samba4_ndr
("ptr-top-push",
144 [public] uint16 echo_TestRef([in] xstruct *foo);
147 struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
148 struct echo_TestRef r;
153 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
156 if (ndr->offset != 2)
159 if (ndr->data[0] != 13 || ndr->data[1] != 0)
163 test_samba4_ndr
("ptr-top-push-null",
169 [public] uint16 echo_TestRef([in] xstruct *foo);
172 struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
173 struct echo_TestRef r;
176 if (NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
179 /* Windows gives [client runtime error 0x6f4] */
183 test_samba4_ndr
("refptr-top-push",
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;
198 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
201 if (ndr->offset != 2)
204 if (ndr->data[0] != 13 || ndr->data[1] != 0)
208 test_samba4_ndr
("refptr-top-push-null",
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;
221 if (NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
224 /* Windows gives [client runtime error 0x6f4] */
228 test_samba4_ndr
("uniqueptr-top-push",
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;
242 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
245 if (ndr->offset != 6)
248 if (ndr->data[0] == 0 && ndr->data[1] == 0 &&
249 ndr->data[2] == 0 && ndr->data[3] == 0)
252 if (ndr->data[4] != 13 || ndr->data[5] != 0)
256 test_samba4_ndr
("uniqueptr-top-push-null",
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;
268 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
271 if (ndr->offset != 4)
274 if (ndr->data[0] != 0 || ndr->data[1] != 0 ||
275 ndr->data[2] != 0 || ndr->data[3] != 0)
280 test_samba4_ndr
("ptr-top-out-pull",
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);
293 struct echo_TestRef r;
297 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_echo_TestRef(ndr, NDR_OUT, &r)))
303 if (r.out.foo->x != 13)
307 test_samba4_ndr
("ptr-top-out-pull-null",
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;
323 if (NDR_ERR_CODE_IS_SUCCESS(ndr_pull_echo_TestRef(ndr, NDR_OUT, &r)))
326 /* Windows gives [client runtime error 0x6f4] */
330 test_samba4_ndr
("refptr-top-out-pull",
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);
343 struct echo_TestRef r;
347 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_echo_TestRef(ndr, NDR_OUT, &r)))
353 if (r.out.foo->x != 13)
357 test_samba4_ndr
("refptr-top-out-pull-null",
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;
373 if (NDR_ERR_CODE_IS_SUCCESS(ndr_pull_echo_TestRef(ndr, NDR_OUT, &r)))
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;
390 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
393 if (ndr->offset != 6)
396 if (ndr->data[0] == 0 && ndr->data[1] == 0 &&
397 ndr->data[2] == 0 && ndr->data[3] == 0)
400 if (ndr->data[4] != 0x0D || ndr->data[5] != 0x00)
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;
416 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
419 if (ndr->offset != 4)
422 if (ndr->data[0] != 0 || ndr->data[1] != 0 ||
423 ndr->data[2] != 0 || ndr->data[3] != 0)
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;
436 if (NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
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;
454 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
457 if (ndr->offset != 6)
460 if (ndr->data[0] == 0 && ndr->data[1] == 0 &&
461 ndr->data[2] == 0 && ndr->data[3] == 0)
464 if (ndr->data[4] != 0x0D || ndr->data[5] != 0x00)
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;
481 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
484 if (ndr->offset != 4)
487 if (ndr->data[0] != 0 || ndr->data[1] != 0 ||
488 ndr->data[2] != 0 || ndr->data[3] != 0)
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;
501 if (NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
504 /* Windows gives [client runtime error 0x6f4] */
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;
520 if (NDR_ERR_CODE_IS_SUCCESS(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
523 if (ndr->offset != 4)