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 test_samba4_ndr
('align-uint8-uint16',
14 typedef [public] struct {
20 struct ndr_push *ndr = ndr_push_init_ctx(NULL);
22 uint8_t expected[] = { 0x0D, 0x00, 0xef, 0xbe };
23 DATA_BLOB expected_blob = { expected, 4 };
24 DATA_BLOB result_blob;
28 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r)))
31 result_blob = ndr_push_blob(ndr);
33 if (data_blob_cmp(&result_blob, &expected_blob) != 0)
37 test_samba4_ndr
('align-uint8-uint32',
39 typedef [public] struct {
45 struct ndr_push *ndr = ndr_push_init_ctx(NULL);
47 uint8_t expected[] = { 0x0D, 0x00, 0x00, 0x00, 0xef, 0xbe, 0xef, 0xbe };
48 DATA_BLOB expected_blob = { expected, 8 };
49 DATA_BLOB result_blob;
53 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r)))
56 result_blob = ndr_push_blob(ndr);
58 if (data_blob_cmp(&result_blob, &expected_blob) != 0)
63 test_samba4_ndr
('align-uint8-hyper',
65 typedef [public] struct {
71 struct ndr_push *ndr = ndr_push_init_ctx(NULL);
73 uint8_t expected[] = { 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
74 0xef, 0xbe, 0xef, 0xbe, 0xef, 0xbe, 0xef, 0xbe };
75 DATA_BLOB expected_blob = { expected, 16 };
76 DATA_BLOB result_blob;
78 r.y = 0xbeefbeefbeefbeefLLU;
80 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r)))
83 result_blob = ndr_push_blob(ndr);
85 if (data_blob_cmp(&result_blob, &expected_blob) != 0)
89 test_samba4_ndr
('noalignflag-uint8-uint16',
91 typedef [public] struct {
97 struct ndr_push *ndr = ndr_push_init_ctx(NULL);
99 uint8_t expected[] = { 0x0D, 0xef, 0xbe };
100 DATA_BLOB expected_blob = { expected, 3 };
101 DATA_BLOB result_blob;
102 ndr->flags |= LIBNDR_FLAG_NOALIGN;
107 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r)))
110 result_blob = ndr_push_blob(ndr);
112 if (data_blob_cmp(&result_blob, &expected_blob) != 0)
116 test_samba4_ndr
('align-blob-align2',
118 typedef [public] struct {
120 [flag(LIBNDR_FLAG_ALIGN2)] DATA_BLOB data;
125 struct ndr_push *ndr = ndr_push_init_ctx(NULL);
127 uint8_t data[] = { 0x01, 0x02 };
128 uint8_t expected[] = { 0x0D, 0x00, 0x0E };
129 DATA_BLOB expected_blob = { expected, 3 };
130 DATA_BLOB result_blob;
137 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_blie(ndr, NDR_SCALARS|NDR_BUFFERS, &r)))
140 result_blob = ndr_push_blob(ndr);
142 if (data_blob_cmp(&result_blob, &expected_blob) != 0)