3 # (C) 2005 Jelmer Vernooij. Published under the GNU GPL
6 use Test
::More tests
=> 5 * 8;
7 use FindBin
qw($RealBin);
9 use Util qw(test_samba4_ndr);
11 # Check that an outgoing scalar pointer is allocated correctly
13 test_samba4_ndr
("alloc-scalar",
19 [public] void TestAlloc([in] bla foo);
21 uint8_t data[] = { 0xde, 0xad, 0xbe, 0xef, 0x03 };
22 DATA_BLOB b = { data, 5 };
23 struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL, NULL);
26 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_TestAlloc(ndr, NDR_IN, &r)))
29 if (r.in.foo.x == NULL)
32 if (*r.in.foo.x != 0x03)
37 # Check that an outgoing buffer pointer is allocated correctly
38 test_samba4_ndr
("alloc-buffer",
40 typedef struct { uint8 data; } blie;
41 typedef struct { blie *x; } bla;
43 [public] void TestAlloc([in] bla foo);
45 uint8_t data[] = { 0xde, 0xad, 0xbe, 0xef, 0x03 };
46 DATA_BLOB b = { data, 5 };
47 struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL, NULL);
50 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_TestAlloc(ndr, NDR_IN, &r)))
53 if (r.in.foo.x == NULL)
56 if (r.in.foo.x->data != 0x03)
61 # Check that ref pointers aren't allocated by default
62 test_samba4_ndr
("ref-noalloc-null",
64 [public] void TestAlloc([in,ref] uint8 *t);
66 uint8_t data[] = { 0x03 };
67 DATA_BLOB b = { data, 1 };
68 struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL, NULL);
72 if (NDR_ERR_CODE_IS_SUCCESS(ndr_pull_TestAlloc(ndr, NDR_IN, &r)))
77 # Check that ref pointers aren't allocated by default
78 test_samba4_ndr
("ref-noalloc",
80 [public] void TestAlloc([in,ref] uint8 *t);
82 uint8_t data[] = { 0x03 };
83 DATA_BLOB b = { data, 1 };
84 struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL, NULL);
89 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_TestAlloc(ndr, NDR_IN, &r)))
97 # Check that an outgoing ref pointer is allocated correctly
98 test_samba4_ndr
("ref-alloc",
100 [public] void TestAlloc([in,ref] uint8 *t);
102 uint8_t data[] = { 0x03 };
103 DATA_BLOB b = { data, 1 };
104 struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL, NULL);
106 ndr->flags |= LIBNDR_FLAG_REF_ALLOC;
109 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_TestAlloc(ndr, NDR_IN, &r)))