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 test_samba4_ndr
('align-uint8-uint16',
13 typedef [public] struct {
19 struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
21 uint8_t expected[] = { 0x0D, 0x00, 0xef, 0xbe };
22 DATA_BLOB expected_blob = { expected, 4 };
23 DATA_BLOB result_blob;
27 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r)))
30 result_blob = ndr_push_blob(ndr);
32 if (data_blob_cmp(&result_blob, &expected_blob) != 0)
36 test_samba4_ndr
('align-uint8-uint32',
38 typedef [public] struct {
44 struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
46 uint8_t expected[] = { 0x0D, 0x00, 0x00, 0x00, 0xef, 0xbe, 0xef, 0xbe };
47 DATA_BLOB expected_blob = { expected, 8 };
48 DATA_BLOB result_blob;
52 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r)))
55 result_blob = ndr_push_blob(ndr);
57 if (data_blob_cmp(&result_blob, &expected_blob) != 0)
62 test_samba4_ndr
('align-uint8-hyper',
64 typedef [public] struct {
70 struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
72 uint8_t expected[] = { 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
73 0xef, 0xbe, 0xef, 0xbe, 0xef, 0xbe, 0xef, 0xbe };
74 DATA_BLOB expected_blob = { expected, 16 };
75 DATA_BLOB result_blob;
77 r.y = 0xbeefbeefbeefbeefLLU;
79 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r)))
82 result_blob = ndr_push_blob(ndr);
84 if (data_blob_cmp(&result_blob, &expected_blob) != 0)
88 test_samba4_ndr
('noalignflag-uint8-uint16',
90 typedef [public] struct {
96 struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
98 uint8_t expected[] = { 0x0D, 0xef, 0xbe };
99 DATA_BLOB expected_blob = { expected, 3 };
100 DATA_BLOB result_blob;
101 ndr->flags |= LIBNDR_FLAG_NOALIGN;
106 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r)))
109 result_blob = ndr_push_blob(ndr);
111 if (data_blob_cmp(&result_blob, &expected_blob) != 0)
115 test_samba4_ndr
('align-blob-align2',
117 typedef [public] struct {
119 [flag(LIBNDR_FLAG_ALIGN2)] DATA_BLOB data;
124 struct ndr_push *ndr = ndr_push_init_ctx(NULL, NULL);
126 uint8_t data[] = { 0x01, 0x02 };
127 uint8_t expected[] = { 0x0D, 0x00, 0x0E };
128 DATA_BLOB expected_blob = { expected, 3 };
129 DATA_BLOB result_blob;
136 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_blie(ndr, NDR_SCALARS|NDR_BUFFERS, &r)))
139 result_blob = ndr_push_blob(ndr);
141 if (data_blob_cmp(&result_blob, &expected_blob) != 0)