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 FindBin
qw($RealBin);
12 my %settings = Test::GetSettings(@ARGV);
13 $settings{'IDL-Arguments'} = ['--quiet', '--parse', '--parser=ndr_test.c', '--header=ndr_test.h'];
14 $settings{'IncludeFiles'} = ['ndr_test.h'];
15 $settings{'ExtraFiles'} = ['ndr_test.c'];
17 Test::test_idl("noptr-push", \%settings,
22 [public] uint16 echo_TestRef([in] xstruct foo);
25 struct ndr_push *ndr = ndr_push_init();
27 struct echo_TestRef r;
30 if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, NDR_IN, &r))) {
31 fprintf(stderr, "push failed\n");
35 if (ndr->offset != 2) {
36 fprintf(stderr, "Offset(%d) != 2\n", ndr->offset);
40 if (ndr->data[0] != 13 || ndr->data[1] != 0) {
41 fprintf(stderr, "Data incorrect\n");
46 Test::test_idl("ptr-embedded-push", \%settings,
51 [public] uint16 echo_TestRef([in] xstruct foo);
55 struct ndr_push *ndr = ndr_push_init();
56 struct echo_TestRef r;
59 if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
65 if (ndr->data[0] == 0 && ndr->data[1] == 0 &&
66 ndr->data[2] == 0 && ndr->data[3] == 0)
69 if (ndr->data[4] != 13 || ndr->data[5] != 0)
73 Test::test_idl("ptr-embedded-push-null", \%settings,
78 [public] uint16 echo_TestRef([in] xstruct foo);
81 struct ndr_push *ndr = ndr_push_init();
82 struct echo_TestRef r;
85 if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
91 if (ndr->data[0] != 0 || ndr->data[1] != 0 ||
92 ndr->data[2] != 0 || ndr->data[3] != 0)
96 Test::test_idl("refptr-embedded-push", \%settings,
102 [public] uint16 echo_TestRef([in] xstruct foo);
106 struct ndr_push *ndr = ndr_push_init();
107 struct echo_TestRef r;
110 if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
113 if (ndr->offset != 6)
116 if (ndr->data[0] == 0 && ndr->data[1] == 0 &&
117 ndr->data[2] == 0 && ndr->data[3] == 0)
120 if (ndr->data[4] != 13 || ndr->data[5] != 0)
124 Test::test_idl("refptr-embedded-push-null", \%settings,
130 [public] uint16 echo_TestRef([in] xstruct foo);
133 struct ndr_push *ndr = ndr_push_init();
134 struct echo_TestRef r;
137 if (NT_STATUS_IS_OK(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
139 /* Windows gives [client runtime error 0x6f4] */
142 Test::test_idl("ptr-top-push", \%settings,
148 [public] uint16 echo_TestRef([in] xstruct *foo);
151 struct ndr_push *ndr = ndr_push_init();
152 struct echo_TestRef r;
157 if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
160 if (ndr->offset != 2)
163 if (ndr->data[0] != 13 || ndr->data[1] != 0)
167 Test::test_idl("ptr-top-push-null", \%settings,
173 [public] uint16 echo_TestRef([in] xstruct *foo);
176 struct ndr_push *ndr = ndr_push_init();
177 struct echo_TestRef r;
180 if (NT_STATUS_IS_OK(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
183 /* Windows gives [client runtime error 0x6f4] */
187 Test::test_idl("refptr-top-push", \%settings,
193 [public] uint16 echo_TestRef([in,ref] xstruct *foo);
196 struct ndr_push *ndr = ndr_push_init();
197 struct echo_TestRef r;
202 if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
205 if (ndr->offset != 2)
208 if (ndr->data[0] != 13 || ndr->data[1] != 0)
212 Test::test_idl("refptr-top-push-null", \%settings,
218 [public] uint16 echo_TestRef([in,ref] xstruct *foo);
221 struct ndr_push *ndr = ndr_push_init();
222 struct echo_TestRef r;
225 if (NT_STATUS_IS_OK(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
228 /* Windows gives [client runtime error 0x6f4] */
232 Test::test_idl("uniqueptr-top-push", \%settings,
237 [public] uint16 echo_TestRef([in,unique] xstruct *foo);
240 struct ndr_push *ndr = ndr_push_init();
241 struct echo_TestRef r;
246 if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
249 if (ndr->offset != 6)
252 if (ndr->data[0] == 0 && ndr->data[1] == 0 &&
253 ndr->data[2] == 0 && ndr->data[3] == 0)
256 if (ndr->data[4] != 13 || ndr->data[5] != 0)
260 Test::test_idl("uniqueptr-top-push-null", \%settings,
265 [public] uint16 echo_TestRef([in,unique] xstruct *foo);
268 struct ndr_push *ndr = ndr_push_init();
269 struct echo_TestRef r;
272 if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
275 if (ndr->offset != 4)
278 if (ndr->data[0] != 0 || ndr->data[1] != 0 ||
279 ndr->data[2] != 0 || ndr->data[3] != 0)
284 Test::test_idl("ptr-top-out-pull", \%settings,
290 [public] void echo_TestRef([out] xstruct *foo);
293 uint8_t data[] = { 0x0D, 0x00 };
294 DATA_BLOB b = { data, 2 };
295 struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL);
297 struct echo_TestRef r;
301 if (NT_STATUS_IS_ERR(ndr_pull_echo_TestRef(ndr, NDR_OUT, &r)))
307 if (r.out.foo->x != 13)
311 Test::test_idl("ptr-top-out-pull-null", \%settings,
317 [public] void echo_TestRef([out] xstruct *foo);
320 uint8_t data[] = { 0x0D, 0x00 };
321 DATA_BLOB b = { data, 2 };
322 struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL);
323 struct echo_TestRef r;
327 if (NT_STATUS_IS_OK(ndr_pull_echo_TestRef(ndr, NDR_OUT, &r)))
330 /* Windows gives [client runtime error 0x6f4] */
334 Test::test_idl("refptr-top-out-pull", \%settings,
340 [public] void echo_TestRef([out,ref] xstruct *foo);
343 uint8_t data[] = { 0x0D, 0x00 };
344 DATA_BLOB b = { data, 2 };
345 struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL);
347 struct echo_TestRef r;
351 if (NT_STATUS_IS_ERR(ndr_pull_echo_TestRef(ndr, NDR_OUT, &r)))
357 if (r.out.foo->x != 13)
361 Test::test_idl("refptr-top-out-pull-null", \%settings,
367 [public] void echo_TestRef([out,ref] xstruct *foo);
370 uint8_t data[] = { 0x0D, 0x00 };
371 DATA_BLOB b = { data, 2 };
372 struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL);
373 struct echo_TestRef r;
377 if (NT_STATUS_IS_OK(ndr_pull_echo_TestRef(ndr, NDR_OUT, &r)))
380 /* Windows gives [client runtime error 0x6f4] */
384 Test::test_idl("ptr-top-push-double", \%settings,
386 [public] void echo_TestRef([in] uint16 **foo);
388 ' struct ndr_push *ndr = ndr_push_init();
389 struct echo_TestRef r;
394 if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
397 if (ndr->offset != 6)
400 if (ndr->data[0] == 0 && ndr->data[1] == 0 &&
401 ndr->data[2] == 0 && ndr->data[3] == 0)
404 if (ndr->data[4] != 0x0D || ndr->data[5] != 0x00)
408 Test::test_idl("ptr-top-push-double-sndnull", \%settings,
410 [public] void echo_TestRef([in] uint16 **foo);
412 ' struct ndr_push *ndr = ndr_push_init();
413 struct echo_TestRef r;
417 if (NT_STATUS_IS_ERR(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)
428 Test::test_idl("ptr-top-push-double-fstnull", \%settings,
430 [public] void echo_TestRef([in] uint16 **foo);
432 ' struct ndr_push *ndr = ndr_push_init();
433 struct echo_TestRef r;
436 if (NT_STATUS_IS_OK(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
439 /* Windows gives [client runtime error 0x6f4] */
444 Test::test_idl("refptr-top-push-double", \%settings,
446 [public] void echo_TestRef([in,ref] uint16 **foo);
448 ' struct ndr_push *ndr = ndr_push_init();
449 struct echo_TestRef r;
454 if (NT_STATUS_IS_ERR(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)
468 Test::test_idl("refptr-top-push-double-sndnull", \%settings,
470 [public] void echo_TestRef([in,ref] uint16 **foo);
472 ' struct ndr_push *ndr = ndr_push_init();
473 struct echo_TestRef r;
477 if (NT_STATUS_IS_ERR(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
480 if (ndr->offset != 4)
483 if (ndr->data[0] != 0 || ndr->data[1] != 0 ||
484 ndr->data[2] != 0 || ndr->data[3] != 0)
488 Test::test_idl("refptr-top-push-double-fstnull", \%settings,
490 [public] void echo_TestRef([in,ref] uint16 **foo);
492 ' struct ndr_push *ndr = ndr_push_init();
493 struct echo_TestRef r;
496 if (NT_STATUS_IS_OK(ndr_push_echo_TestRef(ndr, NDR_IN, &r)))
499 /* Windows gives [client runtime error 0x6f4] */