3 # (C) 2005 Jelmer Vernooij. Published under the GNU GPL
7 use Test
::More tests
=> 5 * 8;
8 use FindBin
qw($RealBin);
10 use Util qw(test_samba4_ndr);
12 # Check that an outgoing scalar pointer is allocated correctly
14 test_samba4_ndr
("alloc-scalar",
20 [public] void TestAlloc([in] bla foo);
22 uint8_t data[] = { 0xde, 0xad, 0xbe, 0xef, 0x03 };
23 DATA_BLOB b = { data, 5 };
24 struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL, NULL);
27 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_TestAlloc(ndr, NDR_IN, &r)))
30 if (r.in.foo.x == NULL)
33 if (*r.in.foo.x != 0x03)
38 # Check that an outgoing buffer pointer is allocated correctly
39 test_samba4_ndr
("alloc-buffer",
41 typedef struct { uint8 data; } blie;
42 typedef struct { blie *x; } bla;
44 [public] void TestAlloc([in] bla foo);
46 uint8_t data[] = { 0xde, 0xad, 0xbe, 0xef, 0x03 };
47 DATA_BLOB b = { data, 5 };
48 struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL, NULL);
51 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_TestAlloc(ndr, NDR_IN, &r)))
54 if (r.in.foo.x == NULL)
57 if (r.in.foo.x->data != 0x03)
62 # Check that ref pointers aren't allocated by default
63 test_samba4_ndr
("ref-noalloc-null",
65 [public] void TestAlloc([in,ref] uint8 *t);
67 uint8_t data[] = { 0x03 };
68 DATA_BLOB b = { data, 1 };
69 struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL, NULL);
73 if (NDR_ERR_CODE_IS_SUCCESS(ndr_pull_TestAlloc(ndr, NDR_IN, &r)))
78 # Check that ref pointers aren't allocated by default
79 test_samba4_ndr
("ref-noalloc",
81 [public] void TestAlloc([in,ref] uint8 *t);
83 uint8_t data[] = { 0x03 };
84 DATA_BLOB b = { data, 1 };
85 struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL, NULL);
90 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_TestAlloc(ndr, NDR_IN, &r)))
98 # Check that an outgoing ref pointer is allocated correctly
99 test_samba4_ndr
("ref-alloc",
101 [public] void TestAlloc([in,ref] uint8 *t);
103 uint8_t data[] = { 0x03 };
104 DATA_BLOB b = { data, 1 };
105 struct ndr_pull *ndr = ndr_pull_init_blob(&b, NULL, NULL);
107 ndr->flags |= LIBNDR_FLAG_REF_ALLOC;
110 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_TestAlloc(ndr, NDR_IN, &r)))